package net.lab1024.sa.admin.module.business.base.location.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.location.dao.LocationDao;
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;

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-18 14:17:31
 * copyright 友仓
 */
@Service
@Slf4j
public class LocationManager extends ServiceImpl<LocationDao, LocationEntity> {


    @Resource
    private LocationDao locationDao;

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

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.LOCATION_ENTITY)
    public LocationEntity queryLocation(Long locationId) {
        return locationDao.selectById(locationId);
    }

}
