Skip to content

Commit

Permalink
feat: Goal read by goalId 기능 추가(#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
heej-ng committed Mar 18, 2022
1 parent 3dac5f9 commit 90a8207
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import planshare.server.planshare.user.dto.CustomUserDetailsVO;

import java.util.List;
import java.util.Optional;

@RequiredArgsConstructor
@RestController
Expand All @@ -25,43 +26,53 @@ public Goal create(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
return goalService.addGoal(userDetailsVO,goalForm);
}

// goal by id
@GetMapping("/read/{goalId}")
public Optional<Goal> readGoal(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@PathVariable(name = "goalId") Long id){
return goalService.findGoalOfId(userDetailsVO, id);
}


// goal of member
@GetMapping("/read_member")
@GetMapping("/read/member")
public List<Goal> listOfMember(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO){

return goalService.findGoalsOfMember(userDetailsVO);
}

// goal of member and name
@GetMapping("/read_member_name")
@GetMapping("/read/member-name")
public List<Goal> listOfMemberAndName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestParam String name){

return goalService.findGoalsOfMemberAndName(userDetailsVO, name);
}

// goals
@GetMapping("/read_alluser")
@GetMapping("/read/alluser")
public List<Goal> listOfGoals(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO){

return goalService.findGoals();
}

// goal of name
@GetMapping("/read_alluser_name")
@GetMapping("/read/alluser-name")
public List<Goal> listOfName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestParam String name){

return goalService.findGoalsOfName(name);
}

// goal update
@PutMapping("/update/{goalId}")
public Goal modifyName(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@RequestBody GoalForm goalForm,
@PathVariable(name = "goalId") Long id){
return goalService.updateGoalName(userDetailsVO, id, goalForm.getName());
}

// goal delete
@DeleteMapping("/delete/{goalId}")
public int deleteGoal(@AuthenticationPrincipal CustomUserDetailsVO userDetailsVO,
@PathVariable(name = "goalId") Long id){
Expand Down

0 comments on commit 90a8207

Please sign in to comment.