|
@@ -6,6 +6,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.dromara.business.domain.bo.BlindLevelsBo;
|
|
import org.dromara.business.domain.bo.BlindLevelsBo;
|
|
|
import org.dromara.business.domain.vo.BlindLevelsImportVo;
|
|
import org.dromara.business.domain.vo.BlindLevelsImportVo;
|
|
|
import org.dromara.business.service.IBlindLevelsService;
|
|
import org.dromara.business.service.IBlindLevelsService;
|
|
|
|
|
+import org.dromara.business.utils.BlindLevelsValidatorUtils;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.service.UserService;
|
|
import org.dromara.common.core.service.UserService;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
@@ -135,9 +136,13 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 3. 校验数据逻辑(可选)
|
|
// 3. 校验数据逻辑(可选)
|
|
|
- /* if (!validateData(dataList)) {
|
|
|
|
|
- return R.fail("导入数据校验失败,请检查等级顺序或数值是否正确");
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ BlindLevelsValidatorUtils.ValidationResult validationResult = BlindLevelsValidatorUtils.validateBlindLevels(dataList);
|
|
|
|
|
+ if (validationResult.isValid()) {
|
|
|
|
|
+ System.out.println("数据校验通过");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return R.fail(validationResult.getErrorMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Long userId = LoginHelper.getUserId();
|
|
Long userId = LoginHelper.getUserId();
|
|
|
add.setCreateUserId(userId);
|
|
add.setCreateUserId(userId);
|
|
|
// 4. 插入主表
|
|
// 4. 插入主表
|
|
@@ -275,44 +280,6 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public static boolean validateData(List<BlindLevelsImportVo> dataList) {
|
|
|
|
|
- if (dataList == null || dataList.isEmpty()) {
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return validateDataRecursively(dataList, 0);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private static boolean validateDataRecursively(List<BlindLevelsImportVo> dataList, int currentIndex) {
|
|
|
|
|
- if (currentIndex >= dataList.size() - 1) {
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- BlindLevelsImportVo current = dataList.get(currentIndex);
|
|
|
|
|
- BlindLevelsImportVo next = dataList.get(currentIndex + 1);
|
|
|
|
|
-
|
|
|
|
|
- // Check if levels are continuous
|
|
|
|
|
- if (current.getLevelNumber() + 1 != next.getLevelNumber()) {
|
|
|
|
|
- System.out.println("Error: Levels are not continuous at index " + currentIndex);
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Check if values are increasing
|
|
|
|
|
- if (current.getSmallBlind() >= next.getSmallBlind() ||
|
|
|
|
|
- current.getBigBlind() >= next.getBigBlind() ||
|
|
|
|
|
- current.getAnte() >= next.getAnte()) {
|
|
|
|
|
- System.out.println("Error: Values are not increasing at index " + currentIndex);
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Check if upgrade time is positive
|
|
|
|
|
- if (next.getDurationMinutes() <= 0){
|
|
|
|
|
- System.out.println("Error: Upgrade time is not positive at index " + (currentIndex + 1));
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return validateDataRecursively(dataList, currentIndex + 1);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|