Commit e289c4ec by archer

fix: ts数据

parent 1cbcc624
...@@ -35,8 +35,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) ...@@ -35,8 +35,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
pageSize, pageSize,
data: dataItems, data: dataItems,
total: await DataItem.countDocuments({ total: await DataItem.countDocuments({
dataId, dataId
status: 0
}) })
} }
}); });
......
...@@ -9,6 +9,7 @@ import { getUserOpenaiKey } from '@/service/utils/tools'; ...@@ -9,6 +9,7 @@ import { getUserOpenaiKey } from '@/service/utils/tools';
import { OpenAiTuneStatusEnum } from '@/service/constants/training'; import { OpenAiTuneStatusEnum } from '@/service/constants/training';
import { sendTrainSucceed } from '@/service/utils/sendEmail'; import { sendTrainSucceed } from '@/service/utils/sendEmail';
import { httpsAgent } from '@/service/utils/tools'; import { httpsAgent } from '@/service/utils/tools';
import { ModelPopulate } from '@/types/mongoSchema';
export default async function handler(req: NextApiRequest, res: NextApiResponse) { export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.headers.auth !== 'archer') { if (req.headers.auth !== 'archer') {
...@@ -31,7 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) ...@@ -31,7 +32,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// 删除训练文件 // 删除训练文件
openai.deleteFile(data.training_files[0].id, { httpsAgent }); openai.deleteFile(data.training_files[0].id, { httpsAgent });
const model = await Model.findById(item.modelId).populate({ const model = await Model.findById<ModelPopulate>(item.modelId).populate({
path: 'userId', path: 'userId',
options: { options: {
strictPopulate: false strictPopulate: false
......
...@@ -46,6 +46,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< ...@@ -46,6 +46,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
// 根据 id 获取用户信息 // 根据 id 获取用户信息
const user = await User.findById(response._id); const user = await User.findById(response._id);
if (!user) {
throw new Error('获取用户信息异常');
}
jsonRes(res, { jsonRes(res, {
data: { data: {
token: generateToken(user._id), token: generateToken(user._id),
......
...@@ -44,6 +44,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< ...@@ -44,6 +44,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
email email
}); });
if (!user) {
throw new Error('获取用户信息异常');
}
jsonRes(res, { jsonRes(res, {
data: { data: {
token: generateToken(user._id), token: generateToken(user._id),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment