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

[deploy] ec2 서버 이전 작업 #98

Merged
merged 29 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
371cf02
[test] Jacoco 설정
pagh2322 Mar 2, 2024
c3887f6
Merge pull request #90 from WooriVeryGood/HC-203-test-coverage
pagh2322 Mar 2, 2024
cd4b2e2
[refactor] Post dto 클래스 필드 이름 변경
pagh2322 Mar 2, 2024
a7b066d
[refactor] 프로젝트 구조를 도메인형 디렉토리 구조로 변경
pagh2322 Mar 31, 2024
b19f52f
[docs] 커버리지 비활성 패키지 적용
pagh2322 Mar 31, 2024
0531a84
Merge pull request #91 from WooriVeryGood/HC-204-refactoring
pagh2322 Mar 31, 2024
460fddb
[docs] adoc 엔드포인트 변경 반영
pagh2322 Mar 31, 2024
6f489da
Merge pull request #92 from WooriVeryGood/HC-204-refactoring
pagh2322 Mar 31, 2024
38d0f6e
[docs] adoc 변경 반영
pagh2322 Mar 31, 2024
4ede47e
[fix] 게시글 불러오기 api 수정
pagh2322 Mar 31, 2024
393a372
Merge pull request #93 from WooriVeryGood/HC-204-refactoring
pagh2322 Mar 31, 2024
a4cef39
[feat] 게시글 목록/상세 내용 요청 분리
pagh2322 Mar 31, 2024
95ff4f9
Merge pull request #94 from WooriVeryGood/HC-204-refactoring
pagh2322 Mar 31, 2024
278798a
[refactor] 리뷰 조회 서비스 분리
pagh2322 Apr 1, 2024
03db49c
[refactor] 리뷰 생성/삭제 서비스 분리
pagh2322 Apr 1, 2024
7f73b10
[refactor] 리뷰 좋아요 서비스 리팩토링
pagh2322 Apr 1, 2024
3807b47
[refactor] 강의 관련 리팩토링
pagh2322 Apr 2, 2024
f69fd60
[refactor] 신고 관련 리팩토링
pagh2322 Apr 2, 2024
f8ac80c
[refactor] 댓글 관련 리팩토링
pagh2322 Apr 2, 2024
90afb9f
[docs] 댓글 관련 예외 클래스 패키지 이동
pagh2322 Apr 2, 2024
d05d323
Merge pull request #95 from WooriVeryGood/HC-204-refactoring
pagh2322 Apr 2, 2024
06e4f80
[fix] Review에 Member적용
pagh2322 Apr 28, 2024
c5cb748
[fix] Post와 Report 패키지에 Member적용
pagh2322 Apr 28, 2024
c196ba6
[fix] Comment 패키지에 Member적용
pagh2322 Apr 28, 2024
0be51b5
wip
pagh2322 Apr 28, 2024
ec7ec23
[fix] PostRepository 쿼리 메서드 이름 에러 수정
pagh2322 Apr 28, 2024
e28c188
Merge pull request #96 from WooriVeryGood/HC-204-refactoring
pagh2322 Apr 28, 2024
2410c24
[fix] CommentLike 테이블 이름 수정
pagh2322 Apr 28, 2024
36126d8
Merge pull request #97 from WooriVeryGood/HC-204-refactoring
pagh2322 Apr 28, 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
10 changes: 0 additions & 10 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ jobs:
with:
arguments: build

- name: 테스트 커버리지를 PR에 코멘트로 등록합니다
id: jacoco
uses: madrapps/jacoco-report@v1.2
with:
title: 📝 테스트 커버리지 리포트입니다
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 50
min-coverage-changed-files: 50

# 3. Docker 이미지 빌드
- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/honeycourses-backend-spring-prod .
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ jobs:
if: ${{ always() }} # 테스트가 실패하여도 Report를 보기 위해 `always`로 설정
with:
files: build/test-results/**/*.xml

- name: 테스트 커버리지를 PR에 코멘트로 등록합니다
id: jacoco
uses: madrapps/jacoco-report@v1.2
with:
title: 📝 테스트 커버리지 리포트입니다
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 50
min-coverage-changed-files: 50
14 changes: 14 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

527 changes: 355 additions & 172 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jacocoTestCoverageVerification {
minimum = 0.75
}

