Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/55-onboarding' into feat/55…
Browse files Browse the repository at this point in the history
…-onboarding
  • Loading branch information
chahyunsoo committed Aug 16, 2024
2 parents e0adf3a + c35386b commit 42dd4da
Show file tree
Hide file tree
Showing 37 changed files with 383 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ public class QPostCommentEntity extends EntityPathBase<PostCommentEntity> {

public static final QPostCommentEntity postCommentEntity = new QPostCommentEntity("postCommentEntity");

public final ussum.homepage.infra.jpa.QBaseEntity _super = new ussum.homepage.infra.jpa.QBaseEntity(this);

public final EnumPath<CommentType> commentType = createEnum("commentType", CommentType.class);

public final StringPath content = createString("content");

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final NumberPath<Long> id = createNumber("id", Long.class);

public final DateTimePath<java.time.LocalDateTime> lastEditedAt = createDateTime("lastEditedAt", java.time.LocalDateTime.class);

public final ussum.homepage.infra.jpa.post.entity.QPostEntity postEntity;

public final EnumPath<CommentType> type = createEnum("type", CommentType.class);
//inherited
public final DateTimePath<java.time.LocalDateTime> updatedAt = _super.updatedAt;

public final ussum.homepage.infra.jpa.user.entity.QUserEntity userEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class QCategoryEntity extends EntityPathBase<CategoryEntity> {

public final QBoardEntity boardEntity;

public final EnumPath<CategoryCode> categoryCode = createEnum("categoryCode", CategoryCode.class);

//inherited
public final DateTimePath<java.time.LocalDateTime> createdAt = _super.createdAt;

public final NumberPath<Long> id = createNumber("id", Long.class);

public final EnumPath<ussum.homepage.infra.jpa.user.entity.MajorCode> majorCode = createEnum("majorCode", ussum.homepage.infra.jpa.user.entity.MajorCode.class);

public final StringPath name = createString("name");

//inherited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class QPostEntity extends EntityPathBase<PostEntity> {

public final DateTimePath<java.time.LocalDateTime> lastEditedAt = createDateTime("lastEditedAt", java.time.LocalDateTime.class);

public final EnumPath<OngoingStatus> ongoingStatus = createEnum("ongoingStatus", OngoingStatus.class);

public final EnumPath<Status> status = createEnum("status", Status.class);

public final StringPath thumbnailImage = createString("thumbnailImage");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public class QPostFileEntity extends EntityPathBase<PostFileEntity> {

public final NumberPath<Long> id = createNumber("id", Long.class);

public final StringPath name = createString("name");

public final QPostEntity postEntity;

public final StringPath size = createString("size");

public final StringPath typeName = createString("typeName");

public final StringPath url = createString("url");

public QPostFileEntity(String variable) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import ussum.homepage.domain.comment.service.PostCommentFormatter;
import ussum.homepage.domain.comment.service.PostCommentModifier;
import ussum.homepage.domain.comment.service.PostCommentReader;
import ussum.homepage.domain.group.Group;
import ussum.homepage.domain.group.service.GroupReader;
import ussum.homepage.domain.member.Member;
import ussum.homepage.domain.member.service.MemberManager;
import ussum.homepage.domain.member.service.MemberReader;
import ussum.homepage.infra.jpa.comment.entity.CommentType;

@Service
@RequiredArgsConstructor
Expand All @@ -30,7 +25,6 @@ public class CommentService {
private final PostCommentFormatter postCommentFormatter;
private final PostCommentAppender postCommentAppender;
private final PostCommentModifier postCommentModifier;
private final MemberReader memberReader;
private final MemberManager memberManager;

public PostCommentListResponse getCommentList(Long postId, int page, int take, String type){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ public record PostOfficialCommentResponse(
String authorName,
String content,
String commentType,
String lastEditedAt
String createdAt,
String lastEditedAt,
Boolean isAuthor
) {
public static PostOfficialCommentResponse of(PostComment postComment, String authorName, String commentType) {
public static PostOfficialCommentResponse of(PostComment postComment, String authorName, String commentType, Boolean isAuthor) {
return new PostOfficialCommentResponse(
postComment.getId(),
authorName,
postComment.getContent(),
commentType,
postComment.getLastEditedAt()
);
postComment.getCreatedAt(),
postComment.getLastEditedAt(),
isAuthor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public ResponseEntity<ApiResponse<?>> createBoardPost(@UserId Long userId,
return ApiResponse.success(postManageService.createBoardPost(userId, boardCode, postCreateRequest));
}

@PostMapping("/{boardCode}/posts/files")
@PostMapping("/{boardCode}/files")
public ResponseEntity<ApiResponse<?>> createBoardPostFile(@UserId Long userId,
@PathVariable(name = "boardCode") String boardCode,
@RequestPart(value = "files") MultipartFile[] files,
@RequestParam(value = "type") String typeName){
@RequestParam(value = "type") String typeName) {
return ApiResponse.success(postManageService.createBoardPostFile(userId, boardCode, files, typeName));
}

Expand All @@ -58,7 +58,7 @@ public ResponseEntity<ApiResponse<?>> editBoardPost(@PathVariable(name = "boardC

@PostMapping("/userIdTest")
public ResponseEntity<ApiResponse<?>> apiTest(@UserId Long userId) {
System.out.println("userId = " + userId);;
System.out.println("userId = " + userId);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import ussum.homepage.application.comment.service.dto.response.PostOfficialCommentResponse;
import ussum.homepage.application.post.service.dto.request.PostCreateRequest;
import ussum.homepage.application.post.service.dto.request.PostUpdateRequest;
import ussum.homepage.application.post.service.dto.request.PostUserRequest;
import ussum.homepage.application.post.service.dto.response.postDetail.*;
import ussum.homepage.application.post.service.dto.response.postList.*;
import ussum.homepage.application.post.service.dto.response.postSave.PostCreateResponse;
import ussum.homepage.application.post.service.dto.response.postSave.PostFileResponse;
import ussum.homepage.domain.comment.PostComment;
import ussum.homepage.domain.comment.service.PostCommentReader;
import ussum.homepage.domain.comment.service.PostOfficialCommentFormatter;
import ussum.homepage.domain.post.Board;
import ussum.homepage.domain.post.Category;
import ussum.homepage.domain.post.Post;
Expand All @@ -25,7 +29,6 @@
import ussum.homepage.global.common.PageInfo;
import ussum.homepage.global.error.exception.GeneralException;
import ussum.homepage.global.error.status.ErrorStatus;
import ussum.homepage.infra.jpa.post.entity.OngoingStatus;
import ussum.homepage.infra.utils.S3utils;

import java.util.List;
Expand All @@ -43,11 +46,13 @@ public class PostManageService {
private final PostReactionReader postReactionReader;
private final CategoryReader categoryReader;
private final UserReader userReader;
private final PostCommentReader postCommentReader;
private final PostFileReader postFileReader;
private final PostAppender postAppender;
private final PostFileAppender postFileAppender;
private final PostModifier postModifier;
private final PostStatusProcessor postStatusProcessor;
private final PostOfficialCommentFormatter postOfficialCommentFormatter;
private final S3utils s3utils;

private final Map<String, BiFunction<Post, Integer, ? extends PostListResDto>> postResponseMap = Map.of(
Expand All @@ -58,12 +63,12 @@ public class PostManageService {
"청원게시판", PetitionPostResponse::of
);

private final Map<String, PostDetailFunction<Post, Boolean, String, Integer, String, String, String, ? extends PostDetailResDto>> postDetailResponseMap = Map.of(
"공지사항게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList) -> NoticePostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"분실물게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, another_ignored) -> LostPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList),
"제휴게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList) -> PartnerPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"감사기구게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList) -> AuditPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"청원게시판", (post, isAuthor, authorName, likeCount, onGoingStatus, imageList, ignored) -> PetitionPostDetailResponse.of(post, isAuthor, authorName, likeCount, onGoingStatus, imageList)
private final Map<String, PostDetailFunction<Post, Boolean, String, Integer, String, String, String, PostOfficialCommentResponse, ? extends PostDetailResDto>> postDetailResponseMap = Map.of(
"공지사항게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList, another_ignored) -> NoticePostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"분실물게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, another_ignored1, another_ignored2) -> LostPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList),
"제휴게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList, another_ignored) -> PartnerPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"감사기구게시판", (post, isAuthor, authorName, ignored, categoryName, imageList, fileList, another_ignored) -> AuditPostDetailResponse.of(post, isAuthor, authorName, categoryName, imageList, fileList),
"청원게시판", (post, isAuthor, authorName, likeCount, onGoingStatus, imageList, ignored, postOfficialCommentResponseList) -> PetitionPostDetailResponse.of(post, isAuthor, authorName, likeCount, onGoingStatus, imageList, postOfficialCommentResponseList)
);


Expand Down Expand Up @@ -109,7 +114,7 @@ public PostDetailRes<?> getPost(PostUserRequest postUserRequest, String boardCod
List<String> fileList = postFileReader.getPostFileListByFileType(postFileList);


PostDetailFunction<Post, Boolean, String, Integer, String, String, String, ? extends PostDetailResDto> responseFunction = postDetailResponseMap.get(board.getName());
PostDetailFunction<Post, Boolean, String, Integer, String, String, String, PostOfficialCommentResponse, ? extends PostDetailResDto> responseFunction = postDetailResponseMap.get(board.getName());

if (responseFunction == null) {
throw new GeneralException(ErrorStatus.INVALID_BOARDCODE);
Expand All @@ -119,11 +124,15 @@ public PostDetailRes<?> getPost(PostUserRequest postUserRequest, String boardCod
if (board.getName().equals("청원게시판")) {
Integer likeCount = postReactionReader.countPostReactionsByType(post.getId(), "like");
String postOnGoingStatus = postStatusProcessor.processStatus(post);
response = responseFunction.apply(post, isAuthor, user.getName(), likeCount, postOnGoingStatus, imageList, null);
List<PostComment> officialPostComments = postCommentReader.getCommentListWithPostIdAndCommentType(userId, postId, "OFFICIAL");
List<PostOfficialCommentResponse> postOfficialCommentResponses = officialPostComments.stream()
.map(postOfficialComment -> postOfficialCommentFormatter.format(postOfficialComment, userId))
.toList();
response = responseFunction.apply(post, isAuthor, user.getName(), likeCount, postOnGoingStatus, imageList, null, postOfficialCommentResponses);
} else if (board.getName().equals("제휴게시판") || board.getName().equals("공지사항게시판") || board.getName().equals("감사기구게시판")) {
response = responseFunction.apply(post, isAuthor, user.getName(), null, category.getName(), imageList, fileList);
response = responseFunction.apply(post, isAuthor, user.getName(), null, category.getName(), imageList, fileList,null);
} else if (board.getName().equals("분실물게시판")) {
response = responseFunction.apply(post, isAuthor, user.getName(), null, category.getName(), imageList, null); //분실물 게시판은 파일첨부 제외
response = responseFunction.apply(post, isAuthor, user.getName(), null, category.getName(), imageList, null, null); //분실물 게시판은 파일첨부 제외
}

return PostDetailRes.of(response);
Expand All @@ -134,7 +143,7 @@ public PostCreateResponse createBoardPost(Long userId, String boardCode, PostCre
Board board = boardReader.getBoardWithBoardCode(boardCode);
Category category = categoryReader.getCategoryWithCode(postCreateRequest.categoryCode());
User user = userReader.getUserWithId(userId);
String onGoingStatus = Objects.equals(boardCode, "PETITION") ? "IN_PROGRESS" : null;
String onGoingStatus = Objects.equals(boardCode, "PETITION") ? category.getCategoryCode() : null;

Post post = postAppender.createPost(postCreateRequest.toDomain(board, user, category, onGoingStatus));
postFileAppender.updatePostIdForIds(postCreateRequest.postFileList(), post.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import lombok.Builder;
import lombok.Getter;
import ussum.homepage.application.comment.service.dto.response.PostCommentResponse;
import ussum.homepage.application.comment.service.dto.response.PostOfficialCommentResponse;
import ussum.homepage.domain.post.Post;
import ussum.homepage.infra.jpa.post.entity.OngoingStatus;

Expand All @@ -12,17 +14,20 @@ public class PetitionPostDetailResponse extends PostDetailResDto {
private final Integer likeCount;
private final String onGoingStatus;
private final List<String> imageList;
private final List<PostOfficialCommentResponse> officialCommentList;

@Builder
private PetitionPostDetailResponse(Long postId, String categoryName, String authorName, String title, String content, String createdAt, Boolean isAuthor,
Integer likeCount, String onGoingStatus, List<String> imageList) {
Integer likeCount, String onGoingStatus, List<String> imageList, List<PostOfficialCommentResponse> officialCommentList) {
super(postId, categoryName, authorName, title, content, createdAt, isAuthor);
this.likeCount = likeCount;
this.onGoingStatus = onGoingStatus;
this.imageList = imageList;
this.officialCommentList = officialCommentList;
}

public static PetitionPostDetailResponse of(Post post, Boolean isAuthor, String authorName, Integer likeCount, String onGoingStatus, List<String> imageList) {
public static PetitionPostDetailResponse of(Post post, Boolean isAuthor, String authorName, Integer likeCount, String onGoingStatus, List<String> imageList,
List<PostOfficialCommentResponse> officialCommentList) {
return PetitionPostDetailResponse.builder()
.postId(post.getId())
.categoryName(OngoingStatus.toKorean(onGoingStatus))
Expand All @@ -34,6 +39,7 @@ public static PetitionPostDetailResponse of(Post post, Boolean isAuthor, String
.likeCount(likeCount)
.onGoingStatus(onGoingStatus)
.imageList(imageList)
.officialCommentList(officialCommentList)
.build();
}

Expand Down
Loading

0 comments on commit 42dd4da

Please sign in to comment.