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

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunxung.factoring.dict.impl.FileModuleDict;
import com.sunxung.factoring.entity.biddingManagement.BiddingBasicInfoHis;
import com.sunxung.factoring.entity.biddingManagement.vo.BiddingBasicInfoResultVo;
import com.sunxung.factoring.entity.sys.FileStorageDO;
import com.sunxung.factoring.mapper.biddingManagement.BiddingBasicInfoHisMapper;
import com.sunxung.factoring.service.biddingManagement.IBiddingBasicInfoHisService;
import com.sunxung.factoring.service.biddingManagement.ICBiddingBasicInfoService;
import com.sunxung.factoring.service.sys.FileService;
import com.sunxung.factoring.service.sys.FileStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 招投标管理基本信息历史表 服务实现类
 * </p>
 *
 * @author author
 * @since 2023-11-20
 */
@Service("bidding_addService")
public class BiddingBasicInfoHisServiceImpl extends ServiceImpl<BiddingBasicInfoHisMapper, BiddingBasicInfoHis> implements
        IBiddingBasicInfoHisService {

    @Autowired
    private FileService fileService;
    @Autowired
    private ICBiddingBasicInfoService biddingBasicInfoService;

    @Override
    public BiddingBasicInfoHis getView(Long id) {

        BiddingBasicInfoResultVo vo = biddingBasicInfoService.getByHisId(id);

        BiddingBasicInfoHis his = getById(id);
        his.setBasicInfoResultVo(vo);

        if (his != null) {
            //填充附件
            //招标文件
            List<FileStorageDO> tendersFiles = fileService.findByBusinessId(id, FileModuleDict.ChildEnum.TENDERS_HIS_FILE.getCode());
            //投标文件
            List<FileStorageDO> binddingFiles = fileService.findByBusinessId(id, FileModuleDict.ChildEnum.BIDDING_HIS_FILE.getCode());
            his.setTendersFileList(tendersFiles);
            his.setBiddingFileList(binddingFiles);
        }

        return his;
    }
}
