관리자 API
- 시리즈 장르 리스트 조회 API 추가
This commit is contained in:
		| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.admin.content.series.genre | ||||
|  | ||||
| import kr.co.vividnext.sodalive.common.ApiResponse | ||||
| import org.springframework.security.access.prepost.PreAuthorize | ||||
| import org.springframework.web.bind.annotation.GetMapping | ||||
| import org.springframework.web.bind.annotation.PostMapping | ||||
| import org.springframework.web.bind.annotation.PutMapping | ||||
| import org.springframework.web.bind.annotation.RequestBody | ||||
| @@ -27,4 +28,7 @@ class AdminContentSeriesGenreController(private val service: AdminContentSeriesG | ||||
|         service.modifySeriesGenreOrders(ids = request.ids), | ||||
|         "수정되었습니다." | ||||
|     ) | ||||
|  | ||||
|     @GetMapping | ||||
|     fun getSeriesGenreList() = ApiResponse.ok(service.getSeriesGenreList()) | ||||
| } | ||||
|   | ||||
| @@ -1,9 +1,24 @@ | ||||
| package kr.co.vividnext.sodalive.admin.content.series.genre | ||||
|  | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.admin.content.series.genre.QSeriesGenre.seriesGenre | ||||
| import org.springframework.data.jpa.repository.JpaRepository | ||||
|  | ||||
| interface AdminContentSeriesGenreRepository : JpaRepository<SeriesGenre, Long>, AdminContentSeriesGenreQueryRepository | ||||
|  | ||||
| interface AdminContentSeriesGenreQueryRepository | ||||
| interface AdminContentSeriesGenreQueryRepository { | ||||
|     fun getSeriesGenreList(): List<GetSeriesGenreListResponse> | ||||
| } | ||||
|  | ||||
| class AdminContentSeriesGenreQueryRepositoryImpl : AdminContentSeriesGenreQueryRepository | ||||
| class AdminContentSeriesGenreQueryRepositoryImpl( | ||||
|     private val queryFactory: JPAQueryFactory | ||||
| ) : AdminContentSeriesGenreQueryRepository { | ||||
|     override fun getSeriesGenreList(): List<GetSeriesGenreListResponse> { | ||||
|         return queryFactory | ||||
|             .select(QGetSeriesGenreListResponse(seriesGenre.id, seriesGenre.genre, seriesGenre.isAdult)) | ||||
|             .from(seriesGenre) | ||||
|             .where(seriesGenre.isActive.isTrue) | ||||
|             .orderBy(seriesGenre.orders.asc()) | ||||
|             .fetch() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -46,4 +46,8 @@ class AdminContentSeriesGenreService(private val repository: AdminContentSeriesG | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun getSeriesGenreList(): List<GetSeriesGenreListResponse> { | ||||
|         return repository.getSeriesGenreList() | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,9 @@ | ||||
| package kr.co.vividnext.sodalive.admin.content.series.genre | ||||
|  | ||||
| import com.querydsl.core.annotations.QueryProjection | ||||
|  | ||||
| data class GetSeriesGenreListResponse @QueryProjection constructor( | ||||
|     val id: Long, | ||||
|     val genre: String, | ||||
|     val isAdult: Boolean | ||||
| ) | ||||
		Reference in New Issue
	
	Block a user