From 483a047d369da5c3ae558c1cb8a23507b37e19e2 Mon Sep 17 00:00:00 2001 From: luoweijian <1329394916@qq.com> Date: Wed, 1 Jul 2026 11:13:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ClassicPaperSetApplicationServiceImpl.java | 22 +++++++++++++++++++ .../impl/SavePaperSetDomainServiceImpl.java | 18 +++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/project/classicpaper/application/impl/ClassicPaperSetApplicationServiceImpl.java b/src/main/java/com/project/classicpaper/application/impl/ClassicPaperSetApplicationServiceImpl.java index d1e17d6..f950ea2 100644 --- a/src/main/java/com/project/classicpaper/application/impl/ClassicPaperSetApplicationServiceImpl.java +++ b/src/main/java/com/project/classicpaper/application/impl/ClassicPaperSetApplicationServiceImpl.java @@ -152,6 +152,28 @@ public class ClassicPaperSetApplicationServiceImpl implements ClassicPaperSetApp computeScoreRatio(paperSet, setDTO); if (paperId == null) { + // 填充版本精简信息(不返回具体题目) + List papers = classicPaperBaseService.list( + new LambdaQueryWrapper() + .select(ClassicPaperEntity::getId, ClassicPaperEntity::getName, + ClassicPaperEntity::getSetIndex, ClassicPaperEntity::getStatus) + .eq(ClassicPaperEntity::getSetId, setId) + .orderByAsc(ClassicPaperEntity::getSetIndex) + ); + if (!papers.isEmpty()) { + List versions = papers.stream() + .map(p -> { + ClassicPaperDTO v = new ClassicPaperDTO(); + v.setId(p.getId()); + v.setName(p.getName()); + v.setSetIndex(p.getSetIndex()); + v.setStatus(p.getStatus()); + v.setStatusText(ClassicPaperStatusEnum.findByValue(p.getStatus())); + return v; + }) + .toList(); + setDTO.setVersions(versions); + } return Result.success(setDTO); } diff --git a/src/main/java/com/project/classicpaper/domain/service/impl/SavePaperSetDomainServiceImpl.java b/src/main/java/com/project/classicpaper/domain/service/impl/SavePaperSetDomainServiceImpl.java index 370f7bc..d417f1f 100644 --- a/src/main/java/com/project/classicpaper/domain/service/impl/SavePaperSetDomainServiceImpl.java +++ b/src/main/java/com/project/classicpaper/domain/service/impl/SavePaperSetDomainServiceImpl.java @@ -1,5 +1,6 @@ package com.project.classicpaper.domain.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -9,7 +10,6 @@ import com.project.classicpaper.domain.dto.ClassicPaperSetDTO; import com.project.classicpaper.domain.entity.ClassicPaperEntity; import com.project.classicpaper.domain.entity.ClassicPaperQuestionEntity; import com.project.classicpaper.domain.entity.ClassicPaperSetEntity; -import com.project.classicpaper.domain.enums.ClassicPaperStatusEnum; import com.project.classicpaper.domain.service.ClassicPaperBaseService; import com.project.classicpaper.domain.service.ClassicPaperQuestionBaseService; import com.project.classicpaper.domain.service.ClassicPaperSetBaseService; @@ -52,7 +52,21 @@ public class SavePaperSetDomainServiceImpl implements SavePaperSetDomainService throw new BusinessErrorException("套题组不存在"); } - // 2. 更新分值比例 + // 2. 更新名称(如果传了且不同) + if (StrUtil.isNotBlank(request.getName()) && !request.getName().equals(paperSet.getName())) { + // 同一分类下名称不能重复(排除自身) + long nameCount = classicPaperSetBaseService.count( + new LambdaQueryWrapper() + .eq(ClassicPaperSetEntity::getClassicCategoryId, paperSet.getClassicCategoryId()) + .eq(ClassicPaperSetEntity::getName, request.getName()) + .ne(ClassicPaperSetEntity::getId, setId)); + if (nameCount > 0) { + throw new BusinessErrorException("同一分类下套题名称已存在"); + } + paperSet.setName(request.getName()); + } + + // 3. 更新分值比例 String scoreRatio = buildScoreRatioFromFields(request); if (scoreRatio != null) { paperSet.setScoreRatio(scoreRatio);