mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 00:57:13 +08:00 
			
		
		
		
	perf: 对查询仪表盘访问趋势信息接口增加缓存处理
This commit is contained in:
		| @@ -52,4 +52,9 @@ public class CacheConsts { | ||||
|      * 菜单缓存键前缀 | ||||
|      */ | ||||
|     public static final String MENU_KEY_PREFIX = "MENU"; | ||||
|  | ||||
|     /** | ||||
|      * 仪表盘缓存键前缀 | ||||
|      */ | ||||
|     public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD"; | ||||
| } | ||||
|   | ||||
| @@ -22,13 +22,15 @@ import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
|  | ||||
| import org.springframework.cache.annotation.CacheConfig; | ||||
| import org.springframework.cache.annotation.Cacheable; | ||||
| import org.springframework.stereotype.Service; | ||||
|  | ||||
| import cn.hutool.core.convert.Convert; | ||||
| import cn.hutool.core.util.NumberUtil; | ||||
|  | ||||
| import top.charles7c.cnadmin.common.constant.CacheConsts; | ||||
| import top.charles7c.cnadmin.monitor.model.vo.DashboardAccessTrendVO; | ||||
| import top.charles7c.cnadmin.monitor.model.vo.DashboardGeoDistributionVO; | ||||
| import top.charles7c.cnadmin.monitor.model.vo.DashboardPopularModuleVO; | ||||
| @@ -44,9 +46,9 @@ import top.charles7c.cnadmin.system.service.AnnouncementService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/9/8 21:32 | ||||
|  */ | ||||
| @Slf4j | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| @CacheConfig(cacheNames = CacheConsts.DASHBOARD_KEY_PREFIX) | ||||
| public class DashboardServiceImpl implements DashboardService { | ||||
|  | ||||
|     private final LogService logService; | ||||
| @@ -65,6 +67,7 @@ public class DashboardServiceImpl implements DashboardService { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     @Cacheable(key = "#days") | ||||
|     public List<DashboardAccessTrendVO> listAccessTrend(Integer days) { | ||||
|         return logService.listDashboardAccessTrend(days); | ||||
|     } | ||||
|   | ||||
| @@ -17,6 +17,7 @@ | ||||
|             COUNT(DISTINCT `client_ip`) AS ipCount | ||||
|         FROM `sys_log` | ||||
|         GROUP BY DATE(`create_time`) | ||||
|         HAVING `date` != CURDATE() | ||||
|         ORDER BY DATE(`create_time`) DESC | ||||
|         LIMIT #{days} | ||||
|     </select> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user