|
|
|
@ -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<ClassicPaperSetEntity>() |
|
|
|
.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); |
|
|
|
|