package com.hys.app.raycoswebapi.service.product.impl;

import cn.hutool.core.bean.BeanUtil;
import com.hys.app.framework.database.WebPage;
import com.hys.app.framework.database.mybatisplus.base.BaseServiceImpl;
import com.hys.app.model.erp.dos.WarehouseEntryDO;
import com.hys.app.model.erp.dto.SaleChannelDTO;
import com.hys.app.raycoswebapi.mapper.product.StockInfoMapper;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockDao;
import com.hys.app.raycoswebapi.service.product.StockInfoManager;
import lombok.AllArgsConstructor;
import com.hys.app.raycoswebapi.model.dto.product.StockInfoDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@AllArgsConstructor
public class StockInfoManagerImpl extends BaseServiceImpl<StockInfoMapper, RaycosStockDao> implements StockInfoManager {

    @Override
    public WebPage<RaycosStockDao> list(StockInfoDto queryParams) {
        WebPage<RaycosStockDao> page = baseMapper.selectPage(queryParams);
        return page;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long add(StockInfoDto stockInfoDto) {
        RaycosStockDao raycosStockDao = BeanUtil.copyProperties(stockInfoDto, RaycosStockDao.class);
        save(raycosStockDao);
        Long id = raycosStockDao.getId();

        return id;
    }

}
