Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
strongmhk committed Dec 4, 2024
2 parents a4bbcd5 + fc8ac86 commit 11d8dd0
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 86 deletions.
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/issue-form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ body:
placeholder: 'GAJI-00'
validations:
required: true

- type: input
id: description
attributes:
label: '이슈 내용(Description)'
description: '이슈에 대해서 간략히 설명해주세요'
validations:
required: true

- type: textarea
id: details
attributes:
Expand All @@ -29,7 +27,6 @@ body:
- About Details
validations:
required: true

- type: textarea
id: tasks
attributes:
Expand All @@ -40,7 +37,6 @@ body:
- [ ] Task2
validations:
required: true

- type: textarea
id: references
attributes:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ jobs:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}

- name: Checkout develop code
uses: actions/checkout@v4
with:
ref: develop

- name: Issue Parser
uses: stefanbuck/github-issue-praser@v3
id: issue-parser
with:
template-path: ./.github/ISSUE_TEMPLATE/issue-form.yml

- name: Log Issue Parser
run: |
echo '${{ steps.issue-parser.outputs.jsonString }}'
- name: Convert markdown to Jira Syntax
uses: peter-evans/jira2md@v1
id: md2jira
Expand All @@ -40,7 +36,6 @@ jobs:
${{ github.event.issue.body }}
mode: md2jira

- name: Create Issue
id: create
uses: atlassian/gajira-create@v3
Expand All @@ -55,23 +50,18 @@ jobs:
"key": "${{ steps.issue-parser.outputs.issueparser_parentKey }}"
}
}
- name: Log created issue
run: echo "Jira Issue ${{ steps.issue-parser.outputs.parentKey }}/${{ steps.create.outputs.issue }} was created"

- name: Checkout develop code
uses: actions/checkout@v4
with:
ref: develop

