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 SUPPLIER_MODIFY_RECORD extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("supplier_id", "String"); KEYS.put("modify_id", "String"); KEYS.put("modify_name", "String"); KEYS.put("gmt_modify", "Long"); KEYS.put("modify_type", "Integer"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String supplier_id; private Boolean isSetted_supplier_id = false; private String modify_id; private Boolean isSetted_modify_id = false; private String modify_name; private Boolean isSetted_modify_name = false; private Long gmt_modify; private Boolean isSetted_gmt_modify = false; private Integer modify_type; private Boolean isSetted_modify_type = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("supplier_id", null); BEAN_VALUES.put("modify_id", null); BEAN_VALUES.put("modify_name", null); BEAN_VALUES.put("gmt_modify", null); BEAN_VALUES.put("modify_type", null); } public SUPPLIER_MODIFY_RECORD() { initBeanValues(); } public SUPPLIER_MODIFY_RECORD(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public SUPPLIER_MODIFY_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 SUPPLIER_MODIFY_RECORD set "); if (isSetted_supplier_id) { sBuffer.append("supplier_id=:supplier_id,"); } if (isSetted_modify_id) { sBuffer.append("modify_id=:modify_id,"); } if (isSetted_modify_name) { sBuffer.append("modify_name=:modify_name,"); } if (isSetted_gmt_modify) { sBuffer.append("gmt_modify=:gmt_modify,"); } if (isSetted_modify_type) { sBuffer.append("modify_type=:modify_type,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into SUPPLIER_MODIFY_RECORD("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("supplier_id,"); values.append(":supplier_id,"); fileds.append("modify_id,"); values.append(":modify_id,"); fileds.append("modify_name,"); values.append(":modify_name,"); fileds.append("gmt_modify,"); values.append(":gmt_modify,"); fileds.append("modify_type,"); values.append(":modify_type,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取供应商ID
* 䣺2017-42-11 hh:06 */ public String getSupplier_id() { return supplier_id; } /** * 设置供应商ID
* 2017-42-11 hh:06 */ public SUPPLIER_MODIFY_RECORD setSupplier_id(String supplier_id) { this.supplier_id = supplier_id; this.isSetted_supplier_id = true; BEAN_VALUES.put("supplier_id",supplier_id); return this; } /** * 获取修改人ID
* 䣺2017-42-11 hh:06 */ public String getModify_id() { return modify_id; } /** * 设置修改人ID
* 2017-42-11 hh:06 */ public SUPPLIER_MODIFY_RECORD setModify_id(String modify_id) { this.modify_id = modify_id; this.isSetted_modify_id = true; BEAN_VALUES.put("modify_id",modify_id); return this; } /** * 获取修改人
* 䣺2017-42-11 hh:06 */ public String getModify_name() { return modify_name; } /** * 设置修改人
* 2017-42-11 hh:06 */ public SUPPLIER_MODIFY_RECORD setModify_name(String modify_name) { this.modify_name = modify_name; this.isSetted_modify_name = true; BEAN_VALUES.put("modify_name",modify_name); return this; } /** * 获取修改时间
* 䣺2017-42-11 hh:06 */ public Long getGmt_modify() { return gmt_modify; } /** * 设置修改时间
* 2017-42-11 hh:06 */ public SUPPLIER_MODIFY_RECORD setGmt_modify(Long gmt_modify) { this.gmt_modify = gmt_modify; this.isSetted_gmt_modify = true; BEAN_VALUES.put("gmt_modify",gmt_modify); return this; } /** * 获取类型【1 创建 2 修改】
* 䣺2017-42-11 hh:06 */ public Integer getModify_type() { return modify_type; } /** * 设置类型【1 创建 2 修改】
* 2017-42-11 hh:06 */ public SUPPLIER_MODIFY_RECORD setModify_type(Integer modify_type) { this.modify_type = modify_type; this.isSetted_modify_type = true; BEAN_VALUES.put("modify_type",modify_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 SUPPLIER_MODIFY_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 SUPPLIER_MODIFY_RECORD queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from SUPPLIER_MODIFY_RECORD where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_supplier_id) { sBuffer.append("supplier_id=:supplier_id and "); } if (isSetted_modify_id) { sBuffer.append("modify_id=:modify_id and "); } if (isSetted_modify_name) { sBuffer.append("modify_name=:modify_name and "); } if (isSetted_gmt_modify) { sBuffer.append("gmt_modify=:gmt_modify and "); } if (isSetted_modify_type) { sBuffer.append("modify_type=:modify_type and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "SUPPLIER_MODIFY_RECORD"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public SUPPLIER_MODIFY_RECORD insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public SUPPLIER_MODIFY_RECORD update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public SUPPLIER_MODIFY_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 SUPPLIER_MODIFY_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("SUPPLIER_ID"); BEAN_VALUES.put("supplier_id",obj); this.setSupplier_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("MODIFY_ID"); BEAN_VALUES.put("modify_id",obj); this.setModify_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("MODIFY_NAME"); BEAN_VALUES.put("modify_name",obj); this.setModify_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("GMT_MODIFY"); BEAN_VALUES.put("gmt_modify",obj); this.setGmt_modify(ConvertUtil.obj2Long(obj)); obj = rs.getObject("MODIFY_TYPE"); BEAN_VALUES.put("modify_type",obj); this.setModify_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 SUPPLIER_MODIFY_RECORD newInstance(){ return new SUPPLIER_MODIFY_RECORD(); } }