|
|
|
@ -39,11 +39,11 @@ public class TagService {
|
|
|
|
|
private final UserClient userClient;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询标签
|
|
|
|
|
* 标签信息分页查询
|
|
|
|
|
* @return PageResult<TagDTO>
|
|
|
|
|
*/
|
|
|
|
|
public PageResult<TagDTO> queryPage(TagQueryReq queryReq){
|
|
|
|
|
Specification<Tag> specification = createSpecification(queryReq);
|
|
|
|
|
Specification<Tag> specification = createTagInfoSpecification(queryReq);
|
|
|
|
|
|
|
|
|
|
PageRequest pageRequest = PageRequest.of(queryReq.getPageNum()-1, queryReq.getPageSize());
|
|
|
|
|
Page<Tag> tagPage = tagDao.findAll(specification, pageRequest);
|
|
|
|
@ -182,6 +182,26 @@ public class TagService {
|
|
|
|
|
tagDao.deleteById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询标签名称
|
|
|
|
|
* @param queryReq 查询条件
|
|
|
|
|
* @return 标签名称
|
|
|
|
|
*/
|
|
|
|
|
public List<TagNameDTO> queryTagNameList(TagNameQueryReq queryReq) {
|
|
|
|
|
Specification<Tag> tagNameSpecification = createTagNameSpecification(queryReq);
|
|
|
|
|
List<Tag> tagList = tagDao.findAll(tagNameSpecification);
|
|
|
|
|
return tagList.stream().map(tag -> {
|
|
|
|
|
TagNameDTO tagNameDTO = new TagNameDTO();
|
|
|
|
|
tagNameDTO.setLevel(tag.getLevel());
|
|
|
|
|
tagNameDTO.setId(tag.getId());
|
|
|
|
|
tagNameDTO.setParentId(tag.getParentId());
|
|
|
|
|
tagNameDTO.setNameCh(tag.getNameCh());
|
|
|
|
|
tagNameDTO.setNameEn(tag.getNameEn());
|
|
|
|
|
tagNameDTO.setState(tag.getState());
|
|
|
|
|
return tagNameDTO;
|
|
|
|
|
}).collect(toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询标签创建人
|
|
|
|
|
* @return 标签创建人列表
|
|
|
|
@ -254,11 +274,11 @@ public class TagService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建动态查询条件
|
|
|
|
|
* 标签信息:创建动态查询条件
|
|
|
|
|
* @param queryReq 列表查询参数
|
|
|
|
|
* @return 动态查询条件
|
|
|
|
|
*/
|
|
|
|
|
private Specification<Tag> createSpecification(TagQueryReq queryReq) {
|
|
|
|
|
private Specification<Tag> createTagInfoSpecification(TagQueryReq queryReq) {
|
|
|
|
|
return (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<>();
|
|
|
|
|
String tagName = queryReq.getName();
|
|
|
|
@ -267,22 +287,21 @@ public class TagService {
|
|
|
|
|
Predicate tagNameEnPredicate = criteriaBuilder.like(root.get("nameEn"), '%'+tagName+'%');
|
|
|
|
|
predicateList.add(criteriaBuilder.or(tagNameChPredicate, tagNameEnPredicate));
|
|
|
|
|
}
|
|
|
|
|
if(Objects.nonNull(queryReq.getLevel())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("level").as(Integer.class), queryReq.getLevel()));
|
|
|
|
|
}
|
|
|
|
|
if(Objects.nonNull(queryReq.getState())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("state").as(Integer.class), queryReq.getState()));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(queryReq.getCreatorId())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("creatorId"), queryReq.getCreatorId()));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(queryReq.getId())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("id"), queryReq.getId()));
|
|
|
|
|
}
|
|
|
|
|
Integer level = queryReq.getLevel();
|
|
|
|
|
if(Objects.nonNull(level)){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("level"), level));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(queryReq.getParentId())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("parentId"), queryReq.getParentId()));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(queryReq.getCreatorId())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("creatorId"), queryReq.getCreatorId()));
|
|
|
|
|
}
|
|
|
|
|
if(Objects.nonNull(queryReq.getCreateTimeStart())){
|
|
|
|
|
predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("createTime").as(LocalDateTime.class),
|
|
|
|
|
queryReq.getCreateTimeStart()));
|
|
|
|
@ -295,4 +314,27 @@ public class TagService {
|
|
|
|
|
return criteriaBuilder.and(predicateList.toArray(predicates));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 标签名称:创建动态查询条件
|
|
|
|
|
* @param queryReq 列表查询参数
|
|
|
|
|
* @return 动态查询条件
|
|
|
|
|
*/
|
|
|
|
|
private Specification<Tag> createTagNameSpecification(TagNameQueryReq queryReq) {
|
|
|
|
|
return (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<>();
|
|
|
|
|
Integer level = queryReq.getLevel();
|
|
|
|
|
if(Objects.nonNull(level)){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("level").as(Integer.class), level));
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(queryReq.getParentId())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("parentId"), queryReq.getParentId()));
|
|
|
|
|
}
|
|
|
|
|
if(Objects.nonNull(queryReq.getState())){
|
|
|
|
|
predicateList.add(criteriaBuilder.equal(root.get("state").as(Integer.class), queryReq.getState()));
|
|
|
|
|
}
|
|
|
|
|
Predicate[] predicates = new Predicate[predicateList.size()];
|
|
|
|
|
return criteriaBuilder.and(predicateList.toArray(predicates));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|