增加店铺游戏主题编辑的相关接口
This commit is contained in:
parent
ec17dbd563
commit
b82ebead9d
@ -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) {
|
||||
|
@ -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()
|
||||
|
60
src/models/shop/ShopGameExt.ts
Normal file
60
src/models/shop/ShopGameExt.ts
Normal 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 })
|
Loading…
x
Reference in New Issue
Block a user