package net.lab1024.sa.admin.module.business.base.item.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.area.dao.AreaDao;
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
import net.lab1024.sa.admin.module.business.base.item.dao.ItemDao;
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;

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 霍锦
 * @Date 2024-11-25 17:08:18
 * @Copyright 友仓
 */
@Service
@Slf4j
public class ItemManager extends ServiceImpl<ItemDao, ItemEntity> {
    @Resource
    private ItemDao itemDao;

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

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.ITEM_ENTITY)
    public ItemEntity queryItem(Long itemId) {
        return itemDao.selectById(itemId);
    }

}
