/*
 * @Author: YKH
 * @Date: 2021-12-23 15:45:46
 * @LastEditTime: 2021-12-23 16:57:08
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\game_list.ts
 */
import { Provide } from '@midwayjs/decorator';
// import { Context } from 'egg';
import { CoolController, BaseController } from 'midwayjs-cool-core';
// import { BaseSysUserEntity } from '../../../base/entity/sys/user';
import { ShuyouGameListEntity } from '../../entity/game_list';
import { ShuyouGameListService } from '../../service/game_list';

/**
 * 商品
 */
@Provide()
@CoolController({
  // 添加通用CRUD接口
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  // 设置表实体
  entity: ShuyouGameListEntity,
  service: ShuyouGameListService,
  // // 向表插入当前登录用户ID
  // insertParam: async (ctx: Context) => {
  //   return {
  //     userId: ctx.admin.userId,
  //   };
  // },
  // // info接口忽略价格字段
  // infoIgnoreProperty: ['price'],

  before: ctx => {
    //前段数据转JSON格式
    const data = ctx.request.body;
    if (data.game_name == "") {
      data.game_name = null
    }
    ctx.request.body.data = JSON.stringify(data);
  },
  // 分页查询配置
  pageQueryOp: {
    // 让字段支持模糊查询
    keyWordLikeFields: ['game_name', 'game_agent', 'login_mode'],
    // 让字段支持筛选
    fieldEq: ['game_name', 'game_agent', 'login_mode']
  },
})
export class ShuyouAdminGameListController extends BaseController {
  /**
   * 其他接口
   */
  // @Get('/other')
  // async other() {
  //   return this.ok('hello, cool-admin!!!');
  // }
}
