1616import com .growit .app .goal .usecase .UpdateGoalUseCase ;
1717import com .growit .app .user .domain .user .User ;
1818import jakarta .validation .Valid ;
19- import java .time .LocalDate ;
20- import java .util .List ;
2119import lombok .RequiredArgsConstructor ;
2220import org .springframework .http .HttpStatus ;
2321import org .springframework .http .ResponseEntity ;
2422import org .springframework .security .core .annotation .AuthenticationPrincipal ;
2523import org .springframework .web .bind .annotation .*;
2624
25+ import java .time .LocalDate ;
26+ import java .util .List ;
27+
2728@ RestController
2829@ RequestMapping ("/goals" )
2930@ RequiredArgsConstructor
@@ -37,15 +38,15 @@ public class GoalController {
3738
3839 @ GetMapping
3940 public ResponseEntity <ApiResponse <List <Goal >>> getMyGoal (
40- @ AuthenticationPrincipal User user , @ RequestParam () GoalStatus status ) {
41+ @ AuthenticationPrincipal User user , @ RequestParam (required = false ) GoalStatus status ) {
4142 status = status == null ? GoalStatus .NONE : status ;
4243 List <Goal > goals = getUserGoalsUseCase .getMyGoals (user , status );
4344 return ResponseEntity .ok (ApiResponse .success (goals ));
4445 }
4546
4647 @ PostMapping
4748 public ResponseEntity <ApiResponse <IdDto >> createGoal (
48- @ AuthenticationPrincipal User user , @ Valid @ RequestBody CreateGoalRequest request ) {
49+ @ AuthenticationPrincipal User user , @ Valid @ RequestBody CreateGoalRequest request ) {
4950 CreateGoalCommand command = goalRequestMapper .toCommand (user .getId (), request );
5051 String goalId = createGoalUseCase .execute (command );
5152
@@ -54,9 +55,9 @@ public ResponseEntity<ApiResponse<IdDto>> createGoal(
5455
5556 @ PutMapping ("{id}" )
5657 public ResponseEntity <ApiResponse <String >> updateGoal (
57- @ PathVariable String id ,
58- @ AuthenticationPrincipal User user ,
59- @ Valid @ RequestBody CreateGoalRequest request ) {
58+ @ PathVariable String id ,
59+ @ AuthenticationPrincipal User user ,
60+ @ Valid @ RequestBody CreateGoalRequest request ) {
6061 UpdateGoalCommand command = goalRequestMapper .toUpdateCommand (id , user .getId (), request );
6162 updateGoalUseCase .execute (command );
6263
@@ -65,7 +66,7 @@ public ResponseEntity<ApiResponse<String>> updateGoal(
6566
6667 @ DeleteMapping ("{id}" )
6768 public ResponseEntity <ApiResponse <String >> deleteGoal (
68- @ PathVariable String id , @ AuthenticationPrincipal User user ) {
69+ @ PathVariable String id , @ AuthenticationPrincipal User user ) {
6970 DeleteGoalCommand command = goalRequestMapper .toDeleteCommand (id , user .getId ());
7071 deleteGoalUseCase .execute (command );
7172
@@ -82,6 +83,12 @@ public ResponseEntity<ApiResponse<String>> getEndedGoals() {
8283 @ GetMapping ("/me/exists" )
8384 public ResponseEntity <ApiResponse <Boolean >> getGoalIsExist (@ AuthenticationPrincipal User user ) {
8485 return ResponseEntity .ok (
85- ApiResponse .success (!getUserGoalsUseCase .getMyGoals (user , GoalStatus .NONE ).isEmpty ()));
86+ ApiResponse .success (!getUserGoalsUseCase .getMyGoals (user , GoalStatus .NONE ).isEmpty ()));
87+ }
88+
89+ @ PutMapping ("/" )
90+ public ResponseEntity <ApiResponse <String >> updatePlanContent (@ AuthenticationPrincipal User user ) {
91+
92+ return ResponseEntity .ok (ApiResponse .success (messageService .msg ("success.goal.status.update" )));
8693 }
8794}
0 commit comments