# Conflicts: # src/core/process/Process.java # src/core/process/ProcessManagement.javawlf
commit
dbc64deef5
@ -1,4 +1,4 @@
|
||||
//package core.process;
|
||||
package core.process;
|
||||
////
|
||||
////import java.util.ArrayList;
|
||||
////import java.util.List;
|
@ -1,42 +1,48 @@
|
||||
package core.process;
|
||||
|
||||
import core.operation.Operation;
|
||||
import core.user.User;
|
||||
import error.GExcptFactory;
|
||||
import error.GExcptSQL;
|
||||
|
||||
public abstract class Process implements Cloneable{
|
||||
|
||||
private static String permission;
|
||||
private static String buttonName;
|
||||
private static String info;
|
||||
|
||||
|
||||
private String permission;
|
||||
private Operation operation;
|
||||
private String buttonName;
|
||||
private String info;
|
||||
@Override
|
||||
public Process clone(){
|
||||
//todo
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Operation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public void setInfo(String info) { this.info = info; }
|
||||
public String getButtonName() {
|
||||
return buttonName;
|
||||
}
|
||||
|
||||
public void setButtonName(String buttonName) {
|
||||
this.buttonName = buttonName;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
package core.process;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProcessManagement {//过程管理
|
||||
//private List<TemporaryProcess> temporaryProcesses;
|
||||
private Map<String, List<Process>> lastProcesses;
|
||||
//private List<AuxiliaryProcess> auxiliaryProcesses;
|
||||
public void setProcessesByJson(File file){
|
||||
//todo
|
||||
}
|
||||
/*public Process getTemporaryProcess(int index){
|
||||
return temporaryProcesses.get(index).clone();
|
||||
}
|
||||
public class ProcessManagement {
|
||||
public Condition getCondition(String userType, List<Integer> index){
|
||||
Condition condition = new Condition(this.lastProcesses.get(userType));
|
||||
for(int i:index){
|
||||
condition.add(getTemporaryProcess(i));
|
||||
return null;
|
||||
}
|
||||
return condition;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package dao;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Delete extends SQLStmt {
|
||||
private static final String fs = "DELETE ";
|
||||
private Map<String,String> limits;
|
||||
|
||||
Delete(String table, Map<String, String> limits) {
|
||||
super(table);
|
||||
this.setLimits(limits);
|
||||
}
|
||||
@Override
|
||||
public String getSQL() {
|
||||
return this.getFs()+this.getLs();
|
||||
}
|
||||
private String getLs(){
|
||||
return dao.Utils.whereAnd(this.getLimits());
|
||||
}
|
||||
public String getFs(){
|
||||
return fs+this.getTable()+" ";
|
||||
}
|
||||
|
||||
private Map<String, String> getLimits() {
|
||||
return limits;
|
||||
}
|
||||
|
||||
private void setLimits(Map<String, String> limits) {
|
||||
this.limits = limits;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package dao;
|
||||
|
||||
import utils.Utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Insert extends SQLStmt {
|
||||
private static final String fs ="INSERT INTO ";
|
||||
private Map<String, String> vMap;
|
||||
Insert(String table, Map<String, String> vMap){
|
||||
super(table);
|
||||
this.setVMap(vMap);
|
||||
}
|
||||
@Override
|
||||
public String getSQL() {
|
||||
return this.getFs()+this.getVs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFs() {
|
||||
return fs+this.getTable()+" ";
|
||||
}
|
||||
private String getVs(){
|
||||
StringBuilder sql = new StringBuilder("(");
|
||||
for(String key: this.getVMap().keySet()){
|
||||
sql.append(key).append(", ");
|
||||
}
|
||||
sql = new StringBuilder(Utils.cutTail(sql.toString(), 2) + ") ");
|
||||
sql.append("VALUES (\'");
|
||||
for(String value: vMap.values()){
|
||||
sql.append(value).append("\', \'");
|
||||
}
|
||||
sql = new StringBuilder(Utils.cutTail(sql.toString(), 3) + ")");
|
||||
return sql.toString();
|
||||
}
|
||||
private Map<String, String> getVMap() {
|
||||
return vMap;
|
||||
}
|
||||
|
||||
private void setVMap(Map<String, String> vMap) {
|
||||
this.vMap = vMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package dao;
|
||||
|
||||
public abstract class SQLStmt {
|
||||
private String table;
|
||||
SQLStmt(String table) {
|
||||
this.setTable(table);
|
||||
}
|
||||
public abstract String getSQL();
|
||||
public abstract String getFs();
|
||||
String getTable() {
|
||||
return table;
|
||||
}
|
||||
public void setTable(String table) {
|
||||
this.table = table;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Select extends SQLStmt {
|
||||
private static final String fs ="SELECT ";
|
||||
private Map<String,String> limits;
|
||||
private List<String> columns;
|
||||
private int startRow;
|
||||
private int endRow;
|
||||
public Select(List<String> columns, String table, Map<String,String> limits, int startRow, int endRow){
|
||||
super(table);
|
||||
this.setColumns(columns);
|
||||
this.setLimits(limits);
|
||||
this.setStartRow(startRow);
|
||||
this.setEndRow(endRow);
|
||||
}
|
||||
@Override
|
||||
public String getSQL() {
|
||||
return this.getFs()+this.getTs()+this.getLs();
|
||||
}
|
||||
private String getLs(){
|
||||
String sql = dao.Utils.whereAnd(this.getLimits())+" ";
|
||||
sql+="LIMIT "+this.getStartRow()+", "+this.getEndRow();
|
||||
return sql;
|
||||
}
|
||||
@Override
|
||||
public String getFs() {
|
||||
return fs+dao.Utils.linkColumn(this.getColumns())+" ";
|
||||
}
|
||||
private String getTs(){
|
||||
return "FROM "+this.getTable()+" ";
|
||||
}
|
||||
private Map<String, String> getLimits() {
|
||||
return limits;
|
||||
}
|
||||
public void setLimits(Map<String, String> limits) {
|
||||
this.limits = limits;
|
||||
}
|
||||
private List<String> getColumns() {
|
||||
return columns;
|
||||
}
|
||||
public void setColumns(List<String> columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
private int getStartRow() {
|
||||
return startRow;
|
||||
}
|
||||
|
||||
private void setStartRow(int startRow) {
|
||||
this.startRow = startRow;
|
||||
}
|
||||
|
||||
private int getEndRow() {
|
||||
return endRow;
|
||||
}
|
||||
|
||||
private void setEndRow(int endRow) {
|
||||
this.endRow = endRow;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package dao;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Update extends SQLStmt {
|
||||
private static final String fs ="UPDATE ";
|
||||
private Map<String,String> limits;
|
||||
private Map<String,String> vMap;
|
||||
|
||||
|
||||
Update(String table, Map<String, String> vMap, Map<String, String> limits) {
|
||||
super(table);
|
||||
this.setVMap(vMap);
|
||||
this.setLimits(limits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL() {
|
||||
return this.getFs()+this.getVs()+this.getLs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFs() {
|
||||
return fs+this.getTable()+" ";
|
||||
}
|
||||
private String getLs(){
|
||||
return dao.Utils.whereAnd(this.getLimits());
|
||||
}
|
||||
private String getVs(){
|
||||
String sql = "SET ";
|
||||
sql+=Utils.linkColumn(Utils.linkKeyValue(this.getVMap()))+" ";
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> getLimits() {
|
||||
return limits;
|
||||
}
|
||||
|
||||
public void setLimits(Map<String, String> limits) {
|
||||
this.limits = limits;
|
||||
}
|
||||
public Map<String, String> getVMap() {
|
||||
return vMap;
|
||||
}
|
||||
|
||||
public void setVMap(Map<String, String> vMap) {
|
||||
this.vMap = vMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,33 @@
|
||||
package dao;
|
||||
|
||||
public interface Utils {
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Utils {
|
||||
static String whereAnd(Map<String,String> map){
|
||||
List<String> list = linkKeyValue(map);
|
||||
String sql = "WHERE ";
|
||||
for(String s:list){
|
||||
sql+=s+" AND ";
|
||||
}
|
||||
sql = utils.Utils.cutTail(sql,5)+"";
|
||||
return sql;
|
||||
}
|
||||
//with ", "
|
||||
static String linkColumn(List<String> list){
|
||||
String sql = "";
|
||||
for(String c:list){
|
||||
sql+=c+", ";
|
||||
}
|
||||
return utils.Utils.cutTail(sql,2);
|
||||
}
|
||||
//with " = "
|
||||
static List<String> linkKeyValue(Map<String, String> map){
|
||||
List<String> list = new ArrayList<>();
|
||||
for(Map.Entry<String,String> entry:map.entrySet()){
|
||||
list.add(entry.getKey()+" = \'"+entry.getValue()+"\'");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue