【7.1.6】首页功能

pull/26/MERGE
xixiaowei 2022-02-10 14:04:35 +08:00
parent 2dbcd912a2
commit 7f57a46f40
19 changed files with 568 additions and 61 deletions

View File

@ -8,4 +8,11 @@ package cn.stylefeng.roses.kernel.system.api;
*/
public interface PositionServiceApi {
/**
*
*
* @author xixiaowei
* @date 2022/2/9 9:37
*/
Integer PositionNum();
}

View File

@ -0,0 +1,20 @@
package cn.stylefeng.roses.kernel.system.api.constants;
/**
*
*
* @author xixiaowei
* @date 2022/2/9 16:42
*/
public interface InterfaceStatisticsCacheConstants {
/**
*
*/
String INTERFACE_STATISTICS_PREFIX = "inter:";
/**
*
*/
Long INTERFACE_STATISTICS_CACHE_TIMEOUT_SECONDS = 1200L;
}

View File

@ -70,6 +70,42 @@
<artifactId>log-api</artifactId>
<version>${roses.version}</version>
</dependency>
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>system-business-user</artifactId>
<version>${roses.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>timer-api</artifactId>
<version>${roses.version}</version>
</dependency>
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>cache-sdk-memory</artifactId>
<version>${roses.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>cache-sdk-redis</artifactId>
<version>${roses.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,59 @@
package cn.stylefeng.roses.kernel.system.modular.home.aop;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* AOP
*
* @author xixiaowei
* @date 2022/2/10 9:56
*/
@Slf4j
@Aspect
public class InterfaceStatisticsAop {
@Resource(name = "interCacheApi")
private CacheOperatorApi<String> interCacheApi;
@Pointcut(value = "@annotation(cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource) ||" +
"@annotation(cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource) ")
public void flowControl() {
}
@Around(value = "flowControl()")
public Object flowControl(ProceedingJoinPoint joinPoint) {
Object proceed = null;
try {
proceed = joinPoint.proceed();
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
//方法执行后
saveFlowControl(joinPoint);
}
return proceed;
}
private void saveFlowControl(ProceedingJoinPoint joinPoint) {
String name = joinPoint.getSignature().getName();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 获取URL
String url = request.getRequestURI();
// 存放到缓存中
interCacheApi.put(name, url, 600L);
}
}

View File

@ -0,0 +1,23 @@
package cn.stylefeng.roses.kernel.system.modular.home.cache;
import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.memory.AbstractMemoryCacheOperator;
import cn.stylefeng.roses.kernel.system.api.constants.InterfaceStatisticsCacheConstants;
/**
*
*
* @author xixiaowei
* @date 2022/2/9 16:36
*/
public class InterfaceStatisticsMemoryCache extends AbstractMemoryCacheOperator<String> {
public InterfaceStatisticsMemoryCache(TimedCache<String, String> timedCache) {
super(timedCache);
}
@Override
public String getCommonKeyPrefix() {
return InterfaceStatisticsCacheConstants.INTERFACE_STATISTICS_PREFIX;
}
}

View File

@ -0,0 +1,23 @@
package cn.stylefeng.roses.kernel.system.modular.home.cache;
import cn.stylefeng.roses.kernel.cache.redis.AbstractRedisCacheOperator;
import cn.stylefeng.roses.kernel.system.api.constants.InterfaceStatisticsCacheConstants;
import org.springframework.data.redis.core.RedisTemplate;
/**
*
*
* @author xixiaowei
* @date 2022/2/9 16:38
*/
public class InterfaceStatisticsRedisCache extends AbstractRedisCacheOperator<String> {
public InterfaceStatisticsRedisCache(RedisTemplate<String, String> redisTemplate) {
super(redisTemplate);
}
@Override
public String getCommonKeyPrefix() {
return InterfaceStatisticsCacheConstants.INTERFACE_STATISTICS_PREFIX;
}
}

View File

@ -1,4 +1,4 @@
package controller;
package cn.stylefeng.roses.kernel.system.modular.home.controller;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest;
@ -7,10 +7,12 @@ import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ResourceRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
import org.springframework.web.bind.annotation.RestController;
import service.HomePageService;
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
import javax.annotation.Resource;
import java.util.List;
@ -34,7 +36,7 @@ public class HomePageController {
* @author xixiaowei
* @date 2022/1/25 14:52
*/
@GetResource(name = "查询动态列表", path = "/page/getDynamicList")
@GetResource(name = "查询动态列表", path = "/homePage/getDynamicList")
public ResponseData<List<LogRecordDTO>> getDynamicList(LogManagerRequest logManagerRequest) {
return new SuccessResponseData<>(homePageService.getDynamicList(logManagerRequest));
}
@ -45,7 +47,7 @@ public class HomePageController {
* @author xixiaowei
* @date 2022/1/25 10:00
*/
@GetResource(name = "查询动态列表(分页)", path = "/page/getDynamicPage")
@GetResource(name = "查询动态列表(分页)", path = "/homePage/getDynamicPage")
public ResponseData<PageResult<LogRecordDTO>> getDynamicPage(LogManagerRequest logManagerRequest) {
return new SuccessResponseData<>(homePageService.getDynamicPage(logManagerRequest));
}
@ -56,8 +58,30 @@ public class HomePageController {
* @author xixiaowei
* @date 2022/1/25 14:11
*/
@GetResource(name = "查询在线用户列表", path = "/page/getOnlineUserList")
@GetResource(name = "查询在线用户列表", path = "/homePage/getOnlineUserList")
public ResponseData<List<OnlineUserDTO>> getOnlineUserList(OnlineUserRequest onlineUserRequest) {
return new SuccessResponseData<>(homePageService.getOnlineUserList(onlineUserRequest));
}
/**
*
*
* @author xixiaowei
* @date 2022/2/9 10:12
*/
@GetResource(name = "获取首页企业和公司信息", path = "/homePage/getHomeCompanyInfo")
public ResponseData<HomeCompanyInfo> getHomeCompanyInfo() {
return new SuccessResponseData<>(homePageService.getHomeCompanyInfo());
}
/**
*
*
* @author xixiaowei
* @date 2022/2/10 11:34
*/
@GetResource(name = "获取常用功能接口", path = "/homePage/getCommonFunctions")
public ResponseData<List<ResourceRequest>> getCommonFunctions() {
return new SuccessResponseData<>(homePageService.getCommonFunctions());
}
}

View File

@ -0,0 +1,50 @@
package cn.stylefeng.roses.kernel.system.modular.home.entity;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author xixiaowei
* @date 2022/2/10 9:59
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("interface_statistics")
public class InterfaceStatistics extends BaseEntity {
/**
* ID
*/
@TableId(value = "statistics_id", type = IdType.ASSIGN_ID)
@ChineseDescription("主键ID")
private Long statisticsId;
/**
*
*/
@TableField("interface_name")
@ChineseDescription("接口名称")
private String interfaceName;
/**
*
*/
@TableField("interface_url")
@ChineseDescription("接口路径")
private String interfaceUrl;
/**
* 访
*/
@TableField("request_count")
@ChineseDescription("访问次数")
private Integer requestCount;
}

View File

@ -0,0 +1,31 @@
package cn.stylefeng.roses.kernel.system.modular.home.holder;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.system.modular.home.entity.InterfaceStatistics;
import cn.stylefeng.roses.kernel.system.modular.home.mapper.InterfaceStatisticsMapper;
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
import cn.stylefeng.roses.kernel.timer.api.TimerAction;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import javax.annotation.Resource;
import java.util.Map;
/**
* 访
*
* @author xixiaowei
* @date 2022/2/9 16:08
*/
public class InterfaceStatisticsHolder implements TimerAction {
@Resource
private HomePageService homePageService;
@Override
public void action(String params) {
homePageService.interfaceStatistics();
}
}

View File

@ -0,0 +1,14 @@
package cn.stylefeng.roses.kernel.system.modular.home.mapper;
import cn.stylefeng.roses.kernel.system.modular.home.entity.InterfaceStatistics;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* mapper
*
* @author xixiaowei
* @date 2022/2/10 10:08
*/
public interface InterfaceStatisticsMapper extends BaseMapper<InterfaceStatistics> {
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.home.mapper.InterfaceStatisticsMapper">
</mapper>

View File

@ -1,11 +1,14 @@
package service;
package cn.stylefeng.roses.kernel.system.modular.home.service;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest;
import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ResourceRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
import cn.stylefeng.roses.kernel.system.modular.home.entity.InterfaceStatistics;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -15,7 +18,7 @@ import java.util.List;
* @author xixiaowei
* @date 2022/1/25 9:43
*/
public interface HomePageService {
public interface HomePageService extends IService<InterfaceStatistics> {
/**
*
@ -48,4 +51,20 @@ public interface HomePageService {
* @date 2022/1/25 15:31
*/
HomeCompanyInfo getHomeCompanyInfo();
/**
*
*
* @author xixiaowei
* @date 2022/2/10 11:19
*/
List<ResourceRequest> getCommonFunctions();
/**
*
*
* @author xixiaowei
* @date 2022/2/10 12:07
*/
void interfaceStatistics();
}

View File

@ -0,0 +1,182 @@
package cn.stylefeng.roses.kernel.system.modular.home.service.Impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.log.api.LogManagerApi;
import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest;
import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceUrlParam;
import cn.stylefeng.roses.kernel.system.api.*;
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
import cn.stylefeng.roses.kernel.system.api.pojo.organization.HrOrganizationDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ResourceRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.SysUserRequest;
import cn.stylefeng.roses.kernel.system.modular.home.entity.InterfaceStatistics;
import cn.stylefeng.roses.kernel.system.modular.home.mapper.InterfaceStatisticsMapper;
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserOrg;
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
*
*
* @author xixiaowei
* @date 2022/1/25 9:45
*/
@Service
public class HomePageServiceImpl extends ServiceImpl<InterfaceStatisticsMapper, InterfaceStatistics> implements HomePageService, HomePageServiceApi {
@Resource
private LogManagerApi logManagerApi;
@Resource
private UserServiceApi userServiceApi;
@Resource
private OrganizationServiceApi organizationServiceApi;
@Resource
private PositionServiceApi positionServiceApi;
@Resource
private SysUserOrgService sysUserOrgService;
@Resource
private ResourceServiceApi resourceServiceApi;
@Resource(name = "interCacheApi")
private CacheOperatorApi<String> interCacheApi;
@Override
public List<LogRecordDTO> getDynamicList(LogManagerRequest logManagerRequest) {
List<LogRecordDTO> logRecordDTOS = logManagerApi.findList(logManagerRequest);
// 当查询数据大于20条
if (logRecordDTOS.size() > 20) {
return logRecordDTOS.subList(0, 19);
}
// 查询数据不大于20条
return logRecordDTOS;
}
@Override
public PageResult<LogRecordDTO> getDynamicPage(LogManagerRequest logManagerRequest) {
return logManagerApi.findPage(logManagerRequest);
}
@Override
public List<OnlineUserDTO> getOnlineUserList(OnlineUserRequest onlineUserRequest) {
List<OnlineUserDTO> onlineUserDTOS = userServiceApi.onlineUserList(onlineUserRequest);
// 在线人数大于20人
if (onlineUserDTOS.size() > 20) {
return onlineUserDTOS.subList(0, 19);
}
// 在线人数小于20人
return onlineUserDTOS;
}
@Override
public HomeCompanyInfo getHomeCompanyInfo() {
HomeCompanyInfo homeCompanyInfo = new HomeCompanyInfo();
// 获取组织机构数量
List<HrOrganizationDTO> hrOrganizationDTOS = organizationServiceApi.orgList();
homeCompanyInfo.setOrganizationNum(hrOrganizationDTOS.size());
// 获取企业人员总数
SysUserRequest sysUserRequest = new SysUserRequest();
List<Long> allUserIdList = userServiceApi.queryAllUserIdList(sysUserRequest);
homeCompanyInfo.setEnterprisePersonnelNum(allUserIdList.size());
// 获取职位总数
int positionNum = positionServiceApi.PositionNum();
homeCompanyInfo.setPositionNum(positionNum);
// 获取当前登录用户
LoginUser loginUser = LoginContext.me().getLoginUser();
// 获取组织公司ID
Long organizationId = loginUser.getOrganizationId();
List<SysUserOrg> sysUserOrgs = sysUserOrgService.list(Wrappers.<SysUserOrg>lambdaQuery().eq(SysUserOrg::getOrgId, organizationId));
homeCompanyInfo.setCompanyPersonnelNum(sysUserOrgs.size());
// 设置公司部门数
int sectionNum = 0;
for (HrOrganizationDTO hrOrganizationDTO : hrOrganizationDTOS) {
String[] orgPids = hrOrganizationDTO.getOrgPids().split(",");
for (String orgPid : orgPids) {
if (organizationId.toString().equals(orgPid)) {
sectionNum ++;
}
}
}
homeCompanyInfo.setSectionNum(sectionNum);
return homeCompanyInfo;
}
@Override
public List<ResourceRequest> getCommonFunctions() {
// 获取当前用户
Long userId = LoginContext.me().getLoginUser().getUserId();
List<InterfaceStatistics> interfaceStatisticsList = this.list(Wrappers.<InterfaceStatistics>lambdaQuery().eq(InterfaceStatistics::getCreateUser, userId));
List<ResourceRequest> resourceRequestList = new ArrayList<>();
for (InterfaceStatistics interfaceStatistics : interfaceStatisticsList) {
ResourceUrlParam resourceUrlParam = new ResourceUrlParam();
resourceUrlParam.setUrl(interfaceStatistics.getInterfaceUrl());
ResourceDefinition apiResourceByUrl = resourceServiceApi.getResourceByUrl(resourceUrlParam);
ResourceRequest resourceRequest = new ResourceRequest();
BeanUtil.copyProperties(apiResourceByUrl, resourceRequest);
resourceRequestList.add(resourceRequest);
}
return resourceRequestList;
}
@Override
public void interfaceStatistics() {
Map<String, String> allKeyValues = interCacheApi.getAllKeyValues();
if (ObjectUtil.isNotNull(allKeyValues.keySet())) {
for (String key : allKeyValues.keySet()) {
String value = interCacheApi.get(key);
InterfaceStatistics statistics = this.getOne(Wrappers.<InterfaceStatistics>lambdaQuery().eq(InterfaceStatistics::getInterfaceUrl, value));
// 不存在的数据添加
if (ObjectUtil.isNull(statistics)) {
InterfaceStatistics interfaceStatistics = new InterfaceStatistics();
interfaceStatistics.setInterfaceName(key);
interfaceStatistics.setInterfaceUrl(value);
interfaceStatistics.setRequestCount(1);
// 保存新数据
this.save(interfaceStatistics);
// 缓存到库中 删除缓存中数据
} else {
InterfaceStatistics interfaceStatistics = new InterfaceStatistics();
BeanUtil.copyProperties(statistics, interfaceStatistics);
interfaceStatistics.setRequestCount(interfaceStatistics.getRequestCount() + 1);
// 更新请求次数
this.updateById(interfaceStatistics);
// 缓存到库中 删除缓存中数据
}
interCacheApi.remove(key);
}
}
}
}

View File

@ -1,53 +0,0 @@
package service.Impl;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.log.api.LogManagerApi;
import cn.stylefeng.roses.kernel.log.api.pojo.manage.LogManagerRequest;
import cn.stylefeng.roses.kernel.log.api.pojo.record.LogRecordDTO;
import cn.stylefeng.roses.kernel.system.api.HomePageServiceApi;
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
import cn.stylefeng.roses.kernel.system.api.pojo.home.HomeCompanyInfo;
import cn.stylefeng.roses.kernel.system.api.pojo.user.OnlineUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.OnlineUserRequest;
import org.springframework.stereotype.Service;
import service.HomePageService;
import javax.annotation.Resource;
import java.util.List;
/**
*
*
* @author xixiaowei
* @date 2022/1/25 9:45
*/
@Service
public class HomePageServiceImpl implements HomePageService, HomePageServiceApi {
@Resource
private LogManagerApi logManagerApi;
@Resource
private UserServiceApi userServiceApi;
@Override
public List<LogRecordDTO> getDynamicList(LogManagerRequest logManagerRequest) {
return logManagerApi.findList(logManagerRequest);
}
@Override
public PageResult<LogRecordDTO> getDynamicPage(LogManagerRequest logManagerRequest) {
return logManagerApi.findPage(logManagerRequest);
}
@Override
public List<OnlineUserDTO> getOnlineUserList(OnlineUserRequest onlineUserRequest) {
return userServiceApi.onlineUserList(onlineUserRequest);
}
@Override
public HomeCompanyInfo getHomeCompanyInfo() {
// TODO 未完成
return null;
}
}

View File

@ -172,4 +172,9 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
return queryWrapper;
}
@Override
public Integer PositionNum() {
List<HrPosition> list = this.list();
return list.size();
}
}

View File

@ -79,6 +79,12 @@
<version>${roses.version}</version>
</dependency>
<!--首页的业务-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>system-business-home</artifactId>
<version>${roses.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,40 @@
package cn.stylefeng.roses.kernel.system.starter;
import cn.stylefeng.roses.kernel.system.modular.home.aop.InterfaceStatisticsAop;
import cn.stylefeng.roses.kernel.system.modular.home.holder.InterfaceStatisticsHolder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
*
*
* @author xixiaowei
* @date 2022/2/9 17:57
*/
@Configuration
public class GunsSystemAutoConfiguration {
/**
* AOP
*
* @author xixiaowei
* @date 2022/2/9 14:00
*/
@Bean
public InterfaceStatisticsAop interfaceStatisticsAspect() {
return new InterfaceStatisticsAop();
}
/**
* 访
*
* @author xixiaowei
* @date 2022/2/9 17:58
*/
@Bean
@ConditionalOnMissingBean(InterfaceStatisticsHolder.class)
public InterfaceStatisticsHolder interfaceStatisticsHolder() {
return new InterfaceStatisticsHolder();
}
}

View File

@ -27,9 +27,12 @@ package cn.stylefeng.roses.kernel.system.starter;
import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.system.api.constants.InterfaceStatisticsCacheConstants;
import cn.stylefeng.roses.kernel.system.api.constants.SystemCachesConstants;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserOrgDTO;
import cn.stylefeng.roses.kernel.system.modular.home.aop.InterfaceStatisticsAop;
import cn.stylefeng.roses.kernel.system.modular.home.cache.InterfaceStatisticsMemoryCache;
import cn.stylefeng.roses.kernel.system.modular.role.cache.RoleDataScopeMemoryCache;
import cn.stylefeng.roses.kernel.system.modular.role.cache.RoleMemoryCache;
import cn.stylefeng.roses.kernel.system.modular.role.cache.RoleResourceMemoryCache;
@ -145,4 +148,16 @@ public class GunsSystemCacheAutoConfiguration {
return new ThemeMemoryCache(themeCache);
}
/**
*
*
* @author xixiaowei
* @date 2022/2/9 16:53
*/
@Bean
@ConditionalOnMissingBean(name = "interCacheApi")
public CacheOperatorApi<String> interCacheApi() {
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(InterfaceStatisticsCacheConstants.INTERFACE_STATISTICS_CACHE_TIMEOUT_SECONDS);
return new InterfaceStatisticsMemoryCache(timedCache);
}
}

View File

@ -1,3 +1,4 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.stylefeng.roses.kernel.system.starter.GunsSystemCacheAutoConfiguration,\
cn.stylefeng.roses.kernel.system.starter.GunsResourceCacheAutoConfiguration
cn.stylefeng.roses.kernel.system.starter.GunsResourceCacheAutoConfiguration,\
cn.stylefeng.roses.kernel.system.starter.GunsSystemAutoConfiguration