util.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
  4. const { BusinessError, ErrorCode } = require('naf-core').Error;
  5. const _ = require('lodash');
  6. const moment = require('moment');
  7. // 业务工具
  8. class UtilController extends Controller {
  9. constructor(ctx) {
  10. super(ctx);
  11. this.queryObject = this.ctx.query;
  12. this.bodyObject = this.ctx.request.body;
  13. this.service = this.ctx.service.util;
  14. this.tradeService = this.ctx.service.util.trade;
  15. }
  16. async util() {
  17. this.ctx.ok();
  18. }
  19. async crk() {
  20. const key = await this.ctx.service.util.rk.crk();
  21. this.ctx.ok({ data: key });
  22. }
  23. /**
  24. * 查询是否可以购买
  25. */
  26. async checkCanBuy() {
  27. const data = await this.tradeService.checkCanBuy(this.bodyObject);
  28. this.ctx.ok({ data });
  29. }
  30. async checkCartBuy() {
  31. const data = await this.tradeService.checkCartBuy(this.bodyObject);
  32. this.ctx.ok({ data });
  33. }
  34. }
  35. module.exports = CrudController(UtilController, {});