package cn.iocoder.yudao.module.wms.service.inouttype;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;
import cn.iocoder.yudao.module.wms.controller.admin.inouttype.vo.*;
import cn.iocoder.yudao.module.wms.dal.dataobject.inouttype.InOutTypeDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.wms.dal.mysql.inouttype.InOutTypeMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.wms.enums.ErrorCodeConstants.*;

/**
 * 出入库类型管理 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class InOutTypeServiceImpl implements InOutTypeService {

    @Resource
    private InOutTypeMapper inOutTypeMapper;

    @Override
    public Long createInOutType(InOutTypeSaveReqVO createReqVO) {
        // 插入
        InOutTypeDO inOutType = BeanUtils.toBean(createReqVO, InOutTypeDO.class);
        inOutTypeMapper.insert(inOutType);
        // 返回
        return inOutType.getId();
    }

    @Override
    public void updateInOutType(InOutTypeSaveReqVO updateReqVO) {
        // 更新
        InOutTypeDO updateObj = BeanUtils.toBean(updateReqVO, InOutTypeDO.class);
        inOutTypeMapper.updateById(updateObj);
    }

    @Override
    public void deleteInOutType(Long id) {
        // 删除
        inOutTypeMapper.deleteById(id);
    }

    @Override
    public InOutTypeDO getInOutType(Long id) {
        return inOutTypeMapper.selectById(id);
    }

    @Override
    public PageResult<InOutTypeDO> getInOutTypePage(InOutTypePageReqVO pageReqVO) {
        return inOutTypeMapper.selectPage(pageReqVO);
    }

}
