部门bean主要代码
private String deptname;//部门名称
private String deptcode;//部门编码
private String fdeptcode;//上级部门编码
private String isleaf;//是否为叶子部门
private List<Dep> children;//子部门集合
private String id;//部门id
//设置如何获取子部门
public void setChildren(String fdeptcode) {
if(isleaf.equals("1")){
}else{
List<Dep> listDep=new ArrayList<Dep>();
DbConn db=new DbConn();
ResultSet rst=null;
String sql1="select deptcode from comdept where fdeptcode='"+fdeptcode+"'";
try {
rst=db.executeQuery(sql1);
while(rst.next()){
String depcode=rst.getString("deptcode");
//调用构造方法如果dep还有子部门也会放到dep下
Dep dep=new Dep(depcode);
listDep.add(dep);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.children = listDep;
}
}
//构造方法
public Dep(String deptcode){
this.deptcode=deptcode;
setAll(deptcode);
setChildren(deptcode);
}