package cn.ezhizao.project.business.companyFollow.service.impl;

import java.util.List;
import javax.annotation.Resource;

import cn.ezhizao.project.system.service.ISysFileStorageService;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import cn.ezhizao.project.business.companyFollow.mapper.BizCompanyFollowDetailMapper;
import cn.ezhizao.project.business.companyFollow.domain.BizCompanyFollowDetail;
import cn.ezhizao.project.business.companyFollow.service.IBizCompanyFollowDetailService;

/**
 * 客户跟进记录Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-17
 */
@Service
public class BizCompanyFollowDetailServiceImpl  extends ServiceImpl<BizCompanyFollowDetailMapper, BizCompanyFollowDetail> implements IBizCompanyFollowDetailService
{
    @Resource
    private BizCompanyFollowDetailMapper bizCompanyFollowDetailMapper;
    @Resource
    private ISysFileStorageService sysFileStorageService;

    /**
     * 查询客户跟进记录列表
     *
     * @param bizCompanyFollowDetail 客户跟进记录
     * @return 客户跟进记录
     */
    @Override
    public List<BizCompanyFollowDetail> getList(BizCompanyFollowDetail bizCompanyFollowDetail)
    {
        return bizCompanyFollowDetailMapper.getList(bizCompanyFollowDetail);
    }

    /**
     * 物理删除
     * @param bizCompanyFollowDetail
     * @return 删除结果
     */
    @Override
    public int physicalDelete(BizCompanyFollowDetail bizCompanyFollowDetail){ return bizCompanyFollowDetailMapper.physicalDelete(bizCompanyFollowDetail); };

    @Override
    public boolean save(BizCompanyFollowDetail bizCompanyFollowDetail) {
        boolean state = super.save(bizCompanyFollowDetail);
        bizCompanyFollowDetail.getFiles().forEach(l -> {
            l.setMasterId(bizCompanyFollowDetail.getId());
            l.setMasterTableName("biz_company_follow_detail");
        });
        sysFileStorageService.saveBatch(bizCompanyFollowDetail.getFiles());
        return state;
    }

}
