渠道
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, modelOptions, ReturnModelType, mongoose } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 私聊信息
|
||||
**/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ roomId: 1, seqId: -1 })
|
||||
@index({ msgId: 1 })
|
||||
export default class ChannelInfo extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
code: string; // 渠道标识
|
||||
|
||||
@prop({ required: true })
|
||||
platform: string; // 渠道标识
|
||||
|
||||
@prop({ required: true })
|
||||
desc: string; // 渠道描述
|
||||
|
||||
@prop({ required: true })
|
||||
isDefaultPolicy: boolean; // 是否使用默认协议
|
||||
|
||||
@prop({ required: true })
|
||||
userPolicyLink: string; // 用户协议
|
||||
|
||||
@prop({ required: true })
|
||||
privacyPolicyLink: string; // 隐私协议
|
||||
|
||||
public static async findAll() {
|
||||
const result: ChannelInfoType[] = await ChannelInfoModel.find().lean();
|
||||
return result
|
||||
}
|
||||
|
||||
public static async findByPlatform(platform: string) {
|
||||
const result: ChannelInfoType = await ChannelInfoModel.findOne({ platform }).lean();
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
export let ChannelInfoModel: ReturnModelType<typeof ChannelInfo, {}>;
|
||||
export function loadChannelInfo(connect: mongoose.Connection) {
|
||||
ChannelInfoModel = getModelForClass(ChannelInfo, {
|
||||
existingConnection: connect
|
||||
});
|
||||
}
|
||||
export interface ChannelInfoType extends Pick<DocumentType<ChannelInfo>, keyof ChannelInfo> {};
|
||||
export type ChannelInfoParam = Partial<ChannelInfoType>;
|
||||
|
||||
Reference in New Issue
Block a user