【fix sonar】SysCheckRuleServiceImpl文件
This commit is contained in:
+11
-3
@@ -9,6 +9,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import com.jero.modules.system.entity.SysCheckRule;
|
import com.jero.modules.system.entity.SysCheckRule;
|
||||||
import com.jero.modules.system.mapper.SysCheckRuleMapper;
|
import com.jero.modules.system.mapper.SysCheckRuleMapper;
|
||||||
import com.jero.modules.system.service.ISysCheckRuleService;
|
import com.jero.modules.system.service.ISysCheckRuleService;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -46,6 +47,15 @@ public class SysCheckRuleServiceImpl extends ServiceImpl<SysCheckRuleMapper, Sys
|
|||||||
if (checkRule != null && StringUtils.isNotBlank(value)) {
|
if (checkRule != null && StringUtils.isNotBlank(value)) {
|
||||||
String ruleJson = checkRule.getRuleJson();
|
String ruleJson = checkRule.getRuleJson();
|
||||||
if (StringUtils.isNotBlank(ruleJson)) {
|
if (StringUtils.isNotBlank(ruleJson)) {
|
||||||
|
JSONObject result = getJsonObject(value, ruleJson);
|
||||||
|
if (result != null) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new JSONObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private JSONObject getJsonObject(String value, String ruleJson) {
|
||||||
// 开始截取的下标,根据规则的顺序递增,但是 * 号不计入递增范围
|
// 开始截取的下标,根据规则的顺序递增,但是 * 号不计入递增范围
|
||||||
int beginIndex = 0;
|
int beginIndex = 0;
|
||||||
JSONArray rules = JSON.parseArray(ruleJson);
|
JSONArray rules = JSON.parseArray(ruleJson);
|
||||||
@@ -90,9 +100,7 @@ public class SysCheckRuleServiceImpl extends ServiceImpl<SysCheckRuleMapper, Sys
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
}
|
|
||||||
return new JSONObject();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user