123456789101112131415161718192021222324252627282930313233343536 |
- 'use strict';
- const Service = require('egg').Service;
- class WXMenuService extends Service {
- async one(id) {
- const { model } = this.ctx;
- return await model.WxMenuModel.findById(id);
- }
- async list(data) {
- const { model } = this.ctx;
- return await model.WxMenuModel.find(data);
- }
- async add(data) {
- const { model } = this.ctx;
- const result = await model.WxMenuModel.create(data);
- return result;
- }
- async update(id, data) {
- const { model } = this.ctx;
- if (data.sub_button === 0) {
- data.sub_button = [];
- }
- const result = await model.WxMenuModel.updateOne({ _id: id }, data);
- return result;
- }
- async dele(id) {
- const { model } = this.ctx;
- const result = await model.WxMenuModel.deleteOne({ _id: id });
- return result;
- }
- }
- module.exports = WXMenuService;
|