渠道
This commit is contained in:
49
shared/db/ChannelInfo.ts
Normal file
49
shared/db/ChannelInfo.ts
Normal file
@@ -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>;
|
||||
|
||||
@@ -11,6 +11,7 @@ import { loadActivity } from "./Activity";
|
||||
import { loadActivityGroup } from "./ActivityGroup";
|
||||
import { loadActivityGroupType } from "./ActivityGroupType";
|
||||
import { loadActivityTaskPoint } from "./ActivityTaskPoint";
|
||||
import { loadChannelInfo } from "./ChannelInfo";
|
||||
|
||||
export function loadGmDb(connect: mongoose.Connection) {
|
||||
// console.log('************')
|
||||
@@ -26,4 +27,5 @@ export function loadGmDb(connect: mongoose.Connection) {
|
||||
loadCounterModal(connect);
|
||||
loadMarqueeModel(connect);
|
||||
loadActivityTaskPoint(connect);
|
||||
loadChannelInfo(connect);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { RedisClient } from 'redis';
|
||||
import { REDIS_KEY } from '@consts';
|
||||
import { RegionModel } from '@db/Region';
|
||||
import { getRandEelmWithWeight, resResult } from 'app/pubUtils/util';
|
||||
import { ChannelInfoModel } from '@db/ChannelInfo';
|
||||
|
||||
export default class GameController extends Controller {
|
||||
|
||||
@@ -33,11 +34,19 @@ export default class GameController extends Controller {
|
||||
|
||||
public async checkReview() {
|
||||
const { ctx } = this;
|
||||
const { version } = ctx.request.body;
|
||||
const { version, platformAppid } = ctx.request.body;
|
||||
|
||||
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
||||
if(!curRegion) return resResult(STATUS.VERSION_ERR);
|
||||
|
||||
let hasPolicy = false, userPolicyLink = '', privacyPolicyLink = ''; // 是否需要替换协议,有就是用下面两个字段替换
|
||||
let channelInfo = await ChannelInfoModel.findByPlatform(platformAppid);
|
||||
if(channelInfo && !channelInfo.isDefaultPolicy) {
|
||||
hasPolicy = true;
|
||||
userPolicyLink = channelInfo.userPolicyLink;
|
||||
privacyPolicyLink = channelInfo.privacyPolicyLink;
|
||||
}
|
||||
|
||||
let isReview = await ctx.service.update.checkReview(curRegion, version);
|
||||
let hasNewWebServer = false, webServerUrl = '';
|
||||
if(isReview && curRegion.reviewEnv) {
|
||||
@@ -46,7 +55,8 @@ export default class GameController extends Controller {
|
||||
hasNewWebServer = true, webServerUrl = reviewRegion.webHost;
|
||||
}
|
||||
}
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isReview, hasNewWebServer, webServerUrl });
|
||||
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { isReview, hasNewWebServer, webServerUrl, hasPolicy, userPolicyLink, privacyPolicyLink });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user