util.js 644 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
  4. // 业务工具
  5. class UtilController extends Controller {
  6. constructor(ctx) {
  7. super(ctx);
  8. this.queryObject = this.ctx.query;
  9. this.bodyObject = this.ctx.request.body;
  10. this.service = this.ctx.service.util;
  11. this.tradeService = this.ctx.service.util.trade;
  12. }
  13. /**
  14. * 查询是否可以购买
  15. */
  16. async checkCanBuy() {
  17. const data = await this.tradeService.checkCanBuy(this.bodyObject);
  18. this.ctx.ok({ data });
  19. }
  20. }
  21. module.exports = CrudController(UtilController, {});