rewrite Process

hechu1
zhai_lw 6 years ago
parent 78666e3a41
commit e2b0fcc128

@ -7,7 +7,7 @@ import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class C_StudentUploadFinishedProduct extends TempProcess { public class C_StudentUploadFinishedProduct extends C_UploadFile {
File finishedProduct; File finishedProduct;
String graduationDesignId; String graduationDesignId;

@ -0,0 +1,7 @@
package core.process;
public abstract class C_UploadFile extends TempProcess {
public String getJspURL(){
return "/home/upload_file.jsp";
}
}

@ -171,6 +171,11 @@ public class DBManagement {
String sql = update.getSQL(); String sql = update.getSQL();
update(sql); update(sql);
} }
public static void updateAll(String table, List<String> fields, String increment) throws GExcptSQL {
UpdateAll updateAll = new UpdateAll(table,fields,increment);
String sql = updateAll.getSQL();
update(sql);
}
public static List<String[]> query(String sql) throws Exception { public static List<String[]> query(String sql) throws Exception {
if(!ifInit) return null; if(!ifInit) return null;
List<String[]> ls; List<String[]> ls;
@ -222,7 +227,5 @@ public class DBManagement {
} }
} }
public static void updateAll(String table, List<String> fields, String increment) {
}
} }

@ -0,0 +1,48 @@
package dao;
import java.util.List;
public class UpdateAll extends SQLStmt {
private static final String fs ="UPDATE ";
List<String> fields;
String increment;
public UpdateAll(String table, List<String> fields, String increment) {
super(table);
this.setFields(fields);
this.setIncrement(increment);
}
@Override
public String getSQL() {
return this.getFs()+this.getUs();
}
@Override
public String getFs() {
return fs+this.getTable()+" ";
}
public String getUs(){
String us = "SET ";
for(String s:this.getFields()){
us+=s+" = "+s+" + "+this.getIncrement()+", ";
}
return utils.Utils.cutTail(us,2);
}
public List<String> getFields() {
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
public String getIncrement() {
return increment;
}
public void setIncrement(String increment) {
this.increment = increment;
}
}

@ -2,6 +2,7 @@ package gdms;
import dao.DBManagement; import dao.DBManagement;
import error.GExcptInit; import error.GExcptInit;
import error.GExcptSQL;
import java.util.*; import java.util.*;
@ -25,14 +26,26 @@ public class GDMS {
public void run() { public void run() {
List<String> fields = new ArrayList<>(); List<String> fields = new ArrayList<>();
fields.add("teacher_choose_student_status"); fields.add("teacher_choose_student_status");
try {
DBManagement.updateAll("graduation_design",fields,"1"); DBManagement.updateAll("graduation_design",fields,"1");
} catch (GExcptSQL gExcptSQL) {
gExcptSQL.printStackTrace();
System.exit(1);
}
} }
}; };
case "student_choose_teacher_start_date": case "student_choose_teacher_start_date":
return new TimerTask() { return new TimerTask() {
@Override @Override
public void run() { public void run() {
; List<String> fields = new ArrayList<>();
fields.add("teacher_choose_student_status");
try {
DBManagement.updateAll("graduation_design",fields,"1");
} catch (GExcptSQL gExcptSQL) {
gExcptSQL.printStackTrace();
System.exit(1);
}
} }
}; };
case "choose_end_date": case "choose_end_date":

@ -2,7 +2,9 @@ package gdms;
import core.operation.utils.Utils; import core.operation.utils.Utils;
import core.process.C_StudentSelectTeacher; import core.process.C_StudentSelectTeacher;
import dao.DBManagement;
import dao.Select; import dao.Select;
import dao.UpdateAll;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -11,12 +13,12 @@ import java.util.Map;
public class test { public class test {
public static void main(String[] args){ public static void main(String[] args){
String s = "graduation_design_finished_product_reviewer_score.reviewer_teacher_id"; List<String> ls = new ArrayList<>();
String[] ss = s.split("\\."); ls.add("teacher_choose_student_status");
System.out.println(ss[0]); ls.add("student_choose_teacher_status");
UpdateAll s = new UpdateAll("graduation_design",ls,"10");
System.out.println(s.getSQL());
}
static void changeB(String a){
a="B";
} }
} }

Loading…
Cancel
Save