|
|
@@ -7,6 +7,7 @@ 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;
|
|
|
|
|
|
@@ -14,6 +15,7 @@ import javax.annotation.PostConstruct;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@@ -50,7 +52,8 @@ public class SysConfigService {
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
- if (sysConfigRepo.findByName("gift_gas_fee").isEmpty()) {
|
|
|
+ List<SysConfig> list = sysConfigRepo.findAll();
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("search_mode"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("gift_gas_fee")
|
|
|
.desc("转赠gas费")
|
|
|
@@ -58,7 +61,7 @@ public class SysConfigService {
|
|
|
.value("1")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("enable_wx_pub").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("enable_wx_pub"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("enable_wx_pub")
|
|
|
.desc("使用公众号支付")
|
|
|
@@ -66,7 +69,7 @@ public class SysConfigService {
|
|
|
.value("FALSE")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("enable_wx_lite").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("enable_wx_lite"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("enable_wx_lite")
|
|
|
.desc("使用小程序支付")
|
|
|
@@ -74,7 +77,7 @@ public class SysConfigService {
|
|
|
.value("FALSE")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("hold_days").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("hold_days"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("hold_days")
|
|
|
.desc("持有满几天可销售")
|
|
|
@@ -82,7 +85,7 @@ public class SysConfigService {
|
|
|
.value("5")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("default_search_mode").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("default_search_mode"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("default_search_mode")
|
|
|
.desc("默认搜索方式")
|
|
|
@@ -90,7 +93,7 @@ public class SysConfigService {
|
|
|
.value("FULL")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("enable_sand_quick").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("enable_sand_quick"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("enable_sand_quick")
|
|
|
.desc("使用衫德h5快捷支付")
|
|
|
@@ -98,7 +101,7 @@ public class SysConfigService {
|
|
|
.value("FALSE")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("order_cancel_interval").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("order_cancel_interval"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("order_cancel_time")
|
|
|
.desc("订单自动取消间隔(S)")
|
|
|
@@ -106,7 +109,7 @@ public class SysConfigService {
|
|
|
.value("210")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("pay_channel").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("pay_channel"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("pay_channel")
|
|
|
.desc("支付通道")
|
|
|
@@ -115,7 +118,7 @@ public class SysConfigService {
|
|
|
.options("hmPay,sandPay")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("gift_days").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("gift_days"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("gift_days")
|
|
|
.desc("转赠满多少天可销售")
|
|
|
@@ -123,7 +126,7 @@ public class SysConfigService {
|
|
|
.value("20")
|
|
|
.build());
|
|
|
}
|
|
|
- if (sysConfigRepo.findByName("min_recharge_amount").isEmpty()) {
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("min_recharge_amount"))) {
|
|
|
sysConfigRepo.save(SysConfig.builder()
|
|
|
.name("min_recharge_amount")
|
|
|
.desc("最小充值金额")
|
|
|
@@ -131,6 +134,14 @@ public class SysConfigService {
|
|
|
.value("100")
|
|
|
.build());
|
|
|
}
|
|
|
+ if (list.stream().anyMatch(i -> i.getName().equals("enable_balance_pay"))) {
|
|
|
+ sysConfigRepo.save(SysConfig.builder()
|
|
|
+ .name("enable_balance_pay")
|
|
|
+ .desc("使用余额支付")
|
|
|
+ .type(SysConfig.ValueType.BOOLEAN)
|
|
|
+ .value("0")
|
|
|
+ .build());
|
|
|
+ }
|
|
|
SearchMode searchMode = SearchMode.valueOf(sysConfigRepo.findByName("default_search_mode").get().getValue());
|
|
|
JpaUtils.setDefaultSearchMode(searchMode);
|
|
|
|