Merge branch 'master' into dev/feat/partner1.4_20231009
# Conflicts: # coolstore-partner-dao/src/main/java/com/cool/store/dao/HyPartnerIntentInfoDAO.java # coolstore-partner-dao/src/main/java/com/cool/store/mapper/HyPartnerIntentInfoMapper.java # coolstore-partner-dao/src/main/resources/mapper/HyPartnerIntentInfoMapper.xml # coolstore-partner-model/src/main/java/com/cool/store/entity/HyPartnerIntentInfoDO.java # coolstore-partner-service/src/main/java/com/cool/store/service/impl/FlowServiceImpl.java # coolstore-partner-service/src/main/java/com/cool/store/service/impl/HyPartnerIntentInfoServiceImpl.java
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
package com.cool.store.http;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dto.mdm.AccessTokenDTO;
|
||||
import com.cool.store.dto.response.MDMResultDTO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.RpcCreateQualifyVerifyReq;
|
||||
import com.cool.store.request.RpcGetMdmTokenReq;
|
||||
import com.cool.store.utils.RestTemplateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Fun Li 2023/9/12 10:07
|
||||
* @version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MDMHttpRequest {
|
||||
|
||||
@Value("${hs.mdm.baseUrl:null}")
|
||||
private String mdmBaseUrl;
|
||||
|
||||
@Value("${hs.mdm.appkey:null}")
|
||||
private String mdmAppKey;
|
||||
|
||||
@Value("${hs.mdm.appsec:null}")
|
||||
private String mdmAppSec;
|
||||
|
||||
/**
|
||||
* 获取 mdm token
|
||||
* @return token
|
||||
* @throws ApiException 接口异常
|
||||
*/
|
||||
public String getMdmAccessToken() throws ApiException {
|
||||
RpcGetMdmTokenReq rpcGetMDMTokenReq = new RpcGetMdmTokenReq();
|
||||
rpcGetMDMTokenReq.setAppKey(mdmAppKey);
|
||||
rpcGetMDMTokenReq.setAppSecret(mdmAppSec);
|
||||
String url = mdmBaseUrl + "/api/oauth2/accessToken";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
responseEntity = RestTemplateUtil.post(url,rpcGetMDMTokenReq, MDMResultDTO.class);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
||||
AccessTokenDTO accessTokenDTO = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), AccessTokenDTO.class);
|
||||
if(accessTokenDTO==null || StringUtils.isBlank(accessTokenDTO.getAccessToken())){
|
||||
throw new ServiceException("获取Mdm token失败!");
|
||||
}
|
||||
return accessTokenDTO.getAccessToken();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("获取MDM Token 出错 url:\t{}, e:\t{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 mdm 所有所属大区
|
||||
* @param headers
|
||||
* @return
|
||||
*/
|
||||
public ResponseEntity<MDMResultDTO> getBelongRegion(Map<String, String> headers) throws ApiException {
|
||||
String url = mdmBaseUrl + "/api/openapi/regionget/getallregion";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
//需要传一个空 body
|
||||
RpcCreateQualifyVerifyReq rpcRequest = new RpcCreateQualifyVerifyReq();
|
||||
RpcCreateQualifyVerifyReq.Data dataBody = new RpcCreateQualifyVerifyReq().new Data();
|
||||
rpcRequest.setData(dataBody);
|
||||
responseEntity = RestTemplateUtil.post(url, headers, rpcRequest, MDMResultDTO.class);
|
||||
return responseEntity;
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, e{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 mdm 所有业务区域
|
||||
* @param headers headers
|
||||
* @return ResponseEntity<MDMResultDTO> JSON
|
||||
* @throws ApiException 接口异常
|
||||
*/
|
||||
public ResponseEntity<MDMResultDTO> getBusinessRegion(Map<String, String> headers) throws ApiException {
|
||||
String url = mdmBaseUrl + "/api/openapi/regionget/getallbuarea";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
//需要传一个空 body
|
||||
RpcCreateQualifyVerifyReq rpcRequest = new RpcCreateQualifyVerifyReq();
|
||||
RpcCreateQualifyVerifyReq.Data dataBody = new RpcCreateQualifyVerifyReq().new Data();
|
||||
rpcRequest.setData(dataBody);
|
||||
responseEntity = RestTemplateUtil.post(url, headers, rpcRequest, MDMResultDTO.class);
|
||||
return responseEntity;
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, e{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起 mdm 审批
|
||||
* @param headers headers
|
||||
* @param rpcRequest 请求参数
|
||||
* @return ResponseEntity<MDMResultDTO> JSON
|
||||
* @throws ApiException 接口异常
|
||||
*/
|
||||
public String createQualifyVerify(Map<String, String> headers, RpcCreateQualifyVerifyReq rpcRequest) throws ApiException{
|
||||
String url = mdmBaseUrl + "/api/openapi/runtime/form/startFraQualExamWithData";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
responseEntity = RestTemplateUtil.post(url, headers, rpcRequest, MDMResultDTO.class);
|
||||
log.info("url:{}, header:{}, request:{} response:{}", url, JSONObject.toJSONString(headers), JSONObject.toJSONString(rpcRequest), JSONObject.toJSONString(responseEntity));
|
||||
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
||||
return JSONObject.toJSONString(responseEntity.getBody().getData());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, e{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param headers headers
|
||||
* @param resource 资源文件
|
||||
* @return ResponseEntity<MDMResultDTO>
|
||||
* @throws ApiException 接口异常
|
||||
*/
|
||||
public ResponseEntity<MDMResultDTO> uploadFile(Map<String, String> headers, Resource resource) throws ApiException {
|
||||
String url = mdmBaseUrl + "/api/openapi/ext/upload/file";
|
||||
MultiValueMap<String,Object> param = new LinkedMultiValueMap<>();
|
||||
try {
|
||||
param.add("file", resource);
|
||||
ResponseEntity<MDMResultDTO> responseEntity = RestTemplateUtil.post(url, headers, param, MDMResultDTO.class);
|
||||
log.info("url:{}, header:{}, response statusCode:{}", url, JSONObject.toJSONString(headers), JSONObject.toJSONString(responseEntity.getStatusCode()));
|
||||
return responseEntity;
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, e{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.entity.MDMAreaDO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.response.mdm.BelongRegion;
|
||||
import com.cool.store.response.mdm.BusinessRegion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,4 +23,17 @@ public interface MDMAreaService {
|
||||
List<MDMAreaDO> getAllAreaCode(String code);
|
||||
|
||||
boolean getAreaProvinceType(String code);
|
||||
|
||||
/**
|
||||
* 获取所有所属大区
|
||||
* @return 所属大区
|
||||
*/
|
||||
List<BelongRegion> getBelongRegion() throws ApiException;
|
||||
|
||||
/**
|
||||
* 获取所有业务区域
|
||||
* @return 业务区域
|
||||
*/
|
||||
List<BusinessRegion> getBusinessRegion() throws ApiException;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.*;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.http.MDMHttpRequest;
|
||||
import com.cool.store.mapper.*;
|
||||
import com.cool.store.oss.OSSServer;
|
||||
import com.cool.store.request.*;
|
||||
@@ -103,6 +104,9 @@ public class FlowServiceImpl implements FlowService {
|
||||
@Autowired
|
||||
private HyPartnerFraSourceMapper hyPartnerFraSourceMapper;
|
||||
|
||||
@Autowired
|
||||
private MDMHttpRequest mdmHttpRequest;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createQualifyVerify(CreateQualifyVerifyReq request) throws ApiException, IOException {
|
||||
@@ -176,12 +180,16 @@ public class FlowServiceImpl implements FlowService {
|
||||
}
|
||||
//通过 rpc 请求审核系统获取返回数据
|
||||
//上传证明文件数据
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", mdmHttpRequest.getMdmAccessToken());
|
||||
if (StringUtils.isNotEmpty(request.getSignerRealControlRelationCert())) {
|
||||
List<String> certFileList = Arrays.asList(request.getSignerRealControlRelationCert().split(","));
|
||||
List<SkrRelshipProve> relshipProves = OSSFileToMDMFile(certFileList);
|
||||
List<SkrRelshipProve> relshipProves = OSSFileToMDMFile(headers, certFileList);
|
||||
rpcRequest.getData().setSkrRelshipProve(relshipProves);
|
||||
}
|
||||
Map<String, String> qualifyVerifyRespData = JSON.parseObject(createQualifyVerify(rpcRequest), new TypeReference<HashMap<String,String>>() {});
|
||||
//调用接口发起审批
|
||||
String qualifyVerify = mdmHttpRequest.createQualifyVerify(headers, rpcRequest);
|
||||
Map<String, String> qualifyVerifyRespData = JSON.parseObject(qualifyVerify, new TypeReference<HashMap<String,String>>() {});
|
||||
|
||||
//2.更新审核信息
|
||||
HyPartnerCertificationInfoDO partnerCertificationInfoDO = new HyPartnerCertificationInfoDO();
|
||||
@@ -301,14 +309,10 @@ public class FlowServiceImpl implements FlowService {
|
||||
return hyPartnerFraSourceMapper.selectAllFraSourceList();
|
||||
}
|
||||
|
||||
public List<SkrRelshipProve> OSSFileToMDMFile(List<String> fileUrlList) throws ApiException, IOException {
|
||||
String url = mdmBaseUrl + "/api/openapi/ext/upload/file";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
RpcGetMdmTokenReq rpcGetMDMTokenReq = new RpcGetMdmTokenReq();
|
||||
rpcGetMDMTokenReq.setAppKey(mdmAppKey);
|
||||
rpcGetMDMTokenReq.setAppSecret(mdmAppSec);
|
||||
private List<SkrRelshipProve> OSSFileToMDMFile(Map<String, String> headers, List<String> fileUrlList) throws ApiException, IOException {
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
List<SkrRelshipProve> relshipProves = new ArrayList<>();
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
|
||||
//逐个处理文件
|
||||
for (String fileUrl : fileUrlList) {
|
||||
@@ -317,76 +321,30 @@ public class FlowServiceImpl implements FlowService {
|
||||
outputStream = ossServer.downloadFileServer(fileName);
|
||||
//2. 将下载到的文件上传到 MDM 系统中
|
||||
try {
|
||||
//获取 token 设置到 header
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getMdmAccessToken(rpcGetMDMTokenReq));
|
||||
//将文件流编辑为 formdata 格式的数据
|
||||
MultiValueMap<String,Object> param = new LinkedMultiValueMap<>();
|
||||
ByteArrayResource resource = new ByteArrayResource(outputStream.toByteArray()) {
|
||||
@Override
|
||||
public String getFilename() throws IllegalStateException {
|
||||
return fileName;
|
||||
}
|
||||
};
|
||||
param.add("file", resource);
|
||||
//上传文件
|
||||
responseEntity = RestTemplateUtil.post(url, headers, param, MDMResultDTO.class);
|
||||
log.info("url:{}, header:{}, response statusCode:{}", url, JSONObject.toJSONString(headers), JSONObject.toJSONString(responseEntity.getStatusCode()));
|
||||
responseEntity = mdmHttpRequest.uploadFile(headers, resource);
|
||||
Map<String, String> data = (Map<String, String>) responseEntity.getBody().getData();
|
||||
SkrRelshipProve skrRelshipProve= BeanUtil.fillBeanWithMap(data, new SkrRelshipProve(), false);
|
||||
relshipProves.add(skrRelshipProve);
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, fileUrl{}, e{}", url, fileUrl, e);
|
||||
log.info("上传文件到MDM出错, e{}", e);
|
||||
throw new ApiException(e.getMessage());
|
||||
} finally {
|
||||
outputStream.close();
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return relshipProves;
|
||||
}
|
||||
|
||||
public String createQualifyVerify(RpcCreateQualifyVerifyReq rpcRequest) throws ApiException{
|
||||
String url = mdmBaseUrl + "/api/openapi/runtime/form/startFraQualExamWithData";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
RpcGetMdmTokenReq rpcGetMDMTokenReq = new RpcGetMdmTokenReq();
|
||||
rpcGetMDMTokenReq.setAppKey(mdmAppKey);
|
||||
rpcGetMDMTokenReq.setAppSecret(mdmAppSec);
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getMdmAccessToken(rpcGetMDMTokenReq));
|
||||
responseEntity = RestTemplateUtil.post(url, headers, rpcRequest, MDMResultDTO.class);
|
||||
log.info("url:{}, header:{}, request:{} response:{}", url, JSONObject.toJSONString(headers), JSONObject.toJSONString(rpcRequest), JSONObject.toJSONString(responseEntity));
|
||||
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
||||
return JSONObject.toJSONString(responseEntity.getBody().getData());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("调用MDM接口出错 url{}, e{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public String getMdmAccessToken(RpcGetMdmTokenReq rpcGetMDMTokenReq) throws ApiException {
|
||||
String url = mdmBaseUrl + "/api/oauth2/accessToken";
|
||||
ResponseEntity<MDMResultDTO> responseEntity = null;
|
||||
try {
|
||||
responseEntity = RestTemplateUtil.post(url,rpcGetMDMTokenReq, MDMResultDTO.class);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if (Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()) {
|
||||
AccessTokenDTO accessTokenDTO = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), AccessTokenDTO.class);
|
||||
if(accessTokenDTO==null || StringUtils.isBlank(accessTokenDTO.getAccessToken())){
|
||||
throw new ServiceException("获取Mdm token失败!");
|
||||
}
|
||||
return accessTokenDTO.getAccessToken();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("获取MDM Token 出错 url:\t{}, e:\t{}", url, e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成授权码
|
||||
|
||||
@@ -220,6 +220,11 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
|
||||
BeanUtil.copyProperties(intentInfoDO, beforeIntentInfoUpdate);
|
||||
fillIntentInfo(intentInfoDO, request);
|
||||
hyPartnerIntentInfoDAO.updateByPrimaryKeySelective(intentInfoDO);
|
||||
//PC端 AcquaintanceFlag 不传值 移动端修改必填
|
||||
if (request.getAcquaintanceFlag()!=null){
|
||||
hyPartnerIntentInfoDAO.updateAcquaintanceFlag(intentInfoDO.getId(),request.getAcquaintanceFlag(), request.getAcquaintanceName(),
|
||||
request.getAcquaintanceRelationshipType(),request.getOtherRelationshipType());
|
||||
}
|
||||
BeanUtil.copyProperties(intentInfoDO, afterIntentInfoUpdate);
|
||||
}
|
||||
redisUtilPool.delKey(cacheKey);
|
||||
@@ -445,6 +450,10 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
|
||||
intentInfoDO.setWantShopArea(request.getWantShopArea());
|
||||
intentInfoDO.setDetailedAddress(request.getDetailedAddress());
|
||||
intentInfoDO.setEmail(request.getEmail());
|
||||
intentInfoDO.setAcquaintanceFlag(request.getAcquaintanceFlag());
|
||||
intentInfoDO.setAcquaintanceName(request.getAcquaintanceName());
|
||||
intentInfoDO.setAcquaintanceRelationshipType(request.getAcquaintanceRelationshipType());
|
||||
intentInfoDO.setOtherRelationshipType(request.getOtherRelationshipType());
|
||||
intentInfoDO.setAcceptAdjustType(request.getAcceptAdjustType());
|
||||
intentInfoDO.setIsHaveWantShop(request.getIsHaveWantShop());
|
||||
intentInfoDO.setWantShopInfo("");
|
||||
@@ -502,6 +511,10 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
|
||||
if(StringUtils.isNotEmpty(hyPartnerIntentInfoDO.getWantShopInfo())){
|
||||
partnerIntentInfoVO.setWantShopInfo(JSONObject.parseArray(hyPartnerIntentInfoDO.getWantShopInfo(), WantShopInfoVO.class));
|
||||
}
|
||||
partnerIntentInfoVO.setAcquaintanceFlag(hyPartnerIntentInfoDO.getAcquaintanceFlag());
|
||||
partnerIntentInfoVO.setAcquaintanceName(hyPartnerIntentInfoDO.getAcquaintanceName());
|
||||
partnerIntentInfoVO.setAcquaintanceRelationshipType(hyPartnerIntentInfoDO.getAcquaintanceRelationshipType());
|
||||
partnerIntentInfoVO.setOtherRelationshipType(hyPartnerIntentInfoDO.getOtherRelationshipType());
|
||||
return partnerIntentInfoVO;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.RedisConstant;
|
||||
import com.cool.store.dto.response.MDMResultDTO;
|
||||
import com.cool.store.entity.MDMAreaDO;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.http.MDMHttpRequest;
|
||||
import com.cool.store.mapper.MdmAreaMapper;
|
||||
import com.cool.store.response.mdm.BelongRegion;
|
||||
import com.cool.store.response.mdm.BusinessRegion;
|
||||
import com.cool.store.service.MDMAreaService;
|
||||
import com.cool.store.utils.RedisUtilPool;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class MDMAreaServiceImpl implements MDMAreaService {
|
||||
@@ -24,6 +33,9 @@ public class MDMAreaServiceImpl implements MDMAreaService {
|
||||
@Autowired
|
||||
private MdmAreaMapper mdmAreaMapper;
|
||||
|
||||
@Autowired
|
||||
private MDMHttpRequest mdmHttpRequest;
|
||||
|
||||
/**
|
||||
* 获取省级数据
|
||||
*/
|
||||
@@ -96,4 +108,42 @@ public class MDMAreaServiceImpl implements MDMAreaService {
|
||||
return CollectionUtils.isEmpty(provinceCodeList)?false:true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有所属大区
|
||||
* @return 所属大区
|
||||
*/
|
||||
@Override
|
||||
public List<BelongRegion> getBelongRegion() throws ApiException {
|
||||
String belongRegionsString = redisUtilPool.getString(RedisConstant.MDM_BELONG_REGION);
|
||||
if (StringUtil.isNotEmpty(belongRegionsString)) {
|
||||
return (List<BelongRegion>) JSONObject.parseObject(belongRegionsString, List.class);
|
||||
}
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", mdmHttpRequest.getMdmAccessToken());
|
||||
ResponseEntity<MDMResultDTO> belongRegionResp = mdmHttpRequest.getBelongRegion(headers);
|
||||
List<BelongRegion> belongRegions = (List<BelongRegion>) belongRegionResp.getBody().getData();
|
||||
//缓存,半个小时过期
|
||||
redisUtilPool.setString(RedisConstant.MDM_BELONG_REGION, JSON.toJSONString(belongRegions), 30 * 60);
|
||||
return belongRegions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有业务区域
|
||||
* @return 业务区域
|
||||
*/
|
||||
@Override
|
||||
public List<BusinessRegion> getBusinessRegion() throws ApiException {
|
||||
String belongRegionsString = redisUtilPool.getString(RedisConstant.MDM_BUSINESS_REGION);
|
||||
if (StringUtil.isNotEmpty(belongRegionsString)) {
|
||||
return (List<BusinessRegion>) JSONObject.parseObject(belongRegionsString, List.class);
|
||||
}
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", mdmHttpRequest.getMdmAccessToken());
|
||||
ResponseEntity<MDMResultDTO> belongRegionResp = mdmHttpRequest.getBusinessRegion(headers);
|
||||
List<BusinessRegion> businessRegions = (List<BusinessRegion>) belongRegionResp.getBody().getData();
|
||||
//缓存,半个小时过期
|
||||
redisUtilPool.setString(RedisConstant.MDM_BUSINESS_REGION, JSON.toJSONString(businessRegions), 30 * 60);
|
||||
return businessRegions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user