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;
|
|
/**
|
* 版本【LARKS_VERSION】
|
*/
|
public class LARKS_VERSION extends BaseBean{
|
|
public final static Map<String, String> KEYS = new HashMap<String, String>();
|
private Map BEAN_VALUES = null;
|
|
static {
|
KEYS.put("id", "String");
|
KEYS.put("version_code", "String");
|
KEYS.put("is_update_html", "Integer");
|
KEYS.put("html_id", "String");
|
KEYS.put("create_time", "Long");
|
KEYS.put("user_id", "String");
|
KEYS.put("user_name", "String");
|
KEYS.put("content", "String");
|
KEYS.put("status", "Integer");
|
KEYS.put("is_force_update", "Integer");
|
}
|
public Map getColumnMap(){
|
return KEYS;
|
}
|
|
private String id;
|
private Boolean isSetted_id = false;;
|
|
private String version_code;
|
private Boolean isSetted_version_code = false;
|
private Integer is_update_html;
|
private Boolean isSetted_is_update_html = false;
|
private String html_id;
|
private Boolean isSetted_html_id = false;
|
private Long create_time;
|
private Boolean isSetted_create_time = false;
|
private String user_id;
|
private Boolean isSetted_user_id = false;
|
private String user_name;
|
private Boolean isSetted_user_name = false;
|
private String content;
|
private Boolean isSetted_content = false;
|
private Integer status;
|
private Boolean isSetted_status = false;
|
private Integer is_force_update;
|
private Boolean isSetted_is_force_update = false;
|
|
private void initBeanValues(){
|
BEAN_VALUES = new HashMap<String, Object>();
|
BEAN_VALUES.put("id",id);
|
BEAN_VALUES.put("version_code", null);
|
BEAN_VALUES.put("is_update_html", null);
|
BEAN_VALUES.put("html_id", null);
|
BEAN_VALUES.put("create_time", null);
|
BEAN_VALUES.put("user_id", null);
|
BEAN_VALUES.put("user_name", null);
|
BEAN_VALUES.put("content", null);
|
BEAN_VALUES.put("status", null);
|
BEAN_VALUES.put("is_force_update", null);
|
}
|
|
public LARKS_VERSION() {
|
initBeanValues();
|
}
|
|
public LARKS_VERSION(String id) {
|
super();
|
this.id = id;
|
initBeanValues();
|
BEAN_VALUES.put("id",id);
|
}
|
|
/**
|
* 获取ID
|
*/
|
public String getId() {
|
return this.id;
|
}
|
/**
|
* 设置ID
|
*/
|
public LARKS_VERSION 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 LARKS_VERSION set ");
|
if (isSetted_version_code) {
|
sBuffer.append("version_code=:version_code,");
|
}
|
if (isSetted_is_update_html) {
|
sBuffer.append("is_update_html=:is_update_html,");
|
}
|
if (isSetted_html_id) {
|
sBuffer.append("html_id=:html_id,");
|
}
|
if (isSetted_create_time) {
|
sBuffer.append("create_time=:create_time,");
|
}
|
if (isSetted_user_id) {
|
sBuffer.append("user_id=:user_id,");
|
}
|
if (isSetted_user_name) {
|
sBuffer.append("user_name=:user_name,");
|
}
|
if (isSetted_content) {
|
sBuffer.append("content=:content,");
|
}
|
if (isSetted_status) {
|
sBuffer.append("status=:status,");
|
}
|
if (isSetted_is_force_update) {
|
sBuffer.append("is_force_update=:is_force_update,");
|
}
|
String sql = sBuffer.toString();
|
return StringUtils.removeEnd(sql, ",") + " where id=:id";
|
}
|
|
|
@Override
|
public String getInsertSql() {
|
StringBuffer sBuffer = new StringBuffer("insert into LARKS_VERSION(");
|
StringBuffer fileds = new StringBuffer("id,");
|
StringBuffer values = new StringBuffer(":id,");
|
fileds.append("version_code,");
|
values.append(":version_code,");
|
fileds.append("is_update_html,");
|
values.append(":is_update_html,");
|
fileds.append("html_id,");
|
values.append(":html_id,");
|
fileds.append("create_time,");
|
values.append(":create_time,");
|
fileds.append("user_id,");
|
values.append(":user_id,");
|
fileds.append("user_name,");
|
values.append(":user_name,");
|
fileds.append("content,");
|
values.append(":content,");
|
fileds.append("status,");
|
values.append(":status,");
|
fileds.append("is_force_update,");
|
values.append(":is_force_update,");
|
sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")");
|
return sBuffer.toString();
|
}
|
|
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public String getVersion_code() {
|
return version_code;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setVersion_code(String version_code) {
|
this.version_code = version_code;
|
this.isSetted_version_code = true;
|
BEAN_VALUES.put("version_code",version_code);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public Integer getIs_update_html() {
|
return is_update_html;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setIs_update_html(Integer is_update_html) {
|
this.is_update_html = is_update_html;
|
this.isSetted_is_update_html = true;
|
BEAN_VALUES.put("is_update_html",is_update_html);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public String getHtml_id() {
|
return html_id;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setHtml_id(String html_id) {
|
this.html_id = html_id;
|
this.isSetted_html_id = true;
|
BEAN_VALUES.put("html_id",html_id);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public Long getCreate_time() {
|
return create_time;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setCreate_time(Long create_time) {
|
this.create_time = create_time;
|
this.isSetted_create_time = true;
|
BEAN_VALUES.put("create_time",create_time);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public String getUser_id() {
|
return user_id;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setUser_id(String user_id) {
|
this.user_id = user_id;
|
this.isSetted_user_id = true;
|
BEAN_VALUES.put("user_id",user_id);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public String getUser_name() {
|
return user_name;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setUser_name(String user_name) {
|
this.user_name = user_name;
|
this.isSetted_user_name = true;
|
BEAN_VALUES.put("user_name",user_name);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public String getContent() {
|
return content;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setContent(String content) {
|
this.content = content;
|
this.isSetted_content = true;
|
BEAN_VALUES.put("content",content);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public Integer getStatus() {
|
return status;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setStatus(Integer status) {
|
this.status = status;
|
this.isSetted_status = true;
|
BEAN_VALUES.put("status",status);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2016-28-02 hh:08
|
*/
|
public Integer getIs_force_update() {
|
return is_force_update;
|
}
|
/**
|
* 设置<BR/>
|
* 2016-28-02 hh:08
|
*/
|
public LARKS_VERSION setIs_force_update(Integer is_force_update) {
|
this.is_force_update = is_force_update;
|
this.isSetted_is_force_update = true;
|
BEAN_VALUES.put("is_force_update",is_force_update);
|
return this;
|
}
|
|
/**
|
* 使用ID删除Bean<BR/>
|
*/
|
public void deleteById() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("删除bean时ID不能为空");
|
}
|
dao.execute("delete from " + getTableName() + " where id = :id", BEAN_VALUES);
|
}
|
|
@Override
|
public LARKS_VERSION getInstanceById() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("获取Bean时ID不能为空");
|
}
|
return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this);
|
}
|
|
|
|
@Override
|
public LARKS_VERSION queryForBean() {
|
StringBuffer sBuffer = new StringBuffer("select * from LARKS_VERSION where ");
|
if(isSetted_id){
|
sBuffer.append("id=:id and ");
|
}
|
if (isSetted_version_code) {
|
sBuffer.append("version_code=:version_code and ");
|
}
|
if (isSetted_is_update_html) {
|
sBuffer.append("is_update_html=:is_update_html and ");
|
}
|
if (isSetted_html_id) {
|
sBuffer.append("html_id=:html_id and ");
|
}
|
if (isSetted_create_time) {
|
sBuffer.append("create_time=:create_time and ");
|
}
|
if (isSetted_user_id) {
|
sBuffer.append("user_id=:user_id and ");
|
}
|
if (isSetted_user_name) {
|
sBuffer.append("user_name=:user_name and ");
|
}
|
if (isSetted_content) {
|
sBuffer.append("content=:content and ");
|
}
|
if (isSetted_status) {
|
sBuffer.append("status=:status and ");
|
}
|
if (isSetted_is_force_update) {
|
sBuffer.append("is_force_update=:is_force_update and ");
|
}
|
String sql = sBuffer.toString();
|
sql = StringUtils.removeEnd(sql, " and ");
|
return dao.queryForBean(sql,this);
|
}
|
|
@Override
|
public String getTableName() {
|
return "LARKS_VERSION";
|
}
|
|
|
public Map getBeanValues(){
|
return this.BEAN_VALUES;
|
}
|
|
@Override
|
public LARKS_VERSION insert() {
|
if (StringUtils.isBlank(id)) {
|
this.setId(StringUtil.getUUID());
|
}
|
dao.execute(getInsertSql(),BEAN_VALUES);
|
return this;
|
}
|
|
@Override
|
public LARKS_VERSION update() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("更新Bean时ID不能为空");
|
}
|
dao.execute(getUpdateSql(),BEAN_VALUES);
|
return this;
|
}
|
|
public LARKS_VERSION 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 LARKS_VERSION 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("VERSION_CODE");
|
BEAN_VALUES.put("version_code",obj);
|
this.setVersion_code(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("IS_UPDATE_HTML");
|
BEAN_VALUES.put("is_update_html",obj);
|
this.setIs_update_html(ConvertUtil.obj2Integer(obj));
|
obj = rs.getObject("HTML_ID");
|
BEAN_VALUES.put("html_id",obj);
|
this.setHtml_id(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("CREATE_TIME");
|
BEAN_VALUES.put("create_time",obj);
|
this.setCreate_time(ConvertUtil.obj2Long(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));
|
obj = rs.getObject("CONTENT");
|
BEAN_VALUES.put("content",obj);
|
this.setContent(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("STATUS");
|
BEAN_VALUES.put("status",obj);
|
this.setStatus(ConvertUtil.obj2Integer(obj));
|
obj = rs.getObject("IS_FORCE_UPDATE");
|
BEAN_VALUES.put("is_force_update",obj);
|
this.setIs_force_update(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 LARKS_VERSION newInstance(){
|
return new LARKS_VERSION();
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|