|
|
@@ -225,22 +225,28 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
//@Transactional(rollbackFor = Exception.class) // 开启事务
|
|
|
public R<Boolean> updateByBo(BlindStructuresBo bo, MultipartFile file) {
|
|
|
try {
|
|
|
+ log.info("开始更新盲注结构,ID: {}", bo.getId());
|
|
|
|
|
|
+ // 1. 检查是否正在使用中
|
|
|
List<TournamentBlindStructuresVo> tournamentBlindStructuresVo = tournamentBlindStructuresMapper.selectTournamentBlindStructureByBlindStructureId(bo.getId());
|
|
|
- //TODO已经在比赛中使用的盲注禁止删除和修改
|
|
|
- if(tournamentBlindStructuresVo!=null && tournamentBlindStructuresVo.size()>0){
|
|
|
+ log.info("查询到使用该盲注的赛事数量: {}", tournamentBlindStructuresVo == null ? 0 : tournamentBlindStructuresVo.size());
|
|
|
+
|
|
|
+ if(tournamentBlindStructuresVo != null && tournamentBlindStructuresVo.size() > 0){
|
|
|
+ log.warn("发现该盲注正在使用中,禁止修改");
|
|
|
return R.fail("该盲注正在使用中,请勿修改");
|
|
|
}
|
|
|
|
|
|
- // 1. 转换 BO -> PO
|
|
|
+ // 2. 转换 BO -> PO
|
|
|
BlindStructures update = MapstructUtils.convert(bo, BlindStructures.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
Long userId = LoginHelper.getUserId();
|
|
|
update.setUpdateUserId(userId);
|
|
|
+ log.info("准备更新盲注结构,用户ID: {}", userId);
|
|
|
|
|
|
- // 1. 解析 Excel 文件
|
|
|
+ // 3. 解析 Excel 文件
|
|
|
List<BlindLevelsImportVo> dataList = List.of();
|
|
|
if (file != null) {
|
|
|
+ log.info("开始解析上传的Excel文件");
|
|
|
try (InputStream inputStream = file.getInputStream()) {
|
|
|
dataList = parseExcel(inputStream);
|
|
|
} catch (IOException e) {
|
|
|
@@ -249,33 +255,35 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
|
|
+ log.warn("导入数据为空");
|
|
|
return R.fail("导入数据为空");
|
|
|
}
|
|
|
|
|
|
- // 校验数据逻辑(可选)
|
|
|
+ // 4. 校验数据逻辑(可选)
|
|
|
BlindLevelsValidatorUtils.ValidationResult validationResult = BlindLevelsValidatorUtils.validateBlindLevels(dataList);
|
|
|
if (validationResult.isValid()) {
|
|
|
- System.out.println("数据校验通过");
|
|
|
+ log.info("数据校验通过,共{}条数据", dataList.size());
|
|
|
} else {
|
|
|
+ log.warn("数据校验失败: {}", validationResult.getErrorMessage());
|
|
|
return R.fail(validationResult.getErrorMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // 2. 更新主表
|
|
|
+ // 5. 更新主表
|
|
|
+ log.info("开始更新主表数据");
|
|
|
int i = baseMapper.updateBlindStructuresById(update);
|
|
|
if (i <= 0) {
|
|
|
+ log.error("更新主表失败");
|
|
|
return R.fail("更新失败");
|
|
|
}
|
|
|
+ log.info("主表更新成功");
|
|
|
+
|
|
|
+ // 6. 处理等级数据
|
|
|
if (file != null) {
|
|
|
- // 3. 删除原有等级数据
|
|
|
+ log.info("开始处理等级数据,删除原有数据");
|
|
|
Boolean b = blindLevelsService.deleteBlindLevelByBlindStructureId(update.getId());
|
|
|
- /* if (!b) {
|
|
|
- return R.fail("删除历史等级失败");
|
|
|
- }*/
|
|
|
|
|
|
- // 5. 插入新等级数据
|
|
|
+ log.info("开始插入新等级数据,共{}条", dataList.size());
|
|
|
for (BlindLevelsImportVo vo : dataList) {
|
|
|
BlindLevelsBo levelBo = new BlindLevelsBo();
|
|
|
levelBo.setBlindStructureId(update.getId());
|
|
|
@@ -287,12 +295,14 @@ public class BlindStructuresServiceImpl implements IBlindStructuresService {
|
|
|
levelBo.setCreateUserId(userId);
|
|
|
blindLevelsService.insertByBo(levelBo);
|
|
|
}
|
|
|
-
|
|
|
+ log.info("等级数据处理完成");
|
|
|
}
|
|
|
+
|
|
|
+ log.info("盲注结构更新成功,ID: {}", bo.getId());
|
|
|
return R.ok(true); // 成功返回 true
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- log.error("更新盲注结构失败", e);
|
|
|
+ log.error("更新盲注结构失败,ID: {}, 错误信息: {}", bo.getId(), e.getMessage(), e);
|
|
|
throw e; // 抛出异常触发事务回滚
|
|
|
}
|
|
|
}
|