'use strict'; const _ = require('lodash'); const Controller = require('egg').Controller; const { CrudController } = require('naf-framework-mongoose/lib/controller'); // 科目管理 class QuestionnaireController extends Controller { constructor(ctx) { super(ctx); this.service = this.ctx.service.questionnaire; } // POST // 新建问卷 async create() { const res = await this.service.create(this.ctx.request.body); this.ctx.ok({ msg: 'created', data: res }); } // POST // 根据id删除问卷 async delete() { const { id } = this.ctx.params; await this.service.delete({ id }); this.ctx.ok({ msg: 'deleted' }); } // POST // 根据id更新信息 async update() { await this.service.update(this.ctx.params, this.ctx.request.body); this.ctx.ok({ msg: 'accepted' }); } // GET // 查询 async query() { const res = await this.service.query(this.ctx.query); this.ctx.ok({ ...res }); } // GET // 查询详情 async show() { const res = await this.service.show(this.ctx.params); this.ctx.ok({ msg: 'queried', data: res }); } } module.exports = QuestionnaireController;