package cokr.xit.ens.biz.traffic.chuncheon.mydoc.domain.repository;

import cokr.xit.ens.biz.traffic.chuncheon.mydoc.domain.ElctrnNticSndngResult;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.RequiredArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

import static cokr.xit.ens.biz.traffic.chuncheon.mydoc.domain.QElctrnNticSndngResult.elctrnNticSndngResult;

@RequiredArgsConstructor
public class ElctrnNticSndngResultRepositoryImpl implements ElctrnNticSndngResultRepositoryCustom {

    private final JPAQueryFactory query;

    @Override
    public void modifyByElctrnNticSndngResults(List<ElctrnNticSndngResult> elctrnNticSndngResults) {
        elctrnNticSndngResults.forEach(data ->
                        query.update(elctrnNticSndngResult)
                                .set(elctrnNticSndngResult.sndngResultCode, data.getSndngResultCode())
                                .set(elctrnNticSndngResult.requstDt, data.getRequstDt())
                                .set(elctrnNticSndngResult.inqireDt, data.getInqireDt())
                                .set(elctrnNticSndngResult.readngDt, data.getReadngDt())
                                .set(elctrnNticSndngResult.errorCn, data.getErrorCn())
//						.set(elctrnNticSndngResult.create, FieldCreate.builder().build())
                                .set(elctrnNticSndngResult.lastUpdtDt, LocalDateTime.now())
                                .where(elctrnNticSndngResult.elctrnNticSndngDetailId.eq(data.getElctrnNticSndngDetailId()))
                                .execute()
        );
    }


}
