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

import cn.hutool.core.collection.CollectionUtil;
import com.sunxung.factoring.dict.impl.FileModuleDict;
import com.sunxung.factoring.entity.fundmanagement.vo.FinancialCustomerExpenditureContractCheckListVo;
import com.sunxung.factoring.entity.sys.FileStorage;
import com.sunxung.factoring.service.fundmanagement.FinancialCustomerExpenditureContractCheckListService;
import com.sunxung.factoring.service.sys.ISysAttachmentRefService;
import com.sunxung.factoring.service.sys.dto.AttachmentDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description :
 * @Author : L.Jia
 * @Date: 2023-03-01 11:32
 */
@Service("financial_customer_expenditure_contract_checklist_uploadService")
public class FinancialCustomerExpenditureContractCheckListServiceImpl implements FinancialCustomerExpenditureContractCheckListService {

    @Autowired
    private ISysAttachmentRefService sysAttachmentRefService;

    @Override
    public FinancialCustomerExpenditureContractCheckListVo getView(Long id) {

        FinancialCustomerExpenditureContractCheckListVo checkListVo = new FinancialCustomerExpenditureContractCheckListVo();
        checkListVo.setId(id);
        //获取合同清单
        List<FileStorage> checklistFileList = sysAttachmentRefService.getFiles(AttachmentDto.builder().setEntityId(id)
                .setChildEnum(FileModuleDict.ChildEnum.FINANCIAL_EXPENDITURE_CONTRACT_CHECKLIST_FILE).build());
        if (CollectionUtil.isNotEmpty(checklistFileList)) {
            checkListVo.setContractCheckListFileList(checklistFileList);
        }
        return checkListVo;
    }
}
