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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ public TodayBattleResponse toTodayResponse(Battle b, List<Tag> tags, List<Battle
b.getTotalParticipantsCount() == null ? 0L : b.getTotalParticipantsCount(),
b.getAudioDuration() == null ? 0 : b.getAudioDuration(),
toTagResponses(tags, null),
toTodayOptionResponses(opts)
toTodayOptionResponses(opts),
b.getTitlePrefix(),
b.getTitleSuffix(),
b.getItemA(),
b.getItemADesc(),
b.getItemB(),
b.getItemBDesc()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ public record TodayBattleResponse(
Long participantsCount, // 누적 참여자 수
Integer audioDuration, // 소요 시간 (분:초 변환용 데이터)
List<BattleTagResponse> tags, // 상단 태그 리스트
List<TodayOptionResponse> options // 중앙 세로형 대결 카드 데이터
List<TodayOptionResponse> options, // 중앙 세로형 대결 카드 데이터
// 퀴즈·투표 전용 필드
String titlePrefix, // 투표 접두사 (예: "도덕의 기준은")
String titleSuffix, // 투표 접미사 (예: "이다")
String itemA, // 퀴즈 O 선택지
String itemADesc, // 퀴즈 O 설명
String itemB, // 퀴즈 X 선택지
String itemBDesc // 퀴즈 X 설명
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,22 @@ public interface BattleRepository extends JpaRepository<Battle, Long> {

// 기본 조회용
List<Battle> findByTargetDateAndStatusAndDeletedAtIsNull(LocalDate date, BattleStatus status);

// 탐색 탭: 전체 배틀 검색 (정렬은 Pageable Sort로 처리)
@Query("SELECT b FROM Battle b WHERE b.status = 'PUBLISHED' AND b.deletedAt IS NULL")
List<Battle> searchAll(Pageable pageable);

@Query("SELECT COUNT(b) FROM Battle b WHERE b.status = 'PUBLISHED' AND b.deletedAt IS NULL")
long countSearchAll();

// 탐색 탭: 카테고리 태그 필터 배틀 검색
@Query("SELECT DISTINCT b FROM Battle b JOIN BattleTag bt ON bt.battle = b JOIN bt.tag t " +
"WHERE t.type = 'CATEGORY' AND t.name = :categoryName " +
"AND b.status = 'PUBLISHED' AND b.deletedAt IS NULL")
List<Battle> searchByCategory(@Param("categoryName") String categoryName, Pageable pageable);

@Query("SELECT COUNT(DISTINCT b) FROM Battle b JOIN BattleTag bt ON bt.battle = b JOIN bt.tag t " +
"WHERE t.type = 'CATEGORY' AND t.name = :categoryName " +
"AND b.status = 'PUBLISHED' AND b.deletedAt IS NULL")
long countSearchByCategory(@Param("categoryName") String categoryName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.swyp.app.domain.tag.enums.TagType;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -58,4 +61,20 @@ public Map<String, Long> getTopTagsByBattleIds(List<Long> battleIds, int limit)
java.util.LinkedHashMap::new
));
}

public Optional<String> getTopPhilosopherTagName(List<Long> battleIds) {
if (battleIds.isEmpty()) return Optional.empty();

List<BattleTag> battleTags = battleTagRepository.findByBattleIdIn(battleIds);

return battleTags.stream()
.filter(bt -> bt.getTag().getType() == TagType.PHILOSOPHER)
.collect(Collectors.groupingBy(
bt -> bt.getTag().getName(),
Collectors.counting()
))
.entrySet().stream()
.max(Map.Entry.comparingByValue())
.map(Map.Entry::getKey);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.swyp.app.domain.home.dto.response;

import com.swyp.app.domain.battle.dto.response.BattleTagResponse;

import java.util.List;

public record HomeBestBattleResponse(
Long battleId,
String philosopherA,
String philosopherB,
String title,
List<BattleTagResponse> tags,
Integer audioDuration,
Integer viewCount
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.swyp.app.domain.home.dto.response;

import com.swyp.app.domain.battle.dto.response.BattleTagResponse;

import java.util.List;

public record HomeEditorPickResponse(
Long battleId,
String thumbnailUrl,
String optionATitle,
String optionBTitle,
String title,
String summary,
List<BattleTagResponse> tags,
Integer viewCount
) {}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package com.swyp.app.domain.home.dto.response;

import com.swyp.app.domain.battle.dto.response.BattleTagResponse;
import com.swyp.app.domain.battle.enums.BattleType;

import java.util.List;

public record HomeBattleResponse(
public record HomeNewBattleResponse(
Long battleId,
String thumbnailUrl,
String title,
String summary,
String thumbnailUrl,
BattleType type,
Integer viewCount,
Long participantsCount,
Integer audioDuration,
String philosopherA,
String philosopherAImageUrl,
String philosopherB,
String philosopherBImageUrl,
List<BattleTagResponse> tags,
List<HomeBattleOptionResponse> options
) {
}
Integer audioDuration,
Integer viewCount
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

public record HomeResponse(
boolean newNotice,
List<HomeBattleResponse> editorPicks,
List<HomeBattleResponse> trendingBattles,
List<HomeBattleResponse> bestBattles,
List<HomeBattleResponse> todayPicks,
List<HomeBattleResponse> newBattles
) {
}
List<HomeEditorPickResponse> editorPicks,
List<HomeTrendingResponse> trendingBattles,
List<HomeBestBattleResponse> bestBattles,
List<HomeTodayQuizResponse> todayQuizzes,
List<HomeTodayVoteResponse> todayVotes,
List<HomeNewBattleResponse> newBattles
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swyp.app.domain.home.dto.response;

public record HomeTodayQuizResponse(
Long battleId,
String title,
String summary,
Long participantsCount,
String itemA,
String itemADesc,
String itemB,
String itemBDesc
) {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import com.swyp.app.domain.battle.enums.BattleOptionLabel;

public record HomeBattleOptionResponse(
public record HomeTodayVoteOptionResponse(
BattleOptionLabel label,
String text
) {
}
String title
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.swyp.app.domain.home.dto.response;

import java.util.List;

public record HomeTodayVoteResponse(
Long battleId,
String titlePrefix,
String titleSuffix,
String summary,
Long participantsCount,
List<HomeTodayVoteOptionResponse> options
) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.swyp.app.domain.home.dto.response;

import com.swyp.app.domain.battle.dto.response.BattleTagResponse;

import java.util.List;

public record HomeTrendingResponse(
Long battleId,
String thumbnailUrl,
String title,
List<BattleTagResponse> tags,
Integer audioDuration,
Integer viewCount
) {}
Loading