"feat(api): 캐릭터 리스트 API 수정 및 데이터 처리 로직 개선
- API 경로를 /admin/chat/character/list로 변경 - size 파라미터 기본값을 20으로 설정 - 응답 데이터 구조 변경 (items → content) - total_page 계산 로직 수정 (전체 개수와 size로 계산) - 태그 표시 기능 추가"
This commit is contained in:
parent
3783714c75
commit
13c85bb2a8
|
@ -1,15 +1,15 @@
|
|||
import Vue from 'vue';
|
||||
|
||||
// 캐릭터 리스트
|
||||
async function getCharacterList(page = 1, size = 10) {
|
||||
return Vue.axios.get('/api/admin/characters', {
|
||||
params: { page, size }
|
||||
async function getCharacterList(page = 1, size = 20) {
|
||||
return Vue.axios.get('/admin/chat/character/list', {
|
||||
params: { page: page - 1, size }
|
||||
})
|
||||
}
|
||||
|
||||
// 캐릭터 검색
|
||||
async function searchCharacters(keyword, page = 1, size = 10) {
|
||||
return Vue.axios.get('/api/admin/characters/search', {
|
||||
async function searchCharacters(keyword, page = 1, size = 20) {
|
||||
return Vue.axios.get('/api/admin/chat/character/search', {
|
||||
params: { keyword, page, size }
|
||||
})
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@
|
|||
<th class="text-center">
|
||||
대화 스타일
|
||||
</th>
|
||||
<th class="text-center">
|
||||
태그
|
||||
</th>
|
||||
<th class="text-center">
|
||||
등록일
|
||||
</th>
|
||||
|
@ -97,7 +100,7 @@
|
|||
</td>
|
||||
<td>{{ item.name }}</td>
|
||||
<td>{{ item.gender || '-' }}</td>
|
||||
<td>{{ calculateAge(item.birthDate) }}</td>
|
||||
<td>{{ item.age || '-' }}</td>
|
||||
<td>
|
||||
<v-btn
|
||||
small
|
||||
|
@ -121,11 +124,26 @@
|
|||
<v-btn
|
||||
small
|
||||
color="info"
|
||||
@click="showDetailDialog(item, 'systemPrompt')"
|
||||
@click="showDetailDialog(item, 'speechStyle')"
|
||||
>
|
||||
보기
|
||||
</v-btn>
|
||||
</td>
|
||||
<td>
|
||||
<div v-if="item.tags && item.tags.length > 0">
|
||||
<v-chip
|
||||
v-for="(tag, index) in item.tags"
|
||||
:key="index"
|
||||
small
|
||||
class="ma-1"
|
||||
color="primary"
|
||||
text-color="white"
|
||||
>
|
||||
{{ tag }}
|
||||
</v-chip>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>{{ item.createdAt }}</td>
|
||||
<td>{{ item.updatedAt || '-' }}</td>
|
||||
<td>
|
||||
|
@ -211,9 +229,11 @@
|
|||
<v-card-title>
|
||||
{{ detail_title }}
|
||||
</v-card-title>
|
||||
<v-divider></v-divider>
|
||||
<v-divider />
|
||||
<v-card-text class="pt-4">
|
||||
<div style="white-space: pre-wrap;">{{ detail_content }}</div>
|
||||
<div style="white-space: pre-wrap;">
|
||||
{{ detail_content }}
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
|
@ -265,23 +285,6 @@ export default {
|
|||
this.$dialog.notify.success(message)
|
||||
},
|
||||
|
||||
calculateAge(birthDate) {
|
||||
if (!birthDate) return '-';
|
||||
|
||||
// birthDate가 YYYY-MM-DD 형식이라고 가정
|
||||
const today = new Date();
|
||||
const birth = new Date(birthDate);
|
||||
|
||||
let age = today.getFullYear() - birth.getFullYear();
|
||||
const monthDiff = today.getMonth() - birth.getMonth();
|
||||
|
||||
// 생일이 아직 지나지 않았으면 나이에서 1을 뺌
|
||||
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return age;
|
||||
},
|
||||
|
||||
showDetailDialog(item, type) {
|
||||
this.selected_character = item;
|
||||
|
@ -297,9 +300,9 @@ export default {
|
|||
this.detail_title = '말투';
|
||||
this.detail_content = item.speechPattern || '내용이 없습니다.';
|
||||
break;
|
||||
case 'systemPrompt':
|
||||
case 'speechStyle':
|
||||
this.detail_title = '대화 스타일';
|
||||
this.detail_content = item.systemPrompt || '내용이 없습니다.';
|
||||
this.detail_content = item.speechStyle || '내용이 없습니다.';
|
||||
break;
|
||||
default:
|
||||
this.detail_title = '';
|
||||
|
@ -374,12 +377,12 @@ export default {
|
|||
|
||||
if (response && response.data) {
|
||||
const data = response.data;
|
||||
this.characters = data.items || [];
|
||||
this.characters = data.content || [];
|
||||
|
||||
const total_page = Math.ceil((data.totalCount || 0) / 10);
|
||||
const total_page = Math.ceil((data.totalCount || 0) / 20);
|
||||
this.total_page = total_page <= 0 ? 1 : total_page;
|
||||
} else {
|
||||
throw new Error('응답 데이터가 없습니다.');
|
||||
this.notifyError('응답 데이터가 없습니다.');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('캐릭터 목록 조회 오류:', e);
|
||||
|
@ -406,12 +409,12 @@ export default {
|
|||
|
||||
if (response && response.data) {
|
||||
const data = response.data;
|
||||
this.characters = data.items || [];
|
||||
this.characters = data.content || [];
|
||||
|
||||
const total_page = Math.ceil((data.totalCount || 0) / 10);
|
||||
const total_page = Math.ceil((data.totalCount || 0) / 20);
|
||||
this.total_page = total_page <= 0 ? 1 : total_page;
|
||||
} else {
|
||||
throw new Error('응답 데이터가 없습니다.');
|
||||
this.notifyError('응답 데이터가 없습니다.');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('캐릭터 검색 오류:', e);
|
||||
|
|
Loading…
Reference in New Issue