|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.springblade.common.utils.SpringContextHolder;
|
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
|
import org.springblade.gateway.common_gateway.constant.PlatformSettingConstant;
|
|
import org.springblade.gateway.common_gateway.constant.PlatformSettingConstant;
|
|
|
import org.springblade.gateway.common_gateway.dto.ActiveSettingDto;
|
|
import org.springblade.gateway.common_gateway.dto.ActiveSettingDto;
|
|
@@ -14,8 +15,6 @@ import org.springblade.gateway.common_gateway.dto.PointGoodsSettingDto;
|
|
|
import org.springblade.gateway.common_gateway.enums.PlatformSettingEnum;
|
|
import org.springblade.gateway.common_gateway.enums.PlatformSettingEnum;
|
|
|
import org.springblade.sing.desk.entity.PlatformSetting;
|
|
import org.springblade.sing.desk.entity.PlatformSetting;
|
|
|
import org.springblade.sing.desk.service.IPlatformSettingService;
|
|
import org.springblade.sing.desk.service.IPlatformSettingService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
|
|
@@ -25,21 +24,18 @@ import javax.validation.constraints.NotNull;
|
|
|
* @Date: Created in 15:18 2021/11/9
|
|
* @Date: Created in 15:18 2021/11/9
|
|
|
* @Modified By:
|
|
* @Modified By:
|
|
|
*/
|
|
*/
|
|
|
-@Component
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class PlatformSettingUtil {
|
|
public class PlatformSettingUtil {
|
|
|
- @Autowired
|
|
|
|
|
- private IPlatformSettingService platformSettingService;
|
|
|
|
|
|
|
+ private final static IPlatformSettingService platformSettingService = SpringContextHolder.getBean(IPlatformSettingService.class);
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BladeRedis bladeRedis;
|
|
|
|
|
|
|
+ private final static BladeRedis bladeRedis = SpringContextHolder.getBean(BladeRedis.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 公共设置
|
|
* 公共设置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public CommonSettingDto getCommonSetting(){
|
|
|
|
|
|
|
+ public static CommonSettingDto getCommonSetting(){
|
|
|
return getPlatformSettingByCache(PlatformSettingEnum.COMMON_SETTING,null);
|
|
return getPlatformSettingByCache(PlatformSettingEnum.COMMON_SETTING,null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -47,7 +43,7 @@ public class PlatformSettingUtil {
|
|
|
* 获取活动配置
|
|
* 获取活动配置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public ActiveSettingDto getActiveSetting(Long activeId){
|
|
|
|
|
|
|
+ public static ActiveSettingDto getActiveSetting(Long activeId){
|
|
|
return getPlatformSettingByCache(PlatformSettingEnum.ACTIVE_SETTING,activeId);
|
|
return getPlatformSettingByCache(PlatformSettingEnum.ACTIVE_SETTING,activeId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -55,7 +51,7 @@ public class PlatformSettingUtil {
|
|
|
* 获取积分商场设置
|
|
* 获取积分商场设置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public PointGoodsSettingDto getPointGoodsSetting(){
|
|
|
|
|
|
|
+ public static PointGoodsSettingDto getPointGoodsSetting(){
|
|
|
return getPlatformSettingByCache(PlatformSettingEnum.POINT_GOODS_SETTING,null);
|
|
return getPlatformSettingByCache(PlatformSettingEnum.POINT_GOODS_SETTING,null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -63,7 +59,7 @@ public class PlatformSettingUtil {
|
|
|
* 获取平台设置
|
|
* 获取平台设置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public <T> T getPlatformSettingByCache(PlatformSettingEnum platformSettingEnum,Long activeId){
|
|
|
|
|
|
|
+ public static <T> T getPlatformSettingByCache(PlatformSettingEnum platformSettingEnum,Long activeId){
|
|
|
String platformSettingByCache = getPlatformSettingByCache(platformSettingEnum.name(),activeId);
|
|
String platformSettingByCache = getPlatformSettingByCache(platformSettingEnum.name(),activeId);
|
|
|
if(StringUtils.isNotEmpty(platformSettingByCache)){
|
|
if(StringUtils.isNotEmpty(platformSettingByCache)){
|
|
|
try {
|
|
try {
|
|
@@ -79,7 +75,7 @@ public class PlatformSettingUtil {
|
|
|
* 获取平台设置
|
|
* 获取平台设置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public <T> T getPlatformSettingByCache(String key,@NotNull Class<T> tClass,Long activeId){
|
|
|
|
|
|
|
+ public static <T> T getPlatformSettingByCache(String key,@NotNull Class<T> tClass,Long activeId){
|
|
|
String platformSettingByCache = getPlatformSettingByCache(key,activeId);
|
|
String platformSettingByCache = getPlatformSettingByCache(key,activeId);
|
|
|
if(StringUtils.isNotEmpty(platformSettingByCache)){
|
|
if(StringUtils.isNotEmpty(platformSettingByCache)){
|
|
|
try {
|
|
try {
|
|
@@ -95,7 +91,7 @@ public class PlatformSettingUtil {
|
|
|
* 获取平台设置
|
|
* 获取平台设置
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public String getPlatformSettingByCache(String key,Long activeId){
|
|
|
|
|
|
|
+ public static String getPlatformSettingByCache(String key,Long activeId){
|
|
|
String value = bladeRedis.hGet(PlatformSettingConstant.getCacheKey(activeId),key);
|
|
String value = bladeRedis.hGet(PlatformSettingConstant.getCacheKey(activeId),key);
|
|
|
if(ObjectUtils.isEmpty(value)){
|
|
if(ObjectUtils.isEmpty(value)){
|
|
|
LambdaQueryWrapper<PlatformSetting> lambdaQueryWrapper = Wrappers.<PlatformSetting>lambdaQuery()
|
|
LambdaQueryWrapper<PlatformSetting> lambdaQueryWrapper = Wrappers.<PlatformSetting>lambdaQuery()
|
|
@@ -118,7 +114,7 @@ public class PlatformSettingUtil {
|
|
|
* 设置平台设置缓存
|
|
* 设置平台设置缓存
|
|
|
* @param platformSetting
|
|
* @param platformSetting
|
|
|
*/
|
|
*/
|
|
|
- public void setPlatformSettingToCache(PlatformSetting platformSetting){
|
|
|
|
|
|
|
+ public static void setPlatformSettingToCache(PlatformSetting platformSetting){
|
|
|
if(ObjectUtils.isEmpty(platformSetting)){
|
|
if(ObjectUtils.isEmpty(platformSetting)){
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|