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_MESSAGE extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("title", "String"); KEYS.put("content", "String"); KEYS.put("web_url", "String"); KEYS.put("wx_url", "String"); KEYS.put("type", "Integer"); KEYS.put("send_time", "Long"); KEYS.put("sender_id", "String"); KEYS.put("sender_name", "String"); KEYS.put("business_id", "String"); KEYS.put("order_code", "String"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String title; private Boolean isSetted_title = false; private String content; private Boolean isSetted_content = false; private String web_url; private Boolean isSetted_web_url = false; private String wx_url; private Boolean isSetted_wx_url = false; private Integer type; private Boolean isSetted_type = false; private Long send_time; private Boolean isSetted_send_time = false; private String sender_id; private Boolean isSetted_sender_id = false; private String sender_name; private Boolean isSetted_sender_name = false; private String business_id; private Boolean isSetted_business_id = false; private String order_code; private Boolean isSetted_order_code = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("title", null); BEAN_VALUES.put("content", null); BEAN_VALUES.put("web_url", null); BEAN_VALUES.put("wx_url", null); BEAN_VALUES.put("type", null); BEAN_VALUES.put("send_time", null); BEAN_VALUES.put("sender_id", null); BEAN_VALUES.put("sender_name", null); BEAN_VALUES.put("business_id", null); BEAN_VALUES.put("order_code", null); } public GG_MESSAGE() { initBeanValues(); } public GG_MESSAGE(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public GG_MESSAGE 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_MESSAGE set "); if (isSetted_title) { sBuffer.append("title=:title,"); } if (isSetted_content) { sBuffer.append("content=:content,"); } if (isSetted_web_url) { sBuffer.append("web_url=:web_url,"); } if (isSetted_wx_url) { sBuffer.append("wx_url=:wx_url,"); } if (isSetted_type) { sBuffer.append("type=:type,"); } if (isSetted_send_time) { sBuffer.append("send_time=:send_time,"); } if (isSetted_sender_id) { sBuffer.append("sender_id=:sender_id,"); } if (isSetted_sender_name) { sBuffer.append("sender_name=:sender_name,"); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id,"); } if (isSetted_order_code) { sBuffer.append("order_code=:order_code,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into GG_MESSAGE("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("title,"); values.append(":title,"); fileds.append("content,"); values.append(":content,"); fileds.append("web_url,"); values.append(":web_url,"); fileds.append("wx_url,"); values.append(":wx_url,"); fileds.append("type,"); values.append(":type,"); fileds.append("send_time,"); values.append(":send_time,"); fileds.append("sender_id,"); values.append(":sender_id,"); fileds.append("sender_name,"); values.append(":sender_name,"); fileds.append("business_id,"); values.append(":business_id,"); fileds.append("order_code,"); values.append(":order_code,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取标题
* 䣺2015-20-23 hh:09 */ public String getTitle() { return title; } /** * 设置标题
* 2015-20-23 hh:09 */ public GG_MESSAGE setTitle(String title) { this.title = title; this.isSetted_title = true; BEAN_VALUES.put("title",title); return this; } /** * 获取内容
* 䣺2015-20-23 hh:09 */ public String getContent() { return content; } /** * 设置内容
* 2015-20-23 hh:09 */ public GG_MESSAGE setContent(String content) { this.content = content; this.isSetted_content = true; BEAN_VALUES.put("content",content); return this; } /** * 获取WEBURL转向
* 䣺2015-20-23 hh:09 */ public String getWeb_url() { return web_url; } /** * 设置WEBURL转向
* 2015-20-23 hh:09 */ public GG_MESSAGE setWeb_url(String web_url) { this.web_url = web_url; this.isSetted_web_url = true; BEAN_VALUES.put("web_url",web_url); return this; } /** * 获取微信URL
* 䣺2015-20-23 hh:09 */ public String getWx_url() { return wx_url; } /** * 设置微信URL
* 2015-20-23 hh:09 */ public GG_MESSAGE setWx_url(String wx_url) { this.wx_url = wx_url; this.isSetted_wx_url = true; BEAN_VALUES.put("wx_url",wx_url); return this; } /** * 获取消息类型(0=公告通知;1=事件管理;2=问题管理;3=变更管理;4=发布管理;5=配置管理;7=)
* 䣺2015-20-23 hh:09 */ public Integer getType() { return type; } /** * 设置消息类型(0=公告通知;1=事件管理;2=问题管理;3=变更管理;4=发布管理;5=配置管理;7=)
* 2015-20-23 hh:09 */ public GG_MESSAGE setType(Integer type) { this.type = type; this.isSetted_type = true; BEAN_VALUES.put("type",type); return this; } /** * 获取发送时间
* 䣺2015-20-23 hh:09 */ public Long getSend_time() { return send_time; } /** * 设置发送时间
* 2015-20-23 hh:09 */ public GG_MESSAGE setSend_time(Long send_time) { this.send_time = send_time; this.isSetted_send_time = true; BEAN_VALUES.put("send_time",send_time); return this; } /** * 获取发送人编号
* 䣺2015-20-23 hh:09 */ public String getSender_id() { return sender_id; } /** * 设置发送人编号
* 2015-20-23 hh:09 */ public GG_MESSAGE setSender_id(String sender_id) { this.sender_id = sender_id; this.isSetted_sender_id = true; BEAN_VALUES.put("sender_id",sender_id); return this; } /** * 获取发送人名称
* 䣺2015-20-23 hh:09 */ public String getSender_name() { return sender_name; } /** * 设置发送人名称
* 2015-20-23 hh:09 */ public GG_MESSAGE setSender_name(String sender_name) { this.sender_name = sender_name; this.isSetted_sender_name = true; BEAN_VALUES.put("sender_name",sender_name); return this; } /** * 获取业务编号
* 䣺2015-20-23 hh:09 */ public String getBusiness_id() { return business_id; } /** * 设置业务编号
* 2015-20-23 hh:09 */ public GG_MESSAGE setBusiness_id(String business_id) { this.business_id = business_id; this.isSetted_business_id = true; BEAN_VALUES.put("business_id",business_id); return this; } /** * 获取
* 䣺2015-20-23 hh:09 */ public String getOrder_code() { return order_code; } /** * 设置
* 2015-20-23 hh:09 */ public GG_MESSAGE setOrder_code(String order_code) { this.order_code = order_code; this.isSetted_order_code = true; BEAN_VALUES.put("order_code",order_code); 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_MESSAGE 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_MESSAGE queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from GG_MESSAGE where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_title) { sBuffer.append("title=:title and "); } if (isSetted_content) { sBuffer.append("content=:content and "); } if (isSetted_web_url) { sBuffer.append("web_url=:web_url and "); } if (isSetted_wx_url) { sBuffer.append("wx_url=:wx_url and "); } if (isSetted_type) { sBuffer.append("type=:type and "); } if (isSetted_send_time) { sBuffer.append("send_time=:send_time and "); } if (isSetted_sender_id) { sBuffer.append("sender_id=:sender_id and "); } if (isSetted_sender_name) { sBuffer.append("sender_name=:sender_name and "); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id and "); } if (isSetted_order_code) { sBuffer.append("order_code=:order_code and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "GG_MESSAGE"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public GG_MESSAGE insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public GG_MESSAGE update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public GG_MESSAGE 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_MESSAGE 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("TITLE"); BEAN_VALUES.put("title",obj); this.setTitle(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CONTENT"); BEAN_VALUES.put("content",obj); this.setContent(ConvertUtil.obj2Str(obj)); obj = rs.getObject("WEB_URL"); BEAN_VALUES.put("web_url",obj); this.setWeb_url(ConvertUtil.obj2Str(obj)); obj = rs.getObject("WX_URL"); BEAN_VALUES.put("wx_url",obj); this.setWx_url(ConvertUtil.obj2Str(obj)); obj = rs.getObject("TYPE"); BEAN_VALUES.put("type",obj); this.setType(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("SEND_TIME"); BEAN_VALUES.put("send_time",obj); this.setSend_time(ConvertUtil.obj2Long(obj)); obj = rs.getObject("SENDER_ID"); BEAN_VALUES.put("sender_id",obj); this.setSender_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("SENDER_NAME"); BEAN_VALUES.put("sender_name",obj); this.setSender_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("BUSINESS_ID"); BEAN_VALUES.put("business_id",obj); this.setBusiness_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("ORDER_CODE"); BEAN_VALUES.put("order_code",obj); this.setOrder_code(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_MESSAGE newInstance(){ return new GG_MESSAGE(); } }