Skip to content

Commit

Permalink
Pull main
Browse files Browse the repository at this point in the history
  • Loading branch information
Gahyun-Lee authored Oct 22, 2023
2 parents 46c0bd2 + 49c8dab commit 470d02c
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/comments")
@Tag(name = "댓글", description = "댓글 API")
@Tag(name = "댓글", description = "커뮤니티 APIs")
public class CommentController {
private final CreateParentCommentUseCase createParentCommentUseCase;
private final CreateChildCommentUseCase createChildCommentUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/commentlike")
@Tag(name = "댓글 좋아요", description = "댓글 좋아요 API")
@Tag(name = "댓글 좋아요", description = "커뮤니티 APIs")
public class CommentLikeController {
private final CreateCommentLikeUseCase createCommentLikeUseCase;
private final SwitchCommentLikeUseCase switchCommentLikeUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.domain.like.postlike.dto.PostLikeResponseDto;
import likelion.univ.like.postlike.dto.PostLikeRequestDto;
import likelion.univ.like.postlike.usecase.CreatePostLikeUseCase;
Expand All @@ -13,6 +14,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/likepost")
@Tag(name = "게시글 좋아요", description = "커뮤니티 APIs")
public class PostLikeController {
private final CreatePostLikeUseCase createPostLikeUseCase;
private final DeletePostLikeUseCase deletePostLikeUseCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.domain.post.dto.response.PostDetailResponseDto;
import likelion.univ.domain.post.dto.response.PostCommandResponseDto;
import likelion.univ.domain.post.entity.enums.MainCategory;
Expand All @@ -22,6 +23,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/posts")
@Tag(name = "게시글", description = "커뮤니티, 마이페이지 APIs")
public class PostController {

private final PostCreateUseCase postCreateUseCase;
Expand All @@ -30,30 +32,33 @@ public class PostController {
private final PostReadRepository postReadRepository;

/* read */
@Operation(summary = "(커뮤니티) 카테고리별 posts 최신순 조회", description = "카테고리가 일치하는 게시글 최신순으로 조회")
@Operation(summary = "(커뮤니티) 카테고리별 posts 최신순 조회", description = "카테고리 params\n- maincatstr : 메인 카테고리 문자열(HQ_BOARD, FREE_BOARD, OVERFLOW)\n- subcatstr : 서브 카테고리 문자열(post 생성 참고)\n\n페이지네이션 params\n- page : 0 이상의 정수 \n- size : 양수")
@GetMapping("")
public SuccessResponse<?> findCategorizedPosts(@RequestParam MainCategory mainCategory, @RequestParam SubCategory subCategory, @RequestParam Integer page, @RequestParam Integer size) {
public SuccessResponse<?> findCategorizedPosts(@RequestParam String maincatstr, @RequestParam String subcatstr, @RequestParam Integer page, @RequestParam Integer size) {
PageRequest pageRequest = PageRequest.of(page, size);
MainCategory mainCategory = MainCategory.valueOf(maincatstr);
SubCategory subCategory = SubCategory.valueOf(subcatstr);

List<PostDetailResponseDto> response = postReadRepository.findAll(mainCategory, subCategory, pageRequest);
return SuccessResponse.of(response);
}
@Operation(summary = "(마이페이지) 유저별 posts 최신순 조회", description = "유저Id를 param으로 넣어서, 유저별로 작성한 게시글을 최신순으로 조회")
@Operation(summary = "(마이페이지) 유저별 posts 최신순 조회", description = "유저Id를 param으로 넣어서, 유저별로 작성한 게시글을 최신순으로 조회 \n- page : 0 이상의 정수 \n- size : 양수")
@GetMapping("/author/{userId}")
public SuccessResponse<?> findAuthorPosts(@PathVariable Long userId, @RequestParam Integer page, @RequestParam Integer size) {
PageRequest pageRequest = PageRequest.of(page, size);
List<PostDetailResponseDto> response = postReadRepository.findAuthorPosts(userId, pageRequest);
return SuccessResponse.of(response);
}

@Operation(summary = "(마이페이지) 유저가 댓글을 단 posts 최신순 조회", description = "(로그인된 유저 기준 only) 댓글 단 posts 최신순 조회")
@Operation(summary = "(마이페이지) 유저가 댓글을 단 posts 최신순 조회", description = "(로그인된 유저 기준 only) 댓글 단 posts 최신순 조회 \n- page : 0 이상의 정수 \n- size : 양수")
@GetMapping("/commented")
public SuccessResponse<?> findCommentedPosts(@RequestParam Integer page, @RequestParam Integer size) {
PageRequest pageRequest = PageRequest.of(page, size);
List<PostDetailResponseDto> response = postReadRepository.findCommentedPosts(pageRequest);
return SuccessResponse.of(response);
}

@Operation(summary = "(마이페이지) 유저가 좋아요한 posts 최신순 조회", description = "(로그인된 유저 기준 only) 좋아요를 누른 posts 최신순 조회")
@Operation(summary = "(마이페이지) 유저가 좋아요한 posts 최신순 조회", description = "(로그인된 유저 기준 only) 좋아요를 누른 posts 최신순 조회 \n- page : 0 이상의 정수 \n- size : 양수")
@GetMapping("/liked")
public SuccessResponse<?> findLikedPosts(@RequestParam Integer page, @RequestParam Integer size) {
PageRequest pageRequest = PageRequest.of(page, size);
Expand All @@ -62,7 +67,7 @@ public SuccessResponse<?> findLikedPosts(@RequestParam Integer page, @RequestPar
}

/* command */
@Operation(summary = "게시글을 생성", description = "(작업중 - 카테고리 반영 필요)")
@Operation(summary = "게시글을 생성", description = "Main Category\n- HQ_BOARD(멋대 중앙)\n- FREE_BOARD(자유게시판)\n- OVERFLOW(멋사 오버플로우) \n\nSub Category\n- HQ_BOARD : NOTICE(공지사항), QNA(질문건의), HQ_INFO(정보공유)\n- FREE_BOARD : FREE_INFO(정보공유), GET_MEMBER(팀원구함), GET_PROJECT(프로젝트 구함), SHOWOFF(프로젝트 자랑)\n- OVERFLOW : FRONTEND(프론트엔드), BACKEND(백엔드), PM(기획), UXUI(디자인), ETC(기타)")
@PostMapping("/new")
public SuccessResponse<?> createPost(@RequestBody @Valid PostCreateRequestDto request/*, BindingResult bindingResult*/) {
PostCommandResponseDto response = postCreateUseCase.execute(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class PostCreateRequestDto {
@Schema(description = "썸네일 이미지", example = "string")
private String thumbnail;
@NotNull
@Schema(description = "메인 카테고리", example = "자유게시판", required = true)
@Schema(description = "메인 카테고리", example = "FREE_BOARD", required = true)
private String mainCategory;
@NotNull
@Schema(description = "서브 카테고리", example = "백엔드", required = true)
@Schema(description = "서브 카테고리", example = "FREE_INFO", required = true)
private String subCategory;
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private static QPostDetailResponseDto postDetailResponseDto() {
post.title,
post.body,
post.thumbnail,
post.postLikes.size(),
post.mainCategory,
post.subCategory,
post.createdDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ public JPAQueryFactory jpaQueryFactory(EntityManager entityManager) {
return new JPAQueryFactory(entityManager);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public class Comment extends BaseTimeEntity {
private Comment parentComment;

@OneToMany(mappedBy = "comment",
cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true) // 안정성 체크해봐야됨
cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true)
private List<CommentLike> commentLikes = new ArrayList<>();


@OneToMany(mappedBy = "parentComment",
cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true) // 안정성 체크해봐야됨
cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true)
private List<Comment> childComments = new ArrayList<>();

@Column(nullable = false, columnDefinition = "TEXT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class PostDetailResponseDto {

private String thumbnail;

private Integer likeCount;

private MainCategory mainCategory;

private SubCategory subCategory;
Expand All @@ -32,13 +34,14 @@ public class PostDetailResponseDto {
private LocalDateTime modifiedDate;

@QueryProjection
public PostDetailResponseDto(Long postId, Long authorId, String authorName, String title, String body, String thumbnail, MainCategory mainCategory, SubCategory subCategory, LocalDateTime createdDate, LocalDateTime modifiedDate) {
public PostDetailResponseDto(Long postId, Long authorId, String authorName, String title, String body, String thumbnail, Integer likeCount, MainCategory mainCategory, SubCategory subCategory, LocalDateTime createdDate, LocalDateTime modifiedDate) {
this.postId = postId;
this.authorId = authorId;
this.authorName = authorName;
this.title = title;
this.body = body;
this.thumbnail = thumbnail;
this.likeCount = likeCount;
this.mainCategory = mainCategory;
this.subCategory = subCategory;
this.createdDate = createdDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package likelion.univ.domain.post.entity;

import likelion.univ.common.entity.BaseTimeEntity;
import likelion.univ.domain.like.postlike.entity.PostLike;
import likelion.univ.domain.post.dto.request.PostUpdateServiceDto;
import likelion.univ.domain.post.entity.enums.MainCategory;
import likelion.univ.domain.post.entity.enums.SubCategory;
import likelion.univ.domain.user.entity.User;
import lombok.*;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand All @@ -32,6 +35,10 @@ public class Post extends BaseTimeEntity {

private String thumbnail;

@OneToMany(mappedBy = "post",
cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, orphanRemoval = true)
private List<PostLike> postLikes = new ArrayList();

@Enumerated(EnumType.STRING)
private MainCategory mainCategory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
@Getter
@RequiredArgsConstructor
public enum MainCategory {
HQ("HQ"),
BOARD("BOARD"),
OVERFLOW("OVERFLOW");

HQ_BOARD("멋대 중앙"),
FREE_BOARD("자유게시판"),
OVERFLOW("멋사 오버플로우");

private final String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
@Getter
@RequiredArgsConstructor
public enum SubCategory {
NOTICE("SUBCATEGORY_NOTICE", "공지"),
QNA("SUBCATEGORY_QNA", "질의응답"),
FREEBOARD("SUBCATEGORY_INFO", "정보공유"),
FRONTEND("SUBCATEGORY_FRONTEND", "프론트"),
BACKEND("SUBCATEGORY_BACKEND", "백엔드"),
DESIGN("SUBCATEGORY_DESIGN", "디자인"),
PROJECT("SUBCATEGORY_PROJECT", "프로젝트");


private final String key;
private final String title;
// HQ
NOTICE("공지사항"),
QNA("질문건의"),
HQ_INFO("중앙정보공유"),

// board
FREE_INFO("멋대정보공유"),
GET_MEMBER("팀원 모집"),
GET_PROJECT("프로젝트 모집"),
SHOWOFF("프로젝트 자랑"),

// overflow
FRONTEND("프론트"),
BACKEND("백엔드"),
PM("기획"),
UXUI("디자인"),
ETC("기타");

private final String value;

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import likelion.univ.domain.post.dto.request.PostUpdateServiceDto;
import likelion.univ.domain.post.dto.response.PostCommandResponseDto;
import likelion.univ.domain.post.entity.Post;
import likelion.univ.domain.post.entity.enums.MainCategory;
import likelion.univ.domain.post.entity.enums.SubCategory;
import likelion.univ.domain.post.exception.PostNoAuthorizationException;
import likelion.univ.domain.user.adaptor.UserAdaptor;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -54,9 +56,8 @@ private Post createEntity(PostCreateServiceDto request) {
.title(request.getTitle())
.body(request.getBody())
.thumbnail(request.getThumbnail())
// TODO : category 입력되도록 수정
// .mainCategory(MainCategory.valueOf(request.getMainCategory()))
// .subCategory(SubCategory.valueOf(request.getSubCategory()))
.mainCategory(MainCategory.valueOf(request.getMainCategory()))
.subCategory(SubCategory.valueOf(request.getSubCategory()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ public enum Part {
PM("기획"),
DESIGNER("디자인"),
PM_DESIGNER("기획/디자인");

private String value;

}

0 comments on commit 470d02c

Please sign in to comment.