fix: jpa设置错误
parent
99afdbf0c7
commit
eb1e8fa0aa
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.model.system.SysNotice;
|
||||
|
@ -14,7 +15,6 @@ public interface ISysNoticeData extends ICommonData<SysNotice, Long> {
|
|||
/**
|
||||
* 按条件分页查询
|
||||
*/
|
||||
Paging<SysNotice> findByConditions(String noticeTitle, String noticeType,
|
||||
String status, int page, int size);
|
||||
Paging<SysNotice> findByConditions(PageRequest<SysNotice> pageRequest);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SysDeptRepository;
|
||||
import cc.iotkit.data.dao.SysNoticRepository;
|
||||
import cc.iotkit.data.model.TbSysNotice;
|
||||
import cc.iotkit.data.system.ISysNoticeData;
|
||||
import cc.iotkit.data.util.PageBuilder;
|
||||
import cc.iotkit.data.util.PredicateBuilder;
|
||||
import cc.iotkit.model.system.SysNotice;
|
||||
import cc.iotkit.model.system.SysUser;
|
||||
import com.querydsl.core.QueryResults;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,6 +24,8 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static cc.iotkit.data.model.QTbSysNotice.tbSysNotice;
|
||||
|
||||
/**
|
||||
* @Author:tfd
|
||||
* @Date:2023/5/30 13:43
|
||||
|
@ -25,7 +36,7 @@ import java.util.List;
|
|||
public class SysNoticeDataImpl implements ISysNoticeData, IJPACommData<SysNotice, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysDeptRepository baseRepository;
|
||||
private SysNoticRepository baseRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
@ -47,7 +58,22 @@ public class SysNoticeDataImpl implements ISysNoticeData, IJPACommData<SysNotice
|
|||
|
||||
|
||||
@Override
|
||||
public Paging<SysNotice> findByConditions(String noticeTitle, String noticeType, String status, int page, int size) {
|
||||
return null;
|
||||
public Paging<SysNotice> findByConditions(PageRequest<SysNotice> pageRequest) {
|
||||
SysNotice data = pageRequest.getData();
|
||||
Predicate predicate = buildQueryCondition(data);
|
||||
QueryResults<TbSysNotice> tbSysNoticeQueryResults = jpaQueryFactory.select(tbSysNotice).from(tbSysNotice).where(predicate).offset(pageRequest.getOffset()).limit(pageRequest.getPageSize()).fetchResults();
|
||||
return new Paging<>(tbSysNoticeQueryResults.getTotal(), MapstructUtils.convert(tbSysNoticeQueryResults.getResults(), SysNotice.class));
|
||||
}
|
||||
|
||||
private Predicate buildQueryCondition(SysNotice query) {
|
||||
return PredicateBuilder.instance().and(StringUtils.isNotBlank(query.getNoticeTitle()), ()->
|
||||
tbSysNotice.noticeTitle.like(query.getNoticeTitle()))
|
||||
.and(StringUtils.isNotBlank(query.getNoticeType()), ()->
|
||||
tbSysNotice.noticeType.eq(query.getNoticeType()))
|
||||
.and(StringUtils.isNotBlank(query.getStatus()), ()->
|
||||
tbSysNotice.status.eq(query.getStatus()))
|
||||
.and(StringUtils.isNotBlank(query.getCreateByName()), ()->(
|
||||
tbSysNotice.createBy.like(query.getCreateByName())))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cc.iotkit.data.service;
|
|||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SysDeptRepository;
|
||||
import cc.iotkit.data.dao.SysOssRepository;
|
||||
import cc.iotkit.data.model.TbSysOss;
|
||||
import cc.iotkit.data.system.ISysOssData;
|
||||
import cc.iotkit.model.system.SysOss;
|
||||
|
@ -23,7 +24,7 @@ import org.springframework.stereotype.Service;
|
|||
public class SysOssDataImpl implements ISysOssData, IJPACommData<SysOss, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysDeptRepository baseRepository;
|
||||
private SysOssRepository baseRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package cc.iotkit.data.service;
|
|||
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.dao.SysDeptRepository;
|
||||
import cc.iotkit.data.dao.SysOssRepository;
|
||||
import cc.iotkit.data.model.TbSysTenantPackage;
|
||||
import cc.iotkit.data.system.ISysTenantPackageData;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
|
@ -22,7 +23,7 @@ import org.springframework.stereotype.Service;
|
|||
public class SysTenantPackageDataImpl implements ISysTenantPackageData, IJPACommData<SysTenantPackage, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysDeptRepository baseRepository;
|
||||
private SysOssRepository baseRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class SysNoticeVo implements Serializable {
|
|||
/**
|
||||
* 公告ID
|
||||
*/
|
||||
private Long noticeId;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 公告标题
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
|
||||
@Override
|
||||
public Paging<SysNoticeVo> selectPageNoticeList( PageRequest<SysNoticeBo> query) {
|
||||
return sysNoticeData.findAll(query.to(SysNotice.class)).to(SysNoticeVo.class);
|
||||
return sysNoticeData.findByConditions(query.to(SysNotice.class)).to(SysNoticeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue