【fix sonar】MockController文件
This commit is contained in:
+21
-18
@@ -3,6 +3,7 @@ package com.jero.modules.demo.mock;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -27,8 +28,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class MockController {
|
||||
|
||||
private final String JSON_PATH = "classpath:com/jero/modules/demo/mock/json";
|
||||
|
||||
private static final String JSON_PATH = "classpath:com/jero/modules/demo/mock/json";
|
||||
|
||||
private static final String CN_TR_NO_COUNT_INFO_PATH = "classpath:com/jero/modules/demo/mock/json/getCntrNoCountInfo.json";
|
||||
|
||||
/**
|
||||
* 通用json访问接口
|
||||
* 格式: http://localhost:8080/jero-boot/api/json/{filename}
|
||||
@@ -40,17 +43,17 @@ public class MockController {
|
||||
String jsonpath = "classpath:com/jero/modules/demo/mock/json/"+filename+".json";
|
||||
return readJson(jsonpath);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/asynTreeList")
|
||||
public String asynTreeList(String id) {
|
||||
return readJson(JSON_PATH + "/asyn_tree_list_" + id + ".json");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/user")
|
||||
public String user() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/user.json");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 老的登录获取用户信息接口
|
||||
* @return
|
||||
@@ -79,7 +82,7 @@ public class MockController {
|
||||
public String permission_no_page() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/permission_no_page.json");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 省市县
|
||||
*/
|
||||
@@ -87,25 +90,25 @@ public class MockController {
|
||||
public String area() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/area.json");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试报表数据
|
||||
*/
|
||||
@GetMapping(value = "/report/getYearCountInfo")
|
||||
public String getYearCountInfo() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/getCntrNoCountInfo.json");
|
||||
return readJson(CN_TR_NO_COUNT_INFO_PATH);
|
||||
}
|
||||
@GetMapping(value = "/report/getMonthCountInfo")
|
||||
public String getMonthCountInfo() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/getCntrNoCountInfo.json");
|
||||
return readJson(CN_TR_NO_COUNT_INFO_PATH);
|
||||
}
|
||||
@GetMapping(value = "/report/getCntrNoCountInfo")
|
||||
public String getCntrNoCountInfo() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/getCntrNoCountInfo.json");
|
||||
return readJson(CN_TR_NO_COUNT_INFO_PATH);
|
||||
}
|
||||
@GetMapping(value = "/report/getCabinetCountInfo")
|
||||
public String getCabinetCountInfo() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/getCntrNoCountInfo.json");
|
||||
return readJson(CN_TR_NO_COUNT_INFO_PATH);
|
||||
}
|
||||
@GetMapping(value = "/report/getTubiao")
|
||||
public String getTubiao() {
|
||||
@@ -128,7 +131,7 @@ public class MockController {
|
||||
File[] fs = File.listRoots();
|
||||
log.info("查询磁盘信息:"+fs.length+"个");
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
|
||||
|
||||
for (int i = 0; i < fs.length; i++) {
|
||||
if(fs[i].getTotalSpace()==0) {
|
||||
continue;
|
||||
@@ -148,7 +151,7 @@ public class MockController {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 工作台首页的数据
|
||||
@@ -163,23 +166,23 @@ public class MockController {
|
||||
public String activity() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/workplace_activity.json");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/workplace/teams")
|
||||
public String teams() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/workplace_teams.json");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/workplace/radar")
|
||||
public String radar() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/workplace_radar.json");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/task/process")
|
||||
public String taskProcess() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/task_process.json");
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//author:lvdandan-----date:20190315---for:添加数据日志json----
|
||||
public String sysDataLogJson() {
|
||||
return readJson("classpath:com/jero/modules/demo/mock/json/sysdatalog.json");
|
||||
@@ -204,7 +207,7 @@ public class MockController {
|
||||
//json = FileUtils.re.readFileToString(jsonFile);
|
||||
//换个写法,解决springboot读取jar包中文件的问题
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
|
||||
json = IOUtils.toString(stream,"UTF-8");
|
||||
json = IOUtils.toString(stream, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user