feat: app detail

This commit is contained in:
archer
2023-07-13 15:07:13 +08:00
parent 6c72c20317
commit b4d46ff34d
47 changed files with 1088 additions and 1091 deletions

View File

@@ -6,22 +6,22 @@ import { Types } from 'mongoose';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { chatId, historyId } = req.query as {
chatId: string;
const { historyId, contentId } = req.query as {
historyId: string;
contentId: string;
};
await connectToDatabase();
const { userId } = await authUser({ req, authToken: true });
if (!chatId || !historyId) {
if (!historyId || !contentId) {
throw new Error('params is error');
}
const history = await Chat.aggregate([
{
$match: {
_id: new Types.ObjectId(chatId),
_id: new Types.ObjectId(historyId),
userId: new Types.ObjectId(userId)
}
},
@@ -30,7 +30,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
},
{
$match: {
'content._id': new Types.ObjectId(historyId)
'content._id': new Types.ObjectId(contentId)
}
},
{

View File

@@ -7,13 +7,13 @@ import { Types } from 'mongoose';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
let {
chatId,
historyId,
contentId,
quoteId,
sourceText = ''
} = req.query as {
chatId: string;
historyId: string;
contentId: string;
quoteId: string;
sourceText: string;
};
@@ -21,15 +21,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const { userId } = await authUser({ req, authToken: true });
if (!chatId || !historyId || !quoteId) {
if (!contentId || !historyId || !quoteId) {
throw new Error('params is error');
}
await Chat.updateOne(
{
_id: new Types.ObjectId(chatId),
_id: new Types.ObjectId(historyId),
userId: new Types.ObjectId(userId),
'content._id': new Types.ObjectId(historyId)
'content._id': new Types.ObjectId(contentId)
},
{
$set: {

View File

@@ -53,7 +53,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const { chat, history = [] }: { chat?: ChatSchema; history?: ChatItemType[] } =
await (async () => {
if (historyId) {
// auth chatId
// auth historyId
const chat = await Chat.findOne({
_id: historyId,
userId