package com.ruoyi.tcZz.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.tcZz.domain.TcWljgtj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.tcZz.mapper.TcZxyhMapper;
import com.ruoyi.tcZz.domain.TcZxyh;
import com.ruoyi.tcZz.service.ITcZxyhService;

/**
 * 最新隐患Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-12
 */
@Service
public class TcZxyhServiceImpl implements ITcZxyhService {
    @Autowired
    private TcZxyhMapper tcZxyhMapper;

    /**
     * 查询最新隐患
     *
     * @param id 最新隐患主键
     * @return 最新隐患
     */
    @Override
    public TcZxyh selectTcZxyhById(Long id) {
        return tcZxyhMapper.selectTcZxyhById(id);
    }

    /**
     * 查询最新隐患列表
     *
     * @param tcZxyh 最新隐患
     * @return 最新隐患
     */
    @Override
    public List<TcZxyh> selectTcZxyhList(TcZxyh tcZxyh) {
        return tcZxyhMapper.selectTcZxyhList(tcZxyh);
    }

    /**
     * 新增最新隐患
     *
     * @param tcZxyh 最新隐患
     * @return 结果
     */
    @Override
    public int insertTcZxyh(TcZxyh tcZxyh) {
        tcZxyh.setCreateTime(DateUtils.getNowDate());
        return tcZxyhMapper.insertTcZxyh(tcZxyh);
    }

    /**
     * 修改最新隐患
     *
     * @param tcZxyh 最新隐患
     * @return 结果
     */
    @Override
    public int updateTcZxyh(TcZxyh tcZxyh) {
        tcZxyh.setUpdateTime(DateUtils.getNowDate());
        return tcZxyhMapper.updateTcZxyh(tcZxyh);
    }

    /**
     * 批量删除最新隐患
     *
     * @param ids 需要删除的最新隐患主键
     * @return 结果
     */
    @Override
    public int deleteTcZxyhByIds(Long[] ids) {
        return tcZxyhMapper.deleteTcZxyhByIds(ids);
    }

    /**
     * 删除最新隐患信息
     *
     * @param id 最新隐患主键
     * @return 结果
     */
    @Override
    public int deleteTcZxyhById(Long id) {
        return tcZxyhMapper.deleteTcZxyhById(id);
    }

    @Override
    public String importUser(List<TcZxyh> tcZxyhList) {
        StringBuilder successMsg = new StringBuilder();
        if (!tcZxyhList.isEmpty()) {
            for (TcZxyh tcZxyh : tcZxyhList) {
                tcZxyhMapper.insertTcZxyh(tcZxyh);
            }
            successMsg.append("导入成功");
        }
        return successMsg.toString();

    }

    @Override
    public void updateByisStatus(Integer isStatus,List<String> ids) {
        tcZxyhMapper.updateByisStatus(isStatus,ids);
    }
}
