fix: add delete all input guide lexicon button (#2241)

* fix: add delete all input guide lexicon button

* fix

* fix permisstion
This commit is contained in:
heheer
2024-08-03 12:29:15 +08:00
committed by GitHub
parent 9f37e56173
commit 48f2c95bb9
7 changed files with 72 additions and 19 deletions

View File

@@ -2,21 +2,14 @@ import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/nex
import { NextAPI } from '@/service/middleware/entry';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { MongoChatInputGuide } from '@fastgpt/service/core/chat/inputGuide/schema';
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
export type deleteChatInputGuideQuery = {};
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
export type deleteInputGuideBody = { appId: string; dataIdList: string[] };
export type deleteInputGuideResponse = {};
async function handler(
req: ApiRequestProps<deleteInputGuideBody, deleteChatInputGuideQuery>,
res: ApiResponseType<any>
): Promise<deleteInputGuideResponse> {
async function handler(req: ApiRequestProps<deleteInputGuideBody, ''>, res: ApiResponseType<any>) {
const { appId, dataIdList } = req.body;
await authApp({ req, appId, authToken: true, per: ReadPermissionVal });
console.log(dataIdList);
await authApp({ req, appId, authToken: true, per: WritePermissionVal });
await MongoChatInputGuide.deleteMany({
_id: { $in: dataIdList },
appId

View File

@@ -0,0 +1,23 @@
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
import { NextAPI } from '@/service/middleware/entry';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { MongoChatInputGuide } from '@fastgpt/service/core/chat/inputGuide/schema';
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
export type deleteAllInputGuideBody = { appId: string };
async function handler(
req: ApiRequestProps<deleteAllInputGuideBody, ''>,
res: ApiResponseType<any>
) {
const { appId } = req.body;
await authApp({ req, appId, authToken: true, per: WritePermissionVal });
await MongoChatInputGuide.deleteMany({
appId
});
return {};
}
export default NextAPI(handler);

View File

@@ -2,7 +2,7 @@ import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/nex
import { NextAPI } from '@/service/middleware/entry';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { MongoChatInputGuide } from '@fastgpt/service/core/chat/inputGuide/schema';
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
export type updateChatInputGuideQuery = {};
@@ -19,7 +19,7 @@ async function handler(
res: ApiResponseType<any>
): Promise<updateInputGuideResponse> {
const { appId, dataId, text } = req.body;
await authApp({ req, appId, authToken: true, per: ReadPermissionVal });
await authApp({ req, appId, authToken: true, per: WritePermissionVal });
await MongoChatInputGuide.findOneAndUpdate(
{