package com.sunxung.factoring.service.purchcontractmanagement.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractApproval;
import com.sunxung.factoring.entity.purchcontractmanagement.PurchContractReplenishInfo;
import com.sunxung.factoring.mapper.purchcontractmanagement.PurchContractReplenishInfoMapper;
import com.sunxung.factoring.service.purchcontractmanagement.PurchContractApprovalService;
import com.sunxung.factoring.service.purchcontractmanagement.PurchContractBasicInfoService;
import com.sunxung.factoring.service.purchcontractmanagement.PurchContractReplenishInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description : 采购合同补充信息service实现类
 * @Author : JiaYf
 * @Date: 2021-09-17 19:12
 */
@Service
public class PurchContractReplenishInfoServiceImpl extends ServiceImpl<PurchContractReplenishInfoMapper, PurchContractReplenishInfo>
        implements PurchContractReplenishInfoService {

    @Autowired
    private PurchContractApprovalService purchContractApprovalService;

    @Override
    public PurchContractReplenishInfo findByPurchContBasicId(Long id) {

        PurchContractApproval purchContractApproval = purchContractApprovalService.lambdaQuery()
                .eq(PurchContractApproval::getPurchContractBasicInfoId,id).orderByDesc(PurchContractApproval::getId).list().get(0);
        PurchContractReplenishInfo replenishInfo = lambdaQuery().eq(PurchContractReplenishInfo::getPurchContractApprovalId, purchContractApproval.getId()).one();

        return replenishInfo;
    }
}
