Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 관리자-수집노선 컨트롤러 누락 해결 #156

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.talkka.server.admin.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.talkka.server.admin.dto.CollectBusRouteCreateDto;
import com.talkka.server.admin.exception.CollectBusRouteAlreadyExistsException;
import com.talkka.server.admin.exception.CollectBusRouteNotFoundException;
import com.talkka.server.admin.service.CollectBusRouteService;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/api/collect")
public class CollectBusRouteController {
private final CollectBusRouteService collectBusRouteService;

@PostMapping("")
public ResponseEntity<?> createCollectRoute(@RequestBody CollectBusRouteCreateDto dto) {
try {
collectBusRouteService.createCollectBusRoute(dto);
} catch (CollectBusRouteNotFoundException | CollectBusRouteAlreadyExistsException exception) {
return ResponseEntity.badRequest().body(exception.getMessage());
}
return ResponseEntity.ok().build();
}

@DeleteMapping("/{collectRouteId}")
public ResponseEntity<?> deleteCollectRoute(@PathVariable Long collectRouteId) {
try {
collectBusRouteService.deleteCollectBusRoute(collectRouteId);
} catch (CollectBusRouteNotFoundException exception) {
return ResponseEntity.badRequest().body(exception.getMessage());
}
return ResponseEntity.ok().build();
}
}
Loading