|
|
@@ -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); |
|
|
|
|
|
|
|
} |
|
|
|
} |