util.js 773 B

123456789101112131415161718192021222324252627
  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. async checkCartBuy() {
  21. const data = await this.tradeService.checkCartBuy(this.bodyObject);
  22. this.ctx.ok({ data });
  23. }
  24. }
  25. module.exports = CrudController(UtilController, {});