package com.zt.plat.module.qms.resource.device.service;

import cn.hutool.core.collection.CollUtil;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceRepairAtPageReqVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceRepairAtRespVO;
import com.zt.plat.module.qms.resource.device.controller.vo.DeviceRepairAtSaveReqVO;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import java.util.*;

import com.zt.plat.module.qms.resource.device.dal.dataobject.DeviceRepairAtDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;

import com.zt.plat.module.qms.resource.device.dal.mapper.DeviceRepairAtMapper;

import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;

/**
 * 故障与处理关系 Service 实现类
 *
 * @author 后台管理-1
 */
@Service
@Validated
public class DeviceRepairAtServiceImpl implements DeviceRepairAtService {

    @Resource
    private DeviceRepairAtMapper deviceRepairAtMapper;

    @Override
    public DeviceRepairAtRespVO createDeviceRepairAt(DeviceRepairAtSaveReqVO createReqVO) {
        // 插入
        DeviceRepairAtDO deviceRepairAt = BeanUtils.toBean(createReqVO, DeviceRepairAtDO.class);
        deviceRepairAtMapper.insert(deviceRepairAt);
        // 返回
        return BeanUtils.toBean(deviceRepairAt, DeviceRepairAtRespVO.class);
    }

    @Override
    public void updateDeviceRepairAt(DeviceRepairAtSaveReqVO updateReqVO) {
        // 校验存在
        // 更新
        DeviceRepairAtDO updateObj = BeanUtils.toBean(updateReqVO, DeviceRepairAtDO.class);
        deviceRepairAtMapper.updateById(updateObj);
    }

    @Override
    public void deleteDeviceRepairAt(Long id) {
        // 校验存在
        // 删除
        deviceRepairAtMapper.deleteById(id);
    }

    @Override
        public void deleteDeviceRepairAtListByIds(List<Long> ids) {
        // 校验存在
        // 删除
        deviceRepairAtMapper.deleteByIds(ids);
        }

    @Override
    public DeviceRepairAtDO getDeviceRepairAt(Long id) {
        return deviceRepairAtMapper.selectById(id);
    }

    @Override
    public PageResult<DeviceRepairAtDO> getDeviceRepairAtPage(DeviceRepairAtPageReqVO pageReqVO) {
        return deviceRepairAtMapper.selectPage(pageReqVO);
    }

}