userInfoController.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // 用户基础信息统计分析管理
  4. class UserInfoController extends Controller {
  5. constructor(ctx) {
  6. super(ctx);
  7. // 特殊的入参校验可以重写在这,默认可以使用commonRule
  8. this.createRule = {
  9. user_id: { type: 'string' },
  10. };
  11. this.createListRule = {
  12. pageNumber: { type: 'number', min: 0, required: false },
  13. pageSize: { type: 'number', min: 0, required: false },
  14. };
  15. }
  16. // 用户基础信息查询
  17. async list() {
  18. const { ctx, service } = this;
  19. const payload = ctx.validate(this.createListRule);
  20. const data = await service.userInfoService.list(payload);
  21. // // 设置响应内容和响应状态码
  22. ctx.success({ data });
  23. }
  24. // 单查用户信息
  25. async index() {
  26. const { ctx, service } = this;
  27. const payload = ctx.validate(this.createRule);
  28. const data = await service.userInfoService.index(payload);
  29. // // 设置响应内容和响应状态码
  30. ctx.success({ data });
  31. }
  32. }
  33. module.exports = UserInfoController;