fix:bug#I8DLHU
parent
0a90c90498
commit
7217438afb
|
@ -7,6 +7,7 @@ import cc.iotkit.data.ICommonData;
|
|||
import cc.iotkit.data.util.PageBuilder;
|
||||
import cc.iotkit.model.Id;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
|
@ -21,7 +22,7 @@ import java.util.Optional;
|
|||
* @Version: V1.0
|
||||
* @Description: 基础数据操作接口
|
||||
*/
|
||||
public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID> {
|
||||
public interface IJPACommData<T extends Id<ID>, ID> extends ICommonData<T, ID> {
|
||||
|
||||
|
||||
JpaRepository getBaseRepository();
|
||||
|
@ -76,10 +77,10 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
default Paging<T> findAll(PageRequest<T> pageRequest) {
|
||||
Example example = genExample(pageRequest.getData());
|
||||
Page<T> all = null;
|
||||
if(Objects.isNull(example)){
|
||||
if (Objects.isNull(example)) {
|
||||
all = getBaseRepository().findAll(PageBuilder.toPageable(pageRequest));
|
||||
}else{
|
||||
all =getBaseRepository().findAll(example, PageBuilder.toPageable(pageRequest));
|
||||
} else {
|
||||
all = getBaseRepository().findAll(example, PageBuilder.toPageable(pageRequest));
|
||||
}
|
||||
return PageBuilder.toPaging(all, getTClass());
|
||||
}
|
||||
|
@ -91,10 +92,10 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
default List<T> findAllByCondition(T data) {
|
||||
Example example = genExample(data);
|
||||
List all = null;
|
||||
if(Objects.isNull(example)){
|
||||
if (Objects.isNull(example)) {
|
||||
all = getBaseRepository().findAll();
|
||||
|
||||
}else{
|
||||
} else {
|
||||
all = getBaseRepository().findAll(example);
|
||||
|
||||
}
|
||||
|
@ -109,7 +110,7 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
Example example = genExample(data);
|
||||
|
||||
Optional one = getBaseRepository().findOne(example);
|
||||
if(one.isPresent()){
|
||||
if (one.isPresent()) {
|
||||
return (T) MapstructUtils.convert(one.get(), getTClass());
|
||||
}
|
||||
return null;
|
||||
|
@ -117,11 +118,12 @@ public interface IJPACommData< T extends Id<ID>, ID> extends ICommonData<T , ID
|
|||
|
||||
|
||||
default Example genExample(T data) {
|
||||
if(Objects.isNull(data)){
|
||||
if (Objects.isNull(data)) {
|
||||
return null;
|
||||
}
|
||||
return Example.of(MapstructUtils.convert(data, getJpaRepositoryClass()));
|
||||
return Example.of(MapstructUtils.convert(data, getJpaRepositoryClass()),
|
||||
ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
convert.setRoles(sysRoles);
|
||||
|
||||
Long deptId = convert.getDeptId();
|
||||
if(deptId==null){
|
||||
if (deptId == null) {
|
||||
return convert;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
.and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysUser.status.eq(data.getStatus()))
|
||||
.and(Objects.nonNull(data.getDeptId()), () -> tbSysUser.deptId.eq(data.getDeptId()))
|
||||
.and(tbSysUser.delFlag.eq(UserConstants.ROLE_NORMAL))
|
||||
.and(Objects.nonNull(data.getRoleId()),()-> tbSysRole.id.eq(data.getRoleId()));
|
||||
.and(Objects.nonNull(data.getRoleId()), () -> tbSysRole.id.eq(data.getRoleId()));
|
||||
|
||||
QueryResults<TbSysUser> tbSysUserQueryResults = jpaQueryFactory.select(Projections.bean(TbSysUser.class, tbSysUser.id, tbSysUser.deptId, tbSysUser.userName,
|
||||
tbSysUser.nickName, tbSysUser.email, tbSysUser.phonenumber, tbSysUser.createTime)).from(tbSysUser)
|
||||
|
@ -244,7 +244,7 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
public Paging<SysUser> selectUnallocatedList(PageRequest<SysUser> to) {
|
||||
SysUser data = to.getData();
|
||||
PredicateBuilder builder = PredicateBuilder.instance();
|
||||
if(Objects.nonNull(data)){
|
||||
if (Objects.nonNull(data)) {
|
||||
builder.and(StringUtils.isNotBlank(data.getPhonenumber()), () -> tbSysUser.phonenumber.like(data.getPhonenumber()))
|
||||
.and(StringUtils.isNotBlank(data.getUserName()), () -> tbSysUser.userName.like(data.getUserName()))
|
||||
.and(StringUtils.isNotBlank(data.getStatus()), () -> tbSysUser.status.eq(data.getStatus()))
|
||||
|
@ -303,9 +303,9 @@ public class SysUserDataImpl implements ISysUserData, IJPACommData<SysUser, Long
|
|||
}
|
||||
return PredicateBuilder.instance()
|
||||
.and(ObjectUtil.isNotNull(user.getId()), () -> tbSysUser.id.eq(user.getId()))
|
||||
.and(StringUtils.isNotEmpty(user.getUserName()), () -> tbSysUser.userName.like(user.getUserName()))
|
||||
.and(StringUtils.isNotEmpty(user.getUserName()), () -> tbSysUser.userName.like("%" + user.getUserName() + "%"))
|
||||
.and(StringUtils.isNotEmpty(user.getStatus()), () -> tbSysUser.status.eq(user.getStatus()))
|
||||
.and(StringUtils.isNotEmpty(user.getPhonenumber()), () -> tbSysUser.phonenumber.like(user.getPhonenumber()))
|
||||
.and(StringUtils.isNotEmpty(user.getPhonenumber()), () -> tbSysUser.phonenumber.like("%" + user.getPhonenumber() + "%"))
|
||||
.and(ObjectUtil.isNotEmpty(ids), () -> tbSysUser.deptId.in(ids)).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
*/
|
||||
package cc.iotkit.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
@Slf4j
|
||||
public class EmbeddedRedisConfig {
|
||||
|
||||
public static boolean embeddedEnable() {
|
||||
|
@ -28,7 +30,14 @@ public class EmbeddedRedisConfig {
|
|||
} else {
|
||||
redisServer = new RedisServer();
|
||||
}
|
||||
try {
|
||||
redisServer.start();
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("Address already in use")) {
|
||||
throw new RuntimeException("redis端口被占用,请先停止本地的redis服务");
|
||||
}
|
||||
log.error("start redis server failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue