package com.xingxi.business.ProdInventory.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.business.ProdInventory.domain.ProdInventory;
import com.xingxi.business.ProdInventory.mapper.ProdInventoryMapper;
import com.xingxi.business.ProdInventory.service.IProdInventoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品库存Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class ProdInventoryServiceImpl implements IProdInventoryService {
    @Resource
    private ProdInventoryMapper prodInventoryMapper;

    /**
     * 查询商品库存
     *
     * @param prodInventoryId 商品库存主键
     * @return 商品库存
     */
    @Override
    public ProdInventory selectProdInventoryByProdInventoryId(Long prodInventoryId) {
        return prodInventoryMapper.selectProdInventoryByProdInventoryId(prodInventoryId);
    }

    /**
     * 查询商品库存列表
     *
     * @param prodInventory 商品库存
     * @return 商品库存
     */
    @Override
    public List<ProdInventory> selectProdInventoryList(ProdInventory prodInventory) {
        return prodInventoryMapper.selectProdInventoryList(prodInventory);
    }

    /**
     * 新增商品库存
     *
     * @param prodInventory 商品库存
     * @return 结果
     */
    @Override
    public int insertProdInventory(ProdInventory prodInventory) {
        prodInventory.setCreateTime(DateUtils.getNowDate());
        return prodInventoryMapper.insertProdInventory(prodInventory);
    }

    /**
     * 新增商品库存
     *
     * @param prodInventoryList 商品库存
     * @return 结果
     */
    @Override
    public int batchInsertProdInventory(List<ProdInventory> prodInventoryList) {
        return prodInventoryMapper.batchInsertProdInventory(prodInventoryList);
    }

    /**
     * 修改商品库存
     *
     * @param prodInventory 商品库存
     * @return 结果
     */
    @Override
    public int updateProdInventory(ProdInventory prodInventory) {
        prodInventory.setUpdateTime(DateUtils.getNowDate());
        return prodInventoryMapper.updateProdInventory(prodInventory);
    }

    /**
     * 批量删除商品库存
     *
     * @param prodInventoryIds 需要删除的商品库存主键
     * @return 结果
     */
    @Override
    public int deleteProdInventoryByProdInventoryIds(String prodInventoryIds) {
        return prodInventoryMapper.deleteProdInventoryByProdInventoryIds(Convert.toStrArray(prodInventoryIds));
    }

    /**
     * 删除商品库存信息
     *
     * @param prodInventoryId 商品库存主键
     * @return 结果
     */
    @Override
    public int deleteProdInventoryByProdInventoryId(Long prodInventoryId) {
        return prodInventoryMapper.deleteProdInventoryByProdInventoryId(prodInventoryId);
    }

    /**
     * 逻辑删除商品库存
     *
     * @param prodInventoryId 商品库存主键
     * @return 结果
     */
    @Override
    public int logicDeleteProdInventoryByProdInventoryId(Long prodInventoryId) {
        return prodInventoryMapper.logicDeleteProdInventoryByProdInventoryId(prodInventoryId);
    }

    /**
     * 逻辑批量删除商品库存
     *
     * @param prodInventoryIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteProdInventoryByProdInventoryIds(String[] prodInventoryIds) {
        return prodInventoryMapper.logicDeleteProdInventoryByProdInventoryIds(prodInventoryIds);
    }

    /**
     * 逻辑批量删除商品库存
     *
     * @param prodInventory 商品库存
     * @return 结果
     */
    @Override
    public int logicDeleteProdInventoryByCondition(ProdInventory prodInventory) {
        return prodInventoryMapper.logicDeleteProdInventoryByCondition(prodInventory);
    }
}
