package com.sooka.sponest.monitor.aidevicedept.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.sooka.sponest.monitor.aidevicedept.domain.CenterdataTAidevicedept;
import com.sooka.sponest.monitor.aidevicedept.mapper.CenterdataTAidevicedeptMapper;
import com.sooka.sponest.monitor.aidevicedept.service.ICenterdataTAidevicedeptService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * AI对应部门Service业务层处理
 *
 * @author yy
 * @date 2022-09-01
 */
@Service
public class CenterdataTAidevicedeptServiceImpl implements ICenterdataTAidevicedeptService
{
    @Resource
    private CenterdataTAidevicedeptMapper centerdataTAidevicedeptMapper;

    /**
     * 查询AI对应部门
     *
     * @param id AI对应部门主键
     * @return AI对应部门
     */
    @Override
    public CenterdataTAidevicedept selectCenterdataTAidevicedeptById(String id)
    {
        return centerdataTAidevicedeptMapper.selectCenterdataTAidevicedeptById(id);
    }

    /**
     * 查询AI对应部门列表
     *
     * @param centerdataTAidevicedept AI对应部门
     * @return AI对应部门
     */
    @Override
    public List<CenterdataTAidevicedept> selectCenterdataTAidevicedeptList(CenterdataTAidevicedept centerdataTAidevicedept)
    {
        return centerdataTAidevicedeptMapper.selectCenterdataTAidevicedeptList(centerdataTAidevicedept);
    }

    /**
     * 新增AI对应部门
     *
     * @param centerdataTAidevicedept AI对应部门
     * @return 结果
     */
    @Override
    public int insertCenterdataTAidevicedept(CenterdataTAidevicedept centerdataTAidevicedept)
    {
        centerdataTAidevicedept.setId(IdUtils.simpleUUID());
        centerdataTAidevicedept.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getUserId().toString());
        centerdataTAidevicedept.setCreateTime(DateUtils.getNowDate());
        return centerdataTAidevicedeptMapper.insertCenterdataTAidevicedept(centerdataTAidevicedept);
    }

    /**
     * 修改AI对应部门
     *
     * @param centerdataTAidevicedept AI对应部门
     * @return 结果
     */
    @Override
    public int updateCenterdataTAidevicedept(CenterdataTAidevicedept centerdataTAidevicedept)
    {
        centerdataTAidevicedept.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getUserId());
        centerdataTAidevicedept.setUpdateTime(DateUtils.getNowDate());
        return centerdataTAidevicedeptMapper.updateCenterdataTAidevicedept(centerdataTAidevicedept);
    }

    /**
     * 批量删除AI对应部门
     *
     * @param ids 需要删除的AI对应部门主键
     * @return 结果
     */
    @Override
    public int deleteCenterdataTAidevicedeptByIds(String[] ids)
    {
        return centerdataTAidevicedeptMapper.deleteCenterdataTAidevicedeptByIds(ids);
    }

    /**
     * 删除AI对应部门信息
     *
     * @param id AI对应部门主键
     * @return 结果
     */
    @Override
    public int deleteCenterdataTAidevicedeptById(String id)
    {
        return centerdataTAidevicedeptMapper.deleteCenterdataTAidevicedeptById(id);
    }

    /**
     * 根据设备code查询
     */
    @Override
    public List<CenterdataTAidevicedept> selectDeptByDeviceCode(String deviceCode)
    {
        return centerdataTAidevicedeptMapper.selectDeptByDeviceCode(deviceCode);
    }
}
