DTO로 조회를 했을 때 org.hibernate.QueryException: not an entity 오류나던 부분 series 모든 필드 조회로 변경
This commit is contained in:
parent
0d709742ed
commit
c95b3db6eb
|
@ -1,10 +1,8 @@
|
||||||
package kr.co.vividnext.sodalive.content.series
|
package kr.co.vividnext.sodalive.content.series
|
||||||
|
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.admin.content.series.genre.QSeriesGenre.seriesGenre
|
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
import kr.co.vividnext.sodalive.creator.admin.content.series.QSeries.series
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
import kr.co.vividnext.sodalive.creator.admin.content.series.Series
|
||||||
import kr.co.vividnext.sodalive.member.QMember.member
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
|
||||||
interface ContentSeriesRepository : JpaRepository<Series, Long>, ContentSeriesQueryRepository
|
interface ContentSeriesRepository : JpaRepository<Series, Long>, ContentSeriesQueryRepository
|
||||||
|
@ -17,7 +15,7 @@ interface ContentSeriesQueryRepository {
|
||||||
isAuth: Boolean,
|
isAuth: Boolean,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<GetSeriesListRawItem>
|
): List<Series>
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContentSeriesQueryRepositoryImpl(
|
class ContentSeriesQueryRepositoryImpl(
|
||||||
|
@ -45,7 +43,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||||
isAuth: Boolean,
|
isAuth: Boolean,
|
||||||
offset: Long,
|
offset: Long,
|
||||||
limit: Long
|
limit: Long
|
||||||
): List<GetSeriesListRawItem> {
|
): List<Series> {
|
||||||
var where = series.member.id.eq(creatorId)
|
var where = series.member.id.eq(creatorId)
|
||||||
.and(series.isActive.isTrue)
|
.and(series.isActive.isTrue)
|
||||||
|
|
||||||
|
@ -54,23 +52,7 @@ class ContentSeriesQueryRepositoryImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryFactory
|
return queryFactory
|
||||||
.select(
|
.selectFrom(series)
|
||||||
QGetSeriesListRawItem(
|
|
||||||
series.id,
|
|
||||||
series.title,
|
|
||||||
series.coverImage.prepend("/").prepend(imageHost),
|
|
||||||
series.publishedDaysOfWeek,
|
|
||||||
series.state,
|
|
||||||
seriesGenre.genre,
|
|
||||||
series.isAdult,
|
|
||||||
member.id,
|
|
||||||
member.nickname,
|
|
||||||
member.profileImage.prepend("/").prepend(imageHost)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(series)
|
|
||||||
.innerJoin(series.member, member)
|
|
||||||
.innerJoin(series.genre, seriesGenre)
|
|
||||||
.where(where)
|
.where(where)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package kr.co.vividnext.sodalive.content.series
|
package kr.co.vividnext.sodalive.content.series
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.content.series.content.ContentSeriesContentRepository
|
import kr.co.vividnext.sodalive.content.series.content.ContentSeriesContentRepository
|
||||||
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesPublishedDaysOfWeek
|
||||||
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesSortType
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesSortType
|
||||||
|
import kr.co.vividnext.sodalive.creator.admin.content.series.SeriesState
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import org.springframework.beans.factory.annotation.Value
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
|
@ -32,7 +34,20 @@ class ContentSeriesService(
|
||||||
)
|
)
|
||||||
|
|
||||||
val items = rawItems
|
val items = rawItems
|
||||||
.map { it.toSeriesListItem() }
|
.map {
|
||||||
|
GetSeriesListResponse.SeriesListItem(
|
||||||
|
seriesId = it.id!!,
|
||||||
|
title = it.title,
|
||||||
|
coverImage = "$coverImageHost/${it.coverImage!!}",
|
||||||
|
publishedDaysOfWeek = publishedDaysOfWeekText(it.publishedDaysOfWeek),
|
||||||
|
isComplete = it.state == SeriesState.COMPLETE,
|
||||||
|
creator = GetSeriesListResponse.SeriesListItemCreator(
|
||||||
|
creatorId = it.member!!.id!!,
|
||||||
|
nickname = it.member!!.nickname,
|
||||||
|
profileImage = "$coverImageHost/${it.member!!.profileImage!!}"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
it.numberOfContent = seriesContentRepository.getContentCount(
|
it.numberOfContent = seriesContentRepository.getContentCount(
|
||||||
seriesId = it.seriesId,
|
seriesId = it.seriesId,
|
||||||
|
@ -56,4 +71,27 @@ class ContentSeriesService(
|
||||||
|
|
||||||
return GetSeriesListResponse(totalCount, items)
|
return GetSeriesListResponse(totalCount, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun publishedDaysOfWeekText(publishedDaysOfWeek: Set<SeriesPublishedDaysOfWeek>): String {
|
||||||
|
val dayOfWeekText = publishedDaysOfWeek.toList().sortedBy { it.ordinal }
|
||||||
|
.map {
|
||||||
|
when (it) {
|
||||||
|
SeriesPublishedDaysOfWeek.SUN -> "일"
|
||||||
|
SeriesPublishedDaysOfWeek.MON -> "월"
|
||||||
|
SeriesPublishedDaysOfWeek.TUE -> "화"
|
||||||
|
SeriesPublishedDaysOfWeek.WED -> "수"
|
||||||
|
SeriesPublishedDaysOfWeek.THU -> "목"
|
||||||
|
SeriesPublishedDaysOfWeek.FRI -> "금"
|
||||||
|
SeriesPublishedDaysOfWeek.SAT -> "토"
|
||||||
|
SeriesPublishedDaysOfWeek.RANDOM -> "랜덤"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.joinToString(", ") { it }
|
||||||
|
|
||||||
|
return if (publishedDaysOfWeek.contains(SeriesPublishedDaysOfWeek.RANDOM)) {
|
||||||
|
dayOfWeekText
|
||||||
|
} else {
|
||||||
|
"매주 ${dayOfWeekText}요일"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue