package net.lab1024.sa.admin.module.business.base.stock.manager;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.constant.AdminCacheConst;
import net.lab1024.sa.admin.module.business.base.stock.dao.StockDao;
import net.lab1024.sa.admin.module.business.base.stock.domain.entity.StockEntity;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * 容器信息  Manager
 *
 * @author 霍锦
 * @since  2024-11-26 11:37:48
 * copyright 友仓
 */
@Service
@Slf4j
public class StockManager extends ServiceImpl<StockDao, StockEntity> {

    @Resource
    private StockDao stockDao;

    /**
     * 根据类目id 移除缓存
     */
    @CacheEvict(value = {AdminCacheConst.Base.STOCK_ENTITY}, allEntries = true)
    public void removeCache() {
        log.info("clear LOCATION_ENTITY");
    }

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.STOCK_ENTITY)
    public StockEntity queryStock(Long stockId) {
        return stockDao.selectById(stockId);
    }

}
