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_FILES extends BaseBean{ public final static Map KEYS = new HashMap(); private Map BEAN_VALUES = null; static { KEYS.put("id", "String"); KEYS.put("file_name", "String"); KEYS.put("file_path", "String"); KEYS.put("file_size", "String"); KEYS.put("file_format", "String"); KEYS.put("business_id", "String"); KEYS.put("ordernum", "Integer"); KEYS.put("file_note", "String"); KEYS.put("file_type", "String"); KEYS.put("extend1", "String"); KEYS.put("extend2", "String"); KEYS.put("extend3", "String"); KEYS.put("create_time", "Long"); KEYS.put("del_flag", "Integer"); KEYS.put("user_id", "String"); KEYS.put("user_name", "String"); } public Map getColumnMap(){ return KEYS; } private String id; private Boolean isSetted_id = false;; private String file_name; private Boolean isSetted_file_name = false; private String file_path; private Boolean isSetted_file_path = false; private String file_size; private Boolean isSetted_file_size = false; private String file_format; private Boolean isSetted_file_format = false; private String business_id; private Boolean isSetted_business_id = false; private Integer ordernum; private Boolean isSetted_ordernum = false; private String file_note; private Boolean isSetted_file_note = false; private String file_type; private Boolean isSetted_file_type = false; private String extend1; private Boolean isSetted_extend1 = false; private String extend2; private Boolean isSetted_extend2 = false; private String extend3; private Boolean isSetted_extend3 = false; private Long create_time; private Boolean isSetted_create_time = false; private Integer del_flag; private Boolean isSetted_del_flag = false; private String user_id; private Boolean isSetted_user_id = false; private String user_name; private Boolean isSetted_user_name = false; private void initBeanValues(){ BEAN_VALUES = new HashMap(); BEAN_VALUES.put("id",id); BEAN_VALUES.put("file_name", null); BEAN_VALUES.put("file_path", null); BEAN_VALUES.put("file_size", null); BEAN_VALUES.put("file_format", null); BEAN_VALUES.put("business_id", null); BEAN_VALUES.put("ordernum", null); BEAN_VALUES.put("file_note", null); BEAN_VALUES.put("file_type", null); BEAN_VALUES.put("extend1", null); BEAN_VALUES.put("extend2", null); BEAN_VALUES.put("extend3", null); BEAN_VALUES.put("create_time", null); BEAN_VALUES.put("del_flag", null); BEAN_VALUES.put("user_id", null); BEAN_VALUES.put("user_name", null); } public GG_FILES() { initBeanValues(); } public GG_FILES(String id) { super(); this.id = id; initBeanValues(); BEAN_VALUES.put("id",id); } /** * 获取ID */ public String getId() { return this.id; } /** * 设置ID */ public GG_FILES 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_FILES set "); if (isSetted_file_name) { sBuffer.append("file_name=:file_name,"); } if (isSetted_file_path) { sBuffer.append("file_path=:file_path,"); } if (isSetted_file_size) { sBuffer.append("file_size=:file_size,"); } if (isSetted_file_format) { sBuffer.append("file_format=:file_format,"); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id,"); } if (isSetted_ordernum) { sBuffer.append("ordernum=:ordernum,"); } if (isSetted_file_note) { sBuffer.append("file_note=:file_note,"); } if (isSetted_file_type) { sBuffer.append("file_type=:file_type,"); } if (isSetted_extend1) { sBuffer.append("extend1=:extend1,"); } if (isSetted_extend2) { sBuffer.append("extend2=:extend2,"); } if (isSetted_extend3) { sBuffer.append("extend3=:extend3,"); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time,"); } if (isSetted_del_flag) { sBuffer.append("del_flag=:del_flag,"); } if (isSetted_user_id) { sBuffer.append("user_id=:user_id,"); } if (isSetted_user_name) { sBuffer.append("user_name=:user_name,"); } String sql = sBuffer.toString(); return StringUtils.removeEnd(sql, ",") + " where id=:id"; } @Override public String getInsertSql() { StringBuffer sBuffer = new StringBuffer("insert into GG_FILES("); StringBuffer fileds = new StringBuffer("id,"); StringBuffer values = new StringBuffer(":id,"); fileds.append("file_name,"); values.append(":file_name,"); fileds.append("file_path,"); values.append(":file_path,"); fileds.append("file_size,"); values.append(":file_size,"); fileds.append("file_format,"); values.append(":file_format,"); fileds.append("business_id,"); values.append(":business_id,"); fileds.append("ordernum,"); values.append(":ordernum,"); fileds.append("file_note,"); values.append(":file_note,"); fileds.append("file_type,"); values.append(":file_type,"); fileds.append("extend1,"); values.append(":extend1,"); fileds.append("extend2,"); values.append(":extend2,"); fileds.append("extend3,"); values.append(":extend3,"); fileds.append("create_time,"); values.append(":create_time,"); fileds.append("del_flag,"); values.append(":del_flag,"); fileds.append("user_id,"); values.append(":user_id,"); fileds.append("user_name,"); values.append(":user_name,"); sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")"); return sBuffer.toString(); } /** * 获取文件名称
* 䣺2016-25-13 hh:05 */ public String getFile_name() { return file_name; } /** * 设置文件名称
* 2016-25-13 hh:05 */ public GG_FILES setFile_name(String file_name) { this.file_name = file_name; this.isSetted_file_name = true; BEAN_VALUES.put("file_name",file_name); return this; } /** * 获取文件路径
* 䣺2016-25-13 hh:05 */ public String getFile_path() { return file_path; } /** * 设置文件路径
* 2016-25-13 hh:05 */ public GG_FILES setFile_path(String file_path) { this.file_path = file_path; this.isSetted_file_path = true; BEAN_VALUES.put("file_path",file_path); return this; } /** * 获取文件大小
* 䣺2016-25-13 hh:05 */ public String getFile_size() { return file_size; } /** * 设置文件大小
* 2016-25-13 hh:05 */ public GG_FILES setFile_size(String file_size) { this.file_size = file_size; this.isSetted_file_size = true; BEAN_VALUES.put("file_size",file_size); return this; } /** * 获取文件格式
* 䣺2016-25-13 hh:05 */ public String getFile_format() { return file_format; } /** * 设置文件格式
* 2016-25-13 hh:05 */ public GG_FILES setFile_format(String file_format) { this.file_format = file_format; this.isSetted_file_format = true; BEAN_VALUES.put("file_format",file_format); return this; } /** * 获取业务编号
* 䣺2016-25-13 hh:05 */ public String getBusiness_id() { return business_id; } /** * 设置业务编号
* 2016-25-13 hh:05 */ public GG_FILES setBusiness_id(String business_id) { this.business_id = business_id; this.isSetted_business_id = true; BEAN_VALUES.put("business_id",business_id); return this; } /** * 获取顺序号
* 䣺2016-25-13 hh:05 */ public Integer getOrdernum() { return ordernum; } /** * 设置顺序号
* 2016-25-13 hh:05 */ public GG_FILES setOrdernum(Integer ordernum) { this.ordernum = ordernum; this.isSetted_ordernum = true; BEAN_VALUES.put("ordernum",ordernum); return this; } /** * 获取文件备注
* 䣺2016-25-13 hh:05 */ public String getFile_note() { return file_note; } /** * 设置文件备注
* 2016-25-13 hh:05 */ public GG_FILES setFile_note(String file_note) { this.file_note = file_note; this.isSetted_file_note = true; BEAN_VALUES.put("file_note",file_note); return this; } /** * 获取类型
* 䣺2016-25-13 hh:05 */ public String getFile_type() { return file_type; } /** * 设置类型
* 2016-25-13 hh:05 */ public GG_FILES setFile_type(String file_type) { this.file_type = file_type; this.isSetted_file_type = true; BEAN_VALUES.put("file_type",file_type); return this; } /** * 获取
* 䣺2016-25-13 hh:05 */ public String getExtend1() { return extend1; } /** * 设置
* 2016-25-13 hh:05 */ public GG_FILES setExtend1(String extend1) { this.extend1 = extend1; this.isSetted_extend1 = true; BEAN_VALUES.put("extend1",extend1); return this; } /** * 获取
* 䣺2016-25-13 hh:05 */ public String getExtend2() { return extend2; } /** * 设置
* 2016-25-13 hh:05 */ public GG_FILES setExtend2(String extend2) { this.extend2 = extend2; this.isSetted_extend2 = true; BEAN_VALUES.put("extend2",extend2); return this; } /** * 获取
* 䣺2016-25-13 hh:05 */ public String getExtend3() { return extend3; } /** * 设置
* 2016-25-13 hh:05 */ public GG_FILES setExtend3(String extend3) { this.extend3 = extend3; this.isSetted_extend3 = true; BEAN_VALUES.put("extend3",extend3); return this; } /** * 获取修改时间
* 䣺2016-25-13 hh:05 */ public Long getCreate_time() { return create_time; } /** * 设置修改时间
* 2016-25-13 hh:05 */ public GG_FILES setCreate_time(Long create_time) { this.create_time = create_time; this.isSetted_create_time = true; BEAN_VALUES.put("create_time",create_time); return this; } /** * 获取删除标识【1:未删除 2:已删除】
* 䣺2016-25-13 hh:05 */ public Integer getDel_flag() { return del_flag; } /** * 设置删除标识【1:未删除 2:已删除】
* 2016-25-13 hh:05 */ public GG_FILES setDel_flag(Integer del_flag) { this.del_flag = del_flag; this.isSetted_del_flag = true; BEAN_VALUES.put("del_flag",del_flag); return this; } /** * 获取上传者
* 䣺2016-25-13 hh:05 */ public String getUser_id() { return user_id; } /** * 设置上传者
* 2016-25-13 hh:05 */ public GG_FILES setUser_id(String user_id) { this.user_id = user_id; this.isSetted_user_id = true; BEAN_VALUES.put("user_id",user_id); return this; } /** * 获取上传者名称
* 䣺2016-25-13 hh:05 */ public String getUser_name() { return user_name; } /** * 设置上传者名称
* 2016-25-13 hh:05 */ public GG_FILES setUser_name(String user_name) { this.user_name = user_name; this.isSetted_user_name = true; BEAN_VALUES.put("user_name",user_name); 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_FILES 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_FILES queryForBean() { StringBuffer sBuffer = new StringBuffer("select * from GG_FILES where "); if(isSetted_id){ sBuffer.append("id=:id and "); } if (isSetted_file_name) { sBuffer.append("file_name=:file_name and "); } if (isSetted_file_path) { sBuffer.append("file_path=:file_path and "); } if (isSetted_file_size) { sBuffer.append("file_size=:file_size and "); } if (isSetted_file_format) { sBuffer.append("file_format=:file_format and "); } if (isSetted_business_id) { sBuffer.append("business_id=:business_id and "); } if (isSetted_ordernum) { sBuffer.append("ordernum=:ordernum and "); } if (isSetted_file_note) { sBuffer.append("file_note=:file_note and "); } if (isSetted_file_type) { sBuffer.append("file_type=:file_type and "); } if (isSetted_extend1) { sBuffer.append("extend1=:extend1 and "); } if (isSetted_extend2) { sBuffer.append("extend2=:extend2 and "); } if (isSetted_extend3) { sBuffer.append("extend3=:extend3 and "); } if (isSetted_create_time) { sBuffer.append("create_time=:create_time and "); } if (isSetted_del_flag) { sBuffer.append("del_flag=:del_flag and "); } if (isSetted_user_id) { sBuffer.append("user_id=:user_id and "); } if (isSetted_user_name) { sBuffer.append("user_name=:user_name and "); } String sql = sBuffer.toString(); sql = StringUtils.removeEnd(sql, " and "); return dao.queryForBean(sql,this); } @Override public String getTableName() { return "GG_FILES"; } public Map getBeanValues(){ return this.BEAN_VALUES; } @Override public GG_FILES insert() { if (StringUtils.isBlank(id)) { this.setId(StringUtil.getUUID()); } dao.execute(getInsertSql(),BEAN_VALUES); return this; } @Override public GG_FILES update() { if (StringUtils.isBlank(id)) { throw new RuntimeException("更新Bean时ID不能为空"); } dao.execute(getUpdateSql(),BEAN_VALUES); return this; } public GG_FILES 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_FILES 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("FILE_NAME"); BEAN_VALUES.put("file_name",obj); this.setFile_name(ConvertUtil.obj2Str(obj)); obj = rs.getObject("FILE_PATH"); BEAN_VALUES.put("file_path",obj); this.setFile_path(ConvertUtil.obj2Str(obj)); obj = rs.getObject("FILE_SIZE"); BEAN_VALUES.put("file_size",obj); this.setFile_size(ConvertUtil.obj2Str(obj)); obj = rs.getObject("FILE_FORMAT"); BEAN_VALUES.put("file_format",obj); this.setFile_format(ConvertUtil.obj2Str(obj)); obj = rs.getObject("BUSINESS_ID"); BEAN_VALUES.put("business_id",obj); this.setBusiness_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("ORDERNUM"); BEAN_VALUES.put("ordernum",obj); this.setOrdernum(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("FILE_NOTE"); BEAN_VALUES.put("file_note",obj); this.setFile_note(ConvertUtil.obj2Str(obj)); obj = rs.getObject("FILE_TYPE"); BEAN_VALUES.put("file_type",obj); this.setFile_type(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND1"); BEAN_VALUES.put("extend1",obj); this.setExtend1(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND2"); BEAN_VALUES.put("extend2",obj); this.setExtend2(ConvertUtil.obj2Str(obj)); obj = rs.getObject("EXTEND3"); BEAN_VALUES.put("extend3",obj); this.setExtend3(ConvertUtil.obj2Str(obj)); obj = rs.getObject("CREATE_TIME"); BEAN_VALUES.put("create_time",obj); this.setCreate_time(ConvertUtil.obj2Long(obj)); obj = rs.getObject("DEL_FLAG"); BEAN_VALUES.put("del_flag",obj); this.setDel_flag(ConvertUtil.obj2Integer(obj)); obj = rs.getObject("USER_ID"); BEAN_VALUES.put("user_id",obj); this.setUser_id(ConvertUtil.obj2Str(obj)); obj = rs.getObject("USER_NAME"); BEAN_VALUES.put("user_name",obj); this.setUser_name(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_FILES newInstance(){ return new GG_FILES(); } }