Browse Source

Merge branch 'xjw' of http://git.mooctest.net/summer/crowdsource-backend into xjw

xujiawei 6 years ago
parent
commit
1833383a05

+ 5 - 7
src/main/java/edu/nju/controller/ItemController.java

@@ -8,9 +8,7 @@ import org.json.JSONArray;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -102,9 +100,9 @@ public class ItemController {
         }
     }
 
-    @RequestMapping(value = "/saveAnswer")
+    @RequestMapping(value = "/saveAnswer", method = RequestMethod.POST)
     @ResponseBody
-    public void saveAnswer(String item_id, String worker_id,String job_id,List<String>answers,List<String> attachment_location, HttpServletResponse response){
+    public void saveAnswer(String item_id, String worker_id,String job_id, @RequestParam("answers")List<String>answers, @RequestParam("attachment_location") List<String> attachment_location, HttpServletResponse response){
         JSONObject result = new JSONObject();
         String id = iservice.saveAnswer(item_id, worker_id, job_id, answers, attachment_location);
         if(id.equals("")) {
@@ -125,9 +123,9 @@ public class ItemController {
         }
     }
 
-    @RequestMapping(value = "/updateAnswer")
+    @RequestMapping(value = "/updateAnswer", method = RequestMethod.POST)
     @ResponseBody
-    public void updateAnswer(String id, String item_id, String worker_id, String job_id, List<String>answers,List<String> attachment_location, HttpServletResponse response){
+    public void updateAnswer(String id, String item_id, String worker_id, String job_id, @RequestParam("answers")List<String>answers,@RequestParam("attachment_location") List<String> attachment_location, HttpServletResponse response){
         JSONObject result = new JSONObject();
         if(iservice.updateAnswer(id, item_id, worker_id, job_id, answers, attachment_location)){
             result.put("status", "200");

+ 1 - 1
src/main/java/edu/nju/controller/ReportController.java

@@ -80,7 +80,7 @@ public class ReportController {
 		}
 	}
 	
-	@RequestMapping(value = "/relations")
+	@RequestMapping(value = "/c")
 	@ResponseBody
 	public void relations(String case_take_id, HttpServletResponse response) {
 		try {

+ 1 - 1
src/main/java/edu/nju/dao/ItemDao.java

@@ -24,7 +24,7 @@ public class ItemDao {
 
     public List<Item>findItemsByJob(String job_id){
         Query query = new Query();
-        query.addCriteria(Criteria.where("task_id").is(job_id));
+        query.addCriteria(Criteria.where("job_id").is(job_id));
         return mongoOperations.find(query, Item.class);
     }
 

+ 3 - 0
src/main/java/edu/nju/entities/Answer.java

@@ -1,6 +1,7 @@
 package edu.nju.entities;
 
 import org.springframework.data.annotation.Id;
+import org.springframework.data.annotation.PersistenceConstructor;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.util.ArrayList;
@@ -25,6 +26,7 @@ public class Answer implements java.io.Serializable{
 
     private List<String> attachment_location;
 
+    @PersistenceConstructor
     public Answer(String item_id, List<String> answers, String worker_id, List<String> attachment_location,String job_id) {
         this.item_id = item_id;
         this.answers = answers;
@@ -32,6 +34,7 @@ public class Answer implements java.io.Serializable{
         this.attachment_location = attachment_location;
         this.job_id=job_id;
     }
+    @PersistenceConstructor
     public Answer(String item_id,String worker_id,String job_id,int optionNum){
         this.item_id = item_id;
         this.worker_id = worker_id;

+ 2 - 0
src/main/java/edu/nju/entities/Job.java

@@ -1,6 +1,7 @@
 package edu.nju.entities;
 
 import org.springframework.data.annotation.Id;
+import org.springframework.data.annotation.PersistenceConstructor;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 @Document
@@ -29,6 +30,7 @@ public class Job implements java.io.Serializable{
 
     private String log_location;
 
+    @PersistenceConstructor
     public Job(String description, String name, String create_time_millis, String device_model, String device_brand, String device_os, String script_location, String report_location, String log_location) {
         this.description = description;
         this.name = name;