|
|
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Component; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Classname TagManage |
|
|
@@ -130,32 +131,29 @@ public class TagManage { |
|
|
|
if(CollUtil.isEmpty(dtos)){ |
|
|
|
return "参入的标签为空"; |
|
|
|
} |
|
|
|
|
|
|
|
UserInfoDetails user = LoginUserUtil.loginUserDetail(); |
|
|
|
|
|
|
|
Integer successNum = 0; |
|
|
|
String projectCode = dtos.get(0).getProjectCode(); |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); |
|
|
|
projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class) |
|
|
|
.eq(ProjectTag::getProjectCode,projectCode)); |
|
|
|
//去重 |
|
|
|
dtos = dtos.stream().distinct().collect(Collectors.toList()); |
|
|
|
for(TagToProjectDTO dto : dtos){ |
|
|
|
String projectCode = dto.getProjectCode(); |
|
|
|
Project project = projectService.getProjectByCode(projectCode); |
|
|
|
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); |
|
|
|
Long tagId = dto.getTagId(); |
|
|
|
Tag tag = tagService.getById(tagId); |
|
|
|
VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); |
|
|
|
|
|
|
|
VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) |
|
|
|
.throwMessage("项目和标签不是一个区域的!"); |
|
|
|
|
|
|
|
ProjectTag projectTag = new ProjectTag(); |
|
|
|
projectTag.setProjectCode(projectCode); |
|
|
|
projectTag.setTagId(tagId); |
|
|
|
projectTag.setCreateOn(LocalDateTime.now()); |
|
|
|
projectTag.setCreateBy(user.getUsername()); |
|
|
|
if(projectTagService.save(projectTag)){ |
|
|
|
successNum ++; |
|
|
|
} |
|
|
|
projectTagService.save(projectTag); |
|
|
|
} |
|
|
|
|
|
|
|
return "保存成功" + successNum + "条"; |
|
|
|
return "保存成功"; |
|
|
|
} |
|
|
|
|
|
|
|
public String removeTagToProject(TagToProjectDTO dto) { |
|
|
|