12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 'use strict';
- const Controller = require('egg').Controller;
- class WXMenuController extends Controller {
- async one() {
- // console.log('one');
- const { ctx, service } = this;
- const query = ctx.query;
- const { id } = query;
- const result = await service.wxMenuService.one(id);
- if (result) {
- ctx.body = {
- data: result,
- code: 0,
- };
- } else {
- ctx.body = {
- message: '微信菜单信息查询失败',
- code: 0,
- };
- }
- }
- async add() {
- // console.log('add');
- const { ctx, service } = this;
- const query = ctx.request.body;
- const result = await service.wxMenuService.add(query);
- ctx.body = {
- data: result,
- code: 0,
- };
- }
- async update() {
- // console.log('update');
- const { ctx, service } = this;
- const query = ctx.request.body;
- const { id } = query;
- delete query.id;
- if (id) {
- const result = await service.wxMenuService.update(id, query);
- ctx.body = {
- data: result,
- code: 0,
- };
- } else {
- ctx.body = {
- code: 1,
- message: 'id is null',
- };
- }
- }
- async delete() {
- // console.log('delete');
- const { ctx, service } = this;
- const query = ctx.query;
- const { id } = query;
- const result = await service.wxMenuService.dele(id);
- ctx.body = {
- data: result,
- code: 0,
- };
- }
- async list() {
- // console.log('list');
- const { ctx, service } = this;
- const query = ctx.query;
- const result = await service.wxMenuService.list(query);
- ctx.body = {
- data: result,
- code: 0,
- };
- }
- }
- module.exports = WXMenuController;
|