package com.sw.mes.store.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sw.mes.core.context.BaseContextHandler;
import com.sw.mes.store.dto.WarehouseOutputAgvDto;
import com.sw.mes.store.entity.WarehouseOutputAgv;
import com.sw.mes.store.mapper.WarehouseOutputAgvMapper;
import com.sw.mes.store.service.WarehouseOutputAgvService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class WarehouseOutputAgvServiceImpl extends ServiceImpl<WarehouseOutputAgvMapper
        , WarehouseOutputAgv> implements WarehouseOutputAgvService {
    @Autowired
    private WarehouseOutputAgvMapper warehouseOutputAgvMapper;
    @Override
    public Boolean create(WarehouseOutputAgvDto warehouseOutputAgvDto) {
        WarehouseOutputAgv warehouseOutputAgv = new WarehouseOutputAgv();
        BeanUtils.copyProperties(warehouseOutputAgvDto,warehouseOutputAgv,"id");
        warehouseOutputAgv.setCreateBy(BaseContextHandler.getUsername());
        warehouseOutputAgv.setCreateTime(new Date());
        return warehouseOutputAgvMapper.insert(warehouseOutputAgv)>=1?true:false;
    }

    @Override
    public Boolean update(WarehouseOutputAgvDto warehouseOutputAgvDto) {
        WarehouseOutputAgv warehouseOutputAgv = new WarehouseOutputAgv();
        BeanUtils.copyProperties(warehouseOutputAgvDto,warehouseOutputAgv);
        return warehouseOutputAgvMapper.updateById(warehouseOutputAgv)>=1?true:false;
    }

    @Override
    public Boolean delete(List<Long> ids) {
        return warehouseOutputAgvMapper.deleteBatchIds(ids)>=1?true:false;
    }

}
