Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
sudo docker run -d -p 9000:9000 \
--log-driver=json-file \
--log-opt max-size=20m \
--log-opt max-file=5 \
--log-opt max-file=5 \
-e EATSSU_DB_URL_DEV="${{ secrets.EATSSU_DB_URL_DEV }}" \
-e EATSSU_DB_USERNAME="${{ secrets.EATSSU_DB_USERNAME }}" \
-e EATSSU_DB_PASSWORD="${{ secrets.EATSSU_DB_PASSWORD }}" \
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ out/
### env file ###
.env

/src/main/resources/application-local.yml
/src/main/resources/application-local.yml

### DS File ###
.DS_Store
*/.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

public interface PartnershipRestaurantRepository extends JpaRepository<PartnershipRestaurant, Long> {
@Query("""
SELECT DISTINCT pr FROM PartnershipRestaurant pr
LEFT JOIN FETCH pr.partnerships p
LEFT JOIN FETCH p.partnershipCollege
LEFT JOIN FETCH p.partnershipDepartment
WHERE p.endDate is null or p.endDate >= CURRENT_DATE""")
SELECT DISTINCT pr FROM PartnershipRestaurant pr
JOIN FETCH pr.partnerships p
LEFT JOIN FETCH p.partnershipCollege
LEFT JOIN FETCH p.partnershipDepartment
WHERE p.endDate IS NULL OR p.endDate >= CURRENT_DATE
""")
List<PartnershipRestaurant> findAllWithDetails();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public record ReportCreateRequest(
@Schema(description = "신고할 리뷰 id", example = "4")
Long reviewId,

@Schema(description = "신고 타입", example = "BAD_WORD")
@Schema(description = "신고 타입", example = "NO_ASSOCIATE_CONTENT")
ReportType reportType,

@Schema(description = "신고 내용", example = "음란성, 욕설 등 부적절한 내용")
@Schema(description = "신고 내용", example = "리뷰 작성 취지에 맞지 않는 내용")
String content) {

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
package ssu.eatssu.domain.report.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ssu.eatssu.domain.review.entity.Report;

import java.time.LocalDateTime;

public interface ReportRepository extends JpaRepository<Report, Long> {

@Query("""
SELECT count(r) > 0
FROM Report r
WHERE r.user.id = :userId
AND r.review.id = :reviewId
AND r.createdDate >= :threshold
""")
boolean existsRecentReport(@Param("userId") Long userId,
@Param("reviewId") Long reviewId,
@Param("threshold") LocalDateTime threshold);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import ssu.eatssu.global.handler.response.BaseException;
import ssu.eatssu.global.log.event.LogEvent;

import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_REVIEW;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_USER;
import java.time.LocalDateTime;

import static ssu.eatssu.global.handler.response.BaseResponseStatus.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

스타일 가이드 3번 규칙에 따라 와일드카드(*) import는 사용하지 않는 것이 좋습니다.1 코드의 가독성을 높이고 불필요한 클래스가 네임스페이스에 포함되는 것을 방지하기 위해, 필요한 static 멤버만 명시적으로 import하는 것을 권장합니다.

Suggested change
import static ssu.eatssu.global.handler.response.BaseResponseStatus.*;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_REVIEW;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.NOT_FOUND_USER;
import static ssu.eatssu.global.handler.response.BaseResponseStatus.RECENT_REPORT_ON_REVIEW;

Style Guide References

Footnotes

  1. Do not use wildcard when importing libraries


@RequiredArgsConstructor
@Service
Expand All @@ -37,6 +38,10 @@ public Report reportReview(CustomUserDetails userDetails, ReportCreateRequest re
Review review = reviewRepository.findById(request.reviewId())
.orElseThrow(() -> new BaseException(NOT_FOUND_REVIEW));

if(reportRepository.existsRecentReport(user.getId(), review.getId(), LocalDateTime.now().minusHours(24))){
throw new BaseException(RECENT_REPORT_ON_REVIEW);
}

Report report = Report.create(user, review, request, ReportStatus.PENDING);
reportRepository.save(report);

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ssu/eatssu/domain/review/dto/ReviewDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ReviewDetail {
private Integer rating;

@Schema(description = "리뷰 작성 날짜(format = yyyy-MM-dd)", example = "2023-04-07")
private LocalDate writedAt;
private LocalDate writtenAt;

@Schema(description = "리뷰 내용", example = "맛있습니당")
private String content;
Expand All @@ -61,7 +61,7 @@ public static ReviewDetail from(Review review, Long userId) {
ReviewDetailBuilder builder = ReviewDetail.builder()
.reviewId(review.getId())
.rating(review.getRatings().getMainRating())
.writedAt(review.getCreatedDate().toLocalDate())
.writtenAt(review.getCreatedDate().toLocalDate())
.content(review.getContent())
.imageUrls(imageUrls)
.menu(new MenuIdNameLikeDto(menu.getId(),menu.getName(),likedMenuIds.contains(menu.getId())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum BaseResponseStatus {
EXISTED_MEAL(false, HttpStatus.BAD_REQUEST, 40011, "이미 존재하는 식단입니다."),
INVALID_TARGET_TYPE(false, HttpStatus.BAD_REQUEST, 40012, "잘못된 targetType 입니다."),
MISSING_USER_DEPARTMENT(false, HttpStatus.BAD_REQUEST, 40013, "사용자의 학과 정보가 없습니다."),
RECENT_REPORT_ON_REVIEW(false, HttpStatus.BAD_REQUEST, 40014, "24시간 이내에 동일 댓글을 신고했습니다."),

/**
* 401 UNAUTHORIZED 권한없음(인증 실패)
Expand Down