lrf hace 2 años
padre
commit
faef9da940
Se han modificado 2 ficheros con 14 adiciones y 1 borrados
  1. 13 1
      app/controller/util.js
  2. 1 0
      app/z_router/util.js

+ 13 - 1
app/controller/util.js

@@ -1,7 +1,7 @@
 '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) {
@@ -11,6 +11,18 @@ class UtilController extends Controller {
     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';
+  }
+
   /**
    * 查询是否可以购买
    */

+ 1 - 0
app/z_router/util.js

@@ -7,6 +7,7 @@ const rkey = 'util';
 const ckey = 'util';
 const keyZh = '工具接口';
 const routes = [
+  { method: 'get', path: `${rkey}/util`, controller: `${ckey}.util`, zh: `${keyZh}-工具` },
   { method: 'post', path: `${rkey}/checkCanBuy`, controller: `${ckey}.checkCanBuy`, zh: `${keyZh}-检查是否可以购买商品` },
   { method: 'post', path: `${rkey}/checkCartBuy`, controller: `${ckey}.checkCartBuy`, zh: `${keyZh}-检查选中的购物车商品是否可以购买` },
 ];