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 CONFIG_DATA_MESSAGE 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("message_key", "String");
|
KEYS.put("message_name", "String");
|
KEYS.put("beiz", "String");
|
KEYS.put("interfacekey", "String");
|
}
|
public Map getColumnMap(){
|
return KEYS;
|
}
|
|
private String id;
|
private Boolean isSetted_id = false;;
|
|
private String message_key;
|
private Boolean isSetted_message_key = false;
|
private String message_name;
|
private Boolean isSetted_message_name = false;
|
private String beiz;
|
private Boolean isSetted_beiz = false;
|
private String interfacekey;
|
private Boolean isSetted_interfacekey = false;
|
|
private void initBeanValues(){
|
BEAN_VALUES = new HashMap<String, Object>();
|
BEAN_VALUES.put("id",id);
|
BEAN_VALUES.put("message_key", null);
|
BEAN_VALUES.put("message_name", null);
|
BEAN_VALUES.put("beiz", null);
|
BEAN_VALUES.put("interfacekey", null);
|
}
|
|
public CONFIG_DATA_MESSAGE() {
|
initBeanValues();
|
}
|
|
public CONFIG_DATA_MESSAGE(String id) {
|
super();
|
this.id = id;
|
initBeanValues();
|
BEAN_VALUES.put("id",id);
|
}
|
|
/**
|
* 获取ID
|
*/
|
public String getId() {
|
return this.id;
|
}
|
/**
|
* 设置ID
|
*/
|
public CONFIG_DATA_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 CONFIG_DATA_MESSAGE set ");
|
if (isSetted_message_key) {
|
sBuffer.append("message_key=:message_key,");
|
}
|
if (isSetted_message_name) {
|
sBuffer.append("message_name=:message_name,");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz,");
|
}
|
if (isSetted_interfacekey) {
|
sBuffer.append("interfacekey=:interfacekey,");
|
}
|
String sql = sBuffer.toString();
|
return StringUtils.removeEnd(sql, ",") + " where id=:id";
|
}
|
|
|
@Override
|
public String getInsertSql() {
|
StringBuffer sBuffer = new StringBuffer("insert into CONFIG_DATA_MESSAGE(");
|
StringBuffer fileds = new StringBuffer("id,");
|
StringBuffer values = new StringBuffer(":id,");
|
fileds.append("message_key,");
|
values.append(":message_key,");
|
fileds.append("message_name,");
|
values.append(":message_name,");
|
fileds.append("beiz,");
|
values.append(":beiz,");
|
fileds.append("interfacekey,");
|
values.append(":interfacekey,");
|
sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")");
|
return sBuffer.toString();
|
}
|
|
|
/**
|
* 获取消息KEY<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getMessage_key() {
|
return message_key;
|
}
|
/**
|
* 设置消息KEY<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_MESSAGE setMessage_key(String message_key) {
|
this.message_key = message_key;
|
this.isSetted_message_key = true;
|
BEAN_VALUES.put("message_key",message_key);
|
return this;
|
}
|
/**
|
* 获取<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getMessage_name() {
|
return message_name;
|
}
|
/**
|
* 设置<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_MESSAGE setMessage_name(String message_name) {
|
this.message_name = message_name;
|
this.isSetted_message_name = true;
|
BEAN_VALUES.put("message_name",message_name);
|
return this;
|
}
|
/**
|
* 获取接口说明<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getBeiz() {
|
return beiz;
|
}
|
/**
|
* 设置接口说明<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_MESSAGE setBeiz(String beiz) {
|
this.beiz = beiz;
|
this.isSetted_beiz = true;
|
BEAN_VALUES.put("beiz",beiz);
|
return this;
|
}
|
/**
|
* 获取接口KEY<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getInterfacekey() {
|
return interfacekey;
|
}
|
/**
|
* 设置接口KEY<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_MESSAGE setInterfacekey(String interfacekey) {
|
this.interfacekey = interfacekey;
|
this.isSetted_interfacekey = true;
|
BEAN_VALUES.put("interfacekey",interfacekey);
|
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 CONFIG_DATA_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 CONFIG_DATA_MESSAGE queryForBean() {
|
StringBuffer sBuffer = new StringBuffer("select * from CONFIG_DATA_MESSAGE where ");
|
if(isSetted_id){
|
sBuffer.append("id=:id and ");
|
}
|
if (isSetted_message_key) {
|
sBuffer.append("message_key=:message_key and ");
|
}
|
if (isSetted_message_name) {
|
sBuffer.append("message_name=:message_name and ");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz and ");
|
}
|
if (isSetted_interfacekey) {
|
sBuffer.append("interfacekey=:interfacekey and ");
|
}
|
String sql = sBuffer.toString();
|
sql = StringUtils.removeEnd(sql, " and ");
|
return dao.queryForBean(sql,this);
|
}
|
|
@Override
|
public String getTableName() {
|
return "CONFIG_DATA_MESSAGE";
|
}
|
|
|
public Map getBeanValues(){
|
return this.BEAN_VALUES;
|
}
|
|
@Override
|
public CONFIG_DATA_MESSAGE insert() {
|
if (StringUtils.isBlank(id)) {
|
this.setId(StringUtil.getUUID());
|
}
|
dao.execute(getInsertSql(),BEAN_VALUES);
|
return this;
|
}
|
|
@Override
|
public CONFIG_DATA_MESSAGE update() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("更新Bean时ID不能为空");
|
}
|
dao.execute(getUpdateSql(),BEAN_VALUES);
|
return this;
|
}
|
|
public CONFIG_DATA_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 CONFIG_DATA_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("MESSAGE_KEY");
|
BEAN_VALUES.put("message_key",obj);
|
this.setMessage_key(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("MESSAGE_NAME");
|
BEAN_VALUES.put("message_name",obj);
|
this.setMessage_name(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("BEIZ");
|
BEAN_VALUES.put("beiz",obj);
|
this.setBeiz(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("INTERFACEKEY");
|
BEAN_VALUES.put("interfacekey",obj);
|
this.setInterfacekey(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 CONFIG_DATA_MESSAGE newInstance(){
|
return new CONFIG_DATA_MESSAGE();
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|