grouppatients.js 940 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. // 群患者
  4. class GroupPatientsController extends Controller {
  5. constructor(ctx) {
  6. super(ctx);
  7. this.service = this.ctx.service.group;
  8. }
  9. // GET LIST
  10. async index() {
  11. const data = await this.service.fetchPatient(this.ctx.params);
  12. this.ctx.ok({ data });
  13. }
  14. // GET /{id}
  15. async fetch() {
  16. const { groupid } = this.ctx.params;
  17. const data = await this.service.fetchPatient({ id: groupid });
  18. this.ctx.ok({ data });
  19. }
  20. // POST /{id}
  21. async update() {
  22. const { groupid, id } = this.ctx.params;
  23. await this.service.updatePatient({ groupid, id }, this.ctx.request.body);
  24. this.ctx.ok({ msg: 'accepted' });
  25. }
  26. // DELETE /{id}
  27. async destroy() {
  28. const { groupid, id } = this.ctx.params;
  29. await this.service.deletePatient({ groupid, id });
  30. this.ctx.ok({ msg: 'deleted' });
  31. }
  32. }
  33. module.exports = GroupPatientsController;