Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat - admin api 추가 #172

Merged
merged 43 commits into from
Jul 12, 2024
Merged

feat - admin api 추가 #172

merged 43 commits into from
Jul 12, 2024

Conversation

kseysh
Copy link
Member

@kseysh kseysh commented Jul 7, 2024

Related issue 🚀

Work Description 💚

  • admin api를 추가하였습니다.
  • admin login을 통해 jwt의 subject 값이 "ADMIN"인 토큰을 발급하고, 그 토큰을 이용해서 admin api를 이용할 수 있도록 하였습니다.
  • admin jwt의 검증은 spring intercepter를 이용하여 controller에 요청이 가기 전, jwtValidator를 이용해서 jwt의 subject값이 "ADMIN"인지 검증하도록 하였습니다.

Admin login api

application.yml에 있는 값인 admin-auth-code값을 이용하여 jwt의 subject 값이 "ADMIN"인 토큰을 발급합니다.
이 토큰은 spring interceptor를 이용해 api/v1/admin으로 시작되는 모든 api를 검증됩니다. (api/v1/admin/login)은 제외됩니다.

Admin 유저 정보 변경 api

admin jwt를 이용해 유저의 이름 및 포인트를 변경할 수 있도록 합니다.

Admin 일별 챌린지 상태 변경 api

admin jwt를 이용해 dailyChallenge의 상태 및 챌린지 날짜를 변경할 수 있도록 합니다.
request로 보낸 statuses가 기존 dailyChallenge의 period와 맞지 않으면 에러를 발생시킵니다.

Admin 회원 탈퇴 api

admin jwt를 이용해 특정 id의 회원을 탈퇴 시킵니다.
특정 id의 회원이 없다면 탈퇴시키지 않습니다.

kseysh added 30 commits July 4, 2024 23:26
@kseysh kseysh added the ✨ Feat 새로운 기능 추가 label Jul 7, 2024
@kseysh kseysh requested a review from jumining July 7, 2024 09:21
@kseysh kseysh self-assigned this Jul 7, 2024
Copy link
Collaborator

@jumining jumining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인터셉터로 슬랙 회원가입 시 메시지 전송하게 하는 분들도 있길래 들어봤는데 여기서도 들어보네요 허허

Comment on lines +43 to +45
return ResponseEntity
.noContent()
.build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀👍

Comment on lines 68 to 71
int challengePeriod = dailyChallenges.size();
for (int i = 0; i < challengePeriod; i++) {
dailyChallenges.get(i).changeStatus(statuses.get(i));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q. int 변수로 선언한 이유가 궁금해요 반복문을 위해서만 사용되는 변수라면 for문 안에 써줘도 가독성도 해치지 않고 메모리에 변수 공간을 차지 안할 것 같아서용! 뒤의 changeChllangeDateOfDailyChallenges메소드도 같은 방식이여서 같이 여쭤봅니당

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음... 좀더 명시적으로 써놓은 거긴한데 들어보니까 굳이인 것 같긴하네요!

Comment on lines 67 to 71
private void changeStatusOfDailyChallenges(List<DailyChallenge> dailyChallenges, List<Status> statuses) {
int challengePeriod = dailyChallenges.size();
for (int i = 0; i < challengePeriod; i++) {
dailyChallenges.get(i).changeStatus(statuses.get(i));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P5. 날짜가 나중에 365일 이렇게 길어지면 바꿀 챌린지 날짜의 정보만 바꿔주는 로직도 좋을 것 같아요..물론 admin이 자주 쓰이면 안되긴 하겠지만

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵넵 그것도 나중에 필요성이 느껴지면 추가하면 좋을 것 같아요!

Comment on lines +113 to +116

public void withdrawImmediately(Long userId) {
userRepository.deleteById(userId);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1. 즉시 삭제할 때 ExpiredUserDeleteScheduler의 deleteExpiredUser메소드 안에 있던 challengeService.deleteChallengeRelatedByUserId(expiredUserList);이 코드도 실행해주어야 챌린지(+일별챌린지, 앱 등)도 삭제될 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와 아주 좋은 지적 감사합니다~!

@kseysh kseysh requested a review from jumining July 7, 2024 13:54
@kseysh kseysh merged commit a489c9a into develop Jul 12, 2024
1 check passed
@jumining jumining changed the title feat: admin api 추가 feat - admin api 추가 Nov 19, 2024
@jumining jumining deleted the feat/#171-add-admin-api branch November 19, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feat 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: admin api 추가
2 participants