|
@@ -0,0 +1,120 @@
|
|
|
+package edu.nju.controller;
|
|
|
+
|
|
|
+import edu.nju.entities.ReviewJob;
|
|
|
+import edu.nju.service.ReviewJobService;
|
|
|
+import edu.nju.service.ReviewService;
|
|
|
+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.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.PrintWriter;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "/job")
|
|
|
+@CrossOrigin(origins = "*", maxAge = 3600, allowCredentials = "true")
|
|
|
+public class ReviewJobController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ReviewJobService reviewJobService;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/getJob")
|
|
|
+ @ResponseBody
|
|
|
+ public void getJobById(String job_id, HttpServletResponse response){
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ ReviewJob job = reviewJobService.getJob(job_id);
|
|
|
+ out.print(new JSONObject(job));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/getJobs")
|
|
|
+ @ResponseBody
|
|
|
+ public void getJobs(HttpServletResponse response){
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ List<ReviewJob> jobs = reviewJobService.getJobs();
|
|
|
+ out.print(new JSONArray(jobs));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadJob", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void uploadJob(String name, String description, String paperId,String startTime, String endTime,List<String>workerList,String workerDistribution, HttpServletResponse response){
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ String jobId = reviewJobService.uploadJob(name, description, paperId, startTime, endTime, workerList, workerDistribution);
|
|
|
+ JSONObject jsonObject=new JSONObject();
|
|
|
+ if(jobId==null){
|
|
|
+ jsonObject.put("status","500");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ jsonObject.put("status","200");
|
|
|
+ jsonObject.put("jobId",jobId);
|
|
|
+ }
|
|
|
+ out.print(jsonObject);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/updateJob", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void updateJob(String jobId, String name, String description, String paperId,String startTime, String endTime,List<String>workerList,String workerDistribution, HttpServletResponse response){
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ if(reviewJobService.updateJob(jobId, name, description, paperId, startTime, endTime, workerList, workerDistribution)){
|
|
|
+ result.put("status", "200");
|
|
|
+ } else {
|
|
|
+ result.put("status", "500");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.print(result);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/delJob")
|
|
|
+ @ResponseBody
|
|
|
+ public void deleteJob(String jobId, HttpServletResponse response){
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ if(reviewJobService.deleteJob(jobId)){
|
|
|
+ result.put("status", "200");
|
|
|
+ } else {
|
|
|
+ result.put("status", "500");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ PrintWriter out = response.getWriter();
|
|
|
+ out.print(result);
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|