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

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.businessordernumber.vo.*;
import cn.iocoder.yudao.module.wms.dal.dataobject.businessordernumber.BusinessOrderNumberDO;
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.businessordernumber.BusinessOrderNumberMapper;

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 BusinessOrderNumberServiceImpl implements BusinessOrderNumberService {

    @Resource
    private BusinessOrderNumberMapper businessOrderNumberMapper;

    @Override
    public Long createBusinessOrderNumber(BusinessOrderNumberSaveReqVO createReqVO) {
        // 插入
        BusinessOrderNumberDO businessOrderNumber = BeanUtils.toBean(createReqVO, BusinessOrderNumberDO.class);
        businessOrderNumberMapper.insert(businessOrderNumber);
        // 返回
        return businessOrderNumber.getId();
    }

    @Override
    public void updateBusinessOrderNumber(BusinessOrderNumberSaveReqVO updateReqVO) {
        // 更新
        BusinessOrderNumberDO updateObj = BeanUtils.toBean(updateReqVO, BusinessOrderNumberDO.class);
        businessOrderNumberMapper.updateById(updateObj);
    }

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

    @Override
    public BusinessOrderNumberDO getBusinessOrderNumber(Long id) {
        return businessOrderNumberMapper.selectById(id);
    }

    @Override
    public PageResult<BusinessOrderNumberDO> getBusinessOrderNumberPage(BusinessOrderNumberPageReqVO pageReqVO) {
        return businessOrderNumberMapper.selectPage(pageReqVO);
    }

}
