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.framework.util.DateUtil;
import com.hys.app.raycoswebapi.mapper.product.StockInfoMapper;
import com.hys.app.raycoswebapi.mapper.product.StockplusInfoMapper;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockDao;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockplusDao;
import com.hys.app.raycoswebapi.model.dto.product.StockInfoDto;
import com.hys.app.raycoswebapi.model.dto.product.StockplusDto;
import com.hys.app.raycoswebapi.service.product.StockInfoManager;
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 StockplusInfoManagerImpl extends BaseServiceImpl<StockplusInfoMapper, RaycosStockplusDao> implements StockplusInfoManager {

    @Override
    public WebPage<RaycosStockplusDao> list(StockplusDto queryParams) {
        queryParams.setCompanyId(AdminUserContext.getCompanyId());
        WebPage<RaycosStockplusDao> page = baseMapper.selectPage(queryParams);
        return page;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long add(StockplusDto stockInfoDto) {
        RaycosStockplusDao raycosStockplusDao = BeanUtil.copyProperties(stockInfoDto, RaycosStockplusDao.class);
        save(raycosStockplusDao);
        Long id = raycosStockplusDao.getId();

        return id;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateInfo(StockplusDto stockplusDto) {
        RaycosStockplusDao raycosStockplusDao = BeanUtil.copyProperties(stockplusDto, RaycosStockplusDao.class);
    }

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