Browse Source

上传job answer item的实体

MengyangDuan 5 years ago
parent
commit
6441ad005a

+ 57 - 1
src/main/java/edu/nju/controller/ExtraController.java

@@ -264,6 +264,59 @@ public class ExtraController {
 		}
 	}
 
+//	@RequestMapping(value = "/uploadExamUrl", method = RequestMethod.POST)
+//	@ResponseBody
+//	public String uploadExamUrl1(String file, String file_name, String paper_type,
+//								String case_id, String test_type, String description, String app_name,
+//								String if_test_case,String if_bug) {
+//		try {
+//
+//			File dest = new File("/Users/hannatao/Downloads/" + file_name);
+//			if(!dest.getParentFile().exists()) { dest.getParentFile().mkdirs(); }
+//			//从oss下载文件
+//			// 统一资源
+//			URL url = new URL(file);
+//			// 连接类的父类,抽象类
+//			URLConnection urlConnection = url.openConnection();
+//			// http的连接类
+//			HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
+//			//设置超时
+//			httpURLConnection.setConnectTimeout(1000*5);
+//			//设置请求方式,默认是GET
+////          httpURLConnection.setRequestMethod("GET");
+//			// 设置字符编码
+//			httpURLConnection.setRequestProperty("Charset", "UTF-8");
+//			// 打开到此 URL引用的资源的通信链接(如果尚未建立这样的连接)。
+//			httpURLConnection.connect();
+//			// 文件大小
+//			int fileLength = httpURLConnection.getContentLength();
+//
+//			// 建立链接从请求中获取数据
+//			URLConnection con = url.openConnection();
+//			BufferedInputStream bin = new BufferedInputStream(httpURLConnection.getInputStream());
+//			// 指定文件名称(有需求可以自定义)
+//			// 指定存放位置(有需求可以自定义)
+//
+//
+//			OutputStream out = new FileOutputStream(dest);
+//			int size = 0;
+//			int len = 0;
+//			byte[] buf = new byte[2048];
+//			while ((size = bin.read(buf)) != -1) {
+//				len += size;
+//				out.write(buf, 0, size);
+//			}
+//			// 关闭资源
+//			bin.close();
+//			out.close();
+//			String json = extraService.saveExam1(case_id, dest.getPath(), app_name, paper_type, test_type, description,if_test_case,if_bug);
+//			return json;
+//		} catch (IOException e) {
+//			e.printStackTrace();
+//			return "";
+//		}
+//	}
+
 	/**
 	 * 47.99.140.117:9001/Bug/api/extra/getExamList
 	 *
@@ -312,8 +365,11 @@ public class ExtraController {
 	@RequestMapping(value = "/uploadTestCase", method = RequestMethod.POST)
 	@ResponseBody
 	public void uploadTestCase(String report_id, String name, String front, String behind, 
-			String description, HttpServletResponse response) {
+			String description,String if_execute,String if_bug, HttpServletResponse response) {
 		try {
+
+			System.out.println(if_execute);
+			System.out.println(if_bug);
 			String id = extraService.saveTestCase(report_id, name, front, behind, description);
 			PrintWriter out = response.getWriter();
 			JSONObject result = new JSONObject();

+ 33 - 1
src/main/java/edu/nju/entities/Exam.java

@@ -25,6 +25,10 @@ public class Exam implements java.io.Serializable {
 
 	private String description;
 
+//	private String if_test_case;
+//
+//	private String if_bug;
+
 	@PersistenceConstructor
 	public Exam(String id, String json, String app_name, String paper_type, String test_type, String description) {
 		this.id = id;
@@ -35,6 +39,19 @@ public class Exam implements java.io.Serializable {
 		this.description = description;
 	}
 
+//	@PersistenceConstructor
+//	public Exam(String id, String json, String app_name, String paper_type, String test_type, String description,
+//				String if_test_case,String if_bug) {
+//		this.id = id;
+//		this.json = json;
+//		this.app_name = app_name;
+//		this.paper_type = paper_type;
+//		this.test_type = test_type;
+//		this.description = description;
+//		this.if_test_case=if_test_case;
+//		this.if_bug=if_bug;
+//	}
+
 	public String getId() {
 		return id;
 	}
@@ -82,5 +99,20 @@ public class Exam implements java.io.Serializable {
 	public void setDescription(String description) {
 		this.description = description;
 	}
-	
+
+//	public String getIf_test_case() {
+//		return if_test_case;
+//	}
+//
+//	public void setIf_test_case(String if_test_case) {
+//		this.if_test_case = if_test_case;
+//	}
+//
+//	public String getIf_bug() {
+//		return if_bug;
+//	}
+//
+//	public void setIf_bug(String if_bug) {
+//		this.if_bug = if_bug;
+//	}
 }

+ 36 - 0
src/main/java/edu/nju/entities/TestCase.java

@@ -29,6 +29,10 @@ public class TestCase implements java.io.Serializable {
 	
 	private String create_time_millis;
 
+//	private String if_execute;
+//
+//	private String if_bug;
+
 	@PersistenceConstructor
 	public TestCase(String name, String front, String behind, String description, String report_id, String create_time_millis) {
 		this.name = name;
@@ -37,8 +41,23 @@ public class TestCase implements java.io.Serializable {
 		this.behind = behind;
 		this.description = description;
 		this.create_time_millis = create_time_millis;
+
 	}
 
+//	@PersistenceConstructor
+//	public TestCase(String name, String front, String behind, String description, String report_id, String create_time_millis,
+//					String if_execute,String if_Bug) {
+//		this.name = name;
+//		this.report_id = report_id;
+//		this.front = front;
+//		this.behind = behind;
+//		this.description = description;
+//		this.create_time_millis = create_time_millis;
+//		this.if_execute=if_execute;
+//		this.if_bug=if_Bug;
+//	}
+
+
 	public String getId() {
 		return id;
 	}
@@ -94,5 +113,22 @@ public class TestCase implements java.io.Serializable {
 	public void setCreate_time_millis(String create_time_millis) {
 		this.create_time_millis = create_time_millis;
 	}
+
+//	public String getIf_execute() {
+//		return if_execute;
+//	}
+//
+//	public void setIf_execute(String if_execute) {
+//		this.if_execute = if_execute;
+//	}
+//
+//	public String getIf_bug() {
+//		return if_bug;
+//	}
+//
+//	public void setIf_bug(String if_bug) {
+//		this.if_bug = if_bug;
+//	}
+
 	
 }

+ 14 - 0
src/main/java/edu/nju/service/ExtraService.java

@@ -37,6 +37,11 @@ public class ExtraService {
 		TestCase testCase = new TestCase(name, front, behind, description, report_id, Long.toString(System.currentTimeMillis()));
 		return testDao.save(testCase);
 	}
+
+//	public String saveTestCase(String report_id, String name, String front, String behind, String description,String if_execute,String if_bug) {
+//		TestCase testCase = new TestCase(name, front, behind, description, report_id, Long.toString(System.currentTimeMillis()),if_execute,if_bug);
+//		return testDao.save(testCase);
+//	}
 	
 	public boolean updateTestCase(String id, String report_id, String name, String front, String behind, String description) {
 		try {
@@ -90,6 +95,15 @@ public class ExtraService {
 		return json;
 	}
 
+// 	public String saveExam1(String case_id, String path, String app_name, String paper_type, String test_type, String description,
+//							String if_test_case,String if_bug) {
+//		String json = ExcelToJson.ExcelTranse(path).toString();
+////		Exam exam = new Exam(case_id, json, app_name, paper_type, test_type, description);
+//		Exam exam = new Exam(case_id, json, app_name, paper_type, test_type, description,if_test_case,if_bug);
+//		examDao.save(exam);
+//		return json;
+//	}
+
 	public JSONArray getExamList() {
 		List<Exam> result = examDao.findAll();
 		JSONArray array = new JSONArray();