package com.zd.chemical.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.zd.common.core.utils.DateUtils;
import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.security.utils.SaveUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zd.chemical.mapper.ActAudituserMapper;
import com.zd.chemical.domain.ActAudituser;
import com.zd.chemical.service.IActAudituserService;

/**
 * 工作流审批用户Service业务层处理
 *
 * @author zd
 * @date 2022-08-16
 */
@Service
public class ActAudituserServiceImpl implements IActAudituserService
{
    @Autowired
    private ActAudituserMapper actAudituserMapper;

    /**
     * 查询工作流审批用户
     *
     * @param id 工作流审批用户主键
     * @return 工作流审批用户
     */
    @Override
    public ActAudituser selectActAudituserById(Long id)
    {
        return actAudituserMapper.selectActAudituserById(id);
    }

    /**
     * 查询工作流审批用户列表
     *
     * @param actAudituser 工作流审批用户
     * @return 工作流审批用户
     */
    @Override
    public List<ActAudituser> selectActAudituserList(ActAudituser actAudituser)
    {
        return actAudituserMapper.selectActAudituserList(actAudituser);
    }

    @Override
    public List<ActAudituser> getListByIds(List<Long> ids){
        if (ids.isEmpty()){
            new ArrayList <>();
        }
        return actAudituserMapper.getListByIds(ids);
    }

    /**
     * 新增工作流审批用户
     *
     * @param actAudituser 工作流审批用户
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertActAudituser(ActAudituser actAudituser)
    {
        //设置其他公共字段
        SaveUtil.setCommonAttr(actAudituser);
        return actAudituserMapper.insertActAudituser(actAudituser);
    }

    /**
     * 修改工作流审批用户
     *
     * @param actAudituser 工作流审批用户
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateActAudituser(ActAudituser actAudituser)
    {
        actAudituser.setUpdateTime(DateUtils.getNowDate());
        actAudituser.setUpdateBy(SecurityUtils.getUsername());
        return actAudituserMapper.updateActAudituser(actAudituser);
    }

    /**
     * 批量删除工作流审批用户
     *
     * @param ids 需要删除的工作流审批用户主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteActAudituserByIds(Long[] ids)
    {
        return actAudituserMapper.deleteActAudituserByIds(ids);
    }

    /**
     * 删除工作流审批用户信息
     *
     * @param id 工作流审批用户主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteActAudituserById(Long id)
    {
        return actAudituserMapper.deleteActAudituserById(id);
    }
}