excludes = ['*.*Controller', '*.advice.*', '*.dto.*', '*.config.*', '*.domain.*', '*.support.*']
excludes = ['*.*Controller', '*.advice.*', '*.dto.*', '*.global.*', '*.domain.*']
}
}
}
28 changes: 13 additions & 15 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,28 @@ operation::reviews/find/success[snippets='http-request,http-response']
==== 실패
===== 최근 작성한 리뷰가 6개월 이상이거나, 없을경우
operation::reviews/find/fail/denied[snippets='http-request,http-response']
===== 수업이 존재하지 않을 경우
operation::reviews/find/fail/noCourse[snippets='http-request,http-response']

=== 특정 강의의 리뷰 작성하기 (POST /courses/{id}/reviews)
==== 성공
operation::reviews/create/success[snippets='http-request,http-response']

=== 리뷰 좋아요 (PUT /courses/reviews/{rid})
=== 리뷰 좋아요 (PUT /reviews/{id}/like)
==== 성공
operation::reviews/like/success[snippets='http-request,http-response']

=== 내 리뷰 보기 (GET /courses/reviews/me)
=== 내 리뷰 보기 (GET /reviews/me)
==== 성공
operation::reviews/find/me/success[snippets='http-request,http-response']

=== 리뷰 수정 (PUT /courses/reviews/{rid})
=== 리뷰 수정 (PUT /reviews/{id})
==== 성공
operation::reviews/update/success[snippets='http-request,http-response']

==== 실패
===== 권한이 없는 경우
operation::reviews/update/fail/noAuth[snippets='http-request,http-response']

=== 리뷰 삭제 (DELETE /courses/reviews/{rid})
=== 리뷰 삭제 (DELETE /reviews/{id})
==== 성공
operation::reviews/delete/success[snippets='http-request,http-response']

Expand All @@ -62,36 +60,36 @@ operation::reviews/delete/fail/noAuth[snippets='http-request,http-response']

== 게시글 관리

=== 모든 게시글 보기 (GET /community)
=== 모든 게시글 보기 (GET /posts)
==== 성공
operation::post/find/all/success[snippets='http-request,http-response']

=== 특정 카테고리 게시글 보기 (GET /community/category/{category})
유효한 category 값: free(자유), question(질문), trade(중고거래), offer(구인)
=== 특정 카테고리 게시글 보기 (GET /posts?page=1&category=free)
유효한 category 값: free(자유), question(질문), trade(중고거래), offer(구인), notice(공지)

==== 성공
operation::post/find/category/success[snippets='http-request,http-response']

=== 특정 게시글 보기 (GET /community/{id})
=== 특정 게시글 보기 (GET /posts/{id})
==== 성공
operation::post/find/one/success[snippets='http-request,http-response']

=== 게시글 작성하기 (POST /community)
=== 게시글 작성하기 (POST /posts)
==== 성공
operation::post/create/success[snippets='http-request,http-response']
==== 실패
===== 제목에 내용이 없는 경우
operation::post/create/fail/noTitle[snippets='http-request,http-response']

=== 내 게시글 보기 (GET /community/me)
=== 내 게시글 보기 (GET /posts/me)
==== 성공
operation::post/find/me/success[snippets='http-request,http-response']

=== 게시글 좋아요 (PUT /community/{id}/like)
=== 게시글 좋아요 (PUT /posts/{id}/like)
==== 성공
operation::post/like/success[snippets='http-request,http-response']

=== 게시글 수정 (PUT /community/{id})
=== 게시글 수정 (PUT /posts/{id})
==== 성공
operation::post/update/success[snippets='http-request,http-response']
==== 실패
Expand All @@ -100,7 +98,7 @@ operation::post/update/fail/noAuth[snippets='http-request,http-response']
===== 제목에 내용이 없는 경우
operation::post/update/fail/noTitle[snippets='http-request,http-response']

=== 게시글 삭제 (DELETE /community/{id})
=== 게시글 삭제 (DELETE /posts/{id})
==== 성공
operation::post/delete/success[snippets='http-request,http-response']
==== 실패
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/wooriverygood/api/SampleApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.wooriverygood.api;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SampleApi {

@GetMapping("/")
public ResponseEntity<String> sample() {
return ResponseEntity.ok("api is online");
}

}
42 changes: 0 additions & 42 deletions src/main/java/org/wooriverygood/api/advice/ControllerAdvice.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/org/wooriverygood/api/advice/ErrorResponse.java

This file was deleted.

