영상관리 select쿼리 수정
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.members.dto.RoleType;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Expression;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
@@ -89,7 +91,13 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
@Override
|
||||
public Page<MapSheetMngDto.MngDto> findMapSheetMngList(MapSheetMngDto.@Valid searchReq searchReq) {
|
||||
|
||||
Pageable pageable = PageRequest.of(searchReq.getPage(), searchReq.getSize());
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
BooleanBuilder whereBuilder = new BooleanBuilder();
|
||||
|
||||
if (searchReq.getMngYyyy() != null ) {
|
||||
whereBuilder.and(mapSheetMngEntity.id.eq(searchReq.getMngYyyy()));
|
||||
}
|
||||
|
||||
List<MapSheetMngDto.MngDto> foundContent = queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
@@ -109,21 +117,16 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
)
|
||||
)
|
||||
.from(mapSheetMngEntity)
|
||||
//.where(
|
||||
// mapSheetMngSearchValue(searchReq)
|
||||
//)
|
||||
//.offset(pageable.getOffset())
|
||||
//.limit(pageable.getPageSize())
|
||||
//.orderBy(mapSheetMngEntity.id.desc())
|
||||
.where(whereBuilder)
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.orderBy(mapSheetMngEntity.createdDttm.desc())
|
||||
.fetch();
|
||||
|
||||
Long countQuery = queryFactory
|
||||
.select(mapSheetMngEntity.id.count())
|
||||
.from(mapSheetMngEntity)
|
||||
//.where(
|
||||
// mapSheetMngEntity.id.eq(searchReq.getMngYyyy()),
|
||||
// mapSheetMngSearchValue(searchReq)
|
||||
//)
|
||||
.where(whereBuilder)
|
||||
.fetchOne();
|
||||
|
||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
||||
@@ -144,16 +147,5 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
|
||||
private NumberExpression<Integer> mngRowNum(){
|
||||
return Expressions.numberTemplate(Integer.class, "row_number() over(order by {0} desc)", mapSheetMngEntity.createdDttm);
|
||||
}
|
||||
|
||||
private BooleanExpression mapSheetMngSearchValue(MapSheetMngDto.searchReq searchReq) {
|
||||
if (Objects.isNull(searchReq.getMngYyyy())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 검색어 1개 값이 도엽명 or 도엽번호 like 검색
|
||||
return Expressions.booleanTemplate("{0} = " + searchReq.getMngYyyy() , mapSheetMngEntity.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user