|
@@ -1,16 +1,39 @@
|
|
|
package com.jiayue.ipfcst.spare2.base4;
|
|
|
|
|
|
-import com.jiayue.ipfcst.spare2.baseinfos.service.SysParameterService;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.SysParameter;
|
|
|
+import com.jiayue.ipfcst.spare2.baseinfos.repository.SysParameterRepository;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.ehcache.EhCacheCacheManager;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
+@Slf4j
|
|
|
public class BaseService implements Serializable {
|
|
|
|
|
|
@Autowired
|
|
|
public EhCacheCacheManager ehCacheCacheManager;
|
|
|
|
|
|
@Autowired
|
|
|
- public SysParameterService sysParameterService;
|
|
|
+ public SysParameterRepository sysParameterRepository;
|
|
|
+
|
|
|
+ private List<SysParameter> sysParameters() {
|
|
|
+ List<SysParameter> result = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ result = sysParameterRepository.findAll(SysParameter.class.getSimpleName());
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getLocalizedMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getSysParameter(String key, String defaultValue) {
|
|
|
+ List<SysParameter> sysParameters = sysParameters();
|
|
|
+ Optional<SysParameter> optional = sysParameters.stream().filter(s -> StrUtil.equals(s.getSysKey(), key)).findFirst();
|
|
|
+ return optional.map(SysParameter::getSysValue).orElse(defaultValue);
|
|
|
+ }
|
|
|
}
|