package cn.ksource.beans; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; 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_RECORD extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("deal_user_id", "String"); KEYS.put("deal_user_name", "String"); KEYS.put("deal_time", "Long"); KEYS.put("deal_content", "String"); KEYS.put("business_id", "String"); KEYS.put("extend1", "String"); KEYS.put("extend2", "String"); KEYS.put("extend3", "String"); KEYS.put("node_id", "String"); KEYS.put("node_name", "String"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String deal_user_id; private Boolean isSetted_deal_user_id = false; private String deal_user_name; private Boolean isSetted_deal_user_name = false; private Long deal_time; private Boolean isSetted_deal_time = false; private String deal_content; private Boolean isSetted_deal_content = false; private String business_id; private Boolean isSetted_business_id = false; private String extend1; private Boolean isSetted_extend1 = false; private String extend2; private Boolean isSetted_extend2 = false; private String extend3; private Boolean isSetted_extend3 = false; private String node_id; private Boolean isSetted_node_id = false; private String node_name; private Boolean isSetted_node_name = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("deal_user_id", null); BEAN_VALUES.put("deal_user_name", null); BEAN_VALUES.put("deal_time", null); BEAN_VALUES.put("deal_content", null); BEAN_VALUES.put("business_id", null); BEAN_VALUES.put("extend1", null); BEAN_VALUES.put("extend2", null); BEAN_VALUES.put("extend3", null); BEAN_VALUES.put("node_id", null); BEAN_VALUES.put("node_name", null); } public GG_RECORD() { initBeanValues(); } public GG_RECORD(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public GG_RECORD 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_RECORD set "); if (isSetted_deal_user_id) { sBuffer.append("deal_user_id=:deal_user_id,"); } if (isSetted_deal_user_name) { sBuffer.append("deal_user_name=:deal_user_name,"); } if (isSetted_deal_time) { sBuffer.append("deal_time=:deal_time,"); } if (isSetted_deal_content) { sBuffer.append("deal_content=:deal_content,"); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id,"); } if (isSetted_extend1) { sBuffer.append("extend1=:extend1,"); } if (isSetted_extend2) { sBuffer.append("extend2=:extend2,"); } if (isSetted_extend3) { sBuffer.append("extend3=:extend3,"); } if (isSetted_node_id) { sBuffer.append("node_id=:node_id,"); } if (isSetted_node_name) { sBuffer.append("node_name=:node_name,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into GG_RECORD("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("deal_user_id,"); values.append(":deal_user_id,"); fileds.append("deal_user_name,"); values.append(":deal_user_name,"); fileds.append("deal_time,"); values.append(":deal_time,"); fileds.append("deal_content,"); values.append(":deal_content,"); fileds.append("business_id,"); values.append(":business_id,"); fileds.append("extend1,"); values.append(":extend1,"); fileds.append("extend2,"); values.append(":extend2,"); fileds.append("extend3,"); values.append(":extend3,"); fileds.append("node_id,"); values.append(":node_id,"); fileds.append("node_name,"); values.append(":node_name,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取处理人编号
* 䣺2015-51-13 hh:08 */ public String getDeal_user_id() { return deal_user_id; } /** * 设置处理人编号
* 2015-51-13 hh:08 */ public GG_RECORD setDeal_user_id(String deal_user_id) { this.deal_user_id = deal_user_id; this.isSetted_deal_user_id = true; BEAN_VALUES.put("deal_user_id",deal_user_id); return this; } /** * 获取处理人名称
* 䣺2015-51-13 hh:08 */ public String getDeal_user_name() { return deal_user_name; } /** * 设置处理人名称
* 2015-51-13 hh:08 */ public GG_RECORD setDeal_user_name(String deal_user_name) { this.deal_user_name = deal_user_name; this.isSetted_deal_user_name = true; BEAN_VALUES.put("deal_user_name",deal_user_name); return this; } /** * 获取处理时间
* 䣺2015-51-13 hh:08 */ public Long getDeal_time() { return deal_time; } /** * 设置处理时间
* 2015-51-13 hh:08 */ public GG_RECORD setDeal_time(Long deal_time) { this.deal_time = deal_time; this.isSetted_deal_time = true; BEAN_VALUES.put("deal_time",deal_time); return this; } /** * 获取记录内容
* 䣺2015-51-13 hh:08 */ public String getDeal_content() { return deal_content; } /** * 设置记录内容
* 2015-51-13 hh:08 */ public GG_RECORD setDeal_content(String deal_content) { this.deal_content = deal_content; this.isSetted_deal_content = true; BEAN_VALUES.put("deal_content",deal_content); return this; } /** * 获取业务编号
* 䣺2015-51-13 hh:08 */ public String getBusiness_id() { return business_id; } /** * 设置业务编号
* 2015-51-13 hh:08 */ public GG_RECORD setBusiness_id(String business_id) { this.business_id = business_id; this.isSetted_business_id = true; BEAN_VALUES.put("business_id",business_id); return this; } /** * 获取扩展1
* 䣺2015-51-13 hh:08 */ public String getExtend1() { return extend1; } /** * 设置扩展1
* 2015-51-13 hh:08 */ public GG_RECORD setExtend1(String extend1) { this.extend1 = extend1; this.isSetted_extend1 = true; BEAN_VALUES.put("extend1",extend1); return this; } /** * 获取扩展2
* 䣺2015-51-13 hh:08 */ public String getExtend2() { return extend2; } /** * 设置扩展2
* 2015-51-13 hh:08 */ public GG_RECORD setExtend2(String extend2) { this.extend2 = extend2; this.isSetted_extend2 = true; BEAN_VALUES.put("extend2",extend2); return this; } /** * 获取扩展3
* 䣺2015-51-13 hh:08 */ public String getExtend3() { return extend3; } /** * 设置扩展3
* 2015-51-13 hh:08 */ public GG_RECORD setExtend3(String extend3) { this.extend3 = extend3; this.isSetted_extend3 = true; BEAN_VALUES.put("extend3",extend3); return this; } /** * 获取当前节点
* 䣺2015-51-13 hh:08 */ public String getNode_id() { return node_id; } /** * 设置当前节点
* 2015-51-13 hh:08 */ public GG_RECORD setNode_id(String node_id) { this.node_id = node_id; this.isSetted_node_id = true; BEAN_VALUES.put("node_id",node_id); return this; } /** * 获取节点名称
* 䣺2015-51-13 hh:08 */ public String getNode_name() { return node_name; } /** * 设置节点名称
* 2015-51-13 hh:08 */ public GG_RECORD setNode_name(String node_name) { this.node_name = node_name; this.isSetted_node_name = true; BEAN_VALUES.put("node_name",node_name); 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_RECORD getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } @Override public GG_RECORD queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from GG_RECORD where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_deal_user_id) { sBuffer.append("deal_user_id=:deal_user_id and "); } if (isSetted_deal_user_name) { sBuffer.append("deal_user_name=:deal_user_name and "); } if (isSetted_deal_time) { sBuffer.append("deal_time=:deal_time and "); } if (isSetted_deal_content) { sBuffer.append("deal_content=:deal_content and "); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id and "); } if (isSetted_extend1) { sBuffer.append("extend1=:extend1 and "); } if (isSetted_extend2) { sBuffer.append("extend2=:extend2 and "); } if (isSetted_extend3) { sBuffer.append("extend3=:extend3 and "); } if (isSetted_node_id) { sBuffer.append("node_id=:node_id and "); } if (isSetted_node_name) { sBuffer.append("node_name=:node_name and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "GG_RECORD"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public GG_RECORD insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public GG_RECORD update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public GG_RECORD 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_RECORD 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("DEAL_USER_ID"); BEAN_VALUES.put("deal_user_id",obj); this.setDeal_user_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("DEAL_USER_NAME"); BEAN_VALUES.put("deal_user_name",obj); this.setDeal_user_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("DEAL_TIME"); BEAN_VALUES.put("deal_time",obj); this.setDeal_time(ConvertUtil.obj2Long(obj)); obj = rs.getObject("DEAL_CONTENT"); BEAN_VALUES.put("deal_content",obj); this.setDeal_content(ConvertUtil.obj2Str(obj)); obj = rs.getObject("BUSINESS_ID"); BEAN_VALUES.put("business_id",obj); this.setBusiness_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND1"); BEAN_VALUES.put("extend1",obj); this.setExtend1(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND2"); BEAN_VALUES.put("extend2",obj); this.setExtend2(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND3"); BEAN_VALUES.put("extend3",obj); this.setExtend3(ConvertUtil.obj2Str(obj)); obj = rs.getObject("NODE_ID"); BEAN_VALUES.put("node_id",obj); this.setNode_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("NODE_NAME"); BEAN_VALUES.put("node_name",obj); this.setNode_name(ConvertUtil.obj2Str(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_RECORD newInstance(){ return new GG_RECORD(); } }