lin 2 vuotta sitten
vanhempi
commit
368cf5c33f
5 muutettua tiedostoa jossa 81 lisäystä ja 4 poistoa
  1. +60
    -0
      gptCApi/src/main/java/com/iformall/controller/WxProductController.java
  2. +1
    -0
      gptCApi/src/main/java/com/iformall/controller/WxUserGrantController.java
  3. +17
    -2
      gptCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java
  4. +1
    -1
      gptService/src/main/java/com/iformall/service/impl/SysConfigServiceImpl.java
  5. +2
    -1
      gptService/src/main/java/com/iformall/utils/SysConfigConstant.java

+ 60
- 0
gptCApi/src/main/java/com/iformall/controller/WxProductController.java Näytä tiedosto

@@ -0,0 +1,60 @@
package com.iformall.controller;

import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.entity.PayAdapterResult;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.BaseEntity.SortField;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.service.wx.WxPayService;
import com.iformall.utils.Constant;
import com.iformall.utils.SysConfigConstant;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/product")
public class WxProductController extends BaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
SysConfigService sysConfigService;
@GetMapping("/detail")
public ResultData payOrderDetail() {
Map retMap = new HashMap();
TenantEntity tenantEntity = getCUser();
SysConfig salePrice = sysConfigService.getByKey(SysConfigConstant.sale_price, tenantEntity);
SysConfig price = sysConfigService.getByKey(SysConfigConstant.price, tenantEntity);
SysConfig days = sysConfigService.getByKey(SysConfigConstant.expired_days, tenantEntity);
SysConfig img = sysConfigService.getByKey(SysConfigConstant.productImg, tenantEntity);
retMap.put("price", price.getConfigItemValue());
retMap.put("salePrice", salePrice.getConfigItemValue());
retMap.put("days", days.getConfigItemValue());
retMap.put("productImg", img.getConfigItemValue());
return new ResultData(retMap);
}

}

+ 1
- 0
gptCApi/src/main/java/com/iformall/controller/WxUserGrantController.java Näytä tiedosto

@@ -130,6 +130,7 @@ public class WxUserGrantController extends BaseController {
logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId);
resultMap.put("openId", openId);
resultMap.put("sessionKey", session_key);
resultMap.put("tenantId", wxAppinfo.getTenantId());
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new ResultData(ErrorCode.PARAM_EMPITY, resultMap);


+ 17
- 2
gptCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java Näytä tiedosto

@@ -9,6 +9,7 @@ import com.iformall.common.TenantThreadLocal;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxCUserService;
import com.iformall.service.cache.WxCUserCache;
import com.iformall.utils.Constant;
import org.apache.commons.lang3.StringUtils;
@@ -34,6 +35,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
@Autowired
@Qualifier("objectCommonRedisTemplate")
RedisTemplate<String, Object> redisTemplate;
@Autowired
WxCUserService wxCUserService;

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -58,15 +62,26 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
if(StringUtils.isBlank(token)){
token = request.getParameter("token");
}
String tenantId = request.getHeader("tenantId");
if(StringUtils.isBlank(tenantId)){
tenantId = request.getParameter("tenantId");
}

//token为空
if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){
if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)
|| StringUtils.isBlank(tenantId) || "null".equals(tenantId) || "undefined".equals(tenantId)){
throw new MallinkException(ErrorCode.UNLOGIN);
}

WxCUser wxCUser = WxCUserCache.getCacheAppInfo(redisTemplate, Long.parseLong(token));
if (null == wxCUser) {
throw new MallinkException(ErrorCode.UNLOGIN);
wxCUser = wxCUserService.getById(Long.parseLong(token), tenantId);
if (null == wxCUser) {
throw new MallinkException(ErrorCode.UNLOGIN);
}
WxCUserCache.cacheApp(redisTemplate, wxCUser);
}

request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId());


+ 1
- 1
gptService/src/main/java/com/iformall/service/impl/SysConfigServiceImpl.java Näytä tiedosto

@@ -21,7 +21,7 @@ import com.iformall.common.IdWorker;
@Service
public class SysConfigServiceImpl implements SysConfigService {
private static final String cache_prex = "sysconfig:%s:%s";
private static final String cache_prex = "gpt:sysconfig:%s:%s";
@Autowired
SysConfigMapper sysConfigMapper;


+ 2
- 1
gptService/src/main/java/com/iformall/utils/SysConfigConstant.java Näytä tiedosto

@@ -3,7 +3,8 @@ package com.iformall.utils;
public class SysConfigConstant {

public static final String sale_price="salePrice";
public static final String pay_call_back = "payCallBack";
public static final String price="price";
public static final String productImg="productImg";
public static final String expired_days = "expiredDays";

}

Ladataan…
Peruuta
Tallenna