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 WORKFLOW_TEMPLATE_NODE_PARTNER extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("partner_id", "String"); KEYS.put("node_id", "String"); KEYS.put("dealer_type", "Integer"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String partner_id; private Boolean isSetted_partner_id = false; private String node_id; private Boolean isSetted_node_id = false; private Integer dealer_type; private Boolean isSetted_dealer_type = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("partner_id", null); BEAN_VALUES.put("node_id", null); BEAN_VALUES.put("dealer_type", null); } public WORKFLOW_TEMPLATE_NODE_PARTNER() { initBeanValues(); } public WORKFLOW_TEMPLATE_NODE_PARTNER(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public WORKFLOW_TEMPLATE_NODE_PARTNER 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 WORKFLOW_TEMPLATE_NODE_PARTNER set "); if (isSetted_partner_id) { sBuffer.append("partner_id=:partner_id,"); } if (isSetted_node_id) { sBuffer.append("node_id=:node_id,"); } if (isSetted_dealer_type) { sBuffer.append("dealer_type=:dealer_type,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into WORKFLOW_TEMPLATE_NODE_PARTNER("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("partner_id,"); values.append(":partner_id,"); fileds.append("node_id,"); values.append(":node_id,"); fileds.append("dealer_type,"); values.append(":dealer_type,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取加盟商编号
* 䣺2015-06-04 hh:05 */ public String getPartner_id() { return partner_id; } /** * 设置加盟商编号
* 2015-06-04 hh:05 */ public WORKFLOW_TEMPLATE_NODE_PARTNER setPartner_id(String partner_id) { this.partner_id = partner_id; this.isSetted_partner_id = true; BEAN_VALUES.put("partner_id",partner_id); return this; } /** * 获取环节编号
* 䣺2015-06-04 hh:05 */ public String getNode_id() { return node_id; } /** * 设置环节编号
* 2015-06-04 hh:05 */ public WORKFLOW_TEMPLATE_NODE_PARTNER setNode_id(String node_id) { this.node_id = node_id; this.isSetted_node_id = true; BEAN_VALUES.put("node_id",node_id); return this; } /** * 获取处理人类型(1=指定角色;2=指定人员;3=上环节指定)
* 䣺2015-06-04 hh:05 */ public Integer getDealer_type() { return dealer_type; } /** * 设置处理人类型(1=指定角色;2=指定人员;3=上环节指定)
* 2015-06-04 hh:05 */ public WORKFLOW_TEMPLATE_NODE_PARTNER setDealer_type(Integer dealer_type) { this.dealer_type = dealer_type; this.isSetted_dealer_type = true; BEAN_VALUES.put("dealer_type",dealer_type); 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 WORKFLOW_TEMPLATE_NODE_PARTNER getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } @Override public WORKFLOW_TEMPLATE_NODE_PARTNER queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from WORKFLOW_TEMPLATE_NODE_PARTNER where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_partner_id) { sBuffer.append("partner_id=:partner_id and "); } if (isSetted_node_id) { sBuffer.append("node_id=:node_id and "); } if (isSetted_dealer_type) { sBuffer.append("dealer_type=:dealer_type and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "WORKFLOW_TEMPLATE_NODE_PARTNER"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public WORKFLOW_TEMPLATE_NODE_PARTNER insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public WORKFLOW_TEMPLATE_NODE_PARTNER update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public WORKFLOW_TEMPLATE_NODE_PARTNER 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 WORKFLOW_TEMPLATE_NODE_PARTNER 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("PARTNER_ID"); BEAN_VALUES.put("partner_id",obj); this.setPartner_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("NODE_ID"); BEAN_VALUES.put("node_id",obj); this.setNode_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("DEALER_TYPE"); BEAN_VALUES.put("dealer_type",obj); this.setDealer_type(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 WORKFLOW_TEMPLATE_NODE_PARTNER newInstance(){ return new WORKFLOW_TEMPLATE_NODE_PARTNER(); } }