package cn.ksource.beans; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import cn.ksource.core.dao.BaseBean; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.StringUtil; /** * 组织架构 */ public class GG_ZZJG extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("jgmc", "String"); KEYS.put("type", "Integer"); KEYS.put("beiz", "String"); KEYS.put("sjbh", "String"); KEYS.put("sxh", "Integer"); KEYS.put("cengj", "Integer"); KEYS.put("zt", "Integer"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String jgmc; private Boolean isSetted_jgmc = false; private Integer type; private Boolean isSetted_type = false; private String beiz; private Boolean isSetted_beiz = false; private String sjbh; private Boolean isSetted_sjbh = false; private Integer sxh; private Boolean isSetted_sxh = false; private Integer cengj; private Boolean isSetted_cengj = false; private Integer zt; private Boolean isSetted_zt = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("jgmc", null); BEAN_VALUES.put("type", null); BEAN_VALUES.put("beiz", null); BEAN_VALUES.put("sjbh", null); BEAN_VALUES.put("sxh", null); BEAN_VALUES.put("cengj", null); BEAN_VALUES.put("zt", null); } public GG_ZZJG() { initBeanValues(); } public GG_ZZJG(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public GG_ZZJG setId(String id) { this.id = id; this.isSetted_id = true; BEAN_VALUES.put("id",id); return this; } @Override public String getUpdateSql() { StringBuffer sBuffer = new StringBuffer("update GG_ZZJG set "); if (isSetted_jgmc) { sBuffer.append("jgmc=:jgmc,"); } if (isSetted_type) { sBuffer.append("type=:type,"); } if (isSetted_beiz) { sBuffer.append("beiz=:beiz,"); } if (isSetted_sjbh) { sBuffer.append("sjbh=:sjbh,"); } if (isSetted_sxh) { sBuffer.append("sxh=:sxh,"); } if (isSetted_cengj) { sBuffer.append("cengj=:cengj,"); } if (isSetted_zt) { sBuffer.append("zt=:zt,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into GG_ZZJG("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("jgmc,"); values.append(":jgmc,"); fileds.append("type,"); values.append(":type,"); fileds.append("beiz,"); values.append(":beiz,"); fileds.append("sjbh,"); values.append(":sjbh,"); fileds.append("sxh,"); values.append(":sxh,"); fileds.append("cengj,"); values.append(":cengj,"); fileds.append("zt,"); values.append(":zt,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取机构名称
* 䣺2014-02-26 hh:06 */ public String getJgmc() { return jgmc; } /** * 设置机构名称
* 2014-02-26 hh:06 */ public GG_ZZJG setJgmc(String jgmc) { this.jgmc = jgmc; this.isSetted_jgmc = true; BEAN_VALUES.put("jgmc",jgmc); return this; } /** * 获取类型(1=部门;2=部门内分组)
* 䣺2014-02-26 hh:06 */ public Integer getType() { return type; } /** * 设置类型(1=部门;2=部门内分组)
* 2014-02-26 hh:06 */ public GG_ZZJG setType(Integer type) { this.type = type; this.isSetted_type = true; BEAN_VALUES.put("type",type); return this; } /** * 获取说明
* 䣺2014-02-26 hh:06 */ public String getBeiz() { return beiz; } /** * 设置说明
* 2014-02-26 hh:06 */ public GG_ZZJG setBeiz(String beiz) { this.beiz = beiz; this.isSetted_beiz = true; BEAN_VALUES.put("beiz",beiz); return this; } /** * 获取上级编号
* 䣺2014-02-26 hh:06 */ public String getSjbh() { return sjbh; } /** * 设置上级编号
* 2014-02-26 hh:06 */ public GG_ZZJG setSjbh(String sjbh) { this.sjbh = sjbh; this.isSetted_sjbh = true; BEAN_VALUES.put("sjbh",sjbh); return this; } /** * 获取顺序号
* 䣺2014-02-26 hh:06 */ public Integer getSxh() { return sxh; } /** * 设置顺序号
* 2014-02-26 hh:06 */ public GG_ZZJG setSxh(Integer sxh) { this.sxh = sxh; this.isSetted_sxh = true; BEAN_VALUES.put("sxh",sxh); return this; } /** * 获取层级(备用字段,主要用来标注部门隶属关系)
* 䣺2014-02-26 hh:06 */ public Integer getCengj() { return cengj; } /** * 设置层级(备用字段,主要用来标注部门隶属关系)
* 2014-02-26 hh:06 */ public GG_ZZJG setCengj(Integer cengj) { this.cengj = cengj; this.isSetted_cengj = true; BEAN_VALUES.put("cengj",cengj); return this; } /** * 获取状态(1=在用;2=已删除)
* 䣺2014-02-26 hh:06 */ public Integer getZt() { return zt; } /** * 设置状态(1=在用;2=已删除)
* 2014-02-26 hh:06 */ public GG_ZZJG setZt(Integer zt) { this.zt = zt; this.isSetted_zt = true; BEAN_VALUES.put("zt",zt); return this; } /** * 使用ID删除Bean
*/ public void deleteById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("删除bean时ID不能为空"); } dao.execute("delete from " + getTableName() + " where id = :id", BEAN_VALUES); } @Override public GG_ZZJG getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } public GG_ZZJG getGG_ZZJG() { if(null == getSjbh()){ throw new RuntimeException("SJBHֵΪnull"); } return new GG_ZZJG(getSjbh()).getInstanceById(); //return dao.queryForBean("select * from gg_zzjg where ID=:sjbh", new GG_ZZJG(this.getSjbh())); } public List getGG_ZZJGList() { if(null == getId()){ throw new RuntimeException("IDֵΪnull"); } return dao.queryForList("select * from gg_zzjg where SJBH=:sjbh",this); } @Override public GG_ZZJG queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from GG_ZZJG where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_jgmc) { sBuffer.append("jgmc=:jgmc and "); } if (isSetted_type) { sBuffer.append("type=:type and "); } if (isSetted_beiz) { sBuffer.append("beiz=:beiz and "); } if (isSetted_sjbh) { sBuffer.append("sjbh=:sjbh and "); } if (isSetted_sxh) { sBuffer.append("sxh=:sxh and "); } if (isSetted_cengj) { sBuffer.append("cengj=:cengj and "); } if (isSetted_zt) { sBuffer.append("zt=:zt and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "GG_ZZJG"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public GG_ZZJG insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public GG_ZZJG update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public GG_ZZJG insertOrUpdate(){ if (StringUtils.isNotBlank(id)) { return update(); } else { return insert(); } } /** * 通过ID获取该条信息的Map结构 */ public Map getBeanMapById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("ID不能为空!"); } return dao.queryForMap("select * from GG_ZZJG where id=:id",BEAN_VALUES); } public Object mapRow(ResultSet rs, int rownum) throws SQLException { Object id = rs.getObject("ID"); this.setId(ConvertUtil.obj2Str(id)); BEAN_VALUES.put("id",id); Object obj = null; obj = rs.getObject("JGMC"); BEAN_VALUES.put("jgmc",obj); this.setJgmc(ConvertUtil.obj2Str(obj)); obj = rs.getObject("TYPE"); BEAN_VALUES.put("type",obj); this.setType(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("BEIZ"); BEAN_VALUES.put("beiz",obj); this.setBeiz(ConvertUtil.obj2Str(obj)); obj = rs.getObject("SJBH"); BEAN_VALUES.put("sjbh",obj); this.setSjbh(ConvertUtil.obj2Str(obj)); obj = rs.getObject("SXH"); BEAN_VALUES.put("sxh",obj); this.setSxh(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("CENGJ"); BEAN_VALUES.put("cengj",obj); this.setCengj(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("ZT"); BEAN_VALUES.put("zt",obj); this.setZt(ConvertUtil.obj2Integer(obj)); return this; } public String toString() { StringBuffer sb = new StringBuffer("["); for (Iterator iterator = KEYS.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); sb.append(key+"=" + BEAN_VALUES.get(key)+","); } sb.append("]"); return sb.toString(); } public GG_ZZJG newInstance(){ return new GG_ZZJG(); } }