123456789101112131415161718192021222324252627282930313233343536373839 |
- 'use strict';
- const Controller = require('egg').Controller;
- const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
- const _ = require('lodash');
- // 业务工具
- class UtilController extends Controller {
- constructor(ctx) {
- super(ctx);
- this.queryObject = this.ctx.query;
- this.bodyObject = this.ctx.request.body;
- this.service = this.ctx.service.util;
- this.tradeService = this.ctx.service.util.trade;
- }
- async util() {
- const request = this.ctx.request;
- console.log(request);
- const ip = _.get(request, 'header.x-real-ip');
- const forward = _.get(request, 'header.x-forwarded-for');
- const host = _.get(request, 'header.host');
- const referer = _.get(request, 'header.referer');
- const query = this.ctx.query;
- const body = _.get(request, 'body');
- this.ctx.body = 'GG';
- }
- /**
- * 查询是否可以购买
- */
- async checkCanBuy() {
- const data = await this.tradeService.checkCanBuy(this.bodyObject);
- this.ctx.ok({ data });
- }
- async checkCartBuy() {
- const data = await this.tradeService.checkCartBuy(this.bodyObject);
- this.ctx.ok({ data });
- }
- }
- module.exports = CrudController(UtilController, {});
|