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