/* * @Author: YKH * @Date: 2022-04-21 16:57:53 * @LastEditTime: 2022-04-21 17:10:01 * @Description: * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\hide\controller\admin\hide_game_agent.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 { HideGameAgentEntity } from '../../entity/hide_game_agent'; /** * 商品 */ @Provide() @CoolController({ // 添加通用CRUD接口 api: ['add', 'delete', 'update', 'info', 'list', 'page'], // 设置表实体 entity: HideGameAgentEntity, // // 向表插入当前登录用户ID // insertParam: async (ctx: Context) => { // return { // userId: ctx.admin.userId, // }; // }, // // info接口忽略价格字段 // infoIgnoreProperty: ['price'], before: ctx => { //前段数据转JSON格式 const data = ctx.request.body; if (data.name == "") { data.name = null } ctx.request.body.data = JSON.stringify(data); }, // 分页查询配置 pageQueryOp: { // 让字段支持模糊查询 keyWordLikeFields: ['name'], // 让字段支持筛选 fieldEq: ['name'] // // 指定返回字段 // select: ['a.*', 'b.name'], // // 关联表用户表 // leftJoin: [ // { // // 管理的表 // entity: BaseSysUserEntity, // // 别名 // alias: 'b', // // 关联条件 // condition: 'a.userId = b.id', // }, // ], // // 增加其他条件 // where: async (ctx: Context) => { // return [ // // 价格大于90 // ['a.price > :price', { price: 90.0 }], // ]; // }, // // 添加排序 // addOrderBy: { // // 排序字段及排序方式 // price: 'desc', // }, }, }) export class HideGameAgentController extends BaseController { /** * 其他接口 */ // @Get('/other') // async other() { // return this.ok('hello, cool-admin!!!'); // } }