123333
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
import com.ruoyi.common.utils.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,34 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.common.utils.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();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
public class RankSystemConfigCheck implements ISystemConfigCheck{
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
boolean b = SystemConfigCheckUtil.checkArrayListLong(value, 10);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail("请填写逗号分割的数字,且需要超过10个!");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
public class Rate1000IntegerSystemConfigCheck implements ISystemConfigCheck{
|
||||
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
boolean b = NumberUtil.isInteger(value);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail("请填写[0-1000]之间的整数");
|
||||
}
|
||||
int val = Integer.parseInt(value);
|
||||
if(val < 0 || val > 1000){
|
||||
return SystemCheckResp.fail("请填写[0-1000]之间的整数");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
public class Rate100IntegerSystemConfigCheck implements ISystemConfigCheck{
|
||||
@Override
|
||||
public SystemCheckResp check(String value) {
|
||||
if(StringUtils.isEmpty(value)){
|
||||
return SystemCheckResp.fail("该配置必填");
|
||||
}
|
||||
boolean b = NumberUtil.isInteger(value);
|
||||
if(!b){
|
||||
return SystemCheckResp.fail("请填写[0-100]之间的整数");
|
||||
}
|
||||
int val = Integer.parseInt(value);
|
||||
if(val < 0 || val > 100){
|
||||
return SystemCheckResp.fail("请填写[0-100]之间的整数");
|
||||
}
|
||||
return SystemCheckResp.ok();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,24 @@
|
||||
package com.ruoyi.cai.enums.systemconfig;
|
||||
|
||||
|
||||
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(",");
|
||||
|
||||
Reference in New Issue
Block a user