forked from Gitlink/microservices
enterprises:tmp cache
This commit is contained in:
parent
438e1e6de8
commit
61fd85c5e9
|
|
@ -2,9 +2,13 @@ package com.microservices.pms.common.service.impl;
|
|||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.redis.service.RedisService;
|
||||
import com.microservices.common.security.service.IRequestCustomService;
|
||||
import com.microservices.pms.document.domain.vo.PmsDocumentVo;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
import com.microservices.pms.enterprise.mapper.PmsEnterpriseMapper;
|
||||
import com.microservices.pms.utils.PmsUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -12,6 +16,10 @@ import org.springframework.web.servlet.HandlerMapping;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.microservices.pms.utils.PmsConstants.ENTERPRISE_INFO_PREFIX;
|
||||
|
||||
/**
|
||||
* @author otto
|
||||
*/
|
||||
|
|
@ -20,6 +28,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
public class PmsRequestCustomServiceImpl implements IRequestCustomService {
|
||||
@Autowired
|
||||
private PmsEnterpriseMapper pmsEnterpriseMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Override
|
||||
public String processRequestDeptId(HttpServletRequest request) {
|
||||
Object attributeObj = request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
|
|
@ -28,8 +38,15 @@ public class PmsRequestCustomServiceImpl implements IRequestCustomService {
|
|||
if (StringUtils.isEmpty(enterpriseIdentifier)) {
|
||||
return null;
|
||||
}
|
||||
PmsEnterprise pmsEnterprise
|
||||
= pmsEnterpriseMapper.selectPmsEnterpriseByIdentifier(enterpriseIdentifier);
|
||||
PmsEnterprise pmsEnterprise = new PmsEnterprise();
|
||||
String enterpriseCacheKey = ENTERPRISE_INFO_PREFIX + enterpriseIdentifier;
|
||||
if (redisService.hasKey(enterpriseCacheKey)) {
|
||||
pmsEnterprise = (PmsEnterprise) redisService.getCacheObject(enterpriseCacheKey);
|
||||
} else {
|
||||
pmsEnterprise
|
||||
= pmsEnterpriseMapper.selectPmsEnterpriseByIdentifier(enterpriseIdentifier);
|
||||
redisService.setCacheObject(enterpriseCacheKey, pmsEnterprise, 1L, TimeUnit.HOURS);
|
||||
}
|
||||
if (pmsEnterprise == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,4 +173,6 @@ public class PmsConstants {
|
|||
* 流水线类型:图形化
|
||||
*/
|
||||
public final static Integer PIPELINE_TYPE_GRAPHIC = 2;
|
||||
|
||||
public final static String ENTERPRISE_INFO_PREFIX = "enterpriseInfo:";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue