Skip to content

Commit

Permalink
[Chore] 컨트롤러 @RequestHeader, @PathVariable 명시(#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkonu committed May 17, 2024
1 parent bdd315d commit 68105e4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@ public class ExerciseController {

//운동 리스트 조회
@GetMapping("/exercises")
public ResponseEntity<BaseResponse<?>> exercisesList(@RequestHeader Long userId) {

return ApiResponseUtil.success(SuccessMessage.EXERCISES_FIND_SUCCESS, routineService.findRoutines(userId));
public ResponseEntity<BaseResponse<?>> exercisesList(
@RequestHeader("user_id") Long userId
) {
return ApiResponseUtil.success(
SuccessMessage.EXERCISES_FIND_SUCCESS,
routineService.findRoutines(userId)
);
}

//운동 리스트 순서 변경
@PutMapping("/exercises")
public ResponseEntity<BaseResponse<?>> exercisesReorder(@RequestHeader Long userId,
@Valid @RequestBody ExerciseReorderAllRequest exercises) {
public ResponseEntity<BaseResponse<?>> exercisesReorder(
@RequestHeader("user_id") Long userId,
@Valid @RequestBody ExerciseReorderAllRequest exercises
) {
routineService.reorderExercises(userId, exercises.exercises());
return ApiResponseUtil.success(SuccessMessage.EXERCISES_REORDER_SUCCESS);

return ApiResponseUtil.success(
SuccessMessage.EXERCISES_REORDER_SUCCESS
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,28 @@ public ResponseEntity<BaseResponse<?>> postRoutine(
}

@PatchMapping("/exercises/{exerciseId}/like")
public ResponseEntity<BaseResponse<?>> patchExerciseLike(@RequestHeader Long userId,
@PathVariable Long exerciseId) {
public ResponseEntity<BaseResponse<?>> patchExerciseLike(
@RequestHeader(name = "user_id") Long userId,
@PathVariable(name = "exercise_id") Long exerciseId
) {

routineService.patchExerciseLike(userId, exerciseId);

return ApiResponseUtil.success(SuccessMessage.EXERCISE_LIKE_POST_SUCCESS);
return ApiResponseUtil.success(
SuccessMessage.EXERCISE_LIKE_POST_SUCCESS
);
}

@PatchMapping("/exercises/{exerciseId}/unlike")
public ResponseEntity<BaseResponse<?>> patchExerciseUnLike(@RequestHeader Long userId,
@PathVariable Long exerciseId) {
public ResponseEntity<BaseResponse<?>> patchExerciseUnLike(
@RequestHeader(name = "user_id") Long userId,
@PathVariable(name = "exercise_id") Long exerciseId
) {

routineService.patchExerciseUnLike(userId, exerciseId);

return ApiResponseUtil.success(SuccessMessage.EXERCISE_DELETE_UNLIKE_SUCCESS);
return ApiResponseUtil.success(
SuccessMessage.EXERCISE_DELETE_UNLIKE_SUCCESS
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,27 @@ public class SetController {
private final SetService setService;

@PostMapping("/exercises/{exerciseId}/set")
public ResponseEntity<BaseResponse<?>> postAddSet(@RequestHeader(name = "user_id") final Long userId,
@PathVariable final Long exerciseId) {
public ResponseEntity<BaseResponse<?>> postAddSet(
@RequestHeader(name = "user_id") final Long userId,
@PathVariable(name = "exercise_id") final Long exerciseId
) {
setService.addSet(userId, exerciseId);

return ApiResponseUtil.success(SuccessMessage.SET_ADD_SET_SUCCESS);
return ApiResponseUtil.success(
SuccessMessage.SET_ADD_SET_SUCCESS
);

}

@PutMapping("/exercises/{exerciseId}/set")
public ResponseEntity<BaseResponse<?>> putSetIsDone(@RequestHeader final Long userId,
@PathVariable final Long exerciseId) {

public ResponseEntity<BaseResponse<?>> putSetIsDone(
@RequestHeader(name = "user_id") final Long userId,
@PathVariable(name = "exercise_id") final Long exerciseId
) {
setService.completeSet(userId, exerciseId);

return ApiResponseUtil.success(SuccessMessage.SET_COMPLETE_SET_SUCCESS);
return ApiResponseUtil.success(
SuccessMessage.SET_COMPLETE_SET_SUCCESS
);
}
}

0 comments on commit 68105e4

Please sign in to comment.