package com.ruoyi.tcZz.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.tcZz.domain.TcWljg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tcZz.mapper.TcDbdwMapper;
import com.ruoyi.tcZz.domain.TcDbdw;
import com.ruoyi.tcZz.service.ITcDbdwService;

/**
 * 等保单位Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-10-13
 */
@Service
public class TcDbdwServiceImpl implements ITcDbdwService 
{
    @Autowired
    private TcDbdwMapper tcDbdwMapper;

    /**
     * 查询等保单位
     * 
     * @param id 等保单位主键
     * @return 等保单位
     */
    @Override
    public TcDbdw selectTcDbdwById(Long id)
    {
        return tcDbdwMapper.selectTcDbdwById(id);
    }

    /**
     * 查询等保单位列表
     * 
     * @param tcDbdw 等保单位
     * @return 等保单位
     */
    @Override
    public List<TcDbdw> selectTcDbdwList(TcDbdw tcDbdw)
    {
        return tcDbdwMapper.selectTcDbdwList(tcDbdw);
    }

    /**
     * 新增等保单位
     * 
     * @param tcDbdw 等保单位
     * @return 结果
     */
    @Override
    public int insertTcDbdw(TcDbdw tcDbdw)
    {
        tcDbdw.setCreateTime(DateUtils.getNowDate());
        return tcDbdwMapper.insertTcDbdw(tcDbdw);
    }

    /**
     * 修改等保单位
     * 
     * @param tcDbdw 等保单位
     * @return 结果
     */
    @Override
    public int updateTcDbdw(TcDbdw tcDbdw)
    {
        tcDbdw.setUpdateTime(DateUtils.getNowDate());
        return tcDbdwMapper.updateTcDbdw(tcDbdw);
    }

    /**
     * 批量删除等保单位
     * 
     * @param ids 需要删除的等保单位主键
     * @return 结果
     */
    @Override
    public int deleteTcDbdwByIds(Long[] ids)
    {
        return tcDbdwMapper.deleteTcDbdwByIds(ids);
    }

    /**
     * 删除等保单位信息
     * 
     * @param id 等保单位主键
     * @return 结果
     */
    @Override
    public int deleteTcDbdwById(Long id)
    {
        return tcDbdwMapper.deleteTcDbdwById(id);
    }

    @Override
    public String importUser(List<TcDbdw> tcDbdwList) {
        StringBuilder successMsg = new StringBuilder();
        if (!tcDbdwList.isEmpty()) {
            for (TcDbdw tcDbdw : tcDbdwList) {
                tcDbdwMapper.insertTcDbdw(tcDbdw);
            }
            successMsg.append("导入成功");
        }

        return successMsg.toString();
    }
    @Override
    public void updateByisStatus(Integer isStatus,List<String> ids) {
        tcDbdwMapper.updateByisStatus(isStatus,ids);
    }
}
