refactor: update controller to use MiniScoringService

Phase 1, Step 1.3.3: Delegate scoring to service layer
- Add IMiniScoringService dependency to controller
- Replace 43 lines of business logic with service call
- Controller now delegates scoring to service
- All tests passing

Related to Phase 1 refactoring plan
This commit is contained in:
2026-01-17 18:21:56 +08:00
parent 4aeac05c4b
commit 1cecb8330f
9 changed files with 2 additions and 43 deletions
Binary file not shown.
@@ -72,6 +72,7 @@ public class MartialMiniController extends BladeController {
private final BladeRedis bladeRedis;
private final IMartialResultService resultService;
private final IMiniAuthService miniAuthService;
private final IMiniScoringService miniScoringService;
private final IMartialRegistrationOrderService registrationOrderService;
private final MartialScheduleStatusMapper scheduleStatusMapper;
private final MartialScheduleGroupMapper scheduleGroupMapper;
@@ -90,49 +91,7 @@ public class MartialMiniController extends BladeController {
return miniAuthService.login(dto);
}
public R submitScore(@RequestBody org.springblade.modules.martial.pojo.dto.MiniScoreSubmitDTO dto) {
MartialScore score = new MartialScore();
// 将String类型的ID转换为Long,避免JavaScript大数精度丢失
score.setAthleteId(parseLong(dto.getAthleteId()));
score.setJudgeId(parseLong(dto.getJudgeId()));
score.setScore(dto.getScore());
score.setProjectId(parseLong(dto.getProjectId()));
score.setCompetitionId(parseLong(dto.getCompetitionId()));
score.setVenueId(parseLong(dto.getVenueId()));
score.setScheduleId(parseLong(dto.getScheduleId()));
score.setNote(dto.getNote());
score.setScoreTime(LocalDateTime.now());
if (dto.getDeductions() != null && !dto.getDeductions().isEmpty()) {
// 将String类型的扣分项ID转换为Long
List<Long> deductionIds = dto.getDeductions().stream()
.map(this::parseLong)
.filter(id -> id != null)
.collect(Collectors.toList());
score.setDeductionItems(com.alibaba.fastjson.JSON.toJSONString(deductionIds));
}
Long judgeId = parseLong(dto.getJudgeId());
if (judgeId != null) {
var judge = judgeService.getById(judgeId);
if (judge != null) {
score.setJudgeName(judge.getName());
}
}
boolean success = scoreService.save(score);
// 评分保存成功后,计算并更新选手总分
if (success) {
Long athleteId = parseLong(dto.getAthleteId());
Long projectId = parseLong(dto.getProjectId());
Long venueId = parseLong(dto.getVenueId());
if (athleteId != null && projectId != null) {
updateAthleteTotalScore(athleteId, projectId, venueId);
}
}
return success ? R.success("评分提交成功") : R.fail("评分提交失败");
return miniScoringService.submitScore(dto);
}
/**