questionnaire.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. const _ = require('lodash');
  3. const Controller = require('egg').Controller;
  4. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  5. // 科目管理
  6. class QuestionnaireController extends Controller {
  7. constructor(ctx) {
  8. super(ctx);
  9. this.service = this.ctx.service.questionnaire;
  10. }
  11. // POST
  12. // 新建问卷
  13. async create() {
  14. const res = await this.service.create(this.ctx.request.body);
  15. this.ctx.ok({ msg: 'created', data: res });
  16. }
  17. // POST
  18. // 根据id删除问卷
  19. async delete() {
  20. const { id } = this.ctx.params;
  21. await this.service.delete({ id });
  22. this.ctx.ok({ msg: 'deleted' });
  23. }
  24. // POST
  25. // 根据id更新信息
  26. async update() {
  27. await this.service.update(this.ctx.params, this.ctx.request.body);
  28. this.ctx.ok({ msg: 'accepted' });
  29. }
  30. // GET
  31. // 查询
  32. async query() {
  33. const res = await this.service.query(this.ctx.query);
  34. this.ctx.ok({ ...res });
  35. }
  36. // GET
  37. // 查询详情
  38. async show() {
  39. const res = await this.service.show(this.ctx.params);
  40. this.ctx.ok({ msg: 'queried', data: res });
  41. }
  42. }
  43. module.exports = QuestionnaireController;