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 CMS_POP extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("pop_up", "Integer"); KEYS.put("pop_left", "String"); KEYS.put("pop_top", "String"); KEYS.put("pop_right", "String"); KEYS.put("pop_bottom", "String"); KEYS.put("pop_width", "String"); KEYS.put("pop_height", "String"); KEYS.put("pop_state", "Integer"); KEYS.put("update_time", "Long"); KEYS.put("update_people_id", "String"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private Integer pop_up; private Boolean isSetted_pop_up = false; private String pop_left; private Boolean isSetted_pop_left = false; private String pop_top; private Boolean isSetted_pop_top = false; private String pop_right; private Boolean isSetted_pop_right = false; private String pop_bottom; private Boolean isSetted_pop_bottom = false; private String pop_width; private Boolean isSetted_pop_width = false; private String pop_height; private Boolean isSetted_pop_height = false; private Integer pop_state; private Boolean isSetted_pop_state = false; private Long update_time; private Boolean isSetted_update_time = false; private String update_people_id; private Boolean isSetted_update_people_id = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("pop_up", null); BEAN_VALUES.put("pop_left", null); BEAN_VALUES.put("pop_top", null); BEAN_VALUES.put("pop_right", null); BEAN_VALUES.put("pop_bottom", null); BEAN_VALUES.put("pop_width", null); BEAN_VALUES.put("pop_height", null); BEAN_VALUES.put("pop_state", null); BEAN_VALUES.put("update_time", null); BEAN_VALUES.put("update_people_id", null); } public CMS_POP() { initBeanValues(); } public CMS_POP(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public CMS_POP 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 CMS_POP set "); if (isSetted_pop_up) { sBuffer.append("pop_up=:pop_up,"); } if (isSetted_pop_left) { sBuffer.append("pop_left=:pop_left,"); } if (isSetted_pop_top) { sBuffer.append("pop_top=:pop_top,"); } if (isSetted_pop_right) { sBuffer.append("pop_right=:pop_right,"); } if (isSetted_pop_bottom) { sBuffer.append("pop_bottom=:pop_bottom,"); } if (isSetted_pop_width) { sBuffer.append("pop_width=:pop_width,"); } if (isSetted_pop_height) { sBuffer.append("pop_height=:pop_height,"); } if (isSetted_pop_state) { sBuffer.append("pop_state=:pop_state,"); } if (isSetted_update_time) { sBuffer.append("update_time=:update_time,"); } if (isSetted_update_people_id) { sBuffer.append("update_people_id=:update_people_id,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into CMS_POP("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("pop_up,"); values.append(":pop_up,"); fileds.append("pop_left,"); values.append(":pop_left,"); fileds.append("pop_top,"); values.append(":pop_top,"); fileds.append("pop_right,"); values.append(":pop_right,"); fileds.append("pop_bottom,"); values.append(":pop_bottom,"); fileds.append("pop_width,"); values.append(":pop_width,"); fileds.append("pop_height,"); values.append(":pop_height,"); fileds.append("pop_state,"); values.append(":pop_state,"); fileds.append("update_time,"); values.append(":update_time,"); fileds.append("update_people_id,"); values.append(":update_people_id,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取弹窗位置(1:左上角,2:右上角,3:左下角,4:右下角)
* 䣺2014-24-25 hh:08 */ public Integer getPop_up() { return pop_up; } /** * 设置弹窗位置(1:左上角,2:右上角,3:左下角,4:右下角)
* 2014-24-25 hh:08 */ public CMS_POP setPop_up(Integer pop_up) { this.pop_up = pop_up; this.isSetted_pop_up = true; BEAN_VALUES.put("pop_up",pop_up); return this; } /** * 获取弹窗居左
* 䣺2014-24-25 hh:08 */ public String getPop_left() { return pop_left; } /** * 设置弹窗居左
* 2014-24-25 hh:08 */ public CMS_POP setPop_left(String pop_left) { this.pop_left = pop_left; this.isSetted_pop_left = true; BEAN_VALUES.put("pop_left",pop_left); return this; } /** * 获取弹窗居上
* 䣺2014-24-25 hh:08 */ public String getPop_top() { return pop_top; } /** * 设置弹窗居上
* 2014-24-25 hh:08 */ public CMS_POP setPop_top(String pop_top) { this.pop_top = pop_top; this.isSetted_pop_top = true; BEAN_VALUES.put("pop_top",pop_top); return this; } /** * 获取弹窗居右
* 䣺2014-24-25 hh:08 */ public String getPop_right() { return pop_right; } /** * 设置弹窗居右
* 2014-24-25 hh:08 */ public CMS_POP setPop_right(String pop_right) { this.pop_right = pop_right; this.isSetted_pop_right = true; BEAN_VALUES.put("pop_right",pop_right); return this; } /** * 获取弹窗居下
* 䣺2014-24-25 hh:08 */ public String getPop_bottom() { return pop_bottom; } /** * 设置弹窗居下
* 2014-24-25 hh:08 */ public CMS_POP setPop_bottom(String pop_bottom) { this.pop_bottom = pop_bottom; this.isSetted_pop_bottom = true; BEAN_VALUES.put("pop_bottom",pop_bottom); return this; } /** * 获取弹窗宽度
* 䣺2014-24-25 hh:08 */ public String getPop_width() { return pop_width; } /** * 设置弹窗宽度
* 2014-24-25 hh:08 */ public CMS_POP setPop_width(String pop_width) { this.pop_width = pop_width; this.isSetted_pop_width = true; BEAN_VALUES.put("pop_width",pop_width); return this; } /** * 获取弹窗高度
* 䣺2014-24-25 hh:08 */ public String getPop_height() { return pop_height; } /** * 设置弹窗高度
* 2014-24-25 hh:08 */ public CMS_POP setPop_height(String pop_height) { this.pop_height = pop_height; this.isSetted_pop_height = true; BEAN_VALUES.put("pop_height",pop_height); return this; } /** * 获取弹窗开启状态(1:打开,2:关闭)
* 䣺2014-24-25 hh:08 */ public Integer getPop_state() { return pop_state; } /** * 设置弹窗开启状态(1:打开,2:关闭)
* 2014-24-25 hh:08 */ public CMS_POP setPop_state(Integer pop_state) { this.pop_state = pop_state; this.isSetted_pop_state = true; BEAN_VALUES.put("pop_state",pop_state); return this; } /** * 获取
* 䣺2014-24-25 hh:08 */ public Long getUpdate_time() { return update_time; } /** * 设置
* 2014-24-25 hh:08 */ public CMS_POP setUpdate_time(Long update_time) { this.update_time = update_time; this.isSetted_update_time = true; BEAN_VALUES.put("update_time",update_time); return this; } /** * 获取
* 䣺2014-24-25 hh:08 */ public String getUpdate_people_id() { return update_people_id; } /** * 设置
* 2014-24-25 hh:08 */ public CMS_POP setUpdate_people_id(String update_people_id) { this.update_people_id = update_people_id; this.isSetted_update_people_id = true; BEAN_VALUES.put("update_people_id",update_people_id); 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 CMS_POP getInstanceById() { if (StringUtils.isBlank(id)) { throw new RuntimeException("获取Bean时ID不能为空"); } return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this); } @Override public CMS_POP queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from CMS_POP where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_pop_up) { sBuffer.append("pop_up=:pop_up and "); } if (isSetted_pop_left) { sBuffer.append("pop_left=:pop_left and "); } if (isSetted_pop_top) { sBuffer.append("pop_top=:pop_top and "); } if (isSetted_pop_right) { sBuffer.append("pop_right=:pop_right and "); } if (isSetted_pop_bottom) { sBuffer.append("pop_bottom=:pop_bottom and "); } if (isSetted_pop_width) { sBuffer.append("pop_width=:pop_width and "); } if (isSetted_pop_height) { sBuffer.append("pop_height=:pop_height and "); } if (isSetted_pop_state) { sBuffer.append("pop_state=:pop_state and "); } if (isSetted_update_time) { sBuffer.append("update_time=:update_time and "); } if (isSetted_update_people_id) { sBuffer.append("update_people_id=:update_people_id and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "CMS_POP"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public CMS_POP insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public CMS_POP update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public CMS_POP 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 CMS_POP 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("POP_UP"); BEAN_VALUES.put("pop_up",obj); this.setPop_up(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("POP_LEFT"); BEAN_VALUES.put("pop_left",obj); this.setPop_left(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_TOP"); BEAN_VALUES.put("pop_top",obj); this.setPop_top(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_RIGHT"); BEAN_VALUES.put("pop_right",obj); this.setPop_right(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_BOTTOM"); BEAN_VALUES.put("pop_bottom",obj); this.setPop_bottom(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_WIDTH"); BEAN_VALUES.put("pop_width",obj); this.setPop_width(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_HEIGHT"); BEAN_VALUES.put("pop_height",obj); this.setPop_height(ConvertUtil.obj2Str(obj)); obj = rs.getObject("POP_STATE"); BEAN_VALUES.put("pop_state",obj); this.setPop_state(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("UPDATE_TIME"); BEAN_VALUES.put("update_time",obj); this.setUpdate_time(ConvertUtil.obj2Long(obj)); obj = rs.getObject("UPDATE_PEOPLE_ID"); BEAN_VALUES.put("update_people_id",obj); this.setUpdate_people_id(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 CMS_POP newInstance(){ return new CMS_POP(); } }