From 5e7b0ed4a154ad067cbcf4aa1a1c7cce32f9864c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 26 四月 2024 18:02:17 +0800
Subject: [PATCH] 唯品会链接解析升级

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java |   88 +++++++++++++++++++++++++++----------------
 1 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
index 8f0bb8e..1f8d1aa 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
@@ -1,44 +1,66 @@
 package com.yeshi.fanli.service.impl.config;
 
-import javax.annotation.Resource;
-
+import com.ks.lib.common.exception.ParamsException;
+import com.yeshi.fanli.dao.mybatis.SystemConfigMapper;
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.config.SystemConfigKeyEnum;
+import com.yeshi.fanli.entity.system.SystemConfig;
+import com.yeshi.fanli.service.inter.config.SystemConfigService;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
-import com.yeshi.fanli.dao.mybatis.SystemConfigMapper;
-import com.yeshi.fanli.entity.system.BusinessSystem;
-import com.yeshi.fanli.entity.system.SystemConfig;
-import com.yeshi.fanli.exception.NotExistObjectException;
-import com.yeshi.fanli.service.inter.config.SystemConfigService;
+import javax.annotation.Resource;
 
 @Service
-public class SystemConfigServiceImpl implements SystemConfigService{
+public class SystemConfigServiceImpl implements SystemConfigService {
 
-	@Resource
-	private SystemConfigMapper systemConfigMapper;
-	
+    @Resource
+    private SystemConfigMapper systemConfigMapper;
 
-	@Cacheable(value={"childSystemCache"}, key="#p0")
-	public String get(String sigkey) throws NotExistObjectException {
-		 SystemConfig systemConfig = systemConfigMapper.getByKey(sigkey);		
-		 if(systemConfig == null ){
-			throw new NotExistObjectException("涓嶅瓨鍦ㄨ鍙傛暟"); 
-		}
-		return systemConfig.getValue();
-	}
-	
-	
-	@Cacheable(value={"childSystemCache"}, key="#p0+#system.id")
-	public String get(String key, BusinessSystem system) {
-		if(system==null || system.getId()==0){
-			return "";
-		}
-		SystemConfig systemConfig = systemConfigMapper.getByKeyAndSystemId(key, system.getId());
-		if(systemConfig != null){;
-			return systemConfig.getValue();
-		}
-		return "";
-	}
-	
 
+    @Override
+    public void save(SystemConfig systemConfig) throws ParamsException {
+
+        if (systemConfig == null || systemConfig.getSystem() == null || systemConfig.getKey() == null) {
+            throw new ParamsException(1, "鍙傛暟涓嶅畬鏁�");
+        }
+
+
+        SystemConfig old = getConfig(SystemConfigKeyEnum.valueOf(systemConfig.getKey()), systemConfig.getSystem());
+        if (old != null) {
+            SystemConfig update = new SystemConfig();
+            update.setId(old.getId());
+            update.setValue(systemConfig.getValue());
+            update.setUpdatetime(System.currentTimeMillis());
+            systemConfigMapper.updateByPrimaryKeySelective(update);
+        } else {
+            if (systemConfig.getUpdatetime() == null) {
+                systemConfig.setUpdatetime(System.currentTimeMillis());
+            }
+            systemConfigMapper.insertSelective(systemConfig);
+        }
+    }
+
+
+    @Override
+    public SystemConfig getConfig(SystemConfigKeyEnum key, SystemEnum system) {
+        return systemConfigMapper.selectByKeyAndSystem(key.name(), system);
+    }
+
+
+    @Cacheable(value = "systemConfig", key = "'getConfig-'+#key+'-'+#system")
+    @Override
+    public SystemConfig getConfigCache(SystemConfigKeyEnum key, SystemEnum system) {
+        return getConfig(key, system);
+    }
+
+    @Cacheable(value = "systemConfig", key = "'getValue-'+#key+'-'+#system")
+    @Override
+    public String getValueCache(SystemConfigKeyEnum key, SystemEnum system) {
+        SystemConfig config = getConfig(key, system);
+        if (config == null) {
+            return null;
+        }
+        return config.getValue();
+    }
 }

--
Gitblit v1.8.0