user.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. const _ = require('lodash');
  3. const meta = require('./.user.js');
  4. const Controller = require('egg').Controller;
  5. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  6. // 管理
  7. class UserController extends Controller {
  8. constructor(ctx) {
  9. super(ctx);
  10. this.service = this.ctx.service.user;
  11. }
  12. async create() {
  13. const res = await this.service.create(this.ctx.request.body);
  14. this.ctx.ok({ data: res });
  15. }
  16. // 学校注册
  17. async register() {
  18. const res = await this.service.register(this.ctx.request.body);
  19. this.ctx.ok({ data: res });
  20. }
  21. // 学生微信绑定
  22. async bind() {
  23. const res = await this.service.bind(this.ctx.request.body);
  24. this.ctx.ok({ data: res });
  25. }
  26. // 其他用户微信绑定
  27. async userbind() {
  28. const res = await this.service.userbind(this.ctx.request.body);
  29. this.ctx.ok({ data: res });
  30. }
  31. // 学校用户生成
  32. async schoolregister() {
  33. const res = await this.service.schoolregister();
  34. this.ctx.ok({ data: res });
  35. }
  36. }
  37. module.exports = CrudController(UserController, meta);