增加店铺游戏主题编辑的相关接口

This commit is contained in:
zhl 2021-05-24 16:41:35 +08:00
parent ec17dbd563
commit b82ebead9d
3 changed files with 102 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import { ZError } from '../../common/ZError'
import { Game } from '../../models/content/Game'
import { generateQrFile } from '../../services/File'
import { isObjectId } from '../../utils/string.util'
import { ShopGameExt } from '../../models/shop/ShopGameExt'
class ShopController extends BaseController {
@ -128,6 +129,10 @@ class ShopController extends BaseController {
return {}
}
/**
*
* @param req
*/
@permission('shop:edit')
@router('post /api/shop/gameinfo')
async getGameInfo(req: any) {
@ -152,6 +157,43 @@ class ShopController extends BaseController {
}
}
/**
*
* @param req
*/
@permission('shop:edit')
@router('post /api/shop/gametheme')
async getGameTheme(req: any) {
let { shop, game, version } = req.params
if (!shop || !game || !version) {
throw new ZError(11, 'params mismatch')
}
let data = (await ShopGameExt.findOrCreate({shop, game, version})).doc
let cfg = data.cfg || {}
return cfg
}
/**
*
* @param req
*/
@permission('shop:edit')
@router('post /api/shop/gametheme/save')
async saveGameTheme(req: any) {
let { shop, game, version } = req.params
if (!shop || !game || !version) {
throw new ZError(11, 'params mismatch')
}
let data = (await ShopGameExt.findOrCreate({shop, game, version})).doc
let cfg = req.params.clone()
delete cfg.shop
delete cfg.game
delete cfg.version
data.cfg = cfg
await data.save()
return {}
}
@permission('shop:edit')
@router('post /api/shop/gameqr')
async getGameQr(req: any) {

View File

@ -8,7 +8,6 @@ import { BaseModule } from '../Base'
import { noJson } from '../../decorators/nojson'
import { Severity } from '@typegoose/typegoose/lib/internal/constants'
import { Base } from '@typegoose/typegoose/lib/defaultClasses'
import { UserReward } from '../UserReward'
export class ShopPuzzleClass extends Base{
@prop()

View File

@ -0,0 +1,60 @@
import { dbconn } from '../../decorators/dbconn'
import {
getModelForClass,
index,
modelOptions,
mongoose,
prop
} from '@typegoose/typegoose'
import { BaseModule } from '../Base'
import { Severity } from '@typegoose/typegoose/lib/internal/constants'
import { ShopExamClass } from './ShopExam'
@dbconn()
@index({ shop:1, game:1}, { unique: false })
@modelOptions({schemaOptions: {collection: "shop_game_ext", timestamps: true}, options: {allowMixed: Severity.ALLOW}})
export class ShopGameExtClass extends BaseModule {
/**
*
* @type {string}
*/
@prop()
public shop: string
@prop()
public game: string
@prop()
public version: string
@prop({type: mongoose.Schema.Types.Mixed})
public cfg: {}
// /**
// * 背景图案
// * @type {string}
// */
// @prop()
// public bg_item_icon: string
// /**
// * 主页正中间图片
// * @type {string}
// */
// @prop()
// public game_main_pic: string
// /**
// * 主页上单人赛按钮文字
// * @type {string}
// */
// @prop()
// public game_single_btn: string
//
// /**
// * 主页上多人赛按钮名字
// * @type {string}
// */
// @prop()
// public game_multi_btn: string
}
export const ShopGameExt = getModelForClass(ShopGameExtClass, { existingConnection: ShopGameExtClass.db })