Skip to content

Commit

Permalink
#91 jwt token using memberId
Browse files Browse the repository at this point in the history
  • Loading branch information
taeyeongKims committed Jan 18, 2025
1 parent 1eca07a commit 2db214c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<CategoryDTO> 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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<LikeEmployeeDTO> 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<EmployerBusinessesRequest> businesses = employerService.getEmployerBusinessList(employeeIdRequest);
return ResponseEntity.ok(businesses);
Expand Down

0 comments on commit 2db214c

Please sign in to comment.