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

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.depotlocationitem.vo.*;
import cn.iocoder.yudao.module.wms.dal.dataobject.depotlocationitem.DepotLocationItemDO;
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.depotlocationitem.DepotLocationItemMapper;

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 DepotLocationItemServiceImpl implements DepotLocationItemService {

    @Resource
    private DepotLocationItemMapper depotLocationItemMapper;

    @Override
    public Long createDepotLocationItem(DepotLocationItemSaveReqVO createReqVO) {
        // 插入
        DepotLocationItemDO depotLocationItem = BeanUtils.toBean(createReqVO, DepotLocationItemDO.class);
        depotLocationItemMapper.insert(depotLocationItem);
        // 返回
        return depotLocationItem.getId();
    }

    @Override
    public void updateDepotLocationItem(DepotLocationItemSaveReqVO updateReqVO) {
        // 更新
        DepotLocationItemDO updateObj = BeanUtils.toBean(updateReqVO, DepotLocationItemDO.class);
        depotLocationItemMapper.updateById(updateObj);
    }

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

    @Override
    public DepotLocationItemDO getDepotLocationItem(Long id) {
        return depotLocationItemMapper.selectById(id);
    }

    @Override
    public PageResult<DepotLocationItemDO> getDepotLocationItemPage(DepotLocationItemPageReqVO pageReqVO) {
        return depotLocationItemMapper.selectPage(pageReqVO);
    }

}
