Commit 7eba9641 authored by zhengjie's avatar zhengjie
Browse files

去除实时控制台功能,查询方式修改成注解方式

parent e6c23f81
package me.zhengjie.modules.system.service.query;
import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.repository.DeptRepository;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.service.dto.JobDTO;
import me.zhengjie.modules.system.repository.JobRepository;
import me.zhengjie.modules.system.service.mapper.JobMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author jie
* @date 2018-12-03
*/
@Service
@CacheConfig(cacheNames = "job")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class JobQueryService {
@Autowired
private JobRepository jobRepository;
@Autowired
private DeptRepository deptRepository;
@Autowired
private JobMapper jobMapper;
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(String name , Boolean enabled, Set<Long> deptIds, Long deptId, Pageable pageable){
Page<Job> page = jobRepository.findAll(new Spec(new JobDTO(name,enabled), deptIds, deptId),pageable);
List<JobDTO> jobs = new ArrayList<>();
for (Job job : page.getContent()) {
jobs.add(jobMapper.toDto(job,deptRepository.findNameById(job.getDept().getPid())));
}
return PageUtil.toPage(jobs,page.getTotalElements());
}
class Spec implements Specification<Job> {
private JobDTO job;
private Long deptId;
private Set<Long> deptIds;
public Spec(JobDTO job, Set<Long> deptIds, Long deptId){
this.job = job;
this.deptId = deptId;
this.deptIds = deptIds;
}
@Override
public Predicate toPredicate(Root<Job> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
// 数据权限
Join<Dept, Job> join = root.join("dept",JoinType.LEFT);
if (!CollectionUtils.isEmpty(deptIds)) {
list.add(join.get("id").in(deptIds));
}
if(!ObjectUtils.isEmpty(job.getEnabled())){
/**
* 精确
*/
list.add(cb.equal(root.get("enabled").as(Boolean.class),job.getEnabled()));
}
if(!ObjectUtils.isEmpty(job.getName())){
/**
* 模糊
*/
list.add(cb.like(root.get("name").as(String.class),"%"+job.getName()+"%"));
}
if (deptId != null) {
/**
* 精确
*/
list.add(cb.equal(join.get("id").as(Long.class),deptId));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
\ No newline at end of file
package me.zhengjie.modules.system.service.query;
import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.repository.MenuRepository;
import me.zhengjie.modules.system.service.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2018-12-17
*/
@Service
@CacheConfig(cacheNames = "menu")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MenuQueryService {
@Autowired
private MenuRepository menuRepository;
@Autowired
private MenuMapper menuMapper;
/**
* 不分页
*/
@Cacheable(key = "'queryAll:'+#p0")
public List queryAll(String name){
return menuMapper.toDto(menuRepository.findAll(new Spec(name)));
}
class Spec implements Specification<Menu> {
private String name;
public Spec(String name) {
this.name = name;
}
@Override
public Predicate toPredicate(Root<Menu> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(name)){
list.add(cb.like(root.get("name").as(String.class),"%"+name+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
package me.zhengjie.modules.system.service.query;
import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.modules.system.repository.PermissionRepository;
import me.zhengjie.modules.system.service.mapper.PermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2018-12-03
*/
@Service
@CacheConfig(cacheNames = "permission")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class PermissionQueryService {
@Autowired
private PermissionRepository permissionRepository;
@Autowired
private PermissionMapper permissionMapper;
/**
* 不分页
*/
@Cacheable(key = "'queryAll:'+#p0")
public List queryAll(String name){
return permissionMapper.toDto(permissionRepository.findAll(new Spec(name)));
}
class Spec implements Specification<Permission> {
private String name;
public Spec(String name) {
this.name = name;
}
@Override
public Predicate toPredicate(Root<Permission> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(name)){
/**
* 模糊
*/
list.add(cb.like(root.get("name").as(String.class),"%"+name+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
package me.zhengjie.modules.system.service.query;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.repository.RoleRepository;
import me.zhengjie.modules.system.service.mapper.RoleMapper;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2018-12-03
*/
@Service
@CacheConfig(cacheNames = "role")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class RoleQueryService {
@Autowired
private RoleRepository roleRepository;
@Autowired
private RoleMapper roleMapper;
/**
* 分页
*/
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(String name, Pageable pageable){
Page<Role> page = roleRepository.findAll(new Spec(name),pageable);
return PageUtil.toPage(page.map(roleMapper::toDto));
}
/**
* 分页
*/
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(Pageable pageable){
List<Role> roles = roleRepository.findAll(new Spec(null),pageable).getContent();
return roleMapper.toDto(roles);
}
class Spec implements Specification<Role> {
private String name;
public Spec(String name){
this.name = name;
}
@Override
public Predicate toPredicate(Root<Role> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(name)){
/**
* 模糊
*/
list.add(cb.like(root.get("name").as(String.class),"%"+name+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
package me.zhengjie.modules.system.service.query;
import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.dto.UserDTO;
import me.zhengjie.modules.system.service.mapper.UserMapper;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author jie
* @date 2018-11-22
*/
@Service
@CacheConfig(cacheNames = "user")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserQueryService {
@Autowired
private UserRepository userRepo;
@Autowired
private UserMapper userMapper;
/**
* 分页
*/
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(UserDTO user, Set<Long> deptIds,Pageable pageable){
Page<User> page = userRepo.findAll(new Spec(user,deptIds),pageable);
return PageUtil.toPage(page.map(userMapper::toDto));
}
class Spec implements Specification<User> {
private UserDTO user;
private Set<Long> deptIds;
public Spec(UserDTO user, Set<Long> deptIds){
this.deptIds = deptIds;
this.user = user;
}
@Override
public Predicate toPredicate(Root<User> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
// 数据权限, 关联查询
Join<Dept,User> join = root.join("dept",JoinType.LEFT);
if (!CollectionUtils.isEmpty(deptIds)) {
list.add(join.get("id").in(deptIds));
}
if(!ObjectUtils.isEmpty(user.getId())){
/**
* 相等
*/
list.add(cb.equal(root.get("id").as(Long.class),user.getId()));
}
if(!ObjectUtils.isEmpty(user.getEnabled())){
/**
* 相等
*/
list.add(cb.equal(root.get("enabled").as(Boolean.class),user.getEnabled()));
}
if(!ObjectUtils.isEmpty(user.getUsername())){
/**
* 模糊
*/
list.add(cb.like(root.get("username").as(String.class),"%"+user.getUsername()+"%"));
}
if(!ObjectUtils.isEmpty(user.getEmail())){
/**
* 模糊
*/
list.add(cb.like(root.get("email").as(String.class),"%"+user.getEmail()+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
......@@ -8,9 +8,6 @@
<pattern>%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)</pattern>
<charset>utf-8</charset>
</encoder>
<!--添加我们自定义的filter-->
<filter class="me.zhengjie.modules.monitor.config.LogFilter"></filter>
</appender>
<!--普通日志输出到控制台-->
......
......@@ -3,7 +3,7 @@ package me.zhengjie.rest;
import me.zhengjie.aop.log.Log;
import me.zhengjie.domain.Picture;
import me.zhengjie.service.PictureService;
import me.zhengjie.service.query.PictureQueryService;
import me.zhengjie.service.dto.PictureQueryCriteria;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
......@@ -26,14 +26,11 @@ public class PictureController {
@Autowired
private PictureService pictureService;
@Autowired
private PictureQueryService pictureQueryService;
@Log("查询图片")
@PreAuthorize("hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_SELECT')")
@GetMapping(value = "/pictures")
public ResponseEntity getRoles(Picture resources, Pageable pageable){
return new ResponseEntity(pictureQueryService.queryAll(resources,pageable),HttpStatus.OK);
public ResponseEntity getRoles(PictureQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(pictureService.queryAll(criteria,pageable),HttpStatus.OK);
}
/**
......
......@@ -5,7 +5,7 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.domain.QiniuConfig;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.service.QiNiuService;
import me.zhengjie.service.query.QiNiuQueryService;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
......@@ -29,9 +29,6 @@ public class QiniuController {
@Autowired
private QiNiuService qiNiuService;
@Autowired
private QiNiuQueryService qiNiuQueryService;
@GetMapping(value = "/qiNiuConfig")
public ResponseEntity get(){
return new ResponseEntity(qiNiuService.find(), HttpStatus.OK);
......@@ -46,8 +43,8 @@ public class QiniuController {
@Log("查询文件")
@GetMapping(value = "/qiNiuContent")
public ResponseEntity getRoles(QiniuContent resources, Pageable pageable){
return new ResponseEntity(qiNiuQueryService.queryAll(resources,pageable),HttpStatus.OK);
public ResponseEntity getRoles(QiniuQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
}
/**
......
package me.zhengjie.service;
import me.zhengjie.domain.Picture;
import me.zhengjie.service.dto.PictureQueryCriteria;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
/**
* @author jie
* @date 2018-12-27
......@@ -13,6 +14,15 @@ import org.springframework.web.multipart.MultipartFile;
@CacheConfig(cacheNames = "picture")
public interface PictureService {
/**
* 查询图片
* @param criteria
* @param pageable
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(PictureQueryCriteria criteria, Pageable pageable);
/**
* 上传图片
* @param file
......
......@@ -2,10 +2,12 @@ package me.zhengjie.service;
import me.zhengjie.domain.QiniuConfig;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile;
/**
......@@ -15,6 +17,15 @@ import org.springframework.web.multipart.MultipartFile;
@CacheConfig(cacheNames = "qiNiu")
public interface QiNiuService {
/**
* 查询文件
* @param criteria
* @param pageable
* @return
*/
@Cacheable(keyGenerator = "keyGenerator")
Object queryAll(QiniuQueryCriteria criteria, Pageable pageable);
/**
* 查配置
* @return
......
package me.zhengjie.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* sm.ms图床
*
* @author jie
* @date 2019-6-4 09:52:09
*/
@Data
public class PictureQueryCriteria{
@Query(type = Query.Type.INNER_LIKE)
private String filename;
@Query(type = Query.Type.INNER_LIKE)
private String username;
}
package me.zhengjie.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* @author jie
* @date 2019-6-4 09:54:37
*/
@Data
public class QiniuQueryCriteria{
@Query(type = Query.Type.INNER_LIKE)
private String key;
}
......@@ -9,10 +9,10 @@ import me.zhengjie.domain.Picture;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.repository.PictureRepository;
import me.zhengjie.service.PictureService;
import me.zhengjie.utils.ElAdminConstant;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.service.dto.PictureQueryCriteria;
import me.zhengjie.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -39,6 +39,11 @@ public class PictureServiceImpl implements PictureService {
public static final String MSG = "msg";
@Override
public Object queryAll(PictureQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
@Override
@Transactional(rollbackFor = Throwable.class)
public Picture upload(MultipartFile multipartFile, String username) {
......
......@@ -15,16 +15,15 @@ import me.zhengjie.exception.BadRequestException;
import me.zhengjie.repository.QiNiuConfigRepository;
import me.zhengjie.repository.QiniuContentRepository;
import me.zhengjie.service.QiNiuService;
import me.zhengjie.utils.QiNiuUtil;
import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.ValidationUtil;
import me.zhengjie.service.dto.QiniuQueryCriteria;
import me.zhengjie.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.Optional;
/**
......@@ -46,6 +45,11 @@ public class QiNiuServiceImpl implements QiNiuService {
private final String TYPE = "公开";
@Override
public Object queryAll(QiniuQueryCriteria criteria, Pageable pageable){
return PageUtil.toPage(qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
}
@Override
public QiniuConfig find() {
Optional<QiniuConfig> qiniuConfig = qiNiuConfigRepository.findById(1L);
......
package me.zhengjie.service.query;
import me.zhengjie.domain.Picture;
import me.zhengjie.repository.PictureRepository;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2018-12-03
*/
@Service
@CacheConfig(cacheNames = "picture")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class PictureQueryService {
@Autowired
private PictureRepository pictureRepository;
/**
* 分页
*/
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(Picture picture, Pageable pageable){
return PageUtil.toPage(pictureRepository.findAll(new Spec(picture),pageable));
}
class Spec implements Specification<Picture> {
private Picture picture;
public Spec(Picture picture){
this.picture = picture;
}
@Override
public Predicate toPredicate(Root<Picture> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(picture.getFilename())){
/**
* 模糊
*/
list.add(cb.like(root.get("filename").as(String.class),"%"+picture.getFilename()+"%"));
}
if(!ObjectUtils.isEmpty(picture.getUsername())){
/**
* 模糊
*/
list.add(cb.like(root.get("username").as(String.class),"%"+picture.getUsername()+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
package me.zhengjie.service.query;
import me.zhengjie.domain.QiniuContent;
import me.zhengjie.repository.QiniuContentRepository;
import me.zhengjie.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @date 2018-12-31
*/
@Service
@CacheConfig(cacheNames = "qiNiu")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class QiNiuQueryService {
@Autowired
private QiniuContentRepository qiniuContentRepository;
/**
* 分页
*/
@Cacheable(keyGenerator = "keyGenerator")
public Object queryAll(QiniuContent qiniuContent, Pageable pageable){
return PageUtil.toPage(qiniuContentRepository.findAll(new Spec(qiniuContent),pageable));
}
class Spec implements Specification<QiniuContent> {
private QiniuContent qiniuContent;
public Spec(QiniuContent qiniuContent){
this.qiniuContent = qiniuContent;
}
@Override
public Predicate toPredicate(Root<QiniuContent> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if(!ObjectUtils.isEmpty(qiniuContent.getKey())){
/**
* 模糊
*/
list.add(cb.like(root.get("key").as(String.class),"%"+qiniuContent.getKey()+"%"));
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment