mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 10:28:42 +00:00
perf: share link
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { connectToDatabase, Bill, User, ShareChat } from '../mongo';
|
||||
import { connectToDatabase, Bill, User, OutLink } from '../mongo';
|
||||
import { BillSourceEnum } from '@/constants/user';
|
||||
import { getModel } from '../utils/data';
|
||||
import { ChatHistoryItemResType } from '@/types/chat';
|
||||
@@ -59,7 +59,7 @@ export const updateShareChatBill = async ({
|
||||
total: number;
|
||||
}) => {
|
||||
try {
|
||||
await ShareChat.findOneAndUpdate(
|
||||
await OutLink.findOneAndUpdate(
|
||||
{ shareId },
|
||||
{
|
||||
$inc: { total },
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import { Schema, model, models, Model } from 'mongoose';
|
||||
import { ShareChatSchema as ShareChatSchemaType } from '@/types/mongoSchema';
|
||||
import { OutLinkSchema as SchmaType } from '@/types/mongoSchema';
|
||||
import { OutLinkTypeEnum } from '@/constants/chat';
|
||||
|
||||
const ShareChatSchema = new Schema({
|
||||
const OutLinkSchema = new Schema({
|
||||
shareId: {
|
||||
type: String,
|
||||
required: true
|
||||
@@ -16,6 +17,10 @@ const ShareChatSchema = new Schema({
|
||||
ref: 'model',
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: OutLinkTypeEnum.share
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true
|
||||
@@ -29,5 +34,4 @@ const ShareChatSchema = new Schema({
|
||||
}
|
||||
});
|
||||
|
||||
export const ShareChat: Model<ShareChatSchemaType> =
|
||||
models['shareChat'] || model('shareChat', ShareChatSchema);
|
||||
export const OutLink: Model<SchmaType> = models['outlinks'] || model('outlinks', OutLinkSchema);
|
@@ -120,7 +120,7 @@ export * from './models/trainingData';
|
||||
export * from './models/openapi';
|
||||
export * from './models/promotionRecord';
|
||||
export * from './models/collection';
|
||||
export * from './models/shareChat';
|
||||
export * from './models/outLink';
|
||||
export * from './models/kb';
|
||||
export * from './models/inform';
|
||||
export * from './models/image';
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import type { NextApiRequest } from 'next';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import Cookie from 'cookie';
|
||||
import { App, OpenApi, User, ShareChat, KB } from '../mongo';
|
||||
import { App, OpenApi, User, OutLink, KB } from '../mongo';
|
||||
import type { AppSchema } from '@/types/mongoSchema';
|
||||
import { formatPrice } from '@/utils/user';
|
||||
import { ERROR_ENUM } from '../errorCode';
|
||||
@@ -216,7 +216,7 @@ export const authKb = async ({ kbId, userId }: { kbId: string; userId: string })
|
||||
|
||||
export const authShareChat = async ({ shareId }: { shareId: string }) => {
|
||||
// get shareChat
|
||||
const shareChat = await ShareChat.findOne({ shareId });
|
||||
const shareChat = await OutLink.findOne({ shareId });
|
||||
|
||||
if (!shareChat) {
|
||||
return Promise.reject('分享链接已失效');
|
||||
|
Reference in New Issue
Block a user