|
|
|
@ -4,10 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.gccloud.dataroom.core.module.basic.entity.PageEntity;
|
|
|
|
|
import com.gccloud.common.service.ISuperService;
|
|
|
|
|
import com.gccloud.common.utils.AssertUtils;
|
|
|
|
|
import com.github.benmanes.caffeine.cache.Cache;
|
|
|
|
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -18,6 +21,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
*/
|
|
|
|
|
public interface IBasePageService extends ISuperService<PageEntity> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面实体缓存
|
|
|
|
|
*/
|
|
|
|
|
Cache<String, PageEntity> PAGE_ENTITY_CACHE = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定类型页面所有名称
|
|
|
|
|
*
|
|
|
|
@ -42,9 +50,16 @@ public interface IBasePageService extends ISuperService<PageEntity> {
|
|
|
|
|
*/
|
|
|
|
|
default PageEntity getByCode(String code) {
|
|
|
|
|
AssertUtils.isTrue(StringUtils.isNotBlank(code), "页面编码不能为空");
|
|
|
|
|
PageEntity ifPresent = PAGE_ENTITY_CACHE.getIfPresent(code);
|
|
|
|
|
if (ifPresent != null) {
|
|
|
|
|
return ifPresent;
|
|
|
|
|
}
|
|
|
|
|
LambdaQueryWrapper<PageEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(PageEntity::getCode, code);
|
|
|
|
|
PageEntity pageEntity = getBaseMapper().selectOne(queryWrapper);
|
|
|
|
|
if (pageEntity != null) {
|
|
|
|
|
PAGE_ENTITY_CACHE.put(code, pageEntity);
|
|
|
|
|
}
|
|
|
|
|
return pageEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|