package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.ActClassification;
import com.ruoyi.system.mapper.ActClassificationMapper;
import com.ruoyi.system.service.IActClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 分配信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-11
 */
@Service
public class ActClassificationServiceImpl implements IActClassificationService
{
    @Autowired
    private ActClassificationMapper actClassificationMapper;

    /**
     * 查询分配信息
     * 
     * @param id 分配信息ID
     * @return 分配信息
     */
    @Override
    public ActClassification selectActClassificationById(Long id)
    {
        return actClassificationMapper.selectActClassificationById(id);
    }

    /**
     * 查询分配信息列表
     * 
     * @param actClassification 分配信息
     * @return 分配信息
     */
    @Override
    public List<ActClassification> selectActClassificationList(ActClassification actClassification)
    {
        return actClassificationMapper.selectActClassificationList(actClassification);
    }

    /**
     * 新增分配信息
     * 
     * @param actClassification 分配信息
     * @return 结果
     */
    @Override
    public int insertActClassification(ActClassification actClassification)
    {
        actClassification.setCreateTime(DateUtils.getNowDate());

        return actClassificationMapper.insertActClassification(actClassification);
    }

    /**
     * 修改分配信息
     * 
     * @param actClassification 分配信息
     * @return 结果
     */
    @Override
    public int updateActClassification(ActClassification actClassification)
    {
        actClassification.setUpdateTime(DateUtils.getNowDate());
        return actClassificationMapper.updateActClassification(actClassification);
    }

    /**
     * 批量删除分配信息
     * 
     * @param ids 需要删除的分配信息ID
     * @return 结果
     */
    @Override
    public int deleteActClassificationByIds(Long[] ids)
    {
        return actClassificationMapper.deleteActClassificationByIds(ids);
    }

    /**
     * 删除分配信息信息
     * 
     * @param id 分配信息ID
     * @return 结果
     */
    @Override
    public int deleteActClassificationById(Long id)
    {
        return actClassificationMapper.deleteActClassificationById(id);
    }


    @Override
    public List<Integer> findId(Long id) {
        return actClassificationMapper.findId(id);
    }
    @Override
    public int setEnable(Long id, Integer status) {
        updateStatusById(id, status);
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("id", id);
        paramMap.put("status", status);
        return actClassificationMapper.setEnable(paramMap);
    }

    @Override
    public int setDisable(Long id, Integer status) {
        updateStatusById(id, status);
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("id", id);
        paramMap.put("status", status);
        return actClassificationMapper.setDisable(paramMap);
    }



    private int updateStatusById(Long id, Integer status){

        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("id", id);
        paramMap.put("status", status);

        return actClassificationMapper.updateActClassification(paramMap);

    }
    @Override
    public List<ActClassification> savePid(Long sskId) {
        return actClassificationMapper.savePid(sskId);
    }

    @Override
    public List<ActClassification> getSubActClassDy(int sskId) {
        return actClassificationMapper.selectSubActDy(sskId);
    }

    @Override
    public List<ActClassification> getAllActClassifications() {
        return actClassificationMapper.selectAll();
    }

    @Override
    public List<ActClassification> getSubActClassifications(int parentId) {
        return actClassificationMapper.selectByParentId(parentId);
    }


}
