渠道
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>;
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ import { loadActivity } from "./Activity";
|
|||||||
import { loadActivityGroup } from "./ActivityGroup";
|
import { loadActivityGroup } from "./ActivityGroup";
|
||||||
import { loadActivityGroupType } from "./ActivityGroupType";
|
import { loadActivityGroupType } from "./ActivityGroupType";
|
||||||
import { loadActivityTaskPoint } from "./ActivityTaskPoint";
|
import { loadActivityTaskPoint } from "./ActivityTaskPoint";
|
||||||
|
import { loadChannelInfo } from "./ChannelInfo";
|
||||||
|
|
||||||
export function loadGmDb(connect: mongoose.Connection) {
|
export function loadGmDb(connect: mongoose.Connection) {
|
||||||
// console.log('************')
|
// console.log('************')
|
||||||
@@ -26,4 +27,5 @@ export function loadGmDb(connect: mongoose.Connection) {
|
|||||||
loadCounterModal(connect);
|
loadCounterModal(connect);
|
||||||
loadMarqueeModel(connect);
|
loadMarqueeModel(connect);
|
||||||
loadActivityTaskPoint(connect);
|
loadActivityTaskPoint(connect);
|
||||||
|
loadChannelInfo(connect);
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import { RedisClient } from 'redis';
|
|||||||
import { REDIS_KEY } from '@consts';
|
import { REDIS_KEY } from '@consts';
|
||||||
import { RegionModel } from '@db/Region';
|
import { RegionModel } from '@db/Region';
|
||||||
import { getRandEelmWithWeight, resResult } from 'app/pubUtils/util';
|
import { getRandEelmWithWeight, resResult } from 'app/pubUtils/util';
|
||||||
|
import { ChannelInfoModel } from '@db/ChannelInfo';
|
||||||
|
|
||||||
export default class GameController extends Controller {
|
export default class GameController extends Controller {
|
||||||
|
|
||||||
@@ -33,11 +34,19 @@ export default class GameController extends Controller {
|
|||||||
|
|
||||||
public async checkReview() {
|
public async checkReview() {
|
||||||
const { ctx } = this;
|
const { ctx } = this;
|
||||||
const { version } = ctx.request.body;
|
const { version, platformAppid } = ctx.request.body;
|
||||||
|
|
||||||
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
let curRegion = await RegionModel.findRegionByEnv(this.app.config.realEnv);
|
||||||
if(!curRegion) return resResult(STATUS.VERSION_ERR);
|
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 isReview = await ctx.service.update.checkReview(curRegion, version);
|
||||||
let hasNewWebServer = false, webServerUrl = '';
|
let hasNewWebServer = false, webServerUrl = '';
|
||||||
if(isReview && curRegion.reviewEnv) {
|
if(isReview && curRegion.reviewEnv) {
|
||||||
@@ -46,7 +55,8 @@ export default class GameController extends Controller {
|
|||||||
hasNewWebServer = true, webServerUrl = reviewRegion.webHost;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user