Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pr Feat/9 member post comment mapping #53

Merged
merged 38 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
36609a3
fix: 순환참조 해결을 위해 공통된 로직 분리 (#51)
toychip Feb 9, 2024
801ae5a
fix: 꿀팁공유해요 좋아요 로직 추가 & Member와 연관관계 매핑 (#51)
toychip Feb 9, 2024
7594bf6
feat: 꿀팁공유해요 수정, 삭제시 검증 (#51)
toychip Feb 9, 2024
9b5a1e9
feat: Comment Member 연관관계 매핑, 댓글 생성시 현재 유저 추출 (#51)
toychip Feb 9, 2024
6deec55
refactor: getCurrentMember SecurityUtil 통합 (#51)
toychip Feb 9, 2024
2626944
feat: 댓글 삭제시 검증 메서드 추가 (#51)
toychip Feb 9, 2024
9116f65
feat: Comment, HoneyTipSingleResponse에 작성자 추가 (#51)
toychip Feb 9, 2024
bd350f9
feat: 좋아요 생성 및 삭제 기능 추가 (#51)
toychip Feb 9, 2024
9e587dc
fix: 잘못된 쿼리 수정 - 게시글이 존재시 저장x -> 회원ID와 게시글이 존재시 저장x (#51)
toychip Feb 10, 2024
3ed123c
fix: 댓글 정렬 수정 - 기본 오름차순, 대댓글시 최후로 조회 (#51)
toychip Feb 10, 2024
1365f80
feat: 좋아요 개수 카운트 (#51)
toychip Feb 10, 2024
5c0881b
refactor: 조회 쿼리를 Service로 담당하도록 이동 (#51)
toychip Feb 10, 2024
60daee8
refactor: 컬렉션 사이즈로 계산한 카운트를 명시적인 카운트 쿼리로 수정 (#51)
toychip Feb 10, 2024
b772377
feat: CommonDefaultResponse.honeyTipCategory 좋아요 수 추가 (#51)
toychip Feb 10, 2024
387d97a
feat: Question & HoneyTip main TOP5 계산 기능 추가 (#51)
toychip Feb 10, 2024
d31a1c2
docs: 꿀팁공유해요 게시글 좋아요 추가 및 취소 명세서 (#51)
toychip Feb 10, 2024
ece6958
feat: Question Member 연관관계 매핑, Question 단건, 전체 조회시 fetch join (#51)
toychip Feb 10, 2024
8cddc90
feat: Report, Member 연관관계 매핑, Report 생성시 사용자 주입 (#51)
toychip Feb 10, 2024
6a3fb57
feat: 회원가입 직후 프로필 사진, 관심사, 닉네임 삽입 로직 (#51)
toychip Feb 10, 2024
9247f00
feat: 닉네임 중복 확인 API (#51)
toychip Feb 10, 2024
5ca0b47
feat: 추가 정보 등록 - 프로필 사진 업로드 추가 (#51)
toychip Feb 10, 2024
81ae249
feat: 독립 경력 자동 증가 로직 - 스케줄러 사용 (#51)
toychip Feb 10, 2024
df3d9d6
fix: BaseEntity.auditorProvider() 객체 참조값을 실제 originName으로 변경 (#51)
toychip Feb 10, 2024
6fdcc51
fix: 프론트 요구사항 반영 - 댓글 삭제(softdelete)가 아닌 삭제된 댓글로 보이게 수정 (#51)
toychip Feb 11, 2024
2e0549d
fix: 프론트 요구사항 반영 - 검색 기능 - 내용 포함 -> 제목 포함 (#51)
toychip Feb 11, 2024
c07695c
fix: oauth 관련 security 제거, accessToken을 활용한 security 초안 (#51)
toychip Feb 12, 2024
04b1b3b
fix: kakao accessToken으로 로그인, Server jwt 발급 (#51)
toychip Feb 12, 2024
769aa7f
fix: naver accessToken으로 로그인 (#51)
toychip Feb 12, 2024
15384bc
Merge pull request #55 from ttoklip/54-fix-web-로그인-방식-sdk-로그인-방식-활용
toychip Feb 12, 2024
5bc24ee
fix: Security 접근 보안 설정, jwt token 필요 (#51)
toychip Feb 12, 2024
2aa6800
docs: Security 접근 보안 설정, jwt token 필요 (#51)
toychip Feb 12, 2024
8e69a19
fix: 개인정보 기입, 로그인 명세서 작성 (#51)
toychip Feb 12, 2024
6da09dd
Merge remote-tracking branch 'origin/54-fix-web-로그인-방식-sdk-로그인-방식-활용'…
toychip Feb 12, 2024
752af78
fix: application.yml 시큐리티 설정 제거 (#51)
toychip Feb 12, 2024
aba7db0
Merge pull request #56 from ttoklip/54-fix-web-로그인-방식-sdk-로그인-방식-활용
toychip Feb 12, 2024
45c1775
fix: System.out.println() -> log.info() (#51)
toychip Feb 12, 2024
f08de8d
fix: security url apply, swagger open (#51)
toychip Feb 12, 2024
7b14e71
feat: 누락 BaseEntity 상속 추가 (#51)
toychip Feb 12, 2024
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 @@ -7,7 +7,7 @@
import com.api.ttoklip.domain.common.report.service.ReportService;
import com.api.ttoklip.domain.honeytip.comment.domain.HoneyTipComment;
import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip;
import com.api.ttoklip.domain.honeytip.post.service.HoneyTipPostService;
import com.api.ttoklip.domain.honeytip.post.service.HoneyTipCommonService;
import com.api.ttoklip.global.success.Message;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
Expand All @@ -19,13 +19,13 @@
@Transactional(readOnly = true)
public class HoneyTipCommentService {

private final HoneyTipPostService honeyTipPostService;
private final HoneyTipCommonService honeyTipCommonService;
private final CommentService commentService;
private final ReportService reportService;

@Transactional
public Message register(final Long postId, final CommentCreateRequest request) {
HoneyTip findHoneyTip = honeyTipPostService.getHoneytip(postId);
HoneyTip findHoneyTip = honeyTipCommonService.getHoneytip(postId);

// comment 부모 찾기
Long parentCommentId = request.getParentCommentId();
Expand Down
toychip marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.api.ttoklip.domain.honeytip.post.service;

import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip;
import com.api.ttoklip.domain.honeytip.post.repository.HoneyTipRepository;
import com.api.ttoklip.global.s3.S3FileUploader;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class HoneyTipCommonService {

private final S3FileUploader s3FileUploader;
private final HoneyTipRepository honeytipRepository;

/* -------------------------------------------- COMMON -------------------------------------------- */
public HoneyTip getHoneytip(final Long postId) {
return honeytipRepository.findByIdActivated(postId);
}

public List<String> uploadImages(final List<MultipartFile> uploadImages) {
return s3FileUploader.uploadMultipartFiles(uploadImages);
}

/* -------------------------------------------- COMMON 끝 -------------------------------------------- */

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.api.ttoklip.domain.common.report.service.ReportService;
import com.api.ttoklip.domain.honeytip.comment.domain.HoneyTipComment;
import com.api.ttoklip.domain.honeytip.image.service.HoneyTipImageService;
import com.api.ttoklip.domain.honeytip.like.service.HoneyTipLikeService;
import com.api.ttoklip.domain.honeytip.post.domain.HoneyTip;
import com.api.ttoklip.domain.honeytip.post.dto.request.HoneyTipCreateReq;
import com.api.ttoklip.domain.honeytip.post.dto.request.HoneyTipEditReq;
Expand All @@ -14,8 +15,9 @@
import com.api.ttoklip.domain.honeytip.url.service.HoneyTipUrlService;
import com.api.ttoklip.domain.main.dto.response.CategoryResponses;
import com.api.ttoklip.domain.main.dto.response.TitleResponse;
import com.api.ttoklip.global.s3.S3FileUploader;
import com.api.ttoklip.domain.member.domain.Member;
import com.api.ttoklip.global.success.Message;
import com.api.ttoklip.global.util.SecurityUtil;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -26,23 +28,14 @@
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class HoneyTipPostService {
private final S3FileUploader s3FileUploader;

private final HoneyTipRepository honeytipRepository;
private final HoneyTipDefaultRepository honeyTipDefaultRepository;
private final ReportService reportService;
private final HoneyTipUrlService honeyTipUrlService;
private final HoneyTipImageService honeyTipImageService;

/* -------------------------------------------- COMMON -------------------------------------------- */
public HoneyTip getHoneytip(final Long postId) {
return honeytipRepository.findByIdActivated(postId);
}

private List<String> uploadImages(final List<MultipartFile> uploadImages) {
return s3FileUploader.uploadMultipartFiles(uploadImages);
}

/* -------------------------------------------- COMMON 끝 -------------------------------------------- */
private final HoneyTipLikeService honeyTipLikeService;
private final HoneyTipCommonService honeyTipCommonService;


/* -------------------------------------------- CREATE -------------------------------------------- */
Expand All @@ -51,7 +44,10 @@ private List<String> uploadImages(final List<MultipartFile> uploadImages) {
public Message register(final HoneyTipCreateReq request) {

// HoneyTip 객체 생성 및 연관 관계 설정
HoneyTip honeytip = HoneyTip.from(request);

Member currentMember = getCurrentMember();

HoneyTip honeytip = HoneyTip.of(request ,currentMember);
honeytipRepository.save(honeytip);

List<MultipartFile> uploadImages = request.getImages();
Expand All @@ -69,7 +65,7 @@ public Message register(final HoneyTipCreateReq request) {

private void registerImages(final HoneyTip honeytip, final List<MultipartFile> uploadImages) {
// S3에 이미지 업로드 후 URL 목록을 가져온다.
List<String> uploadUrls = uploadImages(uploadImages);
List<String> uploadUrls = honeyTipCommonService.uploadImages(uploadImages);
uploadUrls.forEach(uploadUrl -> honeyTipImageService.register(honeytip, uploadUrl));
}

Expand All @@ -85,7 +81,7 @@ private void registerUrls(final HoneyTip honeytip, final List<String> urls) {
public Message edit(final Long postId, final HoneyTipEditReq request) {

// 기존 게시글 찾기
HoneyTip honeyTip = getHoneytip(postId);
HoneyTip honeyTip = honeyTipCommonService.getHoneytip(postId);

// ToDO Validate currentMember

Expand Down Expand Up @@ -125,7 +121,7 @@ private void editImages(final List<MultipartFile> multipartFiles, final HoneyTip
honeyTipImageService.deleteAllByPostId(honeyTipId);

// 새로운 이미지 업로드
List<String> uploadUrls = uploadImages(multipartFiles);
List<String> uploadUrls = honeyTipCommonService.uploadImages(multipartFiles);
uploadUrls.forEach(uploadUrl -> honeyTipImageService.register(honeyTip, uploadUrl));
}

Expand All @@ -135,7 +131,7 @@ private void editImages(final List<MultipartFile> multipartFiles, final HoneyTip
/* -------------------------------------------- DELETE -------------------------------------------- */
@Transactional
public Message delete(final Long postId) {
HoneyTip honeyTip = getHoneytip(postId);
HoneyTip honeyTip = honeyTipCommonService.getHoneytip(postId);
honeyTip.deactivate();

return Message.deletePostSuccess(HoneyTip.class, postId);
Expand All @@ -147,7 +143,7 @@ public Message delete(final Long postId) {
/* -------------------------------------------- REPORT -------------------------------------------- */
@Transactional
public Message report(final Long postId, final ReportCreateRequest request) {
HoneyTip honeytip = getHoneytip(postId);
HoneyTip honeytip = honeyTipCommonService.getHoneytip(postId);
reportService.reportHoneyTip(request, honeytip);

return Message.reportPostSuccess(HoneyTip.class, postId);
Expand Down Expand Up @@ -190,4 +186,12 @@ private List<TitleResponse> convertToTitleResponses(final List<HoneyTip> honeyTi
.toList();
}

public Message like(final Long postId) {
honeyTipLikeService.register(postId);
return Message.likePostSuccess(HoneyTip.class, postId);
}

public static Member getCurrentMember() {
return SecurityUtil.getCurrentMember();
}
}