diff --git a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/controller/RecruitmentController.java b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/controller/RecruitmentController.java index 960cc5d..2b90c10 100644 --- a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/controller/RecruitmentController.java +++ b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/controller/RecruitmentController.java @@ -46,8 +46,11 @@ public ApiResponse createRecruitment( // 모집글 상세 조회 @GetMapping("/{recruitmentId}") - public ApiResponse recruitmentDetailInfo(@PathVariable Long recruitmentId) { - return recruitmentService.getRecruitment(recruitmentId); + public ApiResponse recruitmentDetailInfo( + @LoginUser Users loginUser, + @PathVariable Long recruitmentId + ) { + return recruitmentService.getRecruitment(recruitmentId, loginUser); } // 모집글 수정 diff --git a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/CommentResponse.java b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/CommentResponse.java index fd254f1..00c4385 100644 --- a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/CommentResponse.java +++ b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/CommentResponse.java @@ -11,6 +11,8 @@ public class CommentResponse { private Long commentId; + private Long authorId; + private String authorName; private String content; @@ -20,8 +22,9 @@ public class CommentResponse { private LocalDateTime updatedAt; @Builder - private CommentResponse(Long commentId, String authorName, String content, LocalDateTime createdAt, LocalDateTime updatedAt) { + private CommentResponse(Long commentId, Long authorId, String authorName, String content, LocalDateTime createdAt, LocalDateTime updatedAt) { this.commentId = commentId; + this.authorId = authorId; this.authorName = authorName; this.content = content; this.createdAt = createdAt; @@ -31,6 +34,7 @@ private CommentResponse(Long commentId, String authorName, String content, Local public static CommentResponse of(Comment comment) { return CommentResponse.builder() .commentId(comment.getCommentId()) + .authorId(comment.getAuthor().getUserId()) .authorName(comment.getAuthor().getName()) .authorName(comment.getAuthor().getName()) .content(comment.getContent()) diff --git a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/RecruitmentDetailResponse.java b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/RecruitmentDetailResponse.java index 083fe2a..2459ca3 100644 --- a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/RecruitmentDetailResponse.java +++ b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/dto/response/RecruitmentDetailResponse.java @@ -3,6 +3,7 @@ import MathCaptain.weakness.domain.Group.enums.CategoryStatus; import MathCaptain.weakness.domain.Recruitment.entity.Recruitment; import MathCaptain.weakness.domain.Recruitment.enums.RecruitmentStatus; +import MathCaptain.weakness.domain.User.entity.Users; import lombok.*; import java.time.LocalDateTime; @@ -34,10 +35,12 @@ public class RecruitmentDetailResponse { private List comments; + private boolean isAuthor; + @Builder private RecruitmentDetailResponse(Long authorId, Long recruitGroupId, String authorName, String recruitGroupName, String title, CategoryStatus category, String content, RecruitmentStatus recruitmentStatus, - LocalDateTime createdAt, LocalDateTime updatedAt, List comments) { + LocalDateTime createdAt, LocalDateTime updatedAt, List comments, boolean isAuthor) { this.authorId = authorId; this.recruitGroupId = recruitGroupId; this.authorName = authorName; @@ -49,9 +52,10 @@ private RecruitmentDetailResponse(Long authorId, Long recruitGroupId, String aut this.createdAt = createdAt; this.updatedAt = updatedAt; this.comments = comments; + this.isAuthor = isAuthor; } - public static RecruitmentDetailResponse of(Recruitment recruitment, List comments) { + public static RecruitmentDetailResponse of(Recruitment recruitment, List comments, Users loginUser) { return RecruitmentDetailResponse.builder() .authorId(recruitment.getAuthor().getUserId()) .recruitGroupId(recruitment.getRecruitGroup().getId()) @@ -64,6 +68,7 @@ public static RecruitmentDetailResponse of(Recruitment recruitment, List { - @Query("SELECT r.author.userId FROM Recruitment r WHERE r.postId = :recruitmentId") + @Query("SELECT r.author.userId FROM Recruitment r WHERE r.id = :recruitmentId") Optional findAuthorIdByRecruitmentId(Long recruitmentId); } diff --git a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/service/RecruitmentService.java b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/service/RecruitmentService.java index 4ea3d63..343815b 100644 --- a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/service/RecruitmentService.java +++ b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/Recruitment/service/RecruitmentService.java @@ -39,16 +39,15 @@ public class RecruitmentService { Group group = findLeaderGroupByUser(author); Recruitment recruitment = Recruitment.of(author, group, createRecruitmentRequest); recruitmentRepository.save(recruitment); - RecruitmentDetailResponse recruitmentResponse = RecruitmentDetailResponse.of(recruitment, List.of()); + RecruitmentDetailResponse recruitmentResponse = RecruitmentDetailResponse.of(recruitment, List.of(), author); return ApiResponse.ok(recruitmentResponse); } - // 모집글 조회 - public ApiResponse getRecruitment(Long recruitmentId) { + public ApiResponse getRecruitment(Long recruitmentId, Users loginUser) { Recruitment recruitment = findRecruitmentBy(recruitmentId); List comments = commentService.getComments(recruitmentId); - return ApiResponse.ok(RecruitmentDetailResponse.of(recruitment, comments)); + return ApiResponse.ok(RecruitmentDetailResponse.of(recruitment, comments, loginUser)); } // 모집글 수정 diff --git a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/User/enums/Tiers.java b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/User/enums/Tiers.java index e1c9421..da118c0 100644 --- a/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/User/enums/Tiers.java +++ b/MathCaptain/weakness/src/main/java/MathCaptain/weakness/domain/User/enums/Tiers.java @@ -1,10 +1,34 @@ package MathCaptain.weakness.domain.User.enums; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + public enum Tiers { - BRONZE, - SILVER, - GOLD, - PLATINUM, - DIAMOND, - MASTER + BRONZE("브론즈"), + SILVER("실버"), + GOLD("골드"), + PLATINUM("플레티넘"), + DIAMOND("다이아몬드"), + MASTER("마스터"); + + private final String value; + + Tiers(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @JsonCreator + public static Tiers fromValue(String value) { + for (Tiers tier : Tiers.values()) { + if (tier.value.equals(value) || tier.name().equals(value)) { + return tier; + } + } + throw new IllegalArgumentException("정의되지 않은 값 입니다 : " + value); + } }