package com.psdc.service.impl;

import com.psdc.entity.PsdcDevice;
import com.psdc.mapper.PsdcDeviceMapper;
import com.psdc.service.IPsdcDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

@Service
public class PsdcDeviceServiceImpl implements IPsdcDeviceService{
    @Autowired
    private PsdcDeviceMapper psdcDeviceMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param deviceId 主键
     * @return 实例对象
     */
    public PsdcDevice queryById(Integer deviceId){
        return psdcDeviceMapper.queryById(deviceId);
    }

    /**
     * 新增数据
     *
     * @param psdcDevice 实例对象
     * @return 实例对象
     */
    public PsdcDevice insert(PsdcDevice psdcDevice){
        psdcDeviceMapper.insert(psdcDevice);
        return psdcDevice;
    }

    /**
     * 更新数据
     *
     * @param psdcDevice 实例对象
     * @return 实例对象
     */
    public PsdcDevice update(PsdcDevice psdcDevice){
        psdcDeviceMapper.update(psdcDevice);
        return queryById(psdcDevice.getDeviceId());
    }

    /**
     * 通过主键删除数据
     *
     * @param deviceId 主键
     * @return 是否成功
     */
    public boolean deleteById(Integer deviceId){
        int total = psdcDeviceMapper.deleteById(deviceId);
        return total > 0;
    }
}