dictController.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // 字典
  4. class DictController extends Controller {
  5. constructor(ctx) {
  6. super(ctx);
  7. // 特殊的入参校验可以重写在这,默认可以使用commonRule
  8. ctx.logger.debug('构造');
  9. }
  10. // 字典表查询
  11. async index() {
  12. const { ctx, service } = this;
  13. // 校验参数 组装参数
  14. const payload = ctx.validate({});
  15. // 调用 Service 进行业务处理
  16. const data = await service.dictService.index(payload);
  17. // 设置响应内容和响应状态码
  18. ctx.success({ data });
  19. }
  20. // 省份城市
  21. async place() {
  22. const { ctx, service } = this;
  23. // 调用 Service 进行业务处理
  24. const data = await service.dictService.place();
  25. // 设置响应内容和响应状态码
  26. ctx.success({ data });
  27. }
  28. // 消息类型
  29. async msgType() {
  30. const { ctx, service } = this;
  31. // 调用 Service 进行业务处理
  32. const data = await service.dictService.msgType();
  33. // 设置响应内容和响应状态码
  34. ctx.success({ data });
  35. }
  36. // 车系车型
  37. async car() {
  38. const { ctx, service } = this;
  39. // 调用 Service 进行业务处理
  40. const data = await service.dictService.car(ctx.validate({}));
  41. // 设置响应内容和响应状态码
  42. ctx.success({ data });
  43. }
  44. // 远控失败类型
  45. async rcFailType() {
  46. const { ctx, service } = this;
  47. // 调用 Service 进行业务处理
  48. const data = await service.dictService.rcFailType();
  49. // 设置响应内容和响应状态码
  50. ctx.success({ data });
  51. }
  52. // 自动化测试流程id
  53. async autoTest() {
  54. const { ctx, service } = this;
  55. // 调用 Service 进行业务处理
  56. const data = await service.dictService.autoTest();
  57. // 设置响应内容和响应状态码
  58. ctx.success({ data });
  59. }
  60. }
  61. module.exports = DictController;