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

[#13] GoalController 리소스 이름 수정 #24

Merged
merged 1 commit into from
Apr 13, 2022
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
Expand Up @@ -14,13 +14,12 @@

@RequiredArgsConstructor
@RestController
@RequestMapping("/goal")
public class GoalController {

private final GoalService goalService;

@ApiOperation(value = "goal 생성 API", notes = "생성한 goal 객체 반환")
@PostMapping("/create")
@PostMapping("/goals")
public Goal create(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestBody GoalForm goalForm){

Expand All @@ -30,15 +29,15 @@ public Goal create(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,

// goal by id
@ApiOperation(value = "goal 하나 조회(by goalId) API", notes = "찾은 goal 객체 반환")
@GetMapping("/read/{goalId}")
@GetMapping("/goals/{goalId}")
public Optional<Goal> readGoalById(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@PathVariable(name = "goalId") Long id){
return goalService.findGoalOfId(userDetailsVO, id);
}

// goal of member and name
@ApiOperation(value = "나의 goal 목록 조회 API", notes = "name 파라미터 추가시(필수x) 해당 이름의 goal 리스트 반환")
@GetMapping("/read/myself")
@GetMapping("/goals/my-goals")
public List<Goal> listOfMyselfAndName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestParam(required = false) String name){
if(name == null){
Expand All @@ -48,7 +47,7 @@ public List<Goal> listOfMyselfAndName(@AuthenticationPrincipal CustomUserDetails
}

@ApiOperation(value = "특정 멤버의 goal 목록 조회 API", notes = "name 파라미터 추가시(필수x) 해당 이름의 goal 리스트 반환")
@GetMapping("/read/member/{memberId}")
@GetMapping("/goals/members/{memberId}")
public List<Goal> listOfMemberAndName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestParam(required = false) String name,
@PathVariable(name = "memberId") Long memberId){
Expand All @@ -60,7 +59,7 @@ public List<Goal> listOfMemberAndName(@AuthenticationPrincipal CustomUserDetails

// goal of name
@ApiOperation(value = "모든 멤버의 goal 목록 조회 API", notes = "name 파라미터 추가시(필수x) 해당 이름의 goal 리스트 반환")
@GetMapping("/read/alluser")
@GetMapping("/goals")
public List<Goal> listOfName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestParam(required = false) String name){
if(name == null){
Expand All @@ -71,7 +70,7 @@ public List<Goal> listOfName(@AuthenticationPrincipal CustomUserDetailsVO userDe

// goal update
@ApiOperation(value = "특정 goal 내용 수정 API", notes = "수정한 goal 객체 반환")
@PutMapping("/update/{goalId}")
@PutMapping("/goals/{goalId}")
public Goal modifyGoal(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestBody GoalForm goalForm,
@PathVariable(name = "goalId") Long id){
Expand All @@ -80,7 +79,7 @@ public Goal modifyGoal(@AuthenticationPrincipal CustomUserDetailsVO userDetailsV

// goal delete
@ApiOperation(value = "특정 goal 삭제 API", notes = "삭제 성공시 정수 1 반환 / 실패시 0 반환")
@DeleteMapping("/delete/{goalId}")
@DeleteMapping("/goals/{goalId}")
public int deleteGoal(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@PathVariable(name = "goalId") Long id){
return goalService.deleteGoal(userDetailsVO, id);
Expand Down