Skip to content

Commit

Permalink
FEAT: 설정한 목표 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
seheonnn authored Nov 25, 2023
2 parents 272d526 + 37b3a78 commit a2fbc68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/dev/neordinary/zero/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,32 @@

@RequiredArgsConstructor
@RestController
@RequestMapping("/api/v1/user")
public class UserController {

private final UserService userService;
private final NoteService noteService;

@PostMapping("/api/v1/user")
@PostMapping("")
public UserResponse.UserJoinRes join(@RequestBody UserRequest.UserJoin userJoin) {
return userService.join(userJoin);
}

@GetMapping("/api/v1/user/{userId}")
@GetMapping("/{userId}")
public UserResponse.UserBeverageRes showUserBeverage(@PathVariable Long userId) {
return userService.showUserBeverage(userId);
}

@PostMapping("/api/v1/user/{userId}/note")
@PostMapping("/{userId}/note")
public NoteResponse.NoteJoinRes createNote(@PathVariable Long userId, @RequestBody NoteRequest.NoteJoin noteJoin) {
return noteService.createNote(userId, noteJoin);
}

@GetMapping("/{userId}/purpose")
public int getPurpose(@PathVariable Long userId) {
return userService.getPurpose(userId);
}

// @PostMapping("/api/v2/user")
// public UserResponse.UserJoinRes joinV2(@RequestBody @Valid UserReqRecord.UserJoin userJoinRecord) {
// return userService.joinV2(userJoinRecord);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/dev/neordinary/zero/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public UserResponse.UserBeverageRes showUserBeverage(Long userId) {
return UserConverter.toUserBeverageDto(userEntity);
}

public int getPurpose(Long userId) {
UserEntity userEntity = userRepository.findById(userId).orElseThrow(() -> null);
return userEntity.getMaxSugar().intValue();
}

// public UserResponse.UserJoinRes joinV2(UserReqRecord.UserJoin userJoinRecord) {
//
// return UserConverter.toUserDto(userRepository.save(userJoinRecord.toUser()));
Expand Down

0 comments on commit a2fbc68

Please sign in to comment.