user.js 518 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. // 管理员
  5. class UserController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.service = this.ctx.service.user;
  9. }
  10. async init() {
  11. await this.service.init();
  12. this.ctx.ok();
  13. }
  14. async login() {
  15. const data = await this.service.login(this.ctx.request.body);
  16. this.ctx.ok({ data });
  17. }
  18. }
  19. module.exports = CrudController(UserController, {});