You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.7 KiB
78 lines
2.7 KiB
package core.process;
|
|
|
|
import core.operation.Search;
|
|
import error.GExcptInit;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class C_TeacherSearchStudent extends TempProcess {
|
|
String studentId;
|
|
|
|
static String table="student";
|
|
|
|
public Map<String,String> search() throws Exception{
|
|
if(!check()) throw new GExcptInit("studentId Attrs init error!");
|
|
Map<String,String> studentInfo =new HashMap<>();
|
|
Search search = new Search() ;
|
|
search.setOptions(new HashMap<>());
|
|
search.addOptions("table",table);
|
|
List<String> fields = new ArrayList<>();
|
|
fields.add("*");
|
|
search.addOptions("field",fields);
|
|
Map<String,String> limits = new HashMap<>();
|
|
limits.put("id",this.getStudentId());
|
|
search.addOptions("limits",limits);
|
|
search.addOptions("start",0);
|
|
search.addOptions("end",1);
|
|
Map<String, Object> options = search.execute(null);
|
|
List<String[]> result = (List<String[]>) options.get("result");
|
|
String[] s = result.get(0);
|
|
studentInfo.put("id",s[0]);
|
|
studentInfo.put("name",s[2]);
|
|
studentInfo.put("e_mail_location",s[3]);
|
|
studentInfo.put("phone_number",s[4]);
|
|
return studentInfo;
|
|
}
|
|
public List<Map<String,String>> _search() throws Exception{
|
|
if(!check()) throw new GExcptInit("studentId Attrs init error!");
|
|
Search search = new Search() ;
|
|
search.setOptions(new HashMap<>());
|
|
search.addOptions("table",table);
|
|
List<String> fields = new ArrayList<>();
|
|
fields.add("*");
|
|
search.addOptions("field",fields);
|
|
Map<String,String> limits = new HashMap<>();
|
|
limits.put("id",this.getStudentId());
|
|
search.addOptions("limits",limits);
|
|
search.addOptions("start",0);
|
|
search.addOptions("end",1);
|
|
Map<String, Object> options = search.execute(null);
|
|
List<String[]> result = (List<String[]>) options.get("result");
|
|
List<Map<String,String>> studentsInfo = new ArrayList<>();
|
|
for(String[] s:result){
|
|
Map<String,String> studentInfo = new HashMap<>();
|
|
studentInfo.put("id",s[0]);
|
|
studentInfo.put("name",s[2]);
|
|
studentInfo.put("e_mail_location",s[3]);
|
|
studentInfo.put("phone_number",s[4]);
|
|
studentsInfo.add(studentInfo);
|
|
}
|
|
return studentsInfo;
|
|
}
|
|
protected boolean check() {
|
|
if(this.getStudentId()==null)
|
|
return false;
|
|
return true;
|
|
}
|
|
public String getStudentId(){
|
|
return studentId;
|
|
}
|
|
public void setStudentId(String studentId){
|
|
this.studentId=studentId;
|
|
}
|
|
|
|
}
|