Compare commits

...

2 Commits

6 changed files with 51 additions and 4 deletions

View File

@ -2,6 +2,8 @@ package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
import java.util.List;
@Data
public class FileInfoQueryDTO {
@ -65,4 +67,9 @@ public class FileInfoQueryDTO {
* 状态0-未发布 1-已发布 2-占用
*/
private Integer dataStatus;
/**
* 标签查询ID列表
*/
private List<String> tagIds;
}

View File

@ -3,6 +3,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.FileTagInfo;
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
import javax.swing.text.html.HTML;
@ -69,5 +70,5 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
* 获取所有标签
* @return
*/
List<EdTagLibrary> listAllTags();
List<FileTagInfo> listAllTags();
}

View File

@ -24,4 +24,11 @@ public interface FileTagRelationService extends IService<FileTagRelation> {
* @return
*/
List<FileTagInfo> getFileTags (String fileId);
/**
* 根据标签id获取文件id
* @param tagIds
* @return
*/
List<String> getFileIdsByTagIds(List<String> tagIds);
}

View File

@ -97,7 +97,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
throw new PermissionDeniedException();
}
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
.eq(EdFileInfo::getSaveStatus, EleDataSaveStatusEnum.SUCCESS.code)
@ -142,6 +141,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.or()
.like(EdFileInfo::getFileContent, pars.getKeyword()));
}
// 处理 tagIds 查询
if (!pars.getTagIds().isEmpty()) {
List<String> fileIdsWithTags = fileTagRelationService.getFileIdsByTagIds(pars.getTagIds());
if (fileIdsWithTags.isEmpty()) {
return ElectromagneticResultUtil.success(new RespPageVO<>(0, new ArrayList<>()));
}
queryWrapper.in(EdFileInfo::getId, fileIdsWithTags);
}
Page<EdFileInfo> edFileInfoPage = this.baseMapper.selectPage(new Page<>(pars.getPageNum(), pars.getPageSize()), queryWrapper);
long total = edFileInfoPage.getTotal();
List<FileInfoVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileInfoVO.class);

View File

@ -14,6 +14,7 @@ import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdTagLibraryMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
import org.springframework.beans.BeanUtils;
@ -306,11 +307,16 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
* @return
*/
@Override
public List<EdTagLibrary> listAllTags() {
public List<FileTagInfo> listAllTags() {
LambdaQueryWrapper<EdTagLibrary> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode())
.eq(EdTagLibrary::getType, TagTypeEnum.TAG.getCode());
return this.list(queryWrapper);
return this.list(queryWrapper).stream()
.map(tag -> {
FileTagInfo info = new FileTagInfo();
BeanUtils.copyProperties(tag, info);
return info;
}).collect(Collectors.toList());
}
}

View File

@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMapper, FileTagRelation> implements FileTagRelationService {
@ -84,4 +85,20 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
UserThreadLocal.setSuccessInfo("", "", "获取了标签数据");
return result;
}
/**
* 根据 tagIds 获取文件 ID 列表
* @param tagIds
* @return
*/
@Override
public List<String> getFileIdsByTagIds(List<String> tagIds) {
LambdaQueryWrapper<FileTagRelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(FileTagRelation::getTagId, tagIds);
List<FileTagRelation> relations = this.list(queryWrapper);
return relations.stream()
.map(FileTagRelation::getFileId)
.distinct()
.collect(Collectors.toList());
}
}