hide_game_agent.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * @Author: YKH
  3. * @Date: 2022-04-21 16:57:53
  4. * @LastEditTime: 2022-04-21 17:10:01
  5. * @Description:
  6. * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\hide\controller\admin\hide_game_agent.ts
  7. */
  8. import { Provide } from '@midwayjs/decorator';
  9. // import { Context } from 'egg';
  10. import { CoolController, BaseController } from 'midwayjs-cool-core';
  11. // import { BaseSysUserEntity } from '../../../base/entity/sys/user';
  12. import { HideGameAgentEntity } from '../../entity/hide_game_agent';
  13. /**
  14. * 商品
  15. */
  16. @Provide()
  17. @CoolController({
  18. // 添加通用CRUD接口
  19. api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  20. // 设置表实体
  21. entity: HideGameAgentEntity,
  22. // // 向表插入当前登录用户ID
  23. // insertParam: async (ctx: Context) => {
  24. // return {
  25. // userId: ctx.admin.userId,
  26. // };
  27. // },
  28. // // info接口忽略价格字段
  29. // infoIgnoreProperty: ['price'],
  30. before: ctx => {
  31. //前段数据转JSON格式
  32. const data = ctx.request.body;
  33. if (data.name == "") {
  34. data.name = null
  35. }
  36. ctx.request.body.data = JSON.stringify(data);
  37. },
  38. // 分页查询配置
  39. pageQueryOp: {
  40. // 让字段支持模糊查询
  41. keyWordLikeFields: ['name'],
  42. // 让字段支持筛选
  43. fieldEq: ['name']
  44. // // 指定返回字段
  45. // select: ['a.*', 'b.name'],
  46. // // 关联表用户表
  47. // leftJoin: [
  48. // {
  49. // // 管理的表
  50. // entity: BaseSysUserEntity,
  51. // // 别名
  52. // alias: 'b',
  53. // // 关联条件
  54. // condition: 'a.userId = b.id',
  55. // },
  56. // ],
  57. // // 增加其他条件
  58. // where: async (ctx: Context) => {
  59. // return [
  60. // // 价格大于90
  61. // ['a.price > :price', { price: 90.0 }],
  62. // ];
  63. // },
  64. // // 添加排序
  65. // addOrderBy: {
  66. // // 排序字段及排序方式
  67. // price: 'desc',
  68. // },
  69. },
  70. })
  71. export class HideGameAgentController extends BaseController {
  72. /**
  73. * 其他接口
  74. */
  75. // @Get('/other')
  76. // async other() {
  77. // return this.ok('hello, cool-admin!!!');
  78. // }
  79. }