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

Dev to main #316

Merged
merged 37 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
993e1db
main -> dev merge (#252)
jschoi-96 Mar 25, 2024
45b0935
공지사항, 마이페이지 시작 페이지 번호 수정 완료 (#239)
gywns0417 Mar 25, 2024
bbb5516
답글 조회 API 구현 완료 (#254)
gywns0417 Mar 25, 2024
c48e3ef
feat: 댓글 목록 조회 시 답글 제외 (#249)
Hanjaemo Mar 25, 2024
678383d
feat: 게시글 목록 조회 시 추천수를 기준으로 내림차순 정렬하는 기능 구현 (#248)
Hanjaemo Mar 25, 2024
2d026c2
fix: PostResponse 응답 시 vote.getMember() 가 null일 경우 처리 구현 (#263)
gywns0417 Mar 27, 2024
1556e0c
스웨거 문서 수정 및 시큐리티 URL 허용 (#269)
jschoi-96 Mar 28, 2024
ecae338
feat: 클라이언트에 올바르게 토큰 에러 정보를 보여주도록 수정 (#258)
jschoi-96 Mar 28, 2024
0eb5bb0
회원 조회 시 응답에 있는 프로필 사진의 storedName을 url로 수정 (#268)
Hanjaemo Mar 29, 2024
b62a8db
게시글 조회 응답에 댓글 개수 추가 (#271)
Hanjaemo Mar 29, 2024
64598dc
마이페이지 API 응답 수정 완료 (#253)
gywns0417 Mar 29, 2024
2baa2a7
feat: 쿠키를 이용하여 리프레시 토큰을 추출하고 액세스 토큰을 재발급 하는 방법으로 구현 (#264)
jschoi-96 Mar 29, 2024
f8b8470
fix: merge 후 에러 수정
gywns0417 Mar 29, 2024
f7eff0e
Merge branch 'main' into dev
Hanjaemo Mar 29, 2024
3625309
게시글, 댓글 신고 기능 구현 (#255)
jschoi-96 Mar 30, 2024
093a502
Merge branch 'main' into dev
jschoi-96 Mar 30, 2024
28bbeb0
fix: import 수정
jschoi-96 Mar 30, 2024
9d627ed
Merge remote-tracking branch 'origin/dev' into dev
jschoi-96 Mar 30, 2024
3ca8f23
영속성 전이 (#279)
jschoi-96 Mar 30, 2024
4985d93
submodule
jschoi-96 Mar 30, 2024
891788d
게시글 작성 할때 데드라인에서 @JsonFormat 수정 (#282)
jschoi-96 Mar 31, 2024
3cb4929
태그 검색 시 401 에러가 뜨던 오류 해결 (#290)
jschoi-96 Apr 5, 2024
bfa9890
게시글 좋아요 해제 로직 수정 (#292)
jschoi-96 Apr 5, 2024
5e31706
refactor: Redis에 저장되는 값을 직렬화 하는 빈 추가 (#296)
jschoi-96 Apr 5, 2024
7314760
fix: 게시글 단건 조회 메서드의 readOnly 설정 해제 (#289)
Hanjaemo Apr 5, 2024
8506f60
댓글 목록 조회 API에서 댓글마다 답글 개수 포함하도록 수정 완료 (#287)
gywns0417 Apr 5, 2024
4a7782d
Merge branch 'main' into dev
Hanjaemo Apr 5, 2024
e6b1fb6
토큰 재발급 시 memberId가 토큰에 포함되지 않던 오류 수정 (#301)
jschoi-96 Apr 9, 2024
c0e4fe5
게시글, 댓글 신고 예외 처리 추가 (#299)
jschoi-96 Apr 9, 2024
3dbda89
회원 프로필 조회 기능 구현 (#294)
jschoi-96 Apr 9, 2024
146b6b3
게시글, 댓글 응답에 작성자 ID 추가 (#303)
Hanjaemo Apr 9, 2024
eca8bc5
비회원 상태에서 프로필 조회 시 401에러 (#307)
jschoi-96 Apr 16, 2024
75e07d1
fix: Post 데드라인에서 @Future 어노테이션 제거 (#311)
jschoi-96 Apr 16, 2024
e104037
본인 게시글, 댓글을 신고할 때 에러 메세지 수정 및 데드라인 지난 게시글 조회 시 에러 (#308)
jschoi-96 Apr 22, 2024
5d76ebd
feat: ReplyResponse에 답글 작성자 ID 추가 (#312)
Hanjaemo Apr 22, 2024
1d3f2a1
Merge branch 'main' into dev
jschoi-96 Apr 22, 2024
99c0ce5
feat: 게시글 조회 응답 DTO에 마감 여부 필드 추가 (#315)
Hanjaemo Apr 27, 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 @@ -265,7 +265,8 @@ public List<CommentResponse> findBestComments(Long postId, String token) {
public void reportComment(Long postId, Long commentId, ReportRequest reportRequest) {
Comment comment = validateCommentId(commentId);
Member member = getCurrentMember(memberRepository);
if (reportRepository.existsByReporter(member)) {
if (reportRepository.existsByReporterAndComment(member, comment)) {

throw new BalanceTalkException(ALREADY_REPORTED_COMMENT);
}
if (comment.getMember().equals(member)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class ReplyResponse {
@Schema(description = "답글 수정 날짜")
private LocalDateTime lastModifiedAt;

@Schema(description = "답글 작성자 ID")
private Long writerId;

@Schema(description = "답글 작성자 프로필 사진 경로", example = "https://balance-talk-static-files4df23447-2355-45h2-8783-7f6gd2ceb848_프로필.jpg")
private String profileImageUrl;

Expand All @@ -60,6 +63,7 @@ public static ReplyResponse fromEntity(Comment comment, Long balanceOptionId, bo
.myLike(myLike)
.createdAt(comment.getCreatedAt())
.lastModifiedAt(comment.getLastModifiedAt())
.writerId(comment.getMember().getId())
.profileImageUrl(getProfileImageUrl(comment.getMember()))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package balancetalk.module.member.dto;

import balancetalk.module.file.domain.File;
import balancetalk.module.member.domain.Member;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Optional;

@Data
@Builder
Expand All @@ -33,8 +34,11 @@ public class ProfileResponse {
private int level;

public static ProfileResponse fromEntity(Member member) {
String profileImageUrl = Optional.ofNullable(member.getProfilePhoto())
.map(File::getUrl)
.orElse(null);
return ProfileResponse.builder()
.profileImageUrl(member.getProfilePhoto().getUrl())
.profileImageUrl(profileImageUrl)
.nickname(member.getNickname())
.createdAt(member.getCreatedAt())
.postsCount(member.getPostCount())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public String reissueAccessToken(HttpServletRequest request) {

@ResponseStatus(HttpStatus.OK)
@GetMapping("/{memberId}/profile")
@Operation(summary = "회원 프로필 조회", description = "회원 프로필을 조회한다.")
public ProfileResponse memberProfile(@PathVariable("memberId") Long memberId) {
return memberService.memberProfile(memberId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void reportPost(Long postId, ReportRequest reportRequest) {
Post post = postRepository.findById(postId)
.orElseThrow(() -> new BalanceTalkException(NOT_FOUND_POST));
Member member = getCurrentMember(memberRepository);
if (reportRepository.existsByReporter(member)) {
if (reportRepository.existsByReporterAndPost(member, post)) {
throw new BalanceTalkException(ALREADY_REPORTED_POST);
}
if (post.getMember().equals(member)) {
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/balancetalk/module/post/domain/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
import balancetalk.module.member.domain.Member;
import balancetalk.module.report.domain.Report;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Formula;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.annotations.Formula;

@Entity
@Getter
Expand All @@ -33,7 +37,6 @@ public class Post extends BaseTimeEntity {
private String title;

@NotNull
@Future
@Column(nullable = false)
private LocalDateTime deadline;

Expand Down Expand Up @@ -94,7 +97,7 @@ public long commentsCount() {
}
return comments.size();
}

@PrePersist
public void init() {
this.views = 0L;
Expand All @@ -116,4 +119,8 @@ public boolean hasDeadlineExpired() {
public void increaseViews() {
views++;
}

public boolean isClosed() {
return LocalDateTime.now().isAfter(deadline);
}
}
22 changes: 14 additions & 8 deletions src/main/java/balancetalk/module/post/dto/PostResponse.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package balancetalk.module.post.dto;

import balancetalk.module.ViewStatus;
import balancetalk.module.file.domain.File;
import balancetalk.module.member.domain.Member;
import balancetalk.module.post.domain.BalanceOption;
import balancetalk.module.post.domain.Post;
import balancetalk.module.post.domain.PostCategory;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
Expand All @@ -30,6 +32,9 @@ public class PostResponse {
@Schema(description = "투료 종료 기한", example = "2024/12/25 15:30:00")
private LocalDateTime deadline;

@Schema(description = "마감 여부", example = "true")
private Boolean isClosed;

@Schema(description = "게시글 조회수", example = "126")
private long views;

Expand Down Expand Up @@ -86,6 +91,7 @@ public static PostResponse fromEntity(Post post, Member member, boolean myLike,
.id(post.getId())
.title(post.getTitle())
.deadline(post.getDeadline())
.isClosed(post.isClosed())
.views(post.getViews())
// .viewStatus(post.getViewStatus())
.likesCount(post.likesCount())
Expand Down Expand Up @@ -140,11 +146,11 @@ private static Long getSelectedOptionId(Post post, Member member) {
.orElse(null);
}

private static int getTotalVotes (Post post){
return Optional.ofNullable(post.getOptions())
.map(options -> options.stream()
.mapToInt(option -> Optional.ofNullable(option.getVotes()).map(List::size).orElse(0))
.sum())
.orElse(0);
private static int getTotalVotes(Post post) {
return Optional.ofNullable(post.getOptions())
.map(options -> options.stream()
.mapToInt(option -> Optional.ofNullable(option.getVotes()).map(List::size).orElse(0))
.sum())
.orElse(0);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package balancetalk.module.report.domain;

import balancetalk.module.comment.domain.Comment;
import balancetalk.module.member.domain.Member;
import balancetalk.module.post.domain.Post;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ReportRepository extends JpaRepository<Report, Long> {

boolean existsByReporter(Member reporter);
boolean existsByReporterAndPost(Member reporter, Post post);

boolean existsByReporterAndComment(Member reporter, Comment comment);
}