-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 사용자 정지/경고 기능 구현 #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
795e6e4
fix: 공지사항 페이지 당 5개로 수정
brothergiven fc912ba
feat: 사용자 제재 엔터티 클래스 작성
brothergiven f32d8c1
feat: 사용자 제재 DTO, Repository 작성
brothergiven 1415a3f
feat: UserReport 조회 로직 작성
brothergiven dc4a2ef
feat: 유저 정지 상태를 관리하기 위한 status 필드 추가
brothergiven 73657d5
feat: 유저 정지 처리 로직 추가(User 엔터티)
brothergiven ec124be
feat: 유저 제재 및 기록 저장 로직 작성
brothergiven c7b97ab
fix: 직접 작성한 관리자 인증 코드 PreAuthorize 애노테이션으로 대체
brothergiven 12a893c
feat: 유저 제재 관련 컨트롤러 계층 작성
brothergiven 37a4bd2
docs: swagger 작성
brothergiven beba1f5
docs: Swagger 수정
brothergiven 4e0439e
feat: 제재 기록에 Read 필드 추가
brothergiven 3fc76c5
feat: Read 필드 기준으로 조회하는 로직 작성
brothergiven 90296d8
feat: details 필드 추가된 UserAccountException 예외 작성(정지, 경고 시 세부 정보 함께)
brothergiven c4add8c
fix: ExceptionRes DTO 수정( <String, String> -> <String, Object> )
brothergiven 3b356ff
fix: TokenDto 필드 추가(경고/정지 메시지)
brothergiven d9c2cc9
feat: 로그인 시 경고/정지 처리 로직 작성
brothergiven ede73c8
docs: Swagger 수정
brothergiven 4dd5e81
docs: 오타 수정
brothergiven 8c456c1
fix: Optional 예외처리 수정
Uralauah 06e557a
fix: 불필요 메서드 삭제
Uralauah f76e298
fix: warningCount 기본값 설정
Uralauah 0d744da
fix: 로그인 순서 수정
Uralauah c640f7f
fix: 함수 오버로딩
Uralauah 528dc55
fix: 책임 분리
Uralauah 43b7b99
fix: 제재 기간 필드 수정
Uralauah e212092
fix: 제재 기간 필드 수정
Uralauah 2a072ba
feat: 신고 목록 사용자 uuid 추가
Uralauah a6c925b
docs: SanctionReq 필드 설명 수정
Uralauah 61e758a
fix: QnA 조회 페이지 크기 5로 수정
brothergiven 4faa916
fix: 로그인 책임 분리
Uralauah cbcffc3
Merge remote-tracking branch 'origin/feat/admin' into feat/admin
Uralauah d643adb
Merge branch 'develop' into feat/admin
Uralauah e4ebcb3
docs : 스웨거 설명 추가
jung-min-ju fe99db9
style : 변수명 userUuid로 변경
jung-min-ju 695deb3
add : 정지 취소 기능 추가
jung-min-ju 148e326
docs : 정지 취소 기능 스웨거 설명 추가
jung-min-ju dc95a89
add : 정지 기간 끝났을 시, 유저 활성화
jung-min-ju f693e4b
feat : 근거 사유 서버에서 주입되도록 수정
jung-min-ju e77c265
docs : 스웨거 사용되지 않는 에러 설명 제거
jung-min-ju 1c1a74d
fix: isSuspensionExpired() 직렬화 방지하여 Redis 캐시 에러 해결
jung-min-ju 8f11cb2
Merge branch 'develop' into feat/admin
jung-min-ju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,23 @@ | ||
| package gotcha_auth.dto; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import java.time.LocalDateTime; | ||
|
|
||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public record TokenDto( | ||
| String accessToken, | ||
| String refreshToken, | ||
| LocalDateTime accessTokenExpiredAt, | ||
| boolean autoSignIn | ||
| boolean autoSignIn, | ||
| Object warningDetails | ||
| ) { | ||
| public static TokenDto of(String accessToken, String refreshToken, LocalDateTime accessTokenExpiredAt) { | ||
| return new TokenDto(accessToken, refreshToken, accessTokenExpiredAt, false); | ||
| return new TokenDto(accessToken, refreshToken, accessTokenExpiredAt, false, null); | ||
| } | ||
| public static TokenDto of(String accessToken, String refreshToken, LocalDateTime accessTokenExpiredAt, boolean autoSignIn) { | ||
| return new TokenDto(accessToken, refreshToken, accessTokenExpiredAt, autoSignIn); | ||
| return new TokenDto(accessToken, refreshToken, accessTokenExpiredAt, autoSignIn, null); | ||
| } | ||
| public static TokenDto of(String accessToken, String refreshToken, LocalDateTime accessTokenExpiredAt, boolean autoSignIn, Object warningDetails) { | ||
| return new TokenDto(accessToken, refreshToken, accessTokenExpiredAt, autoSignIn, warningDetails); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
gotcha-domain/src/main/java/gotcha_domain/report/UserReportType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| package gotcha_domain.report; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
|
|
||
| @AllArgsConstructor | ||
| public enum UserReportType { | ||
| BAD_LANGUAGE, // 욕설 | ||
| HATE_SPEECH, // 혐오 발언 | ||
| INAPPROPRIATE_NAME, // 불쾌감을 주거나 부적절한 이름 | ||
| SPAM, // 도배 | ||
| OTHER // 기타 | ||
| BAD_LANGUAGE("욕설"), | ||
| HATE_SPEECH("혐오 발언"), | ||
| INAPPROPRIATE_NAME("불쾌감을 주거나 부적절한 이름"), | ||
| SPAM("도배"), | ||
| OTHER("기타. 신고 기록을 참조하세요."); | ||
|
|
||
| String reason; | ||
|
|
||
| public String getReason() { | ||
| return reason; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
gotcha-domain/src/main/java/gotcha_domain/sanction/SanctionType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package gotcha_domain.sanction; | ||
|
|
||
| import gotcha_domain.user.User; | ||
|
|
||
| public enum SanctionType { | ||
| WARNING { | ||
| @Override | ||
| public void apply(User user, Long days) { | ||
| user.incrementWarningCount(); | ||
| } | ||
| }, | ||
| TEMP_BAN { | ||
| @Override | ||
| public void apply(User user, Long days) { | ||
| user.suspendUser(days); | ||
| } | ||
| }, | ||
| TEMP_BAN_CANCEL { | ||
| @Override | ||
| public void apply(User user, Long days) { | ||
| user.unsuspendUser(); // 정지 취소(즉시 해제) | ||
| } | ||
| }, | ||
| PERM_BAN { | ||
| @Override | ||
| public void apply(User user, Long days) { | ||
| user.banUser(); | ||
| } | ||
| }; | ||
|
|
||
| public abstract void apply(User user, Long days); | ||
| } |
74 changes: 74 additions & 0 deletions
74
gotcha-domain/src/main/java/gotcha_domain/sanction/UserSanction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package gotcha_domain.sanction; | ||
|
|
||
| import gotcha_common.entity.BaseTimeEntity; | ||
| import gotcha_domain.report.UserReport; | ||
| import gotcha_domain.user.User; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class UserSanction extends BaseTimeEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| // 제재를 받은 유저 | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id", nullable = false) | ||
| private User user; | ||
|
|
||
| // 조치를 내린 관리자 | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "admin_id", nullable = false) | ||
| private User admin; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "sanction_type", nullable = false) | ||
| private SanctionType sanctionType; | ||
|
|
||
| // 제재 사유 | ||
| @Column(nullable = false, columnDefinition = "TEXT") | ||
| private String reason; | ||
|
|
||
| // 제재 만료 일시 | ||
| @Column(name = "expire_duration") | ||
| private Long expireDuration; | ||
|
|
||
| // 근거가 된 신고(nullable) | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_report_id") | ||
| private UserReport userReport; | ||
|
|
||
| @Column(name = "is_read", nullable = false) | ||
| private boolean isRead = false; | ||
|
|
||
| @Builder | ||
| public UserSanction(User user, User admin, SanctionType sanctionType, String reason, Long expireDuration, UserReport userReport) { | ||
| this.user = user; | ||
| this.admin = admin; | ||
| this.sanctionType = sanctionType; | ||
| this.reason = reason; | ||
| this.expireDuration = expireDuration; | ||
| this.userReport = userReport; | ||
| } | ||
|
|
||
| public void markAsRead() { | ||
| this.isRead = true; | ||
| } | ||
|
|
||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
gotcha-domain/src/main/java/gotcha_domain/user/UserStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package gotcha_domain.user; | ||
|
|
||
| public enum UserStatus { | ||
| ACTIVE, SUSPENDED, BANNED | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 제재 기간이 끝나면, 해당 유저의 상태를 다시 ACTIVE로 돌려주는 기능이 없는 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞네요 "임시 정지된 유저의 경우" 매 로그인 마다 시간이 지났는지 아닌지를 체크 해주는 로직으로 생각해두고 있었는데 추가한다는걸 깜빡했습니다 (__)