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

import cn.hutool.core.bean.BeanUtil;
import com.hys.app.framework.context.user.AdminUserContext;
import com.hys.app.framework.database.WebPage;
import com.hys.app.framework.database.mybatisplus.base.BaseServiceImpl;
import com.hys.app.raycoswebapi.mapper.product.StockVirtualSkuMapper;
import com.hys.app.raycoswebapi.mapper.product.StockplusInfoMapper;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockplusDao;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockvirtualskuDao;
import com.hys.app.raycoswebapi.model.dto.product.StockVirtualSkuDto;
import com.hys.app.raycoswebapi.model.dto.product.StockplusDto;
import com.hys.app.raycoswebapi.service.product.StockVirtualSkuManager;
import com.hys.app.raycoswebapi.service.product.StockplusInfoManager;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@AllArgsConstructor
public class StockVirtualSkuManagerImpl extends BaseServiceImpl<StockVirtualSkuMapper, RaycosStockvirtualskuDao> implements StockVirtualSkuManager {

    @Override
    public WebPage<RaycosStockvirtualskuDao> list(StockVirtualSkuDto stockVirtualSkuDto) {
        stockVirtualSkuDto.setCompanyId(AdminUserContext.getCompanyId());
        WebPage<RaycosStockvirtualskuDao> page = baseMapper.selectPage(stockVirtualSkuDto);
        return page;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long add(StockVirtualSkuDto stockVirtualSkuDto) {
        RaycosStockvirtualskuDao raycosStockvirtualskuDao = BeanUtil.copyProperties(stockVirtualSkuDto, RaycosStockvirtualskuDao.class);
        raycosStockvirtualskuDao.setCompanyId(AdminUserContext.getCompanyId());
        save(raycosStockvirtualskuDao);
        Long id = raycosStockvirtualskuDao.getId();

        return id;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateInfo(StockVirtualSkuDto stockVirtualSkuDto) {
        RaycosStockvirtualskuDao raycosStockvirtualskuDao = BeanUtil.copyProperties(stockVirtualSkuDto, RaycosStockvirtualskuDao.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(Long id) {
        RaycosStockvirtualskuDao aDo = getById(id);
        removeById(id);
    }
}
