user.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. // 用appopenid查找用户
  37. async toFindAppUser() {
  38. const { appopenid } = this.ctx.request.body;
  39. const res = await this.service.findByAppOpenid(appopenid);
  40. this.ctx.ok({ data: res });
  41. }
  42. }
  43. module.exports = CrudController(UserController, meta);