package com.sinata.appointment.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.sinata.appointment.constants.CacheNames;
|
import com.sinata.appointment.entity.SysBizSetting;
|
import com.sinata.appointment.mapper.SysBizSettingMapper;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.stereotype.Service;
|
|
/** 系统配置缓存(Redis + Spring Cache) */
|
@Service
|
@RequiredArgsConstructor
|
public class SysBizSettingCacheService {
|
|
private final SysBizSettingMapper sysBizSettingMapper;
|
|
@Cacheable(cacheNames = CacheNames.SYS_BIZ_SETTING, key = "#key")
|
public String getValue(String key) {
|
SysBizSetting s =
|
sysBizSettingMapper.selectOne(
|
new LambdaQueryWrapper<SysBizSetting>().eq(SysBizSetting::getSettingKey, key));
|
return s == null ? null : s.getSettingValue();
|
}
|
|
@CacheEvict(cacheNames = CacheNames.SYS_BIZ_SETTING, key = "#key")
|
public void evict(String key) {
|
// use spring cache eviction
|
}
|
}
|