/*
 * @Author: YKH
 * @Date: 2022-04-14 11:46:16
 * @LastEditTime: 2022-04-14 14:44:27
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\controller\admin\vx_api_type.ts
 */
import { Provide } from '@midwayjs/decorator';
import { CoolController, BaseController } from 'midwayjs-cool-core';
import { ShuyouVXApiTypeEntity } from '../../entity/vx_api_type';
import { ShuyouVXApiTypeService } from '../../service/vx_api_type';

/**
 * 特殊卡类型
 */
@Provide()
@CoolController({
  // 添加通用CRUD接口
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  // 设置表实体
  entity: ShuyouVXApiTypeEntity,
  service: ShuyouVXApiTypeService,

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

}