73 changes: 73 additions & 0 deletions src/main/java/org/wooriverygood/api/comment/api/CommentApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.wooriverygood.api.comment.api;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.wooriverygood.api.comment.application.*;
import org.wooriverygood.api.comment.dto.*;
import org.wooriverygood.api.global.auth.AuthInfo;
import org.wooriverygood.api.global.auth.Login;

@RestController
@RequiredArgsConstructor
public class CommentApi {

private final CommentLikeToggleService commentLikeToggleService;

private final CommentFindService commentFindService;

private final CommentCreateService commentCreateService;

private final CommentDeleteService commentDeleteService;

private final CommentUpdateService commentUpdateService;


@GetMapping("/posts/{id}/comments")
public ResponseEntity<CommentsResponse> findAllCommentsByPostId(@PathVariable("id") Long postId,
@Login AuthInfo authInfo) {
CommentsResponse response = commentFindService.findAllCommentsByPostId(postId, authInfo);
return ResponseEntity.ok(response);
}

@PostMapping("/posts/{id}/comments")
public ResponseEntity<Void> addComment(@PathVariable("id") Long postId,
@Login AuthInfo authInfo,
@Valid @RequestBody NewCommentRequest newCommentRequest) {
commentCreateService.addComment(authInfo, postId, newCommentRequest);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@PutMapping("/comments/{id}/like")
public ResponseEntity<CommentLikeResponse> toggleCommentLike(@PathVariable("id") Long commentId,
@Login AuthInfo authInfo) {
CommentLikeResponse response = commentLikeToggleService.likeComment(commentId, authInfo);
return ResponseEntity.ok(response);
}

@PutMapping("/comments/{id}")
public ResponseEntity<Void> updateComment(@PathVariable("id") Long commentId,
@Valid @RequestBody CommentUpdateRequest request,
@Login AuthInfo authInfo) {
commentUpdateService.updateComment(commentId, request, authInfo);
return ResponseEntity.noContent().build();
}

@DeleteMapping("/comments/{id}")
public ResponseEntity<Void> deleteComment(@PathVariable("id") Long commentId,
@Login AuthInfo authInfo) {
commentDeleteService.deleteComment(commentId, authInfo);
return ResponseEntity.noContent().build();
}

@PostMapping("/comments/{id}/reply")
public ResponseEntity<Void> addReply(@PathVariable("id") Long commentId,
@RequestBody NewReplyRequest request,
@Login AuthInfo authInfo) {
commentCreateService.addReply(commentId, request, authInfo);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.wooriverygood.api.comment.application;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.wooriverygood.api.comment.exception.CommentNotFoundException;
import org.wooriverygood.api.comment.exception.ReplyDepthException;
import org.wooriverygood.api.comment.domain.Comment;
import org.wooriverygood.api.comment.dto.NewCommentRequest;
import org.wooriverygood.api.comment.dto.NewReplyRequest;
import org.wooriverygood.api.comment.repository.CommentRepository;
import org.wooriverygood.api.global.auth.AuthInfo;
import org.wooriverygood.api.member.domain.Member;
import org.wooriverygood.api.member.exception.MemberNotFoundException;
import org.wooriverygood.api.member.repository.MemberRepository;
import org.wooriverygood.api.post.domain.Post;
import org.wooriverygood.api.post.exception.PostNotFoundException;
import org.wooriverygood.api.post.repository.PostRepository;

@Service
@Transactional
@RequiredArgsConstructor
public class CommentCreateService {

private final PostRepository postRepository;

private final CommentRepository commentRepository;

private final MemberRepository memberRepository;


public void addComment(AuthInfo authInfo, Long postId, NewCommentRequest request) {
Member member = memberRepository.findById(authInfo.getMemberId())
.orElseThrow(MemberNotFoundException::new);
Post post = postRepository.findById(postId)
.orElseThrow(PostNotFoundException::new);

Comment comment = Comment.builder()
.content(request.getContent())
.post(post)
.member(member)
.build();

commentRepository.save(comment);
}

public void addReply(Long commentId, NewReplyRequest request, AuthInfo authInfo) {
Comment parent = commentRepository.findById(commentId)
.orElseThrow(CommentNotFoundException::new);

if (!parent.isParent())
throw new ReplyDepthException();

Member member = memberRepository.findById(authInfo.getMemberId())
.orElseThrow(MemberNotFoundException::new);

Comment child = Comment.builder()
.content(request.getContent())
.post(parent.getPost())
.parent(parent)
.member(member)
.build();
parent.addReply(child);

commentRepository.save(child);
}

}
Loading
Loading