|
|
@@ -11,6 +11,9 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
|
|
|
const query = getQuery(event);
|
|
|
const page = Number(query.page as string) || 1;
|
|
|
const pageSize = Number(query.pageSize as string) || 10;
|
|
|
+ const onlySelf = query.onlySelf === 'true';
|
|
|
+ const bannedChannels = (query.bannedChannels as string || '').split(',');
|
|
|
+
|
|
|
const channelName = query.channelName as string;
|
|
|
if (!channelName)
|
|
|
return createErrorResponse('分类名称不能为空');
|
|
|
@@ -27,12 +30,17 @@ export default defineEventHandler<EventHandlerRequest, Promise<IResponse<ICommon
|
|
|
.first();
|
|
|
if (channel) {
|
|
|
channelIds.push(channel.id);
|
|
|
- const subChannelIds = (await DB.table('pr_cms_channel')
|
|
|
- .where('parent_id', channel.id)
|
|
|
- .where('status', 'normal')
|
|
|
- .select('id')
|
|
|
- .get()).map(item => item.id);
|
|
|
- channelIds.push(...subChannelIds);
|
|
|
+ if (!onlySelf) {
|
|
|
+ const subChannels = (await DB.table('pr_cms_channel')
|
|
|
+ .where('parent_id', channel.id)
|
|
|
+ .where('status', 'normal')
|
|
|
+ .select('id', '')
|
|
|
+ .get()).map(item => item.id);
|
|
|
+ if (bannedChannels.length > 0) {
|
|
|
+ channelIds.push(...subChannels.filter(item => !bannedChannels.includes(item.name)).map(item => item.id));
|
|
|
+ } else
|
|
|
+ channelIds.push(...subChannels.map(item => item.id));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|