/*
 * @Author: YKH
 * @Date: 2021-12-08 10:26:27
 * @LastEditTime: 2021-12-16 15:11:00
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\reason_incomplete.ts
 */
import { Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from 'midwayjs-cool-core';
import { ShuyouReasonIncompleteEntity } from '../../entity/reason_incomplete';
import { ShuyouReasonIncompleteService } from '../../service/reason_incomplete';

/**
 * 游戏负责人
 */
@Provide()
@CoolController({
  // 添加通用CRUD接口
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  // 设置表实体
  entity: ShuyouReasonIncompleteEntity,
  service: ShuyouReasonIncompleteService,

  before: ctx => {
    //前段数据转JSON格式
    const data = ctx.request.body;
    if (data.directorName == "") {
      data.directorName = null
    }
    if (data.task_id == "") {
      data.task_id = null
    }
    if (data.task_name == "") {
      data.task_name = null
    }
    if (typeof (data.new_date) == "undefined") {
      data.new_date = ['2021-01-01', new Date()]
    }
    ctx.request.body.data = JSON.stringify(data);
  },
  // 分页查询配置
  pageQueryOp: {
    // 让字段支持模糊查询
    keyWordLikeFields: ['directorName'],
    // 让字段支持筛选
    fieldEq: ['directorName'],
    // 添加排序
    addOrderBy: {
      // 排序字段及排序方式
      id: 'desc',
    },
  },
})
export class ShuyouReasonIncompleteController extends BaseController {
  /**
   * 其他接口
   */
  // @Get('/other')
  // async other() {
  //   return this.ok('hello, cool-admin!!!');
  // }
}
