package com.icomsys.main_vm.db.jpa.repo.oprManage.dsl;

import com.icomsys.main_vm.biz.rcp.oprManage.vo.OprManageBgmVO;
import com.icomsys.main_vm.db.jpa.entity.oprManage.QTbBgmMng;
import com.icomsys.main_vm.db.mybatis.alias.OprManageBgmListVo;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;

@Aspect
@Slf4j
@RequiredArgsConstructor
public class TbBgmMngDslRepoImpl implements TbBgmMngDslRepo {

    private final JPAQueryFactory queryFactory;
    private QTbBgmMng qTbBgmMng = QTbBgmMng.tbBgmMng;
    OprManageBgmListVo lvo = new OprManageBgmListVo();
    public QueryResults<OprManageBgmListVo> selectBgmList(OprManageBgmVO vo){
        var result = queryFactory.select(
                Projections.fields(
                        OprManageBgmListVo.class,
                        qTbBgmMng.fileName,
                        qTbBgmMng.filePath,
                        qTbBgmMng.registId,
                        qTbBgmMng.registDate
                )
        )
        .from(qTbBgmMng)
        .where(qTbBgmMng.fileName.like("%".concat(vo.getSearchKeyword()).concat("%")))
        .fetchResults();

        log.info("result : " + result.getResults());
        return result;
    }
}
