Quellcode durchsuchen

修改 数据格式,修改接口使用token访问

insomniaLee vor 4 Jahren
Ursprung
Commit
56176ef514
1 geänderte Dateien mit 44 neuen und 3 gelöschten Zeilen
  1. 44 3
      src/main/java/edu/nju/controller/AnalyzeController.java

+ 44 - 3
src/main/java/edu/nju/controller/AnalyzeController.java

@@ -465,7 +465,21 @@ public class AnalyzeController {
 			response.setContentType("text/html;charset=utf-8");
 			PrintWriter out = response.getWriter();
 			int[][]bugInfo=aservice.getBugInfo(taskId, caseId);
-			out.print(Arrays.deepToString(bugInfo));
+			JSONArray res = new JSONArray();
+			for(int i =0;i<bugInfo.length;i++){
+				for(int j =0;j<bugInfo[0].length;j++){
+					if(bugInfo[i][j]!=0){
+						JSONArray  temp  = new JSONArray();
+						temp.put(i);
+						temp.put(j);
+						temp.put(bugInfo[i][j]);
+						temp.put(bugInfo[i][j]+"个");
+						temp.put("报告数量 ");
+						res.put(temp);
+					}
+				}
+			}
+			out.print(res);
 			out.flush();
 			out.close();
 		} catch (Exception e) {
@@ -473,16 +487,31 @@ public class AnalyzeController {
 		}
 	}
 
+	@RequestMapping(value = "/analyse/BugInfo", method = RequestMethod.GET)
+	public void analyseBugInfoByToken(@RequestParam("token") String token, HttpServletResponse response){
+		try {
+			String realUrl = AESUtil.decrypt(token);
+			String [] decoder = url2decode(realUrl);
+			analyseBugInfo(decoder[1],decoder[0],response);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
 
 	@RequestMapping(value = "/analyseBugSubmitInfo", method = RequestMethod.GET)
-	@ResponseBody
 	public void analyseBugSubmitInfo(@RequestParam("caseId") String caseId, @RequestParam("taskId")  String taskId,@RequestParam("piece")  int piece, HttpServletResponse response){
 		try {
 			response.setCharacterEncoding("utf-8");
 			response.setContentType("text/html;charset=utf-8");
 			PrintWriter out = response.getWriter();
 			Map<Integer,Integer>map=aservice.getBugSubmitInfo(taskId,caseId,piece);
-			out.print(new JSONObject(map));
+			JSONObject res =  new JSONObject();
+			JSONArray label =  new JSONArray(map.keySet());
+			JSONArray data = new JSONArray(map.values());
+			res.put("label",label);
+			res.put("data",data);
+			out.print(res);
 			out.flush();
 			out.close();
 		} catch (Exception e) {
@@ -490,6 +519,18 @@ public class AnalyzeController {
 		}
 	}
 
+	@RequestMapping(value = "/analyse/BugSubmitInfo", method = RequestMethod.GET)
+	@ResponseBody
+	public void analyseBugSubmitInfoByToken(@RequestParam("token") String token ,@RequestParam("piece")  int piece, HttpServletResponse response){
+		try {
+			String realUrl = AESUtil.decrypt(token);
+			String [] decoder = url2decode(realUrl);
+			analyseBugSubmitInfo(decoder[1],decoder[0],piece,response);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
 
 	private String [] url2decode(String str){
 		String [] res = new String[2];