diff --git a/src/main/java/com/umc/TheGoods/domain/community/Comment.java b/src/main/java/com/umc/TheGoods/domain/community/Comment.java index 0641f7d1..8a25e99c 100644 --- a/src/main/java/com/umc/TheGoods/domain/community/Comment.java +++ b/src/main/java/com/umc/TheGoods/domain/community/Comment.java @@ -46,10 +46,18 @@ public class Comment extends BaseDateTimeEntity { @Column(columnDefinition = "TEXT", nullable = false) private String content; - @OneToMany(mappedBy = "comment", cascade = CascadeType.ALL) private List commentLikeList = new ArrayList<>(); @OneToMany(mappedBy = "comment", cascade = CascadeType.ALL) private List commentMentionList = new ArrayList<>(); + + // 엔티티 핵심 메서드 + public void setContent(String newContent) { + this.content = newContent; + } + + public void removeCommentLike(Long id) { + this.commentLikeList.removeIf((like) -> like.getId() == id); + } } diff --git a/src/main/java/com/umc/TheGoods/domain/community/Inquiry.java b/src/main/java/com/umc/TheGoods/domain/community/Inquiry.java index 13870b8b..8e0b247b 100644 --- a/src/main/java/com/umc/TheGoods/domain/community/Inquiry.java +++ b/src/main/java/com/umc/TheGoods/domain/community/Inquiry.java @@ -31,6 +31,10 @@ public class Inquiry extends BaseDateTimeEntity { @JoinColumn(name = "item_id") private Item item; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "seller_id") + private Member seller; + @OneToMany(mappedBy = "inquiry", cascade = CascadeType.ALL) private List inquiryReplyList = new ArrayList<>(); diff --git a/src/main/java/com/umc/TheGoods/domain/member/Member.java b/src/main/java/com/umc/TheGoods/domain/member/Member.java index f49f9882..47fac9bc 100644 --- a/src/main/java/com/umc/TheGoods/domain/member/Member.java +++ b/src/main/java/com/umc/TheGoods/domain/member/Member.java @@ -192,6 +192,9 @@ public class Member extends BaseDateTimeEntity { @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) private List inquiryList = new ArrayList<>(); + @OneToMany(mappedBy = "seller", cascade = CascadeType.ALL) + private List incommingInquiryList = new ArrayList<>(); + // Payment 양방향 매핑 @OneToMany(mappedBy = "member", cascade = CascadeType.ALL) private List paymentList = new ArrayList<>(); diff --git a/src/main/java/com/umc/TheGoods/repository/PostRepository.java b/src/main/java/com/umc/TheGoods/repository/PostRepository.java new file mode 100644 index 00000000..064f4f6c --- /dev/null +++ b/src/main/java/com/umc/TheGoods/repository/PostRepository.java @@ -0,0 +1,10 @@ +package com.umc.TheGoods.repository; + +import com.umc.TheGoods.domain.community.Post; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PostRepository extends JpaRepository { + Page getPostsOrderByLikes(Pageable pageable); +} diff --git a/src/main/java/com/umc/TheGoods/service/.gitkeep b/src/main/java/com/umc/TheGoods/service/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main/java/com/umc/TheGoods/service/PostService/PostCommandService.java b/src/main/java/com/umc/TheGoods/service/PostService/PostCommandService.java new file mode 100644 index 00000000..1e1e3a7b --- /dev/null +++ b/src/main/java/com/umc/TheGoods/service/PostService/PostCommandService.java @@ -0,0 +1,5 @@ +package com.umc.TheGoods.service.PostService; + +public interface PostCommandService { + +} diff --git a/src/main/java/com/umc/TheGoods/service/PostService/PostCommandServiceImpl.java b/src/main/java/com/umc/TheGoods/service/PostService/PostCommandServiceImpl.java new file mode 100644 index 00000000..52a5ba5d --- /dev/null +++ b/src/main/java/com/umc/TheGoods/service/PostService/PostCommandServiceImpl.java @@ -0,0 +1,13 @@ +package com.umc.TheGoods.service.PostService; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Slf4j +@RequiredArgsConstructor +@Transactional +public class PostCommandServiceImpl implements PostCommandService { +} diff --git a/src/main/java/com/umc/TheGoods/service/PostService/PostQueryService.java b/src/main/java/com/umc/TheGoods/service/PostService/PostQueryService.java new file mode 100644 index 00000000..76b828cb --- /dev/null +++ b/src/main/java/com/umc/TheGoods/service/PostService/PostQueryService.java @@ -0,0 +1,9 @@ +package com.umc.TheGoods.service.PostService; + +import com.umc.TheGoods.web.dto.post.PostResponseDto; + +import java.util.List; + +public interface PostQueryService { + List getPostsOrderByLike(); +} diff --git a/src/main/java/com/umc/TheGoods/service/PostService/PostQueryServiceImpl.java b/src/main/java/com/umc/TheGoods/service/PostService/PostQueryServiceImpl.java new file mode 100644 index 00000000..8a67ff2c --- /dev/null +++ b/src/main/java/com/umc/TheGoods/service/PostService/PostQueryServiceImpl.java @@ -0,0 +1,24 @@ +package com.umc.TheGoods.service.PostService; + +import com.umc.TheGoods.repository.PostRepository; +import com.umc.TheGoods.web.dto.post.PostResponseDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class PostQueryServiceImpl implements PostQueryService { + + final PostRepository postRepository; + + @Override + public List getPostsOrderByLike() { + return null; + } +} diff --git a/src/main/java/com/umc/TheGoods/web/controller/PostController.java b/src/main/java/com/umc/TheGoods/web/controller/PostController.java new file mode 100644 index 00000000..2011bf3a --- /dev/null +++ b/src/main/java/com/umc/TheGoods/web/controller/PostController.java @@ -0,0 +1,52 @@ +package com.umc.TheGoods.web.controller; + +import com.umc.TheGoods.apiPayload.ApiResponse; +import com.umc.TheGoods.service.PostService.PostQueryService; +import com.umc.TheGoods.web.dto.post.PostResponseDto; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/posts") +public class PostController { + + final PostQueryService queryService; + + @GetMapping("/") + @Operation(summary = "인기 사장님 피드 전체 조회 API", description = "포스트의 기본 디폴트 정렬로, 좋아요 순으로 내림차순 정렬합니다. \n\n") + @ApiResponses(value = { + @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), + }) + public ApiResponse posts(@RequestParam("like") boolean like) { + return ApiResponse.onSuccess((PostResponseDto.PostListViewDto) queryService.getPostsOrderByLike()); + } + + @GetMapping("/follow") + public ApiResponse following(@RequestParam("like") boolean like) { + return null; + } + + @GetMapping("/{postId}") + public ApiResponse post(@PathVariable Long postId) { + return null; + } + + @PostMapping("/{postId}") + public ApiResponse registerPost(@PathVariable Long postId) { + return null; + } + + @PatchMapping("/{postId}") + public ApiResponse updatePost(@PathVariable Long postId) { + return null; + } + + @DeleteMapping("/{postId}") + public ApiResponse deletePost(@PathVariable Long postId) { + return null; + } + +} diff --git a/src/main/java/com/umc/TheGoods/web/dto/.gitkeep b/src/main/java/com/umc/TheGoods/web/dto/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/src/main/java/com/umc/TheGoods/web/dto/post/PostRequestDto.java b/src/main/java/com/umc/TheGoods/web/dto/post/PostRequestDto.java new file mode 100644 index 00000000..4c14e8eb --- /dev/null +++ b/src/main/java/com/umc/TheGoods/web/dto/post/PostRequestDto.java @@ -0,0 +1,4 @@ +package com.umc.TheGoods.web.dto.post; + +public class PostRequestDto { +} diff --git a/src/main/java/com/umc/TheGoods/web/dto/post/PostResponseDto.java b/src/main/java/com/umc/TheGoods/web/dto/post/PostResponseDto.java new file mode 100644 index 00000000..19bf3d46 --- /dev/null +++ b/src/main/java/com/umc/TheGoods/web/dto/post/PostResponseDto.java @@ -0,0 +1,47 @@ +package com.umc.TheGoods.web.dto.post; + +import com.umc.TheGoods.domain.images.PostImg; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.List; + +public class PostResponseDto { + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class PostViewDto { + Long id; + String title; + String content; + LocalDateTime createdDate; + LocalDateTime updatedDate; + Integer likes; + List images; + Long writerId; + } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class PostListViewDto { + Integer offset; + Integer size; + List posts; + } + + @Builder + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class PostStatusDto { + Long postId; + String status; + } +}