package com.jy.business.payment.dao;

import com.jy.business.contract.model.table.ContractInfoTable;
import com.jy.business.payment.mapper.PaymentRequestsDetailMapper;
import com.jy.business.payment.model.entity.PaymentRequestsDetail;
import com.jy.business.payment.model.table.PaymentRequestsDetailTable;
import com.jy.business.payment.model.vo.PaymentRequestsDetailVo;
import com.jy.framework.model.base.BaseDao;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaymentRequestsDetailDao extends BaseDao<PaymentRequestsDetailMapper, PaymentRequestsDetail> {

    // 获取明细列表
    public List<PaymentRequestsDetailVo> getListByPaymentRequestsId(Long paymentRequestsId) {
        PaymentRequestsDetailTable prd = PaymentRequestsDetailTable.prd;
        ContractInfoTable ci = ContractInfoTable.ci;

        return sql(PaymentRequestsDetailVo.class)
                .select(
                        prd.all,
                        ci.contractNo
                )
                .from(prd)
                .leftJoin(ci).on(ci.id.eq(prd.contractId))
                .where(
                        prd.paymentRequestsId.eq(paymentRequestsId)
                )
                .list();
    }

}
