1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 'use strict';
- const Controller = require('egg').Controller;
- // 用户基础信息统计分析管理
- class UserInfoController extends Controller {
- constructor(ctx) {
- super(ctx);
- // 特殊的入参校验可以重写在这,默认可以使用commonRule
- this.createRule = {
- user_id: { type: 'string' },
- };
- this.createListRule = {
- pageNumber: { type: 'number', min: 0, required: false },
- pageSize: { type: 'number', min: 0, required: false },
- };
- }
- // 用户基础信息查询
- async list() {
- const { ctx, service } = this;
- const payload = ctx.validate(this.createListRule);
- if (ctx.isDev()) {
- const data = ctx.getUserInfo(payload);
- ctx.success({ data });
- } else {
- const data = await service.userInfoService.list(payload);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- }
- async index() {
- const { ctx, service } = this;
- const payload = ctx.validate(this.createRule);
- if (ctx.isDev()) {
- const data = ctx.getUserData();
- ctx.success({ data });
- } else {
- const data = await service.userInfoService.index(payload);
- // // 设置响应内容和响应状态码
- ctx.success({ data });
- }
- }
- }
- module.exports = UserInfoController;
|