package net.lab1024.sa.admin.module.business.base.customer.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.customer.domain.entity.CustomerEntity;
import net.lab1024.sa.admin.module.business.base.customer.dao.CustomerDao;

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 2025-03-25 10:42:33
 * copyright 友仓
 */
@Service
@Slf4j
public class CustomerManager extends ServiceImpl<CustomerDao, CustomerEntity> {

    @Resource
    private CustomerDao customerDao;

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

    /**
     * 查詢类目
     */
    @Cacheable(AdminCacheConst.Base.CUSTOMER_ENTITY)
    public CustomerEntity queryCustomer(Long customerId) {
        return customerDao.selectById(customerId);
    }
}
