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

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 hj
 * @since  2025-03-11 11:12:36
 * copyright 友仓
 */
@Service
@Slf4j
public class AreaManager extends ServiceImpl<AreaDao, AreaEntity> {

    @Resource
    private AreaDao areaDao;

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

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.AREA_ENTITY)
    public AreaEntity queryArea(Long areaId) {
        return areaDao.selectById(areaId);
    }

}
