Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public ApiResponse<RecruitmentDetailResponse> createRecruitment(

// 모집글 상세 조회
@GetMapping("/{recruitmentId}")
public ApiResponse<RecruitmentDetailResponse> recruitmentDetailInfo(@PathVariable Long recruitmentId) {
return recruitmentService.getRecruitment(recruitmentId);
public ApiResponse<RecruitmentDetailResponse> recruitmentDetailInfo(
@LoginUser Users loginUser,
@PathVariable Long recruitmentId
) {
return recruitmentService.getRecruitment(recruitmentId, loginUser);
}

// 모집글 수정
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class CommentResponse {

private Long commentId;

private Long authorId;

private String authorName;

private String content;
Expand All @@ -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;
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,10 +35,12 @@ public class RecruitmentDetailResponse {

private List<CommentResponse> 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<CommentResponse> comments) {
LocalDateTime createdAt, LocalDateTime updatedAt, List<CommentResponse> comments, boolean isAuthor) {
this.authorId = authorId;
this.recruitGroupId = recruitGroupId;
this.authorName = authorName;
Expand All @@ -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<CommentResponse> comments) {
public static RecruitmentDetailResponse of(Recruitment recruitment, List<CommentResponse> comments, Users loginUser) {
return RecruitmentDetailResponse.builder()
.authorId(recruitment.getAuthor().getUserId())
.recruitGroupId(recruitment.getRecruitGroup().getId())
Expand All @@ -64,6 +68,7 @@ public static RecruitmentDetailResponse of(Recruitment recruitment, List<Comment
.createdAt(recruitment.getPostTime())
.updatedAt(recruitment.getLastModifiedTime())
.comments(comments)
.isAuthor(recruitment.getAuthor().getUserId().equals(loginUser.getUserId()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class RecruitmentResponse {

private Long recruitmentId;

private String authorName;

private String recruitGroupName;
Expand All @@ -28,9 +30,10 @@ public class RecruitmentResponse {
private LocalDateTime updatedAt;

@Builder
private RecruitmentResponse(String authorName, String recruitGroupName, String title,
private RecruitmentResponse(Long recruitmentId, String authorName, String recruitGroupName, String title,
CategoryStatus category, String content, RecruitmentStatus recruitmentStatus,
LocalDateTime createdAt, LocalDateTime updatedAt) {
this.recruitmentId = recruitmentId;
this.authorName = authorName;
this.recruitGroupName = recruitGroupName;
this.title = title;
Expand All @@ -43,6 +46,7 @@ private RecruitmentResponse(String authorName, String recruitGroupName, String t

public static RecruitmentResponse of(Recruitment recruitment) {
return RecruitmentResponse.builder()
.recruitmentId(recruitment.getId())
.authorName(recruitment.getAuthor().getName())
.recruitGroupName(recruitment.getRecruitGroup().getName())
.title(recruitment.getTitle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ public void updateComment(UpdateCommentRequest updateRequest) {
}

public Boolean isBelongToPost(Long recruitmentId) {
return this.post.getPostId().equals(recruitmentId);
return this.post.getId().equals(recruitmentId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Recruitment {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long postId;
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
@Repository
public interface RecruitmentRepository extends JpaRepository<Recruitment, Long> {

@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<Long> findAuthorIdByRecruitmentId(Long recruitmentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecruitmentDetailResponse> getRecruitment(Long recruitmentId) {
public ApiResponse<RecruitmentDetailResponse> getRecruitment(Long recruitmentId, Users loginUser) {
Recruitment recruitment = findRecruitmentBy(recruitmentId);
List<CommentResponse> comments = commentService.getComments(recruitmentId);
return ApiResponse.ok(RecruitmentDetailResponse.of(recruitment, comments));
return ApiResponse.ok(RecruitmentDetailResponse.of(recruitment, comments, loginUser));
}

// 모집글 수정
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}