Compare commits
2 Commits
5f0c7ce861
...
5a3874a748
| Author | SHA1 | Date |
|---|---|---|
|
|
5a3874a748 | |
|
|
3e6471079d |
|
|
@ -2,6 +2,8 @@ package com.electromagnetic.industry.software.manage.pojo.req;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class FileInfoQueryDTO {
|
public class FileInfoQueryDTO {
|
||||||
|
|
||||||
|
|
@ -65,4 +67,9 @@ public class FileInfoQueryDTO {
|
||||||
* 状态(0-未发布 1-已发布 2-占用)
|
* 状态(0-未发布 1-已发布 2-占用)
|
||||||
*/
|
*/
|
||||||
private Integer dataStatus;
|
private Integer dataStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签查询ID列表
|
||||||
|
*/
|
||||||
|
private List<String> tagIds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.electromagnetic.industry.software.manage.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.electromagnetic.industry.software.common.pojo.TreeNode;
|
import com.electromagnetic.industry.software.common.pojo.TreeNode;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
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.pojo.resp.TagListVO;
|
||||||
|
|
||||||
import javax.swing.text.html.HTML;
|
import javax.swing.text.html.HTML;
|
||||||
|
|
@ -69,5 +70,5 @@ public interface EdTagLibraryService extends IService<EdTagLibrary> {
|
||||||
* 获取所有标签
|
* 获取所有标签
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<EdTagLibrary> listAllTags();
|
List<FileTagInfo> listAllTags();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,11 @@ public interface FileTagRelationService extends IService<FileTagRelation> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<FileTagInfo> getFileTags (String fileId);
|
List<FileTagInfo> getFileTags (String fileId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据标签id获取文件id
|
||||||
|
* @param tagIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getFileIdsByTagIds(List<String> tagIds);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
throw new PermissionDeniedException();
|
throw new PermissionDeniedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
.select(EdFileInfo.class, file -> !file.getColumn().equals("file_content"))
|
||||||
.eq(EdFileInfo::getSaveStatus, EleDataSaveStatusEnum.SUCCESS.code)
|
.eq(EdFileInfo::getSaveStatus, EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
|
|
@ -142,6 +141,16 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
||||||
.or()
|
.or()
|
||||||
.like(EdFileInfo::getFileContent, pars.getKeyword()));
|
.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);
|
Page<EdFileInfo> edFileInfoPage = this.baseMapper.selectPage(new Page<>(pars.getPageNum(), pars.getPageSize()), queryWrapper);
|
||||||
long total = edFileInfoPage.getTotal();
|
long total = edFileInfoPage.getTotal();
|
||||||
List<FileInfoVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileInfoVO.class);
|
List<FileInfoVO> records = BeanUtil.copyToList(edFileInfoPage.getRecords(), FileInfoVO.class);
|
||||||
|
|
|
||||||
|
|
@ -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.common.util.UserThreadLocal;
|
||||||
import com.electromagnetic.industry.software.manage.mapper.EdTagLibraryMapper;
|
import com.electromagnetic.industry.software.manage.mapper.EdTagLibraryMapper;
|
||||||
import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
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.pojo.resp.TagListVO;
|
||||||
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
|
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
@ -306,11 +307,16 @@ public class EdTagLibraryServiceImpl extends ServiceImpl<EdTagLibraryMapper, EdT
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<EdTagLibrary> listAllTags() {
|
public List<FileTagInfo> listAllTags() {
|
||||||
LambdaQueryWrapper<EdTagLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<EdTagLibrary> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode())
|
queryWrapper.eq(EdTagLibrary::getIsPublished, PublishEnum.PUBLISHED.getCode())
|
||||||
.eq(EdTagLibrary::getType, TagTypeEnum.TAG.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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMapper, FileTagRelation> implements FileTagRelationService {
|
public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMapper, FileTagRelation> implements FileTagRelationService {
|
||||||
|
|
@ -84,4 +85,20 @@ public class FileTagRelationServiceImpl extends ServiceImpl<FileTagRelationMappe
|
||||||
UserThreadLocal.setSuccessInfo("", "", "获取了标签数据");
|
UserThreadLocal.setSuccessInfo("", "", "获取了标签数据");
|
||||||
return result;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue