doctormoney.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. const _ = require('lodash');
  3. const Controller = require('egg').Controller;
  4. // 打赏管理
  5. class DoctorMoneyController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.service = this.ctx.service.doctormoney;
  9. }
  10. // 查询列表
  11. async index() {
  12. let { skip, limit, ...info } = this.ctx.query;
  13. if (skip && !_.isNumber(skip)) skip = Number(skip);
  14. if (limit && !_.isNumber(limit)) limit = Number(limit);
  15. const data = await this.service.query(info, { skip, limit });
  16. this.ctx.ok({ ...data });
  17. }
  18. // POST
  19. // 添加群
  20. async create() {
  21. // 如果参数校验未通过,将会抛出一个 status = 422 的异常
  22. const res = await this.service.create(this.ctx.params, this.ctx.request.body);
  23. this.ctx.ok({ msg: 'created', data: res });
  24. }
  25. // DELETE /{id}
  26. // 删除群信息
  27. async destroy() {
  28. const { id } = this.ctx.params;
  29. await this.service.delete({ id });
  30. this.ctx.ok({ msg: 'deleted' });
  31. }
  32. }
  33. module.exports = DoctorMoneyController;