浏览代码

提供获得用户点赞点踩数和总bug数的接口

MengyangDuan 5 年之前
父节点
当前提交
c6640d41bf

+ 23 - 0
src/main/java/edu/nju/controller/ReportController.java

@@ -2,11 +2,13 @@ package edu.nju.controller;
 
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
 import edu.nju.controller.interceptor.AuthRequired;
+import edu.nju.service.AnalyzeService;
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +35,9 @@ public class ReportController {
 	
 	@Autowired
 	DotService dservice;
+
+	@Autowired
+	AnalyzeService aservice;
 	
 	//获取用户的有效信息
 	@AuthRequired
@@ -54,6 +59,24 @@ public class ReportController {
 			e.printStackTrace();
 		}
 	}
+
+	@AuthRequired
+	@RequestMapping(value = "/reportRepoview")
+	@ResponseBody
+	public void getReportReview(String report_id, String case_take_id, HttpServletResponse response) {
+		try {
+			PrintWriter out = response.getWriter();
+			JSONObject result = new JSONObject();
+			result.put("thumsup", rservice.getAllThumsNum(report_id));
+			result.put("diss", rservice.getAllDissNum(report_id));
+			result.put("bug", aservice.getValid(case_take_id).size());
+			out.print(result);
+			out.flush();
+			out.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
 	
 	@RequestMapping(value = "/ThumsRank")
 	@ResponseBody

+ 17 - 0
src/main/java/edu/nju/service/ReportService.java

@@ -98,12 +98,29 @@ public class ReportService {
 		if(thumsup != null) {return thumsup.getThums();}
 		return null;
 	}
+
+	public int getAllThumsNum(String report_id) {
+		Set<String>thums=getAllThums(report_id);
+		if(thums==null)
+			return 0;
+		else
+			return thums.size();
+
+	}
 	
 	public Set<String> getAllDiss(String report_id) {
 		ThumsUp thumsup = tdao.findByReport(report_id);
 		if(thumsup != null) {return thumsup.getDiss();}
 		return null;
 	}
+
+	public int getAllDissNum(String report_id) {
+		Set<String>thums=getAllDiss(report_id);
+		if(thums==null)
+			return 0;
+		else
+			return thums.size();
+	}
 	
 	public int getValidThums(String report_id) {
 		Set<String> thums = getAllThums(report_id);