fix:修复因缓存导致行程规划单权限消失的问题
This commit is contained in:
parent
801952c971
commit
cd0fcd4f1a
|
@ -5,7 +5,6 @@ import com.chint.domain.repository.PermissionConfigRepository;
|
|||
import com.chint.infrastructure.repository.cache.CachePermissionConfigRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcPermissionConfigRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -20,12 +19,18 @@ public class PermissionConfigRepositoryImpl implements PermissionConfigRepositor
|
|||
@Autowired
|
||||
private CachePermissionConfigRepository cachePermissionConfigRepository;
|
||||
|
||||
@Cacheable(value = "PermissionConfig", key = "#permissionName")
|
||||
|
||||
@Override
|
||||
public Optional<PermissionConfig> findByPermissionName(String permissionName) {
|
||||
return jdbcPermissionConfigRepository.findByPermissionName(permissionName)
|
||||
PermissionConfig permissionConfig = cachePermissionConfigRepository.cacheByName(permissionName, null);
|
||||
if (permissionConfig == null) {
|
||||
Optional<PermissionConfig> first = jdbcPermissionConfigRepository.findByPermissionName(permissionName)
|
||||
.stream()
|
||||
.findFirst();
|
||||
first.ifPresent(it -> cachePermissionConfigRepository.cacheByName(it));
|
||||
return first;
|
||||
}
|
||||
return Optional.of(permissionConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,6 +40,11 @@ public class CachePermissionConfigRepository {
|
|||
return permissionConfig;
|
||||
}
|
||||
|
||||
@Cacheable(value = "PermissionConfig", key = "#permissionConfigName")
|
||||
public PermissionConfig cacheByName(String permissionConfigName, PermissionConfig permissionConfig) {
|
||||
return permissionConfig;
|
||||
}
|
||||
|
||||
@Cacheable(value = "PermissionConfig", key = "#permissionName")
|
||||
public void cacheEvictByName(String permissionName) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue