package net.lab1024.sa.admin.module.business.base.address.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.address.domain.entity.AddressEntity;
import net.lab1024.sa.admin.module.business.base.address.dao.AddressDao;

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 2024-12-26 15:35:23
 * copyright 友仓
 */
@Service
@Slf4j
public class AddressManager extends ServiceImpl<AddressDao, AddressEntity> {

    @Resource
    private AddressDao addressDao;

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

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.ADDRESS_ENTITY)
    public AddressEntity queryAddress(Long addressId) {
        return addressDao.selectById(addressId);
    }
}
