Browse Source

知识点确认,资料名称修改

master
luoweijian 2 months ago
parent
commit
5834f09b81
  1. 2
      src/main/java/com/project/information/application/DraftReviewApplicationService.java
  2. 23
      src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java
  3. 4
      src/main/java/com/project/information/controller/InformationController.java

2
src/main/java/com/project/information/application/DraftReviewApplicationService.java

@ -26,5 +26,5 @@ public interface DraftReviewApplicationService {
* 批量保存草稿并确认替代逐条编辑+单独确认
* 前端编辑完所有草稿后一次性提交提交后自动固化
*/
Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList);
Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList, String name);
}

23
src/main/java/com/project/information/application/impl/DraftReviewApplicationServiceImpl.java

@ -1,5 +1,6 @@
package com.project.information.application.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.project.base.domain.exception.BusinessErrorException;
import com.project.base.config.CustomIdGenerator;
@ -148,12 +149,8 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication
return confirmKnowledgePointDraftDomainService.confirm(informationId);
}
/**
* 批量保存草稿并确认替代逐条编辑+单独确认
* 前端编辑完所有草稿后一次性提交提交后自动固化
*/
@Override
public Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList) {
public Result<String> batchSaveAndConfirm(Long informationId, List<DraftSaveDTO> draftList, String name) {
if (informationId == null) {
throw new BusinessErrorException("资料ID不能为空");
}
@ -173,7 +170,21 @@ public class DraftReviewApplicationServiceImpl implements DraftReviewApplication
throw new BusinessErrorException("该资料不在待审核状态");
}
// 2. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输)
// 2. 如果传了名称且与原名不同,查重并更新
if (StrUtil.isNotBlank(name) && !StrUtil.equals(name, information.getName())) {
boolean exists = informationBaseService.lambdaQuery()
.eq(InformationEntity::getSubLineId, information.getSubLineId())
.eq(InformationEntity::getName, name)
.ne(InformationEntity::getId, informationId)
.exists();
if (exists) {
throw new BusinessErrorException("该子产品线下已存在同名资料「" + name + "」,请修改文件名");
}
information.setName(name);
informationBaseService.updateById(information);
}
// 3. 获取该资料下所有待审核草稿ID(仅查ID,减少数据传输)
List<Long> existingIds = knowledgePointDraftBaseService.lambdaQuery()
.select(KnowledgePointDraftEntity::getId)
.eq(KnowledgePointDraftEntity::getInformationId, informationId)

4
src/main/java/com/project/information/controller/InformationController.java

@ -135,14 +135,14 @@ public class InformationController {
* 使用 form-data 传参informationId + draftListJSON字符串
*/
@PostMapping("/draft/batchSaveAndConfirm")
public Result<String> batchSaveAndConfirm(Long informationId, @RequestParam("draftList") String draftListJson) throws Exception {
public Result<String> batchSaveAndConfirm(Long informationId, @RequestParam("draftList") String draftListJson, String name) throws Exception {
// Postman form-data 会对 JSON 字符串做 URL 编码,先解码
// String decodedJson = java.net.URLDecoder.decode(draftListJson, java.nio.charset.StandardCharsets.UTF_8);
ObjectMapper objectMapper = new ObjectMapper();
// 直接使用 draftListJson
List<DraftSaveDTO> draftList = objectMapper.readValue(draftListJson,
objectMapper.getTypeFactory().constructCollectionType(List.class, DraftSaveDTO.class));
return draftReviewApplicationService.batchSaveAndConfirm(informationId, draftList);
return draftReviewApplicationService.batchSaveAndConfirm(informationId, draftList, name);
}
// =============== 测试用:模拟算法服务回调生成草稿 ===============

Loading…
Cancel
Save