package com.ruoyi.invest.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.invest.mapper.TProjectInvestigatePersonMapper;
import com.ruoyi.invest.domain.TProjectInvestigatePerson;
import com.ruoyi.invest.service.ITProjectInvestigatePersonService;

/**
 * 尽调人员关联表Service业务层处理
 * 
 * @author zjc
 * @date 2024-03-13
 */
@Service
public class TProjectInvestigatePersonServiceImpl implements ITProjectInvestigatePersonService 
{
    @Autowired
    private TProjectInvestigatePersonMapper tProjectInvestigatePersonMapper;

    /**
     * 查询尽调人员关联表
     * 
     * @param id 尽调人员关联表主键
     * @return 尽调人员关联表
     */
    @Override
    public TProjectInvestigatePerson selectTProjectInvestigatePersonById(String id)
    {
        return tProjectInvestigatePersonMapper.selectTProjectInvestigatePersonById(id);
    }

    /**
     * 查询尽调人员关联表列表
     * 
     * @param tProjectInvestigatePerson 尽调人员关联表
     * @return 尽调人员关联表
     */
    @Override
    public List<TProjectInvestigatePerson> selectTProjectInvestigatePersonList(TProjectInvestigatePerson tProjectInvestigatePerson)
    {
        return tProjectInvestigatePersonMapper.selectTProjectInvestigatePersonList(tProjectInvestigatePerson);
    }

    /**
     * 新增尽调人员关联表
     * 
     * @param tProjectInvestigatePerson 尽调人员关联表
     * @return 结果
     */
    @Override
    public int insertTProjectInvestigatePerson(TProjectInvestigatePerson tProjectInvestigatePerson)
    {
        TProjectInvestigatePerson po = tProjectInvestigatePersonMapper.selectTProjectInvestigatePersonById(tProjectInvestigatePerson.getId());
        if(StringUtils.isNotNull(po)){
            tProjectInvestigatePerson.setUpdateTime(DateUtils.getNowDate());
            return tProjectInvestigatePersonMapper.updateTProjectInvestigatePerson(tProjectInvestigatePerson);
        }else{
            tProjectInvestigatePerson.setCreateTime(DateUtils.getNowDate());
            return tProjectInvestigatePersonMapper.insertTProjectInvestigatePerson(tProjectInvestigatePerson);
        }
    }

    /**
     * 修改尽调人员关联表
     * 
     * @param tProjectInvestigatePerson 尽调人员关联表
     * @return 结果
     */
    @Override
    public int updateTProjectInvestigatePerson(TProjectInvestigatePerson tProjectInvestigatePerson)
    {
        tProjectInvestigatePerson.setUpdateTime(DateUtils.getNowDate());
        return tProjectInvestigatePersonMapper.updateTProjectInvestigatePerson(tProjectInvestigatePerson);
    }

    /**
     * 批量删除尽调人员关联表
     * 
     * @param ids 需要删除的尽调人员关联表主键
     * @return 结果
     */
    @Override
    public int deleteTProjectInvestigatePersonByIds(String[] ids)
    {
        return tProjectInvestigatePersonMapper.deleteTProjectInvestigatePersonByIds(ids);
    }

    /**
     * 删除尽调人员关联表信息
     * 
     * @param id 尽调人员关联表主键
     * @return 结果
     */
    @Override
    public int deleteTProjectInvestigatePersonById(String id)
    {
        return tProjectInvestigatePersonMapper.deleteTProjectInvestigatePersonById(id);
    }

    /**
     * 根据尽调申请ID获取尽调人员关联表详细信息
     *
     * @param projectInvestigateId
     * @param userId
     * @return
     */
    @Override
    public TProjectInvestigatePerson selectByProjectInvestigateId(String projectInvestigateId, Long userId) {
        return tProjectInvestigatePersonMapper.selectByProjectInvestigateId(projectInvestigateId,userId);
    }

    /**
     * 根据尽调申请ID获取尽调人员关联表集合
     * @param projectInvestigateId
     * @return
     */
    @Override
    public List<TProjectInvestigatePerson> selectProjectInvestigateIdList(String projectInvestigateId) {
        return tProjectInvestigatePersonMapper.selectProjectInvestigateIdList(projectInvestigateId);
    }
}