- name: Create branch with Ticket number
run: |
sanitized_branch_name=$(echo '${{ github.event.issue.title }}/${{ steps.create.outputs.issue }}' | sed 's/[^a-zA-Z0-9_/-]/-/g')
sanitized_branch_name=$(echo "$sanitized_branch_name" | sed 's/-\+/-/g' | sed 's/-$//g' | sed 's/^-\+//g')
git checkout -b "$sanitized_branch_name"
git push origin "$sanitized_branch_name"
- name: Update issue title
uses: actions-cool/issues-helper@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gaji/service/domain/enums/PostTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static PostTypeEnum from(String param) {
}
}
log.error("PostTypeEnum.from() exception occur param: {}", param);
throw new RestApiException(CommunityPostErrorStatus._INVALID_POST_TYPE);
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static CommunityPostCommentResponseDTO.PostCommentDTO toPostCommentDTO(Co
return CommunityPostCommentResponseDTO.PostCommentDTO.builder()
.commentId(comment.getId())
.userId(comment.getUser().getId())
.userNickName(comment.getUser().getName())
.userNickName(comment.getUser().getNickname())
.commentBody(comment.getBody())
.groupNum(comment.getGroupNum())
.depth(comment.getDepth())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,15 @@
@RequiredArgsConstructor
@Component
public class CommunityPostConverter {
private final HashtagService hashtagService;
private final CategoryService categoryService;
private final CommunityPostBookMarkService postBookMarkService;
private final CommunityPostLikesService postLikesService;
private final CommunityPostQueryService communityPostQueryService;

// 초기 PostStatus 지정
public static PostStatusEnum getInitialPostStatus(PostTypeEnum type) {
return (type == PostTypeEnum.QUESTION) ? PostStatusEnum.NEED_RESOLUTION :
(type == PostTypeEnum.PROJECT) ? PostStatusEnum.RECRUITING : PostStatusEnum.BLOGING;
}

public static CommunityPostResponseDTO.UploadPostResponseDTO toUploadPostResponseDTO(CommnuityPost post) {
return CommunityPostResponseDTO.UploadPostResponseDTO
public static CommunityPostResponseDTO.PostIdResponseDTO toPostIdResponseDTO(CommnuityPost post) {
return CommunityPostResponseDTO.PostIdResponseDTO
.builder()
.postId(post.getId())
.build();
Expand All @@ -63,14 +58,15 @@ public static CommunityPostResponseDTO.PostLikesIdDTO toPostLikesIdDTO(PostLikes
}

public static CommnuityPost toPost(CommunityPostRequestDTO.UploadPostRequestDTO request, User user) {
PostTypeEnum postTypeEnum = PostTypeEnum.from(request.getType());

return CommnuityPost.builder()
.user(user)
.title(request.getTitle())
.body(request.getBody())
.thumbnailUrl(/*(request.getThumbnailUrl() == null) ? Post.getDefaultThumbnailUrl() : request.getThumbnailUrl()*/
request.getThumbnailUrl())
.type(request.getType())
.status(getInitialPostStatus(request.getType()))
.thumbnailUrl(request.getThumbnailUrl())
.type(postTypeEnum)
.status(getInitialPostStatus(postTypeEnum))
.build();
}

Expand All @@ -97,8 +93,7 @@ public static PostLikes toPostLikes(User user, CommnuityPost post) {
.build();
}

public CommunityPostResponseDTO.PostPreviewDTO toPostPreviewDTO(CommnuityPost post) {
List<SelectHashtag> selectHashtagList = hashtagService.findAllFetchJoinWithHashtagByEntityIdAndPostType(post.getId(), post.getType());
public static CommunityPostResponseDTO.PostPreviewDTO toPostPreviewDTO(CommnuityPost post, List<SelectHashtag> selectHashtagList) {
List<String> hashtagList = HashtagConverter.toHashtagNameList(selectHashtagList);

return CommunityPostResponseDTO.PostPreviewDTO.builder()
Expand All @@ -117,10 +112,9 @@ public CommunityPostResponseDTO.PostPreviewDTO toPostPreviewDTO(CommnuityPost po
.build();
}

public CommunityPostResponseDTO.PostPreviewListDTO toPostPreviewListDTO(List<CommnuityPost> postList, boolean hasNext) {
CommunityPostConverter postConverter = new CommunityPostConverter(hashtagService, categoryService, postBookMarkService, postLikesService, communityPostQueryService);
public static CommunityPostResponseDTO.PostPreviewListDTO toPostPreviewListDTO(List<CommnuityPost> postList, boolean hasNext, List<SelectHashtag> selectHashtagList) {
List<CommunityPostResponseDTO.PostPreviewDTO> postPreviewDTOList = postList.stream()
.map(postConverter::toPostPreviewDTO)
.map(post -> CommunityPostConverter.toPostPreviewDTO(post, selectHashtagList))
.collect(Collectors.toList());

return CommunityPostResponseDTO.PostPreviewListDTO.builder()
Expand All @@ -129,20 +123,10 @@ public CommunityPostResponseDTO.PostPreviewListDTO toPostPreviewListDTO(List<Com
.build();
}

public CommunityPostResponseDTO.PostDetailDTO toPostDetailDTO(CommnuityPost post, Long userId, SelectCategory selectCategory) {
List<SelectHashtag> selectHashtagList = hashtagService.findAllFetchJoinWithHashtagByEntityIdAndPostType(post.getId(), post.getType());
public static CommunityPostResponseDTO.PostDetailDTO toPostDetailDTO(CommnuityPost post, SelectCategory selectCategory, List<SelectHashtag> selectHashtagList,
boolean isBookmarked, boolean isLiked, boolean isWriter) {
List<HashtagResponseDTO.HashtagNameAndIdDTO> hashtagNameAndIdDTOList = HashtagConverter.toHashtagNameAndIdDTOList(selectHashtagList);

// ofNullable 메서드로 NPE 방지
/*CategoryEnum category = Optional.ofNullable(categoryService.findOneFetchJoinWithCategoryByEntityIdAndPostType(post.getId(), post.getType()))
.map(SelectCategory::getCategory)
.map(Category::getCategory)
.orElse(null);*/

boolean isBookmarked = (userId == null) ? false : postBookMarkService.existsByUserAndPost(userId, post);
boolean isLiked = (userId == null) ? false : postLikesService.existsByUserAndPost(userId, post);
boolean isWriter = (userId == null) ? false : communityPostQueryService.isPostWriter(userId, post);

return CommunityPostResponseDTO.PostDetailDTO.builder()
.userId(post.getUser().getId())
.type(post.getType())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package gaji.service.domain.post.converter;

import gaji.service.domain.enums.PostTypeEnum;
import gaji.service.domain.post.code.CommunityPostErrorStatus;
import gaji.service.global.exception.RestApiException;
import org.springframework.core.convert.converter.Converter;

public class PostTypeConverter implements Converter<String, PostTypeEnum> {

@Override
public PostTypeEnum convert(String param) {
return PostTypeEnum.from(param);
PostTypeEnum postType = PostTypeEnum.from(param);
if (postType == null) {
throw new RestApiException(CommunityPostErrorStatus._INVALID_POST_TYPE);
}
return postType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gaji.service.domain.post.entity.CommnuityPost;
import gaji.service.domain.post.entity.CommunityComment;
import gaji.service.domain.post.web.dto.CommunityPostCommentResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostRequestDTO;
import gaji.service.domain.user.entity.User;
import org.springframework.data.domain.Slice;
Expand All @@ -13,7 +14,7 @@ public interface CommunityCommentService {
CommunityComment createCommentByCheckParentCommentIdIsNull(Long parentCommentId, CommunityPostRequestDTO.WriteCommentRequestDTO request, User findUser, CommnuityPost findPost);
void hardDeleteComment(CommunityComment comment);
CommunityComment findByCommentId(Long commentId);
Slice<CommunityComment> getCommentListByPost(Long postId, Integer lastGroupNum, int page, int size);
CommunityPostCommentResponseDTO.PostCommentListDTO getCommentListByPost(Long userId, Long postId, Integer lastGroupNum, int page, int size);
boolean isCommentWriter(Long userId, CommunityComment comment);
void validCommentWriter(Long userId, CommunityComment comment);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package gaji.service.domain.post.service;

import gaji.service.domain.post.code.CommunityCommentErrorStatus;
import gaji.service.domain.post.converter.CommunityCommentConverter;
import gaji.service.domain.post.converter.CommunityPostConverter;
import gaji.service.domain.post.entity.CommnuityPost;
import gaji.service.domain.post.entity.CommunityComment;
import gaji.service.domain.post.repository.CommunityCommentJpaRepository;
import gaji.service.domain.post.web.dto.CommunityPostCommentResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostRequestDTO;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;
import gaji.service.domain.user.entity.User;
import gaji.service.global.exception.RestApiException;
import lombok.RequiredArgsConstructor;
Expand All @@ -14,6 +17,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Expand Down Expand Up @@ -45,10 +51,22 @@ public void hardDeleteComment(CommunityComment comment) {
}

@Override
public Slice<CommunityComment> getCommentListByPost(Long postId, Integer lastGroupNum, int page, int size) {
public CommunityPostCommentResponseDTO.PostCommentListDTO getCommentListByPost(Long userId, Long postId, Integer lastGroupNum, int page, int size) {
PageRequest pageRequest = PageRequest.of(page, size);
CommnuityPost findPost = communityPostQueryService.findPostByPostId(postId);
return communityCommentJpaRepository.findBySliceAndPostFetchJoinWithUser(lastGroupNum, findPost, pageRequest);
Slice<CommunityComment> commentSlice = communityCommentJpaRepository.findBySliceAndPostFetchJoinWithUser(lastGroupNum, findPost, pageRequest);

List<CommunityPostCommentResponseDTO.PostCommentDTO> postCommentDTOList = new ArrayList<>();

for (CommunityComment communityComment : commentSlice.getContent()) {
boolean isWriter = (userId == null) ? false : isCommentWriter(userId, communityComment);
postCommentDTOList.add(CommunityCommentConverter.toPostCommentDTO(communityComment, isWriter));
}

return CommunityPostCommentResponseDTO.PostCommentListDTO.builder()
.commentList(postCommentDTOList)
.hasNext(commentSlice.hasNext())
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
import gaji.service.domain.post.entity.CommunityComment;
import gaji.service.domain.post.entity.PostBookmark;
import gaji.service.domain.post.entity.PostLikes;
import gaji.service.domain.post.web.dto.CommunityPostCommentResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostRequestDTO;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;

public interface CommunityPostCommandService {

CommnuityPost uploadPost(Long userId, CommunityPostRequestDTO.UploadPostRequestDTO request);
CommunityComment writeCommentOnCommunityPost(Long userId, Long postId, Long parentCommentId, CommunityPostRequestDTO.WriteCommentRequestDTO request);
CommunityPostResponseDTO.PostIdResponseDTO uploadPost(Long userId, CommunityPostRequestDTO.UploadPostRequestDTO request);
CommunityPostResponseDTO.PostIdResponseDTO editPost(Long userId, Long postId, CommunityPostRequestDTO.EditPostRequestDTO request);
CommunityPostCommentResponseDTO.WriteCommentResponseDTO writeCommentOnCommunityPost(Long userId, Long postId, Long parentCommentId, CommunityPostRequestDTO.WriteCommentRequestDTO request);
void hardDeleteComment(Long userId, Long commentId);
void hardDeleteCommunityPost(Long userId, Long postId);
PostBookmark bookmarkCommunityPost(Long userId, Long postId);
CommunityPostResponseDTO.PostBookmarkIdDTO bookmarkCommunityPost(Long userId, Long postId);
void cancelbookmarkCommunityPost(Long userId, Long postId);
PostLikes likeCommunityPost(Long userId, Long postId);
CommunityPostResponseDTO.PostLikesIdDTO likeCommunityPost(Long userId, Long postId);
void cancelLikeCommunityPost(Long userId, Long postId);

}
Loading

0 comments on commit 11d8dd0

Please sign in to comment.