mirror of https://gitee.com/stylefeng/roses
【7.1.6】【statistics】更新统计业务结构名
parent
7f57a46f40
commit
d6ec22408f
|
@ -15,4 +15,5 @@ public interface PositionServiceApi {
|
|||
* @date 2022/2/9 9:37
|
||||
*/
|
||||
Integer PositionNum();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
|
@ -20,12 +20,12 @@ 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.home.service.HomePageService;
|
||||
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;
|
||||
|
@ -59,8 +59,8 @@ public class HomePageServiceImpl extends ServiceImpl<InterfaceStatisticsMapper,
|
|||
@Resource
|
||||
private ResourceServiceApi resourceServiceApi;
|
||||
|
||||
@Resource(name = "interCacheApi")
|
||||
private CacheOperatorApi<String> interCacheApi;
|
||||
@Resource(name = "interCountCacheApi")
|
||||
private CacheOperatorApi<String> interCountCacheApi;
|
||||
|
||||
@Override
|
||||
public List<LogRecordDTO> getDynamicList(LogManagerRequest logManagerRequest) {
|
||||
|
@ -153,10 +153,10 @@ public class HomePageServiceImpl extends ServiceImpl<InterfaceStatisticsMapper,
|
|||
|
||||
@Override
|
||||
public void interfaceStatistics() {
|
||||
Map<String, String> allKeyValues = interCacheApi.getAllKeyValues();
|
||||
Map<String, String> allKeyValues = interCountCacheApi.getAllKeyValues();
|
||||
if (ObjectUtil.isNotNull(allKeyValues.keySet())) {
|
||||
for (String key : allKeyValues.keySet()) {
|
||||
String value = interCacheApi.get(key);
|
||||
String value = interCountCacheApi.get(key);
|
||||
InterfaceStatistics statistics = this.getOne(Wrappers.<InterfaceStatistics>lambdaQuery().eq(InterfaceStatistics::getInterfaceUrl, value));
|
||||
// 不存在的数据添加
|
||||
if (ObjectUtil.isNull(statistics)) {
|
||||
|
@ -175,7 +175,7 @@ public class HomePageServiceImpl extends ServiceImpl<InterfaceStatisticsMapper,
|
|||
this.updateById(interfaceStatistics);
|
||||
// 缓存到库中 删除缓存中数据
|
||||
}
|
||||
interCacheApi.remove(key);
|
||||
interCountCacheApi.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.home.timer;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.modular.home.service.HomePageService;
|
||||
import cn.stylefeng.roses.kernel.timer.api.TimerAction;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 定时刷新接口访问次数统计
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/2/9 16:08
|
||||
*/
|
||||
public class InterfaceStatisticsTimer implements TimerAction {
|
||||
|
||||
@Resource
|
||||
private HomePageService homePageService;
|
||||
|
||||
@Override
|
||||
public void action(String params) {
|
||||
homePageService.interfaceStatistics();
|
||||
}
|
||||
|
||||
}
|
|
@ -174,7 +174,7 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
|
|||
|
||||
@Override
|
||||
public Integer PositionNum() {
|
||||
List<HrPosition> list = this.list();
|
||||
return list.size();
|
||||
return this.count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--首页的业务-->
|
||||
<!--首页统计的业务-->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>system-business-home</artifactId>
|
||||
|
|
|
@ -31,7 +31,6 @@ import cn.stylefeng.roses.kernel.system.api.constants.InterfaceStatisticsCacheCo
|
|||
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;
|
||||
|
@ -155,8 +154,8 @@ public class GunsSystemCacheAutoConfiguration {
|
|||
* @date 2022/2/9 16:53
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "interCacheApi")
|
||||
public CacheOperatorApi<String> interCacheApi() {
|
||||
@ConditionalOnMissingBean(name = "interCountCacheApi")
|
||||
public CacheOperatorApi<String> interCountCacheApi() {
|
||||
TimedCache<String, String> timedCache = CacheUtil.newTimedCache(InterfaceStatisticsCacheConstants.INTERFACE_STATISTICS_CACHE_TIMEOUT_SECONDS);
|
||||
return new InterfaceStatisticsMemoryCache(timedCache);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
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 cn.stylefeng.roses.kernel.system.modular.home.timer.InterfaceStatisticsTimer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 系统自动配置
|
||||
* 首页统计数据的装载
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/2/9 17:57
|
||||
*/
|
||||
@Configuration
|
||||
public class GunsSystemAutoConfiguration {
|
||||
public class GunsSystemHomeStatisticsAutoConfiguration {
|
||||
|
||||
/**
|
||||
* 接口统计的AOP
|
||||
|
@ -27,14 +26,14 @@ public class GunsSystemAutoConfiguration {
|
|||
}
|
||||
|
||||
/**
|
||||
* 定时统计接口访问次数
|
||||
* 定时将统计数据存入数据库
|
||||
*
|
||||
* @author xixiaowei
|
||||
* @date 2022/2/9 17:58
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(InterfaceStatisticsHolder.class)
|
||||
public InterfaceStatisticsHolder interfaceStatisticsHolder() {
|
||||
return new InterfaceStatisticsHolder();
|
||||
public InterfaceStatisticsTimer interfaceStatisticsHolder() {
|
||||
return new InterfaceStatisticsTimer();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +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.GunsSystemAutoConfiguration
|
||||
cn.stylefeng.roses.kernel.system.starter.GunsSystemHomeStatisticsAutoConfiguration
|
||||
|
|
Loading…
Reference in New Issue