fix: undo & redo (#2493)

* fix: undo & redo

* fix

* fix
This commit is contained in:
heheer
2024-08-24 23:15:28 +08:00
committed by GitHub
parent 3e57c7f559
commit 3248e95d53
17 changed files with 207 additions and 66 deletions

View File

@@ -0,0 +1,22 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { NextAPI } from '@/service/middleware/entry';
import { MongoAppVersion } from '@fastgpt/service/core/app/version/schema';
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
import { authApp } from '@fastgpt/service/support/permission/app/auth';
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
type Props = {
versionId: string;
appId: string;
};
async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
const { versionId, appId } = req.query as Props;
await authApp({ req, authToken: true, appId, per: ReadPermissionVal });
const result = await MongoAppVersion.findById(versionId);
return result;
}
export default NextAPI(handler);

View File

@@ -0,0 +1,56 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { NextAPI } from '@/service/middleware/entry';
import { MongoAppVersion } from '@fastgpt/service/core/app/version/schema';
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
type Props = PaginationProps<{
appId: string;
}>;
export type versionListResponse = {
_id: string;
appId: string;
versionName: string;
time: Date;
isPublish: boolean | undefined;
tmbId: string;
};
type Response = PaginationResponse<versionListResponse>;
async function handler(req: NextApiRequest, res: NextApiResponse<any>): Promise<Response> {
const { current, pageSize, appId } = req.body as Props;
const [result, total] = await Promise.all([
MongoAppVersion.find(
{
appId
},
'_id appId versionName time isPublish tmbId'
)
.sort({
time: -1
})
.skip((current - 1) * pageSize)
.limit(pageSize),
MongoAppVersion.countDocuments({ appId })
]);
const versionList = result.map((item) => {
return {
_id: item._id,
appId: item.appId,
versionName: item.versionName,
time: item.time,
isPublish: item.isPublish,
tmbId: item.tmbId
};
});
return {
total,
list: versionList
};
}
export default NextAPI(handler);