group.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. const _ = require('lodash');
  3. const meta = require('./.group.js');
  4. const Controller = require('egg').Controller;
  5. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  6. // 分组管理
  7. class GroupController extends Controller {
  8. constructor(ctx) {
  9. super(ctx);
  10. this.service = this.ctx.service.group;
  11. }
  12. async insert() {
  13. const res = await this.service.insert(this.ctx.request.body);
  14. this.ctx.ok({ msg: 'ok', data: res });
  15. }
  16. async exit() {
  17. const res = await this.service.exit(this.ctx.request.body);
  18. this.ctx.ok({ msg: 'ok', data: res });
  19. }
  20. async sethead() {
  21. const res = await this.service.sethead(this.ctx.request.body);
  22. this.ctx.ok({ msg: 'ok', data: res });
  23. }
  24. async findbystuid() {
  25. const res = await this.service.findbystuid(this.ctx.request.body);
  26. this.ctx.ok({ msg: 'ok', data: res });
  27. }
  28. async index() {
  29. const data = await this.service.query(this.ctx.query);
  30. this.ctx.ok({ ...data });
  31. }
  32. }
  33. module.exports = CrudController(GroupController, meta);