疯狂的狮子li
2022-05-12 af6a08398e2bc22f3c8a3a615cbd9e23190be906
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
@@ -1,15 +1,14 @@
package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.core.domain.AjaxResult;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisServerCommands;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -22,7 +21,7 @@
 * @author Lion Li
 */
@Api(value = "缓存监控", tags = {"缓存监控管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RequiredArgsConstructor
@RestController
@RequestMapping("/monitor/cache")
public class CacheController {
@@ -30,9 +29,9 @@
    private final RedisTemplate<String, String> redisTemplate;
    @ApiOperation("获取缓存监控详细信息")
    @PreAuthorize("@ss.hasPermi('monitor:cache:list')")
    @SaCheckPermission("monitor:cache:list")
    @GetMapping()
    public AjaxResult<Map<String, Object>> getInfo() throws Exception {
    public R<Map<String, Object>> getInfo() throws Exception {
        Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::info);
        Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
        Object dbSize = redisTemplate.execute((RedisCallback<Object>) RedisServerCommands::dbSize);
@@ -52,6 +51,6 @@
            });
        }
        result.put("commandStats", pieList);
        return AjaxResult.success(result);
        return R.ok(result);
    }
}