@Override public Paging<EmployeeSearchDto> listEmpsCorpId(EmpPageListRequest empPageListRequest) {
BooleanBuilder builder = new BooleanBuilder(); if(!StringUtils.isEmpty(empPageListRequest.getSearchTxt())){ builder.andAnyOf( builder.or(EMPLOYEE.name.like('%'+empPageListRequest.getSearchTxt()+'%')), builder.or(EMPLOYEE.jobNumber.like('%'+empPageListRequest.getSearchTxt()+'%')), builder.or(USER.phone.like('%'+empPageListRequest.getSearchTxt()+'%')) ) .and(EMPLOYEE.corpId.eq(empPageListRequest.getCorpId()) .and(EMPLOYEE.state.eq(EmployeeState.ENABLED))); } QueryResults<EmployeeSearchDto> employeeDtoQueryResults = jpqlQueryFactory.select( Projections.bean( EmployeeSearchDto.class, EMPLOYEE.id, EMPLOYEE.corpId, EMPLOYEE.name, USER.phone, EMPLOYEE.jobNumber, EMPLOYEE.position)).from(EMPLOYEE) .leftJoin(USER).on(EMPLOYEE.userId.eq(USER.id)) .where(builder).offset((employeePageRequest.getPageNumber()-1)*employeePageRequest.getPageSize() .limit(empPageListRequest.getPageSize()).fetchResults(); return Paging.convert(employeeDtoQueryResults,empPageListRequest.pageRequest(),empPageListRequest.getDtoClass());
|