package com.njcn.energy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.energy.mapper.HardwareMapper;
import com.njcn.energy.pojo.param.HardwareParam;
import com.njcn.energy.pojo.po.Hardware;
import com.njcn.energy.service.IHardwareService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/3/8 10:53
 */
@Service
public class HardwareServiceImpl extends ServiceImpl<HardwareMapper, Hardware> implements IHardwareService {

    @Override
    public Hardware addHardware(HardwareParam hardwareParam) {
        Hardware hardware = new Hardware();
        BeanUtils.copyProperties(hardwareParam, hardware);
        this.save(hardware);
        return hardware;
    }

    @Override
    public boolean deleteHardware(List<String> list) {
        QueryWrapper<Hardware> hardwareQueryWrapper = new QueryWrapper<>();
        hardwareQueryWrapper.in("Id",list);
        return this.remove(hardwareQueryWrapper);
    }
}
