Compare commits

..

3 Commits

8 changed files with 105 additions and 18 deletions

View File

@ -69,5 +69,12 @@ public class EdTagLibraryController {
String updatedBy = UserThreadLocal.getUserId();
return ElectromagneticResultUtil.success(edTagLibraryService.updateTagInfo(tagId, tagName, updatedBy));
}
// 查看标签树
@GetMapping ("/tree")
@UserOperation(value="查看了标签树", modelName = UserOperationModuleEnum.TAG)
public ElectromagneticResult<?> listTagTree() {
return ElectromagneticResultUtil.success(edTagLibraryService.listTagTree());
}
}

View File

@ -193,4 +193,10 @@ public interface EdFileInfoService {
*/
void resetFileInfoName(EdFileInfo fileInfo);
/**
* 判断是否是文件夹
* @param id
* @return
*/
public boolean isFolder(String id);
}

View File

@ -1,6 +1,7 @@
package com.electromagnetic.industry.software.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.electromagnetic.industry.software.common.pojo.TreeNode;
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
@ -56,4 +57,10 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
* @return 更新结果
*/
Boolean updateTagInfo(String tagId, String tagName, String updatedBy);
/**
* 构建标签树
* @return
*/
List<TreeNode> listTagTree();
}

View File

@ -1279,4 +1279,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
public IPage<FileInfoVO> queryFileList (Page<FileInfoVO> page, List<String> ids, FileInfoQueryDTO queryDTO, int saveStatus, int effectFlag) {
return this.baseMapper.queryFileList(page, ids, queryDTO, saveStatus, effectFlag);
}
/**
* 判断是否是文件夹
* @param id
* @return
*/
@Override
public boolean isFolder(String id) {
EdFileInfo fileInfo = this.baseMapper.selectById(id);
Assert.notNull(fileInfo, StrFormatter.format("文件不存在ID为{}", id));
return fileInfo.getDataType().equals(EleDataTypeEnum.FOLDER.code);
}
}

View File

@ -57,6 +57,11 @@ public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper,
// 无法建立已建立的关系
String queryId1 = edFileRelation.getId1();
String queryId2 = edFileRelation.getId2();
if (edFileInfoService.isFolder(queryId1) || edFileInfoService.isFolder(queryId2)) {
throw new BizException("文件夹无法建立关系");
}
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdFileRelation::getId1, queryId1).eq(EdFileRelation::getId2, queryId2)
.or()

View File

@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.common.enums.PublishEnum;
import com.electromagnetic.industry.software.common.enums.TagTypeEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.pojo.TreeNode;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdTagLibraryMapper;
@ -146,24 +147,15 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
public Boolean batchPublishTagGroups(List<String> tagGroupIds) {
Assert.notEmpty(tagGroupIds, "参数 tagGroupIds 不能为空");
boolean groupUpdated = this.update(new LambdaUpdateWrapper<EdTagLibrary>()
this.update(new LambdaUpdateWrapper<EdTagLibrary>()
.in(EdTagLibrary::getTagId, tagGroupIds)
.eq(EdTagLibrary::getType, TagTypeEnum.GROUP.getCode()) // 只更新标签组
.set(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode()));
if (!groupUpdated) {
throw new BizException("发布标签组失败");
}
boolean tagUpdated = this.update(new LambdaUpdateWrapper<EdTagLibrary>()
this.update(new LambdaUpdateWrapper<EdTagLibrary>()
.in(EdTagLibrary::getParentId, tagGroupIds) // ID 是传入的标签组
.eq(EdTagLibrary::getType, TagTypeEnum.TAG.getCode()) // 只更新标签
.set(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode()));
if (!tagUpdated) {
throw new RuntimeException("发布标签失败");
}
UserThreadLocal.setSuccessInfo("", "", "发布了标签");
return true;
}
@ -264,5 +256,49 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
this.update(updateWrapper);
}
/**
* 构建标签树
* @return
*/
@Override
public List<TreeNode> listTagTree() {
LambdaQueryWrapper<EdTagLibrary> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode());
List<EdTagLibrary> tags = this.list(queryWrapper);
Map<String, TreeNode> map = new HashMap<>();
List<TreeNode> list = new ArrayList<>();
for (EdTagLibrary tag : tags) {
TreeNode node = null;
if (tag.getType().equals(TagTypeEnum.GROUP.getCode())) {
node = TreeNode.builder()
.title(tag.getTagName())
.key(tag.getTagId())
.children(new ArrayList<>())
.build();
} else if(tag.getType().equals(TagTypeEnum.TAG.getCode())) {
node = TreeNode.builder()
.title(tag.getTagName())
.key(tag.getTagId())
.children(null)
.build();
}
map.put(tag.getTagId(), node);
}
for (EdTagLibrary tag : tags) {
if (tag.getType().equals(TagTypeEnum.GROUP.getCode())) {
list.add(map.get(tag.getTagId()));
} else if (tag.getType().equals(TagTypeEnum.TAG.getCode())) {
TreeNode parentNode = map.get(tag.getParentId());
if (parentNode != null) {
parentNode.getChildren().add(map.get(tag.getTagId()));
}
}
}
return list;
}
}

View File

@ -361,16 +361,9 @@ public class UserServiceImpl implements UserService {
@Override
public ElectromagneticResult<?> validateOldPassword(String userId, String oldInputPassword) {
// To lzh: UserId可以从UserThreadLocal中获取
// To lzh代码可以尽量简洁避免过多的嵌套和逻辑判断注释也不用写太多简单的逻辑简单处理
User user = userMapper.getSingleUser(userId);
Assert.notNull(user, StrFormatter.format("用户不存在ID为 {}", userId));
String decodeOldPwd = AESUtils.decrypt(oldInputPassword, UserConstants.SECRET_KEY);
// if (!user.getUserPwd().equals(SignUtils.MD5(decodeOldPwd + user.getSalt()))) {
// return ElectromagneticResultUtil.fail("53107", "OLD_PASSWORD_INCORRECT");
// }
Assert.isTrue(matchPassword(user,decodeOldPwd), StrFormatter.format("旧密码错误ID为 {}", userId));
return ElectromagneticResultUtil.success(true);
}

View File

@ -0,0 +1,21 @@
package com.electromagnetic.industry.software.common.pojo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
public class TreeNode {
private String title;
private String key;
@JsonInclude(JsonInclude.Include.NON_NULL)
private List<TreeNode> children;
}