package com.yanzhu.manage.service.impl;

import java.util.List;

import com.yanzhu.common.core.context.SecurityContextHolder;
import com.yanzhu.common.core.utils.DateUtils;
import com.yanzhu.manage.service.IUniService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanzhu.manage.mapper.AttendanceUbiDeviceMapper;
import com.yanzhu.manage.domain.AttendanceUbiDevice;
import com.yanzhu.manage.service.IAttendanceUbiDeviceService;

/**
 * 宇泛的设备信息Service业务层处理
 * 
 * @author yanzhu
 * @date 2024-10-08
 */
@Service
public class AttendanceUbiDeviceServiceImpl implements IAttendanceUbiDeviceService 
{
    @Autowired
    private AttendanceUbiDeviceMapper attendanceUbiDeviceMapper;

    @Autowired
    private IUniService uniService;
    /**
     * 查询宇泛的设备信息
     * 
     * @param id 宇泛的设备信息主键
     * @return 宇泛的设备信息
     */
    @Override
    public AttendanceUbiDevice selectAttendanceUbiDeviceById(Long id)
    {
        return attendanceUbiDeviceMapper.selectAttendanceUbiDeviceById(id);
    }

    @Override
    public AttendanceUbiDevice selectAttendanceUbiDeviceByNo(String no) {
        return attendanceUbiDeviceMapper.selectAttendanceUbiDeviceByNo(no);
    }

    /**
     * 查询宇泛的设备信息列表
     * 
     * @param attendanceUbiDevice 宇泛的设备信息
     * @return 宇泛的设备信息
     */
    @Override
    public List<AttendanceUbiDevice> selectAttendanceUbiDeviceList(AttendanceUbiDevice attendanceUbiDevice)
    {
        return attendanceUbiDeviceMapper.selectAttendanceUbiDeviceList(attendanceUbiDevice);
    }

    /**
     * 新增宇泛的设备信息
     * 
     * @param attendanceUbiDevice 宇泛的设备信息
     * @return 结果
     */
    @Override
    public int insertAttendanceUbiDevice(AttendanceUbiDevice attendanceUbiDevice)
    {
        attendanceUbiDevice.setCreateBy(SecurityContextHolder.getUserName());
        attendanceUbiDevice.setCreateTime(DateUtils.getNowDate());
        int data= attendanceUbiDeviceMapper.insertAttendanceUbiDevice(attendanceUbiDevice);
        uniService.syncUniDevice(attendanceUbiDevice.getId(),attendanceUbiDevice.getProjectId());
        uniService.syncUniDeviceUser(attendanceUbiDevice.getId(),attendanceUbiDevice.getProjectId());
        return  data;
    }

    /**
     * 修改宇泛的设备信息
     * 
     * @param attendanceUbiDevice 宇泛的设备信息
     * @return 结果
     */
    @Override
    public int updateAttendanceUbiDevice(AttendanceUbiDevice attendanceUbiDevice)
    {
        attendanceUbiDevice.setUpdateBy(SecurityContextHolder.getUserName());
        attendanceUbiDevice.setUpdateTime(DateUtils.getNowDate());
        int data= attendanceUbiDeviceMapper.updateAttendanceUbiDevice(attendanceUbiDevice);
        uniService.syncUniDevice(attendanceUbiDevice.getId(),attendanceUbiDevice.getProjectId());
        return  data;
    }

    /**
     * 批量删除宇泛的设备信息
     * 
     * @param ids 需要删除的宇泛的设备信息主键
     * @return 结果
     */
    @Override
    public int deleteAttendanceUbiDeviceByIds(Long[] ids)
    {
        uniService.syncUniDeviceDelete(ids);
        return attendanceUbiDeviceMapper.deleteAttendanceUbiDeviceByIds(ids);
    }

    /**
     * 删除宇泛的设备信息信息
     * 
     * @param id 宇泛的设备信息主键
     * @return 结果
     */
    @Override
    public int deleteAttendanceUbiDeviceById(Long id)
    {
        return attendanceUbiDeviceMapper.deleteAttendanceUbiDeviceById(id);
    }
}
