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