xiongzhu 4 yıl önce
ebeveyn
işleme
83efe2e0e4

+ 9 - 0
src/main/java/com/izouma/nineth/repo/SysConfigRepo.java

@@ -1,11 +1,20 @@
 package com.izouma.nineth.repo;
 
 import com.izouma.nineth.domain.SysConfig;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 
+import javax.annotation.Nonnull;
 import java.util.Optional;
 
 public interface SysConfigRepo extends JpaRepository<SysConfig, String>, JpaSpecificationExecutor<SysConfig> {
+    @Cacheable("sysConfig")
     Optional<SysConfig> findByName(String name);
+
+    @Override
+    @CachePut(value = "sysConfig", key = "#record.name")
+    @Nonnull
+    SysConfig save(@Nonnull SysConfig record);
 }

+ 0 - 5
src/main/java/com/izouma/nineth/service/SysConfigService.java

@@ -6,7 +6,6 @@ import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.SysConfigRepo;
 import com.izouma.nineth.utils.JpaUtils;
 import lombok.AllArgsConstructor;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
@@ -24,13 +23,11 @@ public class SysConfigService {
         return sysConfigRepo.findAll(JpaUtils.toSpecification(pageQuery, SysConfig.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    @Cacheable("SysConfigServiceGetBigDecimal")
     public BigDecimal getBigDecimal(String name) {
         return sysConfigRepo.findByName(name).map(sysConfig -> new BigDecimal(sysConfig.getValue()))
                 .orElse(BigDecimal.ZERO);
     }
 
-    @Cacheable("SysConfigServiceGetTime")
     public LocalTime getTime(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));
@@ -38,14 +35,12 @@ public class SysConfigService {
         return LocalTime.from(dateTimeFormatter.parse(str));
     }
 
-    @Cacheable("SysConfigServiceGetBoolean")
     public boolean getBoolean(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));
         return str.equals("1");
     }
 
-    @Cacheable("SysConfigServiceGetInt")
     public int getInt(String name) {
         String str = sysConfigRepo.findByName(name).map(SysConfig::getValue)
                 .orElseThrow(new BusinessException("配置不存在"));

+ 0 - 1
src/main/java/com/izouma/nineth/web/SysConfigController.java

@@ -43,7 +43,6 @@ public class SysConfigController extends BaseController {
         return sysConfigRepo.findByName(id).orElseThrow(new BusinessException("无记录"));
     }
 
-    @Cacheable("SysConfigServiceGetBigDecimal")
     @GetMapping("/getDecimal/{id}")
     public BigDecimal getDecimal(@PathVariable String id) {
         return sysConfigService.getBigDecimal(id);

+ 1 - 1
src/main/resources/static/download_raex.html

@@ -59,7 +59,7 @@
             align-items: center;
             justify-content: center;
             color: rgb(0, 255, 18);
-            font-size: 18px;
+            font-size: 16px;
             border-radius: 10px;
             background: rgba(0, 0, 0, 0);
             outline: none;

BIN
src/main/resources/static/img/app_icon_raex.png