diff --git a/src/main/java/com/example/api/board/controller/BoardController.java b/src/main/java/com/example/api/board/controller/BoardController.java index c859c87d..a0330352 100644 --- a/src/main/java/com/example/api/board/controller/BoardController.java +++ b/src/main/java/com/example/api/board/controller/BoardController.java @@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -25,16 +26,16 @@ public class BoardController { private final CategoryService categoryService; private final EmployeeService employeeService; - @GetMapping("/api/v1/possible-board/form/{employeeId}") - public Board findBoardByEmployeeId(@PathVariable() final Long employeeId) { + @GetMapping("/api/v1/possible-board/form") + public Board findBoardByEmployeeId(@AuthenticationPrincipal final Long employeeId) { EmployeeIdRequest employeeIdRequest = new EmployeeIdRequest(employeeId); MyInfoDTO myInfoById = boardService.findMyInfoById(employeeIdRequest); List categoryList = categoryService.getAllCategories(); return new Board(myInfoById, categoryList); } - @PostMapping("/api/v1/{employeeId}") - public ResponseEntity changeOpenStatus(@PathVariable("employeeId") Long employeeId, @RequestParam ("openStatus") Boolean openStatus) { + @PostMapping("/api/v1") + public ResponseEntity changeOpenStatus(@AuthenticationPrincipal final Long employeeId, @RequestParam ("openStatus") Boolean openStatus) { EmployeeIdRequest employeeIdRequest = new EmployeeIdRequest(employeeId); boolean updated = employeeService.changeOpenStatus(employeeIdRequest, openStatus); if (updated) { @@ -44,8 +45,8 @@ public ResponseEntity changeOpenStatus(@PathVariable("employeeId") Long employee } } - @PostMapping("/api/v1/possible-board/submit/{employeeId}") - public ResponseEntity submitBoard(@PathVariable("employeeId") Long employeeId, @RequestBody MyInfoDTO myInfo) { + @PostMapping("/api/v1/possible-board/submit") + public ResponseEntity submitBoard(@AuthenticationPrincipal final Long employeeId, @RequestBody MyInfoDTO myInfo) { EmployeeIdRequest employeeIdRequest = new EmployeeIdRequest(employeeId); employeeService.updateUserInfo(employeeIdRequest, myInfo); MyInfoDTO myInfoById = boardService.findMyInfoById(employeeIdRequest); diff --git a/src/main/java/com/example/api/employer/controller/EmployerController.java b/src/main/java/com/example/api/employer/controller/EmployerController.java index 1a5fc8ed..5b5c2334 100644 --- a/src/main/java/com/example/api/employer/controller/EmployerController.java +++ b/src/main/java/com/example/api/employer/controller/EmployerController.java @@ -6,6 +6,7 @@ import com.example.api.employer.service.EmployerService; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @@ -17,15 +18,15 @@ public class EmployerController { private final EmployerService employerService; - @GetMapping("favorites/{employerId}") - public ResponseEntity getLikeEmployee(@PathVariable() Long employerId) { + @GetMapping("favorites") + public ResponseEntity getLikeEmployee(@AuthenticationPrincipal final Long employerId) { EmployeeIdRequest employeeIdRequest = new EmployeeIdRequest(employerId); List result = employerService.getLikeEmployee(employeeIdRequest); return ResponseEntity.ok(result); } - @GetMapping("businesses/{employerId}") - public ResponseEntity getEmployeeBusinessList(@PathVariable Long employerId) { + @GetMapping("businesses") + public ResponseEntity getEmployeeBusinessList(@AuthenticationPrincipal final Long employerId) { EmployeeIdRequest employeeIdRequest = new EmployeeIdRequest(employerId); List businesses = employerService.getEmployerBusinessList(employeeIdRequest); return ResponseEntity.ok(businesses);