feat: 添加主定调过滤选项,优化内容列表查询功能
This commit is contained in:
@@ -88,6 +88,7 @@ type CreatorContentListFilter struct {
|
||||
requests.Pagination
|
||||
Status *string `query:"status"`
|
||||
Genre *string `query:"genre"`
|
||||
Key *string `query:"key"`
|
||||
Keyword *string `query:"keyword"`
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,9 @@ func (s *creator) ListContents(
|
||||
q = q.Where(tbl.Genre.Eq(val))
|
||||
}
|
||||
}
|
||||
if filter.Key != nil && *filter.Key != "" {
|
||||
q = q.Where(tbl.Key.Eq(*filter.Key))
|
||||
}
|
||||
if filter.Keyword != nil && *filter.Keyword != "" {
|
||||
q = q.Where(tbl.Title.Like("%" + *filter.Keyword + "%"))
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
<option v-for="opt in genreOptions" :key="opt.key" :value="opt.key">{{ opt.value }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-sm font-bold text-slate-500">主定调:</span>
|
||||
<select v-model="filterKey"
|
||||
class="h-9 px-3 rounded border border-slate-200 text-sm focus:border-primary-500 outline-none bg-white cursor-pointer min-w-[100px]">
|
||||
<option value="all">全部</option>
|
||||
<option v-for="k in keys" :key="k" :value="k">{{ k }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="ml-auto relative">
|
||||
<i class="pi pi-search absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"></i>
|
||||
<input type="text" placeholder="搜索标题..." v-model="searchKeyword" @keyup.enter="handleSearch"
|
||||
@@ -129,9 +137,11 @@ const toast = useToast();
|
||||
const contents = ref([]);
|
||||
const filterStatus = ref('all');
|
||||
const filterGenre = ref('all');
|
||||
const filterKey = ref('all');
|
||||
const searchKeyword = ref('');
|
||||
const statusOptions = ref([]);
|
||||
const genreOptions = ref([]);
|
||||
const keys = ['C大调', 'D大调', 'E大调', 'F大调', 'G大调', 'A大调', 'B大调', '降E大调'];
|
||||
|
||||
const fetchOptions = async () => {
|
||||
try {
|
||||
@@ -150,6 +160,7 @@ const fetchContents = async () => {
|
||||
const params = {};
|
||||
if (filterStatus.value !== 'all') params.status = filterStatus.value;
|
||||
if (filterGenre.value !== 'all') params.genre = filterGenre.value;
|
||||
if (filterKey.value !== 'all') params.key = filterKey.value;
|
||||
if (searchKeyword.value) params.keyword = searchKeyword.value;
|
||||
|
||||
const res = await creatorApi.listContents(params);
|
||||
@@ -164,7 +175,7 @@ onMounted(() => {
|
||||
fetchContents();
|
||||
});
|
||||
|
||||
watch([filterStatus, filterGenre], () => {
|
||||
watch([filterStatus, filterGenre, filterKey], () => {
|
||||
fetchContents();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user