feat(ai-character): 캐릭터 관리자 API를 추가한다
This commit is contained in:
+45
@@ -1,8 +1,11 @@
|
||||
package kr.co.vividnext.sodalive.chat.character.repository
|
||||
|
||||
import kr.co.vividnext.sodalive.chat.character.ChatCharacter
|
||||
import kr.co.vividnext.sodalive.member.MemberKind
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import org.springframework.data.domain.Page
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.jpa.repository.EntityGraph
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.data.repository.query.Param
|
||||
@@ -53,6 +56,48 @@ interface ChatCharacterRepository : JpaRepository<ChatCharacter, Long> {
|
||||
pageable: Pageable
|
||||
): Page<ChatCharacter>
|
||||
|
||||
@EntityGraph(attributePaths = ["creatorMember", "originalWork"])
|
||||
@Query(
|
||||
value = """
|
||||
SELECT DISTINCT c FROM ChatCharacter c
|
||||
JOIN c.creatorMember cm
|
||||
LEFT JOIN c.tagMappings tm
|
||||
LEFT JOIN tm.tag t
|
||||
WHERE c.isActive = true
|
||||
AND cm.role = :role
|
||||
AND cm.memberKind = :memberKind
|
||||
AND (
|
||||
:searchTerm = '' OR
|
||||
LOWER(c.name) LIKE LOWER(CONCAT('%', :searchTerm, '%')) OR
|
||||
LOWER(c.description) LIKE LOWER(CONCAT('%', :searchTerm, '%')) OR
|
||||
(c.mbti IS NOT NULL AND LOWER(c.mbti) LIKE LOWER(CONCAT('%', :searchTerm, '%'))) OR
|
||||
(t.tag IS NOT NULL AND LOWER(t.tag) LIKE LOWER(CONCAT('%', :searchTerm, '%')))
|
||||
)
|
||||
""",
|
||||
countQuery = """
|
||||
SELECT COUNT(DISTINCT c) FROM ChatCharacter c
|
||||
JOIN c.creatorMember cm
|
||||
LEFT JOIN c.tagMappings tm
|
||||
LEFT JOIN tm.tag t
|
||||
WHERE c.isActive = true
|
||||
AND cm.role = :role
|
||||
AND cm.memberKind = :memberKind
|
||||
AND (
|
||||
:searchTerm = '' OR
|
||||
LOWER(c.name) LIKE LOWER(CONCAT('%', :searchTerm, '%')) OR
|
||||
LOWER(c.description) LIKE LOWER(CONCAT('%', :searchTerm, '%')) OR
|
||||
(c.mbti IS NOT NULL AND LOWER(c.mbti) LIKE LOWER(CONCAT('%', :searchTerm, '%'))) OR
|
||||
(t.tag IS NOT NULL AND LOWER(t.tag) LIKE LOWER(CONCAT('%', :searchTerm, '%')))
|
||||
)
|
||||
"""
|
||||
)
|
||||
fun searchAiCharacters(
|
||||
@Param("searchTerm") searchTerm: String,
|
||||
@Param("role") role: MemberRole,
|
||||
@Param("memberKind") memberKind: MemberKind,
|
||||
pageable: Pageable
|
||||
): Page<ChatCharacter>
|
||||
|
||||
/**
|
||||
* 특정 캐릭터와 태그를 공유하는 다른 캐릭터를 무작위로 조회 (현재 캐릭터 제외)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user