관리자 태그 큐레이션 등록
- 동일한 태그가 등록되지 않도록 validation 추가
This commit is contained in:
@@ -18,6 +18,7 @@ interface AdminHashTagCurationRepository :
|
|||||||
interface AdminHashTagCurationQueryRepository {
|
interface AdminHashTagCurationQueryRepository {
|
||||||
fun getContentHashTagCurationList(): List<GetAdminContentHashTagCurationResponse>
|
fun getContentHashTagCurationList(): List<GetAdminContentHashTagCurationResponse>
|
||||||
fun searchHashTagCurationContentItem(curationId: Long, searchWord: String): List<SearchCurationItemResponse>
|
fun searchHashTagCurationContentItem(curationId: Long, searchWord: String): List<SearchCurationItemResponse>
|
||||||
|
fun isExistsTag(tag: String): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
@@ -69,4 +70,12 @@ class AdminHashTagCurationQueryRepositoryImpl(
|
|||||||
)
|
)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun isExistsTag(tag: String): Boolean {
|
||||||
|
return queryFactory
|
||||||
|
.select(contentHashTagCuration.id)
|
||||||
|
.from(contentHashTagCuration)
|
||||||
|
.where(contentHashTagCuration.tag.eq(tag))
|
||||||
|
.fetch().isNotEmpty()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,12 @@ class AdminHashTagCurationService(
|
|||||||
) {
|
) {
|
||||||
@Transactional
|
@Transactional
|
||||||
fun createContentHashTagCuration(request: CreateContentHashTagCurationRequest) {
|
fun createContentHashTagCuration(request: CreateContentHashTagCurationRequest) {
|
||||||
|
val isExists = repository.isExistsTag(tag = request.tag.trim())
|
||||||
|
|
||||||
|
if (isExists) {
|
||||||
|
throw SodaException("이미 등록된 태그 입니다.")
|
||||||
|
}
|
||||||
|
|
||||||
repository.save(
|
repository.save(
|
||||||
ContentHashTagCuration(
|
ContentHashTagCuration(
|
||||||
tag = request.tag,
|
tag = request.tag,
|
||||||
|
Reference in New Issue
Block a user