diff --git a/src/core/operation/Delete.java b/src/core/operation/Delete.java new file mode 100644 index 0000000..c9a78c5 --- /dev/null +++ b/src/core/operation/Delete.java @@ -0,0 +1,15 @@ +package core.operation; + +import core.user.User; +import dao.DBManagement; +import error.GExcptSQL; + +public class Delete extends Operation { + @Override + public void execute(User subject) throws GExcptSQL { + String id = (String)options.get("id"); + String sql = "DELETE FROM graduation_design WHERE id = \'"+ + id+"\'"; + DBManagement.update(sql); + } +} diff --git a/src/core/operation/Delete.json b/src/core/operation/Delete.json new file mode 100644 index 0000000..183384f --- /dev/null +++ b/src/core/operation/Delete.json @@ -0,0 +1,3 @@ +{ + "id": "java.lang.String" +} \ No newline at end of file diff --git a/src/core/operation/DownloadFile.java b/src/core/operation/DownloadFile.java new file mode 100644 index 0000000..1154c74 --- /dev/null +++ b/src/core/operation/DownloadFile.java @@ -0,0 +1,4 @@ +package core.operation; + +public class DownloadFile { +} diff --git a/src/core/operation/FillInformation.java b/src/core/operation/FillInformation.java new file mode 100644 index 0000000..4c954b2 --- /dev/null +++ b/src/core/operation/FillInformation.java @@ -0,0 +1,4 @@ +package core.operation; + +public class FillInformation { +} diff --git a/src/core/operation/Operation.java b/src/core/operation/Operation.java index 195dbfa..7c7971f 100644 --- a/src/core/operation/Operation.java +++ b/src/core/operation/Operation.java @@ -9,8 +9,8 @@ import java.util.Map; public abstract class Operation { - private Map options; - private User subject; + protected Map options; + protected User subject; Operation(){ super(); } @@ -38,6 +38,6 @@ public abstract class Operation { } this.options.put(key,value); } - public abstract void execute(User subject) throws GExcptSQL; + public abstract void execute(User subject) throws Exception; } diff --git a/src/core/operation/Search.java b/src/core/operation/Search.java new file mode 100644 index 0000000..5176b57 --- /dev/null +++ b/src/core/operation/Search.java @@ -0,0 +1,22 @@ +package core.operation; + +import core.user.User; +import dao.DBManagement; + +import java.sql.ResultSet; + +public class Search extends Operation { + @Override + public void execute(User subject) throws Exception { + String table = (String)options.get("table"); + String field = (String)options.get("field"); + String value = (String)options.get("value"); + int start = (int)options.get("start"); + int end = (int)options.get("end"); + String sql = "SELECT * FROM "+table+ + " WHERE "+field+" = \'"+value+"\'"+ + " limit "+start+", "+end; + ResultSet rs = DBManagement.query(sql); + //todo + } +} diff --git a/src/core/operation/Search.json b/src/core/operation/Search.json new file mode 100644 index 0000000..38d8115 --- /dev/null +++ b/src/core/operation/Search.json @@ -0,0 +1,8 @@ +{ + "table": "java.lang.String", + "field": "java.lang.String", + "value": "java.lang.String", + "start": "int", + "end": "int", + "return": "java.lang.String[][]" +} \ No newline at end of file diff --git a/src/core/operation/Select.java b/src/core/operation/Select.java index 3ea81dd..f58ea03 100644 --- a/src/core/operation/Select.java +++ b/src/core/operation/Select.java @@ -8,11 +8,15 @@ import java.util.Map; public class Select extends Operation { - private Map options; - private User subject; @Override public void execute(User subject) throws GExcptSQL { - this.setSubject(subject); - DBManagement.update("update stu "); + String student_id = (String)options.get("student_id"); + String teacher_id = (String)options.get("teacher_id"); + String id = student_id; + String sql = "INSERT INTO graduation_design VALUES (\'"+ + id+"\', "+ + student_id+"\', "+ + teacher_id+"\', \'m\', \'m\')"; + DBManagement.update(sql); } } diff --git a/src/core/operation/Select.json b/src/core/operation/Select.json new file mode 100644 index 0000000..6b2332b --- /dev/null +++ b/src/core/operation/Select.json @@ -0,0 +1,4 @@ +{ + "student_id": "java.lang.String", + "teacher_id": "java.lang.String" +} \ No newline at end of file