feat: 게시판 관리 반영
parent
483ae3580a
commit
44ad4143a3
@ -1,12 +1,12 @@
|
||||
package com.xit.biz.ctgy.dto.struct;
|
||||
|
||||
import com.xit.biz.ctgy.dto.MinCivBoard680Dto;
|
||||
import com.xit.biz.ctgy.dto.BoardDto;
|
||||
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
||||
import com.xit.core.support.jpa.mapstruct.IMapstruct;
|
||||
import com.xit.core.support.jpa.mapstruct.MapStructMapperConfig;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(config = MapStructMapperConfig.class)
|
||||
public interface MinCivBoard680Mapstruct extends IMapstruct<MinCivBoard680Dto, MinCivBoard680> {
|
||||
public interface MinCivBoard680Mapstruct extends IMapstruct<BoardDto, MinCivBoard680> {
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.xit.biz.ctgy.repository;
|
||||
|
||||
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
||||
import com.xit.biz.ctgy.dto.BoardDto;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface IBoardRepositoryCustom {
|
||||
|
||||
Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable);
|
||||
Page<BoardDto> findAll(final BoardDto dto, Pageable pageable);
|
||||
}
|
||||
|
@ -1,35 +1,78 @@
|
||||
package com.xit.biz.ctgy.repository;
|
||||
|
||||
import com.querydsl.core.QueryResults;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
||||
import com.xit.biz.ctgy.dto.BoardDto;
|
||||
import com.xit.core.util.Checks;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.xit.biz.ctgy.entity.QMinCivBoard680.minCivBoard680;
|
||||
import static com.xit.biz.ctgy.entity.QMinUserinfo.minUserinfo;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class IBoardRepositoryImpl implements IBoardRepositoryCustom{
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
@Override
|
||||
public Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable){
|
||||
/*
|
||||
SELECT Ci_code,
|
||||
Ci_name,
|
||||
ci_contentNo,
|
||||
Ci_title,
|
||||
Ci_nalja,
|
||||
Ci_step,
|
||||
Ci_revel,
|
||||
Ci_ref,
|
||||
ci_hit
|
||||
FROM MIN_CIV_BOARD680
|
||||
WHERE Ci_code IN (SELECT Ci_code
|
||||
FROM (SELECT Ci_code, rownum RCNT
|
||||
FROM MIN_CIV_BOARD680 "& strSearchSQL1 &"
|
||||
ORDER BY Ci_ref DESC, ci_step ASC, Ci_code DESC))
|
||||
*/
|
||||
|
||||
return null;
|
||||
public Page<BoardDto> findAll(final BoardDto dto, Pageable pageable){
|
||||
|
||||
// 커버링 인덱스로 대상 조회
|
||||
QueryResults<Long> ciCodes = queryFactory
|
||||
.select(minCivBoard680.ciCode)
|
||||
.from(minCivBoard680)
|
||||
.where(ciTitleLike(dto.getCiTitle()), ciNameLike(dto.getCiName()))
|
||||
.orderBy(minCivBoard680.ciRef.desc(), minCivBoard680.ciStep.asc(), minCivBoard680.ciCode.desc())
|
||||
.offset(pageable.getOffset())
|
||||
.limit(pageable.getPageSize())
|
||||
.fetchResults();
|
||||
|
||||
if (Checks.isEmpty(ciCodes)) {
|
||||
new PageImpl<>(new ArrayList<>(), pageable, 0);
|
||||
}
|
||||
|
||||
List<BoardDto> rslt = queryFactory
|
||||
.select(Projections.fields(
|
||||
BoardDto.class,
|
||||
minCivBoard680.ciCode,
|
||||
minUserinfo.name.as("ciName"),
|
||||
minCivBoard680.ciContentno,
|
||||
minCivBoard680.ciTitle,
|
||||
minCivBoard680.ciContents,
|
||||
minCivBoard680.ciNalja,
|
||||
minCivBoard680.ciStep,
|
||||
minCivBoard680.ciRevel,
|
||||
minCivBoard680.ciRef,
|
||||
minCivBoard680.ciHit,
|
||||
minCivBoard680.ciPass,
|
||||
minCivBoard680.ciId
|
||||
))
|
||||
.from(minCivBoard680)
|
||||
.leftJoin(minUserinfo)
|
||||
.on(minCivBoard680.ciId.eq(minUserinfo.userid))
|
||||
.where(minCivBoard680.ciCode.in(ciCodes.getResults()))
|
||||
.orderBy(minCivBoard680.ciRef.desc(), minCivBoard680.ciStep.asc(), minCivBoard680.ciCode.desc())
|
||||
.fetch();
|
||||
|
||||
return new PageImpl<>(rslt, pageable, ciCodes.getTotal());
|
||||
}
|
||||
|
||||
private BooleanExpression ciTitleLike(String ciTitle){
|
||||
if(Checks.isEmpty(ciTitle)) return null;
|
||||
return minCivBoard680.ciTitle.contains(ciTitle);
|
||||
}
|
||||
|
||||
private BooleanExpression ciNameLike(String ciName){
|
||||
if(Checks.isEmpty(ciName)) return null;
|
||||
return minCivBoard680.ciName.contains(ciName);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.xit.biz.ctgy.service;
|
||||
|
||||
import com.xit.biz.ctgy.dto.BoardDto;
|
||||
import com.xit.biz.ctgy.entity.MinCivBoard680;
|
||||
import com.xit.core.support.jpa.IJpaOperation;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface IBoardService {
|
||||
|
||||
Page<MinCivBoard680> findAll(final MinCivBoard680 minCivBoard680, Pageable pageable);
|
||||
Page<BoardDto> findAll(final BoardDto dto, Pageable pageable);
|
||||
Page<MinCivBoard680> findAll2(final MinCivBoard680 entity, Pageable pageable);
|
||||
|
||||
int modifyByCiCode(Long ciCode);
|
||||
|
||||
void saveBoard(BoardDto dto);
|
||||
}
|
||||
|
Loading…
Reference in New Issue