|
@@ -25,6 +25,21 @@ public class ItemController {
|
|
|
@Autowired
|
|
|
ItemService iservice;
|
|
|
|
|
|
+ @RequestMapping(value = "/getJob")
|
|
|
+ @ResponseBody
|
|
|
+ public void getJobById(String job_id, HttpServletResponse response){
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ Job job = iservice.getJob(job_id);
|
|
|
+ out.print(new JSONObject(job));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/getItemsByJob")
|
|
|
@ResponseBody
|
|
|
public void getItemListByJobId(String job_id, HttpServletResponse response){
|
|
@@ -41,28 +56,29 @@ public class ItemController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/getJob")
|
|
|
+ @RequestMapping(value = "/getItemsByWorker")
|
|
|
@ResponseBody
|
|
|
- public void getJobById(String job_id, HttpServletResponse response){
|
|
|
+ public void getItemListByWorkerJob(String job_id, String worker_id, HttpServletResponse response){
|
|
|
try {
|
|
|
PrintWriter out = response.getWriter();
|
|
|
- Job job = iservice.getJob(job_id);
|
|
|
- out.print(new JSONObject(job));
|
|
|
+ List<Item> items = iservice.getItemsByWorkerJob(worker_id, job_id);
|
|
|
+ out.print(new JSONArray(items));
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
}catch (IOException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/getAnswersByWorker")
|
|
|
+ @RequestMapping(value = "/getAnswerByWorkerItem")
|
|
|
@ResponseBody
|
|
|
- public void getAnswerByWorkerId(String item_id,String worker_id, HttpServletResponse response){
|
|
|
+ public void getAnswerByWorkerItem(String item_id,String worker_id, HttpServletResponse response){
|
|
|
try {
|
|
|
PrintWriter out = response.getWriter();
|
|
|
- List<Answer> answers = iservice.getAnswerByWorker(item_id, worker_id);
|
|
|
- out.print(new JSONArray(answers));
|
|
|
+ Answer answer = iservice.getAnswerByItemWorker(item_id, worker_id);
|
|
|
+ out.print(new JSONObject(answer));
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
}catch (IOException e) {
|
|
@@ -71,27 +87,26 @@ public class ItemController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/getItemsByWorker")
|
|
|
+ @RequestMapping(value = "/getAnswersByWorkerJob")
|
|
|
@ResponseBody
|
|
|
- public void getItemListByWorkerJob(String job_id, String worker_id, HttpServletResponse response){
|
|
|
+ public void getAnswersByWorkerJob(String job_id,String worker_id, HttpServletResponse response){
|
|
|
try {
|
|
|
PrintWriter out = response.getWriter();
|
|
|
- List<Item> items = iservice.getItemsByWorkerJob(worker_id, job_id);
|
|
|
- out.print(new JSONArray(items));
|
|
|
+ List<Answer>answers=iservice.getAnswersByWorkerJob(job_id, worker_id);
|
|
|
+ out.print(new JSONArray(answers));
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
}catch (IOException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/saveAnswer")
|
|
|
@ResponseBody
|
|
|
- public void saveAnswer(String item_id, String worker_id,List<String>answers,String attachment_location, HttpServletResponse response){
|
|
|
+ public void saveAnswer(String item_id, String worker_id,String job_id,List<String>answers,List<String> attachment_location, HttpServletResponse response){
|
|
|
JSONObject result = new JSONObject();
|
|
|
- String id = iservice.saveAnswer(item_id, worker_id, answers, attachment_location);
|
|
|
+ String id = iservice.saveAnswer(item_id, worker_id, job_id, answers, attachment_location);
|
|
|
if(id.equals("")) {
|
|
|
result.put("status", "200");
|
|
|
result.put("id", id);
|
|
@@ -112,9 +127,9 @@ public class ItemController {
|
|
|
|
|
|
@RequestMapping(value = "/updateAnswer")
|
|
|
@ResponseBody
|
|
|
- public void saveAnswer(String id, String item_id, String worker_id,List<String>answers,String attachment_location, HttpServletResponse response){
|
|
|
+ public void updateAnswer(String id, String item_id, String worker_id, String job_id, List<String>answers,List<String> attachment_location, HttpServletResponse response){
|
|
|
JSONObject result = new JSONObject();
|
|
|
- if(iservice.updateAnswer(id, item_id, worker_id, answers, attachment_location)){
|
|
|
+ if(iservice.updateAnswer(id, item_id, worker_id, job_id, answers, attachment_location)){
|
|
|
result.put("status", "200");
|
|
|
} else {
|
|
|
result.put("status", "500");
|