| @@ -0,0 +1,75 @@ | |||||
| package com.ruoyi.web.controller.bigscreen; | |||||
| import com.ruoyi.common.constant.CacheConstants; | |||||
| import com.ruoyi.common.core.controller.BaseController; | |||||
| import com.ruoyi.common.core.domain.AjaxResult; | |||||
| import com.ruoyi.common.core.domain.entity.SysDept; | |||||
| import com.ruoyi.common.core.redis.RedisCache; | |||||
| import com.ruoyi.framework.web.service.TokenService; | |||||
| import com.ruoyi.system.service.ISysDeptService; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PathVariable; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.util.List; | |||||
| import java.util.Objects; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| /** | |||||
| * @description: 通用大屏接口 | |||||
| * @author: zzl | |||||
| * @date: Created in 2025-09-02 15:11 | |||||
| * @version: 1.0 | |||||
| * @modified By: | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/big/common") | |||||
| public class CommonBigController extends BaseController { | |||||
| @Autowired | |||||
| private ISysDeptService sysDeptService; | |||||
| @Autowired | |||||
| private TokenService tokenService; | |||||
| @Autowired | |||||
| private RedisCache redisCache; | |||||
| // 大屏接口缓存时间 | |||||
| @Value("${rongxin.big.expireTime}") | |||||
| private int expireTime; | |||||
| @ApiOperation("根据部门deptId获取其下级部门列表") | |||||
| @GetMapping(value = "/nextDeptListByDeptId/{deptId}") | |||||
| public AjaxResult nextDeptListByDeptId(@PathVariable("deptId") Long deptId) { | |||||
| Object geoJson = redisCache.getCacheObject(CacheConstants.BIG_DATA_COMMON_KEY + "_nextDeptList_" + deptId); | |||||
| if (Objects.nonNull(geoJson)) { | |||||
| return AjaxResult.success(geoJson); | |||||
| } | |||||
| List<SysDept> deptList = sysDeptService.selectDeptByParentId(deptId); | |||||
| redisCache.setCacheObject(CacheConstants.BIG_DATA_COMMON_KEY + "_nextDeptList_" + deptId, deptList, expireTime, TimeUnit.MINUTES); | |||||
| return AjaxResult.success(deptList); | |||||
| } | |||||
| @ApiOperation("根据部门deptId获取其下级部门列表") | |||||
| @GetMapping(value = "/nextDeptListByOrgCode/{orgCode}") | |||||
| public AjaxResult nextDeptListByOrgCode(@PathVariable("orgCode") String orgCode) { | |||||
| Object geoJson = redisCache.getCacheObject(CacheConstants.BIG_DATA_COMMON_KEY + "_nextDeptList_" + orgCode); | |||||
| if (Objects.nonNull(geoJson)) { | |||||
| return AjaxResult.success(geoJson); | |||||
| } | |||||
| SysDept dept = sysDeptService.selectDeptByOrgCode(orgCode); | |||||
| List<SysDept> deptList = sysDeptService.selectDeptByParentId(dept.getDeptId()); | |||||
| redisCache.setCacheObject(CacheConstants.BIG_DATA_COMMON_KEY + "_nextDeptList_" + orgCode, deptList, expireTime, TimeUnit.MINUTES); | |||||
| return AjaxResult.success(deptList); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,38 @@ | |||||
| package com.ruoyi.web.controller.bigscreen; | |||||
| import com.ruoyi.common.core.controller.BaseController; | |||||
| import com.ruoyi.common.core.redis.RedisCache; | |||||
| import com.ruoyi.framework.web.service.TokenService; | |||||
| import com.ruoyi.system.service.ISysDeptService; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| /** | |||||
| * @description: | |||||
| * @author: zzl | |||||
| * @date: Created in 2025-09-02 15:11 | |||||
| * @version: 1.0 | |||||
| * @modified By: | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("/big/resource") | |||||
| public class ResourceBigController extends BaseController { | |||||
| @Autowired | |||||
| private ISysDeptService sysDeptService; | |||||
| @Autowired | |||||
| private TokenService tokenService; | |||||
| @Autowired | |||||
| private RedisCache redisCache; | |||||
| // 大屏接口缓存时间 | |||||
| @Value("${rongxin.big.expireTime}") | |||||
| private int expireTime; | |||||
| } | |||||
| @@ -1,30 +1,20 @@ | |||||
| package com.ruoyi.web.controller.monitor; | package com.ruoyi.web.controller.monitor; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Collection; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.Properties; | |||||
| import java.util.Set; | |||||
| import java.util.TreeSet; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.security.access.prepost.PreAuthorize; | |||||
| import org.springframework.web.bind.annotation.DeleteMapping; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.PathVariable; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import com.ruoyi.common.constant.CacheConstants; | import com.ruoyi.common.constant.CacheConstants; | ||||
| import com.ruoyi.common.core.domain.AjaxResult; | import com.ruoyi.common.core.domain.AjaxResult; | ||||
| import com.ruoyi.common.utils.StringUtils; | import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.system.domain.SysCache; | import com.ruoyi.system.domain.SysCache; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.data.redis.core.RedisCallback; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.security.access.prepost.PreAuthorize; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.*; | |||||
| /** | /** | ||||
| * 缓存监控 | * 缓存监控 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| @RestController | @RestController | ||||
| @@ -43,6 +33,8 @@ public class CacheController | |||||
| caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); | caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交")); | ||||
| caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); | caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理")); | ||||
| caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); | caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数")); | ||||
| caches.add(new SysCache(CacheConstants.BIG_DATA_COMMON_KEY, "通用大屏数据")); | |||||
| caches.add(new SysCache(CacheConstants.BIG_DATA_RESOURCE_KEY, "资源大屏数据")); | |||||
| } | } | ||||
| @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | @PreAuthorize("@ss.hasPermi('monitor:cache:list')") | ||||
| @@ -99,6 +99,10 @@ token: | |||||
| # 令牌有效期(默认30分钟) | # 令牌有效期(默认30分钟) | ||||
| expireTime: 30 | expireTime: 30 | ||||
| rongxin: | |||||
| big: | |||||
| expireTime: 30 | |||||
| # MyBatis配置 | # MyBatis配置 | ||||
| mybatis: | mybatis: | ||||
| # 搜索指定包别名 | # 搜索指定包别名 | ||||
| @@ -2,7 +2,7 @@ package com.ruoyi.common.constant; | |||||
| /** | /** | ||||
| * 缓存的key 常量 | * 缓存的key 常量 | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public class CacheConstants | public class CacheConstants | ||||
| @@ -41,4 +41,14 @@ public class CacheConstants | |||||
| * 登录账户密码错误次数 redis key | * 登录账户密码错误次数 redis key | ||||
| */ | */ | ||||
| public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; | public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:"; | ||||
| /** | |||||
| * 【通用】大屏接口数据缓存 redis key | |||||
| */ | |||||
| public static final String BIG_DATA_COMMON_KEY = "big_data_common:"; | |||||
| /** | |||||
| * 【资源】大屏接口数据缓存 redis key | |||||
| */ | |||||
| public static final String BIG_DATA_RESOURCE_KEY = "big_data_resource:"; | |||||
| } | } | ||||
| @@ -53,6 +53,8 @@ public interface SysDeptMapper | |||||
| */ | */ | ||||
| public int selectNormalChildrenDeptById(Long deptId); | public int selectNormalChildrenDeptById(Long deptId); | ||||
| public List<SysDept> selectDeptByParentId(Long parentId); | |||||
| /** | /** | ||||
| * 是否存在子节点 | * 是否存在子节点 | ||||
| * | * | ||||
| @@ -69,6 +69,10 @@ public interface ISysDeptService | |||||
| */ | */ | ||||
| public int selectNormalChildrenDeptById(Long deptId); | public int selectNormalChildrenDeptById(Long deptId); | ||||
| public List<SysDept> selectDeptByParentId(Long parentId); | |||||
| public SysDept selectDeptByOrgCode(String orgCode); | |||||
| /** | /** | ||||
| * 是否存在部门子节点 | * 是否存在部门子节点 | ||||
| * | * | ||||
| @@ -143,6 +143,16 @@ public class SysDeptServiceImpl implements ISysDeptService { | |||||
| return deptMapper.selectNormalChildrenDeptById(deptId); | return deptMapper.selectNormalChildrenDeptById(deptId); | ||||
| } | } | ||||
| @Override | |||||
| public List<SysDept> selectDeptByParentId(Long parentId) { | |||||
| return deptMapper.selectDeptByParentId(parentId); | |||||
| } | |||||
| @Override | |||||
| public SysDept selectDeptByOrgCode(String orgCode) { | |||||
| return deptMapper.selectDeptByOrgCode(orgCode); | |||||
| } | |||||
| /** | /** | ||||
| * 是否存在子节点 | * 是否存在子节点 | ||||
| * | * | ||||
| @@ -249,6 +249,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||||
| delete from sys_dept | delete from sys_dept | ||||
| </delete> | </delete> | ||||
| <select id="selectDeptByParentId" parameterType="Long" resultMap="SysDeptResult"> | |||||
| <include refid="selectDeptVo"/> | |||||
| where d.parent_id = #{parentId} | |||||
| </select> | |||||
| <select id="selectDeptByOrgCode" parameterType="String" resultMap="SysDeptResult"> | <select id="selectDeptByOrgCode" parameterType="String" resultMap="SysDeptResult"> | ||||
| <include refid="selectDeptVo"/> | <include refid="selectDeptVo"/> | ||||
| where d.org_code = #{orgCode} | where d.org_code = #{orgCode} | ||||