mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00
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:
@@ -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
|
||||
|
23
projects/app/src/pages/api/core/chat/inputGuide/deleteAll.ts
Normal file
23
projects/app/src/pages/api/core/chat/inputGuide/deleteAll.ts
Normal 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);
|
@@ -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(
|
||||
{
|
||||
|
Reference in New Issue
Block a user