wxMenuService.js 833 B

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. const Service = require('egg').Service;
  3. class WXMenuService extends Service {
  4. async one(id) {
  5. const { model } = this.ctx;
  6. return await model.WxMenuModel.findById(id);
  7. }
  8. async list(data) {
  9. const { model } = this.ctx;
  10. return await model.WxMenuModel.find(data);
  11. }
  12. async add(data) {
  13. const { model } = this.ctx;
  14. const result = await model.WxMenuModel.create(data);
  15. return result;
  16. }
  17. async update(id, data) {
  18. const { model } = this.ctx;
  19. if (data.sub_button === 0) {
  20. data.sub_button = [];
  21. }
  22. const result = await model.WxMenuModel.updateOne({ _id: id }, data);
  23. return result;
  24. }
  25. async dele(id) {
  26. const { model } = this.ctx;
  27. const result = await model.WxMenuModel.deleteOne({ _id: id });
  28. return result;
  29. }
  30. }
  31. module.exports = WXMenuService;