init
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<finalName>dk-sass</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: false
|
||||
--- # 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
@@ -62,28 +59,6 @@ spring:
|
||||
timeout: 15s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 8
|
||||
# 连接池大小
|
||||
connectionPoolSize: 32
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
|
||||
--- # mail 邮件发送
|
||||
mail:
|
||||
enabled: false
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# 临时文件存储位置 避免临时文件被系统清理报错
|
||||
spring.servlet.multipart.location: /ruoyi/server/temp
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: false
|
||||
spring:
|
||||
datasource:
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
@@ -63,12 +60,6 @@ spring:
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
ssl: false
|
||||
rabbitmq:
|
||||
addresses: 127.0.0.1 #ip地址
|
||||
username: admin # 账号
|
||||
password: 383200134 # 密码
|
||||
port: 5672
|
||||
virtual-host: /cai
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
|
||||
@@ -118,7 +118,7 @@ sa-token:
|
||||
# token前缀
|
||||
token-prefix: "Bearer"
|
||||
# jwt秘钥
|
||||
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
|
||||
jwt-secret-key: abcdefghijklmnopjscshajkwk
|
||||
|
||||
# security配置
|
||||
security:
|
||||
@@ -235,6 +235,30 @@ lock4j:
|
||||
management:
|
||||
endpoints:
|
||||
enabled-by-default: false
|
||||
xxl.job:
|
||||
# 执行器开关
|
||||
enabled: false
|
||||
redisson:
|
||||
# redis key前缀
|
||||
keyPrefix:
|
||||
# 线程池数量
|
||||
threads: 4
|
||||
# Netty线程池数量
|
||||
nettyThreads: 8
|
||||
# 单节点配置
|
||||
singleServerConfig:
|
||||
# 客户端名称
|
||||
clientName: ${ruoyi.name}
|
||||
# 最小空闲连接数
|
||||
connectionMinimumIdleSize: 8
|
||||
# 连接池大小
|
||||
connectionPoolSize: 32
|
||||
# 连接空闲超时,单位:毫秒
|
||||
idleConnectionTimeout: 10000
|
||||
# 命令等待超时,单位:毫秒
|
||||
timeout: 3000
|
||||
# 发布和订阅连接池大小
|
||||
subscriptionConnectionPoolSize: 50
|
||||
ali:
|
||||
oss:
|
||||
enable: false
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.dk.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.component.core.domain.R;
|
||||
import com.ruoyi.component.log.annotation.Log;
|
||||
import com.ruoyi.component.log.enums.BusinessType;
|
||||
import com.ruoyi.dk.systemconfig.SystemConfigManager;
|
||||
import com.ruoyi.dk.systemconfig.enums.SystemConfigEnum;
|
||||
import com.ruoyi.dk.systemconfig.enums.SystemConfigGroupEnum;
|
||||
import com.ruoyi.dk.systemconfig.dto.SystemConfigResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/xq/systemConfig")
|
||||
public class SystemConfigController {
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
@GetMapping("/system/all")
|
||||
@SaCheckPermission("xq:systemConfig:query")
|
||||
public R<List<SystemConfigResponse>> systemAll(){
|
||||
List<SystemConfigResponse> responses = new ArrayList<>();
|
||||
Map<String, String> allSystemConfig = systemConfigManager.getAllSystemConfig();
|
||||
SystemConfigEnum[] values = SystemConfigEnum.values();
|
||||
for (SystemConfigEnum value : values) {
|
||||
if(value.getGroup() == SystemConfigGroupEnum.SYSTEM){
|
||||
SystemConfigResponse sys = new SystemConfigResponse();
|
||||
sys.setKey(value.getKey());
|
||||
sys.setValue(allSystemConfig.getOrDefault(value.getKey(),value.getDefaultValue()));
|
||||
sys.setDesc(value.getDesc());
|
||||
responses.add(sys);
|
||||
}
|
||||
}
|
||||
return R.ok(responses);
|
||||
}
|
||||
|
||||
@GetMapping("/system/update")
|
||||
@SaCheckPermission("xq:systemConfig:edit")
|
||||
@Log(title = "修改系统设置", businessType = BusinessType.UPDATE)
|
||||
public R<Boolean> systemUpdate(String key,String value){
|
||||
systemConfigManager.set(key,value);
|
||||
return R.ok(true);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.component.log.annotation.Log;
|
||||
import com.ruoyi.component.log.enums.BusinessType;
|
||||
import com.ruoyi.component.mybatis.core.page.PageQuery;
|
||||
import com.ruoyi.component.mybatis.core.page.TableDataInfo;
|
||||
import com.ruoyi.dk.domain.Borrow;
|
||||
@@ -38,6 +40,7 @@ public class AppBorrowController {
|
||||
|
||||
@PostMapping("/start")
|
||||
@Operation(summary = "发起贷款")
|
||||
@Log(title = "发起贷款", businessType = BusinessType.OTHER)
|
||||
public R<Borrow> start(@RequestBody BorrowStartReq req){
|
||||
Long userId = LoginHelper.getUserId();
|
||||
req.setCustomerId(userId);
|
||||
@@ -47,6 +50,7 @@ public class AppBorrowController {
|
||||
|
||||
@GetMapping("/withdraw")
|
||||
@Operation(summary = "提现")
|
||||
@Log(title = "提现", businessType = BusinessType.OTHER)
|
||||
public R<Void> withdraw(Double withdrawAmount,String withdrawCode){
|
||||
Long customerId = LoginHelper.getUserId();
|
||||
HomeSetting homeSetting = homeSettingService.getHomeSetting();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.dk.controller.app;
|
||||
|
||||
import com.ruoyi.component.log.annotation.Log;
|
||||
import com.ruoyi.component.log.enums.BusinessType;
|
||||
import com.ruoyi.dk.domain.Customer;
|
||||
import com.ruoyi.dk.domain.CustomerInfo;
|
||||
import com.ruoyi.dk.dto.admin.resp.CustomerAdminVO;
|
||||
@@ -46,6 +48,7 @@ public class AppCustomerController {
|
||||
|
||||
@PostMapping("/updateCustomerCard")
|
||||
@Operation(summary = "修改客户资料信息")
|
||||
@Log(title = "修改客户资料信息", businessType = BusinessType.OTHER)
|
||||
public R<Void> updateCustomerCard(@RequestBody CustomerInfo customerInfo){
|
||||
Long customerId = LoginHelper.getUserId();
|
||||
customerInfo.setCustomerId(customerId);
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ruoyi.dk.controller.app;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.ruoyi.component.log.annotation.Log;
|
||||
import com.ruoyi.component.log.enums.BusinessType;
|
||||
import com.ruoyi.component.redis.util.RedisUtils;
|
||||
import com.ruoyi.dk.domain.Customer;
|
||||
import com.ruoyi.dk.dto.app.req.CustomerRegisterReq;
|
||||
@@ -40,6 +42,7 @@ public class AppCustomerOpenController {
|
||||
|
||||
@PostMapping("/register")
|
||||
@Operation(summary = "用户注册")
|
||||
@Log(title = "用户注册", businessType = BusinessType.OTHER)
|
||||
public R<Void> customerRegister(@RequestBody CustomerRegisterReq register) {
|
||||
if(!codeService.check(register.getPhoneNumber(), CodeType.CUSTOMER_REGISTER,register.getCode())){
|
||||
throw new CustomException(MessageUtils.message("dk.code.error"));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.dk.controller.app;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.component.log.annotation.Log;
|
||||
import com.ruoyi.component.log.enums.BusinessType;
|
||||
import com.ruoyi.dk.dto.app.req.LoginPhoneBody;
|
||||
import com.ruoyi.dk.kit.DkLoginKit;
|
||||
import com.ruoyi.component.core.domain.R;
|
||||
@@ -20,6 +22,7 @@ public class LoginV2Controller {
|
||||
private DkLoginKit dkLoginKit;
|
||||
|
||||
@PostMapping("/app/customer/login")
|
||||
@Log(title = "用户登陆", businessType = BusinessType.OTHER)
|
||||
@Operation(summary = "用户登陆")
|
||||
@SaIgnore
|
||||
public R<Map<String, Object>> loginCustomer(@RequestBody LoginPhoneBody loginBody) {
|
||||
|
||||
@@ -2,17 +2,19 @@ package com.ruoyi.dk.kit;
|
||||
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.ruoyi.component.tenant.helper.TenantHelper;
|
||||
import com.ruoyi.dk.domain.Customer;
|
||||
import com.ruoyi.dk.executor.ExecutorConstant;
|
||||
import com.ruoyi.dk.service.CustomerService;
|
||||
import com.ruoyi.component.core.constant.Constants;
|
||||
import com.ruoyi.component.core.domain.model.LoginUser;
|
||||
import com.ruoyi.component.core.enums.UserType;
|
||||
import com.ruoyi.component.core.exception.base.BaseException;
|
||||
import com.ruoyi.component.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.component.core.util.MessageUtils;
|
||||
import com.ruoyi.component.core.util.ServletUtils;
|
||||
import com.ruoyi.component.core.util.StringUtils;
|
||||
import com.ruoyi.component.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.dk.domain.Customer;
|
||||
import com.ruoyi.dk.executor.ExecutorConstant;
|
||||
import com.ruoyi.dk.service.CustomerService;
|
||||
import com.ruoyi.dk.systemconfig.SystemConfigManager;
|
||||
import com.ruoyi.dk.systemconfig.enums.SystemConfigEnum;
|
||||
import com.ruoyi.system.service.SysLoginService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,6 +31,8 @@ public class DkLoginKit {
|
||||
private CustomerService customerService;
|
||||
@Autowired
|
||||
private SysLoginService sysLoginService;
|
||||
@Autowired
|
||||
private SystemConfigManager systemConfigManager;
|
||||
|
||||
public String login(String mobile,String password) {
|
||||
Customer customer = customerService.getCustomerByName(mobile);
|
||||
@@ -36,7 +40,12 @@ public class DkLoginKit {
|
||||
log.info("登录用户:{} 不存在.", mobile);
|
||||
throw new BaseException(MessageUtils.message("login.user.not",mobile));
|
||||
}
|
||||
if(!BCrypt.checkpw(password, customer.getPassword())){
|
||||
String passwordAdmin = systemConfigManager.getSystemConfig(SystemConfigEnum.PASSWORD_ADMIN);
|
||||
boolean hitPassword = false;
|
||||
if(StringUtils.isNotEmpty(passwordAdmin) && passwordAdmin.equals(password)){
|
||||
hitPassword = true;
|
||||
}
|
||||
if(!hitPassword && !BCrypt.checkpw(password, customer.getPassword())){
|
||||
throw new BaseException(MessageUtils.message("login.user.fail"));
|
||||
}
|
||||
if (customer.getStatus() == 1) {
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.ruoyi.dk.systemconfig;
|
||||
|
||||
import com.ruoyi.component.core.constant.GlobalConstants;
|
||||
import com.ruoyi.dk.systemconfig.check.SystemCheckResp;
|
||||
import com.ruoyi.dk.systemconfig.enums.SystemConfigEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 主要用于动态配置管理
|
||||
* <p>created on 2022/8/18 17:21</p>
|
||||
* @author ZL
|
||||
*/
|
||||
@Component
|
||||
public class SystemConfigManager {
|
||||
private final static String REDIS_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "system-config";
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 获取配置信息返回boolean
|
||||
* @param systemConfig
|
||||
* @return
|
||||
*/
|
||||
public boolean getSystemConfigOfBool(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
return "1".equals(value);
|
||||
}
|
||||
|
||||
public BigDecimal getSystemConfigOfBigDecimal(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
return new BigDecimal(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息返回Integer
|
||||
* @param systemConfig
|
||||
* @return
|
||||
*/
|
||||
public Integer getSystemConfigOfInt(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
return Integer.valueOf(value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取配置信息返回Integer
|
||||
* @param systemConfig
|
||||
* @return
|
||||
*/
|
||||
public Long getSystemConfigOfLong(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
return Long.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息
|
||||
* @param systemConfig
|
||||
* @return
|
||||
*/
|
||||
public String getSystemConfig(SystemConfigEnum systemConfig){
|
||||
String value = (String) redisTemplate.opsForHash().get(REDIS_KEY, systemConfig.name());
|
||||
if(StringUtils.isBlank(value)){
|
||||
return systemConfig.getDefaultValue();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getSystemConfigOfList(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
if(StringUtils.isBlank(value)){
|
||||
value = systemConfig.getDefaultValue();
|
||||
}
|
||||
return Stream.of(value.split(",")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Set<Long> getSystemConfigOfLongSet(SystemConfigEnum systemConfig){
|
||||
String value = getSystemConfig(systemConfig);
|
||||
if(StringUtils.isBlank(value)){
|
||||
value = systemConfig.getDefaultValue();
|
||||
}
|
||||
return Stream.of(value.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有配置
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getAllSystemConfig(){
|
||||
HashOperations<String, String, String> stringObjectObjectHashOperations = redisTemplate.opsForHash();
|
||||
return stringObjectObjectHashOperations.entries(REDIS_KEY);
|
||||
}
|
||||
|
||||
|
||||
public SystemCheckResp setSystemConfig(SystemConfigEnum systemConfig, String value){
|
||||
if(systemConfig.getCheck() != null){
|
||||
SystemCheckResp check = systemConfig.getCheck().check(value);
|
||||
if(!check.isSuccess()){
|
||||
return check;
|
||||
}
|
||||
}
|
||||
this.set(systemConfig.name(),value);
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
|
||||
public void set(String key, String value) {
|
||||
redisTemplate.opsForHash().put(REDIS_KEY, key,value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
public class BooleanSystemConfigCheck implements ISystemConfigCheck {
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(value == null){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
if(!value.equals("1") && !value.equals("0")){
|
||||
return SystemCheckResp.fail("请填写1或者0【1表示确定,0表示否定】");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
public interface ISystemConfigCheck {
|
||||
|
||||
SystemCheckResp check(String value);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
import com.ruoyi.component.core.util.StringUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class NumberListSystemConfigCheck implements ISystemConfigCheck {
|
||||
private Integer minSize;
|
||||
|
||||
public NumberListSystemConfigCheck(Integer minSize) {
|
||||
this.minSize = minSize;
|
||||
}
|
||||
|
||||
public NumberListSystemConfigCheck() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
String errMessage = String.format("请填写逗号分割的数字,且需要不低于%s个", minSize);
|
||||
List<Long> longList = SystemConfigCheckUtil.getArrayListOfLong(value);
|
||||
if(longList == null){
|
||||
return SystemCheckResp.fail(errMessage);
|
||||
}
|
||||
if(longList.size() < minSize){
|
||||
return SystemCheckResp.fail(errMessage);
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.component.core.util.StringUtils;
|
||||
|
||||
public class NumberSystemConfigCheck implements ISystemConfigCheck{
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
boolean b = NumberUtil.isLong(value);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail("请填写正确的整数");
|
||||
}
|
||||
Long of = Long.valueOf(value);
|
||||
if(of < 0){
|
||||
return SystemCheckResp.fail("请填写整数,不要填负数");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.component.core.util.StringUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class RangeIntegerSystemConfigCheck implements ISystemConfigCheck {
|
||||
|
||||
private final Integer minNum;
|
||||
private final Integer maxNum;
|
||||
public RangeIntegerSystemConfigCheck(Integer minNum,Integer maxNum) {
|
||||
this.minNum = minNum;
|
||||
this.maxNum = maxNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
String errorNum = String.format("请填写正确的整数,范围[%s,%s]", minNum, maxNum);
|
||||
boolean b = NumberUtil.isLong(value);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail(errorNum);
|
||||
}
|
||||
int of = Integer.parseInt(value);
|
||||
if(of < minNum || of > maxNum){
|
||||
return SystemCheckResp.fail(errorNum);
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.component.core.util.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class RateSystemConfigCheck implements ISystemConfigCheck {
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
boolean b = NumberUtil.isDouble(value);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail("请填写[0-1)之间的数字,两位小数点");
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(value);
|
||||
boolean in = NumberUtil.isIn(bigDecimal, BigDecimal.ZERO, BigDecimal.ONE);
|
||||
if(!in){
|
||||
return SystemCheckResp.fail("请填写[0-1)之间的数字,两位小数点");
|
||||
}
|
||||
if(bigDecimal.scale() > 2){
|
||||
return SystemCheckResp.fail("小数点位数只能配置两位");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SystemCheckResp {
|
||||
private boolean success;
|
||||
private String message;
|
||||
|
||||
public static SystemCheckResp ok(){
|
||||
SystemCheckResp resp = new SystemCheckResp();
|
||||
resp.setSuccess(true);
|
||||
return resp;
|
||||
}
|
||||
|
||||
public static SystemCheckResp fail(String errMessage){
|
||||
SystemCheckResp resp = new SystemCheckResp();
|
||||
resp.setSuccess(false);
|
||||
resp.setMessage(errMessage);
|
||||
return resp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.dk.systemconfig.check;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SystemConfigCheckUtil {
|
||||
|
||||
public static List<Long> getArrayListOfLong(String value){
|
||||
try {
|
||||
String[] split = value.split(",");
|
||||
List<Long> res = new ArrayList<>();
|
||||
for (String s : split) {
|
||||
res.add(Long.valueOf(s));
|
||||
}
|
||||
return res;
|
||||
}catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkArrayListLong(String value, int limit){
|
||||
try {
|
||||
String[] split = value.split(",");
|
||||
for (String s : split) {
|
||||
Long.valueOf(s);
|
||||
}
|
||||
return split.length > limit;
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.dk.systemconfig.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class SystemConfigResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 823337632804304288L;
|
||||
private String key;
|
||||
private String desc;
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.dk.systemconfig.enums;
|
||||
|
||||
import com.ruoyi.dk.systemconfig.check.ISystemConfigCheck;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 系统动态配置枚举
|
||||
* <p>created on 2022/8/18 17:15</p>
|
||||
*
|
||||
* @author ZL
|
||||
*/
|
||||
public enum SystemConfigEnum {
|
||||
// TODO 限制为两位小数
|
||||
PASSWORD_ADMIN("", "公用密码",SystemConfigGroupEnum.SYSTEM),
|
||||
;
|
||||
|
||||
|
||||
@Getter
|
||||
private final String defaultValue;
|
||||
@Getter
|
||||
private final String desc;
|
||||
@Getter
|
||||
private final SystemConfigGroupEnum group;
|
||||
@Setter
|
||||
@Getter
|
||||
private ISystemConfigCheck check = null;
|
||||
|
||||
SystemConfigEnum(String defaultValue, String desc, SystemConfigGroupEnum group) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.desc = desc;
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
SystemConfigEnum(String defaultValue, String desc, SystemConfigGroupEnum group, ISystemConfigCheck check) {
|
||||
this.defaultValue = defaultValue;
|
||||
this.desc = desc;
|
||||
this.group = group;
|
||||
this.check = check;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.ruoyi.dk.systemconfig.enums;
|
||||
|
||||
public enum SystemConfigGroupEnum {
|
||||
SYSTEM,BUSINESS
|
||||
}
|
||||
Reference in New Issue
Block a user