package com.ycwl.basic.service.notify; import com.ycwl.basic.model.pc.notify.entity.WechatSubscribeTemplateConfigEntity; import com.ycwl.basic.repository.WechatSubscribeNotifyConfigRepository; import org.springframework.stereotype.Service; import java.util.List; /** * 微信订阅消息配置查询服务(仅负责"配置解析",不包含授权/发送逻辑) * 底层通过 Repository 实现 Redis 缓存 * * @Author: System * @Date: 2025/12/31 */ @Service public class WechatSubscribeNotifyConfigService { private final WechatSubscribeNotifyConfigRepository configRepository; public WechatSubscribeNotifyConfigService(WechatSubscribeNotifyConfigRepository configRepository) { this.configRepository = configRepository; } /** * 获取场景下的模板配置列表(带缓存) * * @param scenicId 景区ID * @param sceneKey 场景标识 * @return 启用的模板配置列表 */ public List listSceneTemplateConfigs(Long scenicId, String sceneKey) { return configRepository.getSceneTemplateConfigsCached(scenicId, sceneKey); } /** * 获取事件下的模板配置列表(带缓存) * * @param scenicId 景区ID * @param eventKey 事件标识 * @return 启用的模板配置列表 */ public List listEventTemplateConfigs(Long scenicId, String eventKey) { return configRepository.getEventTemplateConfigsCached(scenicId, eventKey); } /** * 清除指定场景的配置缓存 */ public void clearSceneConfigsCache(Long scenicId, String sceneKey) { configRepository.clearSceneTemplateConfigsCache(scenicId, sceneKey); } /** * 清除指定事件的配置缓存 */ public void clearEventConfigsCache(Long scenicId, String eventKey) { configRepository.clearEventTemplateConfigsCache(scenicId, eventKey); } /** * 清除景区下所有订阅消息配置缓存 */ public void clearAllConfigsCacheByScenic(Long scenicId) { configRepository.clearAllConfigsCacheByScenic(scenicId); } /** * 清除所有订阅消息配置缓存(全局配置变更时调用) */ public void clearAllConfigsCache() { configRepository.clearAllConfigsCache(); } }