영상관리 select쿼리 수정
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||||
|
|
||||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
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.kamco.cd.kamcoback.postgres.entity.MapSheetMngHstEntity;
|
||||||
|
import com.querydsl.core.BooleanBuilder;
|
||||||
import com.querydsl.core.types.Expression;
|
import com.querydsl.core.types.Expression;
|
||||||
import com.querydsl.core.types.Projections;
|
import com.querydsl.core.types.Projections;
|
||||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||||
@@ -89,7 +91,13 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
@Override
|
@Override
|
||||||
public Page<MapSheetMngDto.MngDto> findMapSheetMngList(MapSheetMngDto.@Valid searchReq searchReq) {
|
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
|
List<MapSheetMngDto.MngDto> foundContent = queryFactory
|
||||||
.select(
|
.select(
|
||||||
Projections.constructor(
|
Projections.constructor(
|
||||||
@@ -109,21 +117,16 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.from(mapSheetMngEntity)
|
.from(mapSheetMngEntity)
|
||||||
//.where(
|
.where(whereBuilder)
|
||||||
// mapSheetMngSearchValue(searchReq)
|
.offset(pageable.getOffset())
|
||||||
//)
|
.limit(pageable.getPageSize())
|
||||||
//.offset(pageable.getOffset())
|
.orderBy(mapSheetMngEntity.createdDttm.desc())
|
||||||
//.limit(pageable.getPageSize())
|
|
||||||
//.orderBy(mapSheetMngEntity.id.desc())
|
|
||||||
.fetch();
|
.fetch();
|
||||||
|
|
||||||
Long countQuery = queryFactory
|
Long countQuery = queryFactory
|
||||||
.select(mapSheetMngEntity.id.count())
|
.select(mapSheetMngEntity.id.count())
|
||||||
.from(mapSheetMngEntity)
|
.from(mapSheetMngEntity)
|
||||||
//.where(
|
.where(whereBuilder)
|
||||||
// mapSheetMngEntity.id.eq(searchReq.getMngYyyy()),
|
|
||||||
// mapSheetMngSearchValue(searchReq)
|
|
||||||
//)
|
|
||||||
.fetchOne();
|
.fetchOne();
|
||||||
|
|
||||||
return new PageImpl<>(foundContent, pageable, countQuery);
|
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