'use strict'; const Controller = require('egg').Controller; // 通常接口 class UsualController extends Controller { constructor(ctx) { super(ctx); this.params = this.ctx.params; this.queryObject = this.ctx.request.query; this.service = this.ctx.service.usual; this.reqBody = this.ctx.request.body; this.queryService = this.ctx.service.query; this.fetchService = this.ctx.service.fetch; this.createService = this.ctx.service.create; this.updateService = this.ctx.service.update; this.deleteService = this.ctx.service.delete; this.importService = this.ctx.service.import; this.statisService = this.ctx.service.statis; } // 通用多查 async query() { const data = await this.queryService.index(this.params, this.queryObject); this.ctx.ok(data); } // 通用单查 async fetch() { const data = await this.fetchService.index(this.params, this.queryObject); this.ctx.ok(data); } // 通用创建 async create() { const data = await this.createService.index(this.params, this.reqBody); this.ctx.ok(data); } // 通用修改 async update() { const data = await this.updateService.index(this.params, this.queryObject, this.reqBody); this.ctx.ok(data); } // 通用删除 async delete() { const data = await this.deleteService.index(this.params, this.queryObject); this.ctx.ok(data); } // 通用导入 async import() { const data = await this.importService.index(this.params, this.reqBody); this.ctx.ok(data); } // 统计透传 async statis() { const data = await this.statisService.index(this.params, this.queryObject); this.ctx.ok(data); } // 预约采集信息报名 async reserve() { const data = await this.service.reserve(this.reqBody); this.ctx.ok(data); } // 发送消息(微信推送) async sendMessage() { const data = await this.service.sendMessage(this.reqBody); this.ctx.ok(data); } // 确认消息(微信推送) async readMessage() { const data = await this.service.readMessage(this.params); this.ctx.ok(data); } } module.exports = UsualController;