Skip to content

Commit

Permalink
[Feat] 승인여부 변경 API
Browse files Browse the repository at this point in the history
  • Loading branch information
ibaesuyeon committed Apr 27, 2024
1 parent 2c91b68 commit 3efb08f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,12 @@ public ResponseEntity<List<UserResponse>> getAllUsers() {
List<UserResponse> users = userService.getAllUsers();
return ResponseEntity.ok(users);
}

//승인 여부 변경
@PutMapping("/approve")
public ResponseEntity approveUser(@RequestParam("userId") @Valid Long userId,
@RequestParam("approved") boolean approved) {
boolean isApproved = userService.updateApproved(userId, approved);
return ResponseEntity.ok().body(isApproved);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ public interface UserService{
ResponseEntity unregister(Long userId);

List<UserResponse> getAllUsers();

boolean updateApproved(Long userId, boolean approved);
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,12 @@ public List<UserResponse> getAllUsers() {
}
return userResponses;
}

@Override
public boolean updateApproved(Long userId, boolean approved) {
UserEntity user = userRepository.findById(userId).orElseThrow();
user.setApproved(approved);
userRepository.save(user);
return user.isApproved();
}
}

0 comments on commit 3efb08f

Please sign in to comment.