admin
2021-02-06 d1f26741bddf6f512d62c0100d42c52be8d37e76
fanli/src/main/java/com/yeshi/fanli/service/impl/config/SystemConfigServiceImpl.java
@@ -1,44 +1,44 @@
package com.yeshi.fanli.service.impl.config;
import javax.annotation.Resource;
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;
@Service
public class SystemConfigServiceImpl implements SystemConfigService{
   @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 "";
   }
}
package com.yeshi.fanli.service.impl.config;
import javax.annotation.Resource;
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;
@Service
public class SystemConfigServiceImpl implements SystemConfigService{
   @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 "";
   }
}