|
|
@@ -79,6 +79,21 @@ public class CoreSafeLevelServiceImpl extends ServiceImpl<CoreSafeLevelMapper, C
|
|
|
return coreSafeLevelMapper.insert(coreSafeLevel);
|
|
|
}
|
|
|
|
|
|
+ private void checkParam(CoreSafeLevel coreSafeLevel) {
|
|
|
+ if (ObjectUtil.isEmpty(coreSafeLevel.getMaxValue()) || ObjectUtil.isEmpty(coreSafeLevel.getMinValue())) {
|
|
|
+ throw new RuntimeException("区间最大值或最小值不能为空!");
|
|
|
+ }
|
|
|
+ if (coreSafeLevel.getMaxValue().intValue() < 0 || coreSafeLevel.getMinValue().intValue() < 0) {
|
|
|
+ throw new RuntimeException("区间最大值或最小值不能小于0!");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.equals(coreSafeLevel.getMaxValue(), coreSafeLevel.getMinValue())) {
|
|
|
+ throw new RuntimeException("区间最大值或最小值不能小于相等!");
|
|
|
+ }
|
|
|
+ if (coreSafeLevel.getMinValue().intValue() > coreSafeLevel.getMaxValue().intValue()) {
|
|
|
+ throw new RuntimeException("区间最小值不能大于最大值!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改安全等级配置
|
|
|
*
|
|
|
@@ -87,12 +102,7 @@ public class CoreSafeLevelServiceImpl extends ServiceImpl<CoreSafeLevelMapper, C
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateCoreSafeLevel(CoreSafeLevel coreSafeLevel) {
|
|
|
- if (coreSafeLevel.getMaxValue().intValue() < 0 || coreSafeLevel.getMinValue().intValue() < 0) {
|
|
|
- throw new RuntimeException("区间最大值或最小值不能小于0!");
|
|
|
- }
|
|
|
- if (ObjectUtil.equals(coreSafeLevel.getMaxValue(), coreSafeLevel.getMinValue())) {
|
|
|
- throw new RuntimeException("区间最大值或最小值不能小于相等!");
|
|
|
- }
|
|
|
+ checkParam(coreSafeLevel);
|
|
|
final List<CoreSafeLevel> list = coreSafeLevelMapper.selectList(null);
|
|
|
list.removeIf(item -> ObjectUtil.equal(item.getId(), coreSafeLevel.getId()));
|
|
|
for (CoreSafeLevel level : list) {
|