/*
 * @Author: YKH
 * @Date: 2021-12-08 10:26:27
 * @LastEditTime: 2022-04-02 09:22:39
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\computer_usage.ts
 */
import { Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from 'midwayjs-cool-core';
import { ShuyouComputerUsageEntity } from '../../entity/computer_usage';
import { ShuyouComputerUsageService } from '../../service/computer_usage';

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

  before: ctx => {
    //前段数据转JSON格式
    const data = ctx.request.body;
    // console.log(ctx.request.header.referer)
    if (data.task_id == "") {
      data.task_id = null
    }
    if (data.pc_num == "") {
      data.pc_num == null
    }
    ctx.request.body.data = JSON.stringify(data);
  },
  // 分页查询配置
  pageQueryOp: {
    // 让字段支持模糊查询
    keyWordLikeFields: ['task_id', 'pc_num'],
    // 让字段支持筛选
    fieldEq: ['task_id', 'pc_num'],
    // 添加排序
    addOrderBy: {
      // 排序字段及排序方式
      task_id: 'asc',
    },
  },
})
export class ShuyouComputerUsageController extends BaseController {

  // @Inject()
  // ShuyouGameTaskService: ShuyouGameTaskService;

  /**
   * 其他接口
   */
  // @Get('/other')
  // async other() {
  //   return this.ok('hello, cool-admin!!!');
  // }
}
