Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@
* μƒμ˜κ΄€ 리뷰듀 μ€‘μ—μ„œ 많이 μ‚¬μš©λœ ν•΄μ‹œνƒœκ·Έλ₯Ό νŒŒμ•…ν•˜κΈ° μœ„ν•œ DTO μž…λ‹ˆλ‹€.
* @param hashTagId ν•΄μ‹œνƒœκ·Έ ID
* @param hashTagName ν•΄μ‹œνƒœκ·Έ 이름
* @param hashType ν•΄μ‹œνƒœκ·Έ νƒ€μž…
* @param count 개수
*/
@Builder
@Schema(name = "[응닡][μƒμ˜κ΄€] μƒμ˜κ΄€ ν•΄μ‹œνƒœκ·Έ Response",description = "μƒμ˜κ΄€μ—μ„œ 자주 μ‚¬μš©λ˜λŠ” ν•΄μ‹œνƒœκ·Έ λͺ©λ‘μ— λŒ€ν•œ DTO μž…λ‹ˆλ‹€.")
public record AuditoriumHashTagResponse(
Long hashTagId,
String hashTagName,
String hashType,
Long count
) {

/// 정적 νŒ©ν† λ¦¬ λ©”μ„œλ“œ
public static AuditoriumHashTagResponse from(ReviewHashTagWithCount withCount) {
return AuditoriumHashTagResponse.builder()
.hashTagId(withCount.getHashTagId())
.hashTagName(withCount.getHashTagName())
.hashTagId(withCount.getHashTag().getId())
.hashTagName(withCount.getHashTag().getName())
.hashType(withCount.getHashTag().getType().getLabel())
.count(withCount.getCount())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public interface ReviewHashTagRepository extends JpaRepository<ReviewHashTag, Lo
* @return List<Review>
*/
@Query("""
SELECT rh.hashTag.id as hashTagId,
rh.hashTag.name as hashTagName,
SELECT rh.hashTag as hashTag,
COUNT(DISTINCT r.id) AS count
FROM Auditorium a
LEFT JOIN Seat s ON s.auditorium = a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.seeat.server.domain.hashtag.domain.repository;

public interface ReviewHashTagWithCount {
import com.seeat.server.domain.hashtag.domain.entity.HashTag;

Long getHashTagId();
public interface ReviewHashTagWithCount {

String getHashTagName();
HashTag getHashTag();

Long getCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public interface AuditoriumRepository extends JpaRepository<Auditorium, String>

/// 리뷰 개수 및 평점 같이 κ°€μ Έμ˜€κΈ°
@Query("""
select a as auditorium,
SUM(sr.totalReviews) as totalReviews,
AVG(sr.averageGrade) as averageRating
from Auditorium a
left join SeatRatingSummary sr on sr.seat.auditorium.id = a.id
where a.id = :auditoriumId
group by a
""")
SELECT
a AS auditorium,
COUNT(DISTINCT r.id) AS totalReviews,
AVG(DISTINCT r.rating) AS averageRating
FROM Auditorium a
LEFT JOIN Seat s ON s.auditorium = a
LEFT JOIN ReviewSeat rs ON rs.seat = s
LEFT JOIN Review r ON rs.review = r
WHERE a.id = :auditoriumId
GROUP BY a
""")
Optional<AuditoriumWithRating> findAuditoriumWithRating(@Param("auditoriumId") String auditoriumId);


Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/seeat/server/global/logging/LogFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public class LogFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {

/// μš”μ²­ 둜그 남기기
String username = request.getUserPrincipal() != null ? request.getUserPrincipal().getName() : "anonymous";
String httpMethod = request.getMethod();
String uri = URLDecoder.decode(request.getRequestURI(), StandardCharsets.UTF_8);

log.info("[HTTP μš”μ²­ λ‘œκΉ…]: [{}] {} - μ‚¬μš©μž: {}", httpMethod, uri, username);
// Origin 헀더 κ°€μ Έμ˜€κΈ°
String origin = request.getHeader("Origin");

/// 둜그 남기고 λ„˜κΈ°κΈ°
filterChain.doFilter(request, response);
log.info("[HTTP μš”μ²­ λ‘œκΉ…]: [{}] {} - μ‚¬μš©μž: {} - Origin: {}", httpMethod, uri, username, origin);

filterChain.doFilter(request, response);
}
}
Loading