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; /** * CMDB信息的厂商与集成商、运维商信息 */ public class CMDB_MAINUFACTURER extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("manufacturername", "String"); KEYS.put("zh_name", "String"); KEYS.put("type", "Integer"); KEYS.put("phone", "String"); KEYS.put("web_url", "String"); KEYS.put("note", "String"); KEYS.put("state", "Integer"); KEYS.put("partner_id", "String"); KEYS.put("customer_id", "String"); KEYS.put("create_time", "Long"); KEYS.put("name_pinyin", "String"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String manufacturername; private Boolean isSetted_manufacturername = false; private String zh_name; private Boolean isSetted_zh_name = false; private Integer type; private Boolean isSetted_type = false; private String phone; private Boolean isSetted_phone = false; private String web_url; private Boolean isSetted_web_url = false; private String note; private Boolean isSetted_note = false; private Integer state; private Boolean isSetted_state = false; private String partner_id; private Boolean isSetted_partner_id = false; private String customer_id; private Boolean isSetted_customer_id = false; private Long create_time; private Boolean isSetted_create_time = false; private String name_pinyin; private Boolean isSetted_name_pinyin = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("manufacturername", null); BEAN_VALUES.put("zh_name", null); BEAN_VALUES.put("type", null); BEAN_VALUES.put("phone", null); BEAN_VALUES.put("web_url", null); BEAN_VALUES.put("note", null); BEAN_VALUES.put("state", null); BEAN_VALUES.put("partner_id", null); BEAN_VALUES.put("customer_id", null); BEAN_VALUES.put("create_time", null); BEAN_VALUES.put("name_pinyin", null); } public CMDB_MAINUFACTURER() { initBeanValues(); } public CMDB_MAINUFACTURER(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public CMDB_MAINUFACTURER 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 CMDB_MAINUFACTURER set "); if (isSetted_manufacturername) { sBuffer.append("manufacturername=:manufacturername,"); } if (isSetted_zh_name) { sBuffer.append("zh_name=:zh_name,"); } if (isSetted_type) { sBuffer.append("type=:type,"); } if (isSetted_phone) { sBuffer.append("phone=:phone,"); } if (isSetted_web_url) { sBuffer.append("web_url=:web_url,"); } if (isSetted_note) { sBuffer.append("note=:note,"); } if (isSetted_state) { sBuffer.append("state=:state,"); } if (isSetted_partner_id) { sBuffer.append("partner_id=:partner_id,"); } if (isSetted_customer_id) { sBuffer.append("customer_id=:customer_id,"); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time,"); } if (isSetted_name_pinyin) { sBuffer.append("name_pinyin=:name_pinyin,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into CMDB_MAINUFACTURER("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("manufacturername,"); values.append(":manufacturername,"); fileds.append("zh_name,"); values.append(":zh_name,"); fileds.append("type,"); values.append(":type,"); fileds.append("phone,"); values.append(":phone,"); fileds.append("web_url,"); values.append(":web_url,"); fileds.append("note,"); values.append(":note,"); fileds.append("state,"); values.append(":state,"); fileds.append("partner_id,"); values.append(":partner_id,"); fileds.append("customer_id,"); values.append(":customer_id,"); fileds.append("create_time,"); values.append(":create_time,"); fileds.append("name_pinyin,"); values.append(":name_pinyin,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取厂商集成商简称
* 䣺2016-13-04 hh:07 */ public String getManufacturername() { return manufacturername; } /** * 设置厂商集成商简称
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setManufacturername(String manufacturername) { this.manufacturername = manufacturername; this.isSetted_manufacturername = true; BEAN_VALUES.put("manufacturername",manufacturername); return this; } /** * 获取厂商集成商全称
* 䣺2016-13-04 hh:07 */ public String getZh_name() { return zh_name; } /** * 设置厂商集成商全称
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setZh_name(String zh_name) { this.zh_name = zh_name; this.isSetted_zh_name = true; BEAN_VALUES.put("zh_name",zh_name); return this; } /** * 获取类型(1=厂商;2=集成商;3=运维服务商)
* 䣺2016-13-04 hh:07 */ public Integer getType() { return type; } /** * 设置类型(1=厂商;2=集成商;3=运维服务商)
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setType(Integer type) { this.type = type; this.isSetted_type = true; BEAN_VALUES.put("type",type); return this; } /** * 获取电话
* 䣺2016-13-04 hh:07 */ public String getPhone() { return phone; } /** * 设置电话
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setPhone(String phone) { this.phone = phone; this.isSetted_phone = true; BEAN_VALUES.put("phone",phone); return this; } /** * 获取网址
* 䣺2016-13-04 hh:07 */ public String getWeb_url() { return web_url; } /** * 设置网址
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setWeb_url(String web_url) { this.web_url = web_url; this.isSetted_web_url = true; BEAN_VALUES.put("web_url",web_url); return this; } /** * 获取简介
* 䣺2016-13-04 hh:07 */ public String getNote() { return note; } /** * 设置简介
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setNote(String note) { this.note = note; this.isSetted_note = true; BEAN_VALUES.put("note",note); return this; } /** * 获取状态(1=启用;2=禁用)
* 䣺2016-13-04 hh:07 */ public Integer getState() { return state; } /** * 设置状态(1=启用;2=禁用)
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setState(Integer state) { this.state = state; this.isSetted_state = true; BEAN_VALUES.put("state",state); return this; } /** * 获取加盟商编号
* 䣺2016-13-04 hh:07 */ public String getPartner_id() { return partner_id; } /** * 设置加盟商编号
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setPartner_id(String partner_id) { this.partner_id = partner_id; this.isSetted_partner_id = true; BEAN_VALUES.put("partner_id",partner_id); return this; } /** * 获取客户编号
* 䣺2016-13-04 hh:07 */ public String getCustomer_id() { return customer_id; } /** * 设置客户编号
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setCustomer_id(String customer_id) { this.customer_id = customer_id; this.isSetted_customer_id = true; BEAN_VALUES.put("customer_id",customer_id); return this; } /** * 获取添加时间
* 䣺2016-13-04 hh:07 */ public Long getCreate_time() { return create_time; } /** * 设置添加时间
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setCreate_time(Long create_time) { this.create_time = create_time; this.isSetted_create_time = true; BEAN_VALUES.put("create_time",create_time); return this; } /** * 获取名称拼音
* 䣺2016-13-04 hh:07 */ public String getName_pinyin() { return name_pinyin; } /** * 设置名称拼音
* 2016-13-04 hh:07 */ public CMDB_MAINUFACTURER setName_pinyin(String name_pinyin) { this.name_pinyin = name_pinyin; this.isSetted_name_pinyin = true; BEAN_VALUES.put("name_pinyin",name_pinyin); 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 CMDB_MAINUFACTURER getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } @Override public CMDB_MAINUFACTURER queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from CMDB_MAINUFACTURER where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_manufacturername) { sBuffer.append("manufacturername=:manufacturername and "); } if (isSetted_zh_name) { sBuffer.append("zh_name=:zh_name and "); } if (isSetted_type) { sBuffer.append("type=:type and "); } if (isSetted_phone) { sBuffer.append("phone=:phone and "); } if (isSetted_web_url) { sBuffer.append("web_url=:web_url and "); } if (isSetted_note) { sBuffer.append("note=:note and "); } if (isSetted_state) { sBuffer.append("state=:state and "); } if (isSetted_partner_id) { sBuffer.append("partner_id=:partner_id and "); } if (isSetted_customer_id) { sBuffer.append("customer_id=:customer_id and "); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time and "); } if (isSetted_name_pinyin) { sBuffer.append("name_pinyin=:name_pinyin and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "CMDB_MAINUFACTURER"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public CMDB_MAINUFACTURER insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public CMDB_MAINUFACTURER update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public CMDB_MAINUFACTURER 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 CMDB_MAINUFACTURER 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("MANUFACTURERNAME"); BEAN_VALUES.put("manufacturername",obj); this.setManufacturername(ConvertUtil.obj2Str(obj)); obj = rs.getObject("ZH_NAME"); BEAN_VALUES.put("zh_name",obj); this.setZh_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("TYPE"); BEAN_VALUES.put("type",obj); this.setType(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("PHONE"); BEAN_VALUES.put("phone",obj); this.setPhone(ConvertUtil.obj2Str(obj)); obj = rs.getObject("WEB_URL"); BEAN_VALUES.put("web_url",obj); this.setWeb_url(ConvertUtil.obj2Str(obj)); obj = rs.getObject("NOTE"); BEAN_VALUES.put("note",obj); this.setNote(ConvertUtil.obj2Str(obj)); obj = rs.getObject("STATE"); BEAN_VALUES.put("state",obj); this.setState(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("PARTNER_ID"); BEAN_VALUES.put("partner_id",obj); this.setPartner_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CUSTOMER_ID"); BEAN_VALUES.put("customer_id",obj); this.setCustomer_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CREATE_TIME"); BEAN_VALUES.put("create_time",obj); this.setCreate_time(ConvertUtil.obj2Long(obj)); obj = rs.getObject("NAME_PINYIN"); BEAN_VALUES.put("name_pinyin",obj); this.setName_pinyin(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 CMDB_MAINUFACTURER newInstance(){ return new CMDB_MAINUFACTURER(); } }