首页>代码>spring boot+vue开发前后端分离无限速文件管理系统-兜兜网盘1.0>/兜兜网盘(1.0)/v1.0/后端源码/cloud-disk/src/main/java/cn/novelweb/chart/controller/ChartController.java
                
                package cn.novelweb.chart.controller;
import cn.novelweb.chart.dto.UsageRateDTO;
import cn.novelweb.tool.http.Result;
import cn.novelweb.util.system.SystemInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DecimalFormat;
/**
 * <p>各类图表接口</p>
 * <p>2020-04-24 16:47</p>
 *
 * @author Dan
 **/
@Slf4j
@RestController
@EnableSwagger2
@Api(tags = {"图表信息数据"})
@RequiresPermissions({"manager"})
@RequestMapping(value = "/chart", method = {RequestMethod.GET})
public class ChartController {
    @ApiOperation(value = "获取当前服务器信息(注:该接口请求速度可能略微大于其他接口)", notes = "参数:无参")
    @RequestMapping(value = "/system-info", produces = "application/json;charset=UTF-8")
    public Result<SystemInfo> getSystemInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("application/json;charset=UTF-8");
        // 获取系统数据信息
        return Result.ok(new SystemInfo());
    }
    @ApiOperation(value = "构建仪表盘相关信息(注:该接口请求速度可能略微大于其他接口)", notes = "参数:无参")
    @RequestMapping(value = "/usage-rate", produces = "application/json;charset=UTF-8")
    public Result<UsageRateDTO> getUsageRate(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("application/json;charset=UTF-8");
        // 设置系统等待时间
        SystemInfo.OSHI_WAIT_SECOND = 2000;
        SystemInfo systemInfo = new SystemInfo();
        //设置数据
        double cpu = (100 - systemInfo.getCpuInfo().getFree());
        DecimalFormat format = new DecimalFormat("#.00");
        // 构建返回数据模型
        UsageRateDTO usageRateDTO = new UsageRateDTO();
        usageRateDTO.setCpu(Double.parseDouble(format.format(cpu)));
        usageRateDTO.setJvm(systemInfo.getJvmInfo().getUsage());
        usageRateDTO.setMem(systemInfo.getMemoryInfo().getUsage());
        return Result.ok(usageRateDTO);
    }
}
 最近下载更多
最近下载更多
                
                1098992849     LV1
                2023年3月13日
            
            
        
                81013466     LV1
                2023年2月10日
            
            
        
                testuser1234567     LV24
                2023年1月15日
            
            
        
                清横白川玉     LV6
                2023年1月3日
            
            
        
                SZEPEZS     LV9
                2022年6月9日
            
            
        
                wwwwwjiawen     LV1
                2022年5月3日
            
            
        
                a273580046     LV1
                2022年4月27日
            
            
        
                591231555     LV20
                2022年4月18日
            
            
        
                yangctz     LV25
                2022年3月22日
            
            
        
                HappierLee     LV1
                2022年3月21日
            
            
         最近浏览更多
最近浏览更多
                
                微信网友_7442146341474304    
                3月27日
            
            
                    暂无贡献等级
            
        
                陈小灏     LV18
                2月18日
            
            
        
                微信网友_7371218154688512     LV4
                2月5日
            
            
        
                Bosan007    
                2024年12月29日
            
            
                    暂无贡献等级
            
        
                citybird     LV4
                2024年11月18日
            
            
        
                296954293     LV1
                2024年10月31日
            
            
        
                withyouatdusk     LV2
                2024年10月19日
            
            
        
                TY0165     LV20
                2024年6月18日
            
            
        
                XiaoSong888     LV3
                2024年6月2日
            
            
        
                LXQ666666    
                2024年4月8日
            
            
                    暂无贡献等级
            
        
 
     
                 
                