package com.zehong.system.service.impl;

import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TSpecialWorkPermitSignMapper;
import com.zehong.system.domain.TSpecialWorkPermitSign;
import com.zehong.system.service.ITSpecialWorkPermitSignService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author zehong
 * @date 2022-10-17
 */
@Service
public class TSpecialWorkPermitSignServiceImpl implements ITSpecialWorkPermitSignService 
{
    @Autowired
    private TSpecialWorkPermitSignMapper tSpecialWorkPermitSignMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param signId 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public TSpecialWorkPermitSign selectTSpecialWorkPermitSignById(Long signId)
    {
        return tSpecialWorkPermitSignMapper.selectTSpecialWorkPermitSignById(signId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param tSpecialWorkPermitSign 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TSpecialWorkPermitSign> selectTSpecialWorkPermitSignList(TSpecialWorkPermitSign tSpecialWorkPermitSign)
    {
        return tSpecialWorkPermitSignMapper.selectTSpecialWorkPermitSignList(tSpecialWorkPermitSign);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param tSpecialWorkPermitSign 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertTSpecialWorkPermitSign(TSpecialWorkPermitSign tSpecialWorkPermitSign)
    {
        tSpecialWorkPermitSign.setCreateTime(DateUtils.getNowDate());
        return tSpecialWorkPermitSignMapper.insertTSpecialWorkPermitSign(tSpecialWorkPermitSign);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param tSpecialWorkPermitSign 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTSpecialWorkPermitSign(TSpecialWorkPermitSign tSpecialWorkPermitSign)
    {
        return tSpecialWorkPermitSignMapper.updateTSpecialWorkPermitSign(tSpecialWorkPermitSign);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param signIds 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteTSpecialWorkPermitSignByIds(Long[] signIds)
    {
        return tSpecialWorkPermitSignMapper.deleteTSpecialWorkPermitSignByIds(signIds);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param signId 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteTSpecialWorkPermitSignById(Long signId)
    {
        return tSpecialWorkPermitSignMapper.deleteTSpecialWorkPermitSignById(signId);
    }

    /**
     * 批量更新
     * @param tSpecialWorkPermitSigns
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchUpdateSignWorkPermit(List<TSpecialWorkPermitSign> tSpecialWorkPermitSigns) throws Exception {
        int count = 0;
        for(TSpecialWorkPermitSign tSpecialWorkPermitSign :tSpecialWorkPermitSigns){
            int result = tSpecialWorkPermitSignMapper.updateTSpecialWorkPermitSign(tSpecialWorkPermitSign);
            if(result == 0){
                throw new Exception("签名更新失败！");
            }
            count++;
        }
        return count;
    }
}
