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_DICTIONARY 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("categoryid", "String");
|
KEYS.put("datakey", "String");
|
KEYS.put("datavalue", "String");
|
KEYS.put("beiz", "String");
|
KEYS.put("ordernum", "Integer");
|
KEYS.put("usestate", "Integer");
|
}
|
public Map getColumnMap(){
|
return KEYS;
|
}
|
|
private String id;
|
private Boolean isSetted_id = false;;
|
|
private String categoryid;
|
private Boolean isSetted_categoryid = false;
|
private String datakey;
|
private Boolean isSetted_datakey = false;
|
private String datavalue;
|
private Boolean isSetted_datavalue = false;
|
private String beiz;
|
private Boolean isSetted_beiz = false;
|
private Integer ordernum;
|
private Boolean isSetted_ordernum = false;
|
private Integer usestate;
|
private Boolean isSetted_usestate = false;
|
|
private void initBeanValues(){
|
BEAN_VALUES = new HashMap<String, Object>();
|
BEAN_VALUES.put("id",id);
|
BEAN_VALUES.put("categoryid", null);
|
BEAN_VALUES.put("datakey", null);
|
BEAN_VALUES.put("datavalue", null);
|
BEAN_VALUES.put("beiz", null);
|
BEAN_VALUES.put("ordernum", null);
|
BEAN_VALUES.put("usestate", null);
|
}
|
|
public CONFIG_DATA_DICTIONARY() {
|
initBeanValues();
|
}
|
|
public CONFIG_DATA_DICTIONARY(String id) {
|
super();
|
this.id = id;
|
initBeanValues();
|
BEAN_VALUES.put("id",id);
|
}
|
|
/**
|
* 获取ID
|
*/
|
public String getId() {
|
return this.id;
|
}
|
/**
|
* 设置ID
|
*/
|
public CONFIG_DATA_DICTIONARY 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_DICTIONARY set ");
|
if (isSetted_categoryid) {
|
sBuffer.append("categoryid=:categoryid,");
|
}
|
if (isSetted_datakey) {
|
sBuffer.append("datakey=:datakey,");
|
}
|
if (isSetted_datavalue) {
|
sBuffer.append("datavalue=:datavalue,");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz,");
|
}
|
if (isSetted_ordernum) {
|
sBuffer.append("ordernum=:ordernum,");
|
}
|
if (isSetted_usestate) {
|
sBuffer.append("usestate=:usestate,");
|
}
|
String sql = sBuffer.toString();
|
return StringUtils.removeEnd(sql, ",") + " where id=:id";
|
}
|
|
|
@Override
|
public String getInsertSql() {
|
StringBuffer sBuffer = new StringBuffer("insert into CONFIG_DATA_DICTIONARY(");
|
StringBuffer fileds = new StringBuffer("id,");
|
StringBuffer values = new StringBuffer(":id,");
|
fileds.append("categoryid,");
|
values.append(":categoryid,");
|
fileds.append("datakey,");
|
values.append(":datakey,");
|
fileds.append("datavalue,");
|
values.append(":datavalue,");
|
fileds.append("beiz,");
|
values.append(":beiz,");
|
fileds.append("ordernum,");
|
values.append(":ordernum,");
|
fileds.append("usestate,");
|
values.append(":usestate,");
|
sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")");
|
return sBuffer.toString();
|
}
|
|
|
/**
|
* 获取分类编号<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getCategoryid() {
|
return categoryid;
|
}
|
/**
|
* 设置分类编号<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setCategoryid(String categoryid) {
|
this.categoryid = categoryid;
|
this.isSetted_categoryid = true;
|
BEAN_VALUES.put("categoryid",categoryid);
|
return this;
|
}
|
/**
|
* 获取标识<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getDatakey() {
|
return datakey;
|
}
|
/**
|
* 设置标识<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setDatakey(String datakey) {
|
this.datakey = datakey;
|
this.isSetted_datakey = true;
|
BEAN_VALUES.put("datakey",datakey);
|
return this;
|
}
|
/**
|
* 获取值<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getDatavalue() {
|
return datavalue;
|
}
|
/**
|
* 设置值<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setDatavalue(String datavalue) {
|
this.datavalue = datavalue;
|
this.isSetted_datavalue = true;
|
BEAN_VALUES.put("datavalue",datavalue);
|
return this;
|
}
|
/**
|
* 获取备注<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getBeiz() {
|
return beiz;
|
}
|
/**
|
* 设置备注<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setBeiz(String beiz) {
|
this.beiz = beiz;
|
this.isSetted_beiz = true;
|
BEAN_VALUES.put("beiz",beiz);
|
return this;
|
}
|
/**
|
* 获取顺序号<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public Integer getOrdernum() {
|
return ordernum;
|
}
|
/**
|
* 设置顺序号<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setOrdernum(Integer ordernum) {
|
this.ordernum = ordernum;
|
this.isSetted_ordernum = true;
|
BEAN_VALUES.put("ordernum",ordernum);
|
return this;
|
}
|
/**
|
* 获取状态(1=正常;2=禁用)<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public Integer getUsestate() {
|
return usestate;
|
}
|
/**
|
* 设置状态(1=正常;2=禁用)<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY setUsestate(Integer usestate) {
|
this.usestate = usestate;
|
this.isSetted_usestate = true;
|
BEAN_VALUES.put("usestate",usestate);
|
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_DICTIONARY getInstanceById() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("获取Bean时ID不能为空");
|
}
|
return dao.queryForBean("select * from " + getTableName() + " where id=:id", BEAN_VALUES, this);
|
}
|
|
public CONFIG_DATA_DICTIONARY_CATEGORY getCONFIG_DATA_DICTIONARY_CATEGORY() {
|
if(null == getCategoryid()){
|
throw new RuntimeException("CATEGORYIDֵΪnull");
|
}
|
return new CONFIG_DATA_DICTIONARY_CATEGORY(getCategoryid()).getInstanceById();
|
//return dao.queryForBean("select * from config_data_dictionary_category where ID=:categoryid", new CONFIG_DATA_DICTIONARY_CATEGORY(this.getCategoryid()));
|
}
|
|
|
@Override
|
public CONFIG_DATA_DICTIONARY queryForBean() {
|
StringBuffer sBuffer = new StringBuffer("select * from CONFIG_DATA_DICTIONARY where ");
|
if(isSetted_id){
|
sBuffer.append("id=:id and ");
|
}
|
if (isSetted_categoryid) {
|
sBuffer.append("categoryid=:categoryid and ");
|
}
|
if (isSetted_datakey) {
|
sBuffer.append("datakey=:datakey and ");
|
}
|
if (isSetted_datavalue) {
|
sBuffer.append("datavalue=:datavalue and ");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz and ");
|
}
|
if (isSetted_ordernum) {
|
sBuffer.append("ordernum=:ordernum and ");
|
}
|
if (isSetted_usestate) {
|
sBuffer.append("usestate=:usestate and ");
|
}
|
String sql = sBuffer.toString();
|
sql = StringUtils.removeEnd(sql, " and ");
|
return dao.queryForBean(sql,this);
|
}
|
|
@Override
|
public String getTableName() {
|
return "CONFIG_DATA_DICTIONARY";
|
}
|
|
|
public Map getBeanValues(){
|
return this.BEAN_VALUES;
|
}
|
|
@Override
|
public CONFIG_DATA_DICTIONARY insert() {
|
if (StringUtils.isBlank(id)) {
|
this.setId(StringUtil.getUUID());
|
}
|
dao.execute(getInsertSql(),BEAN_VALUES);
|
return this;
|
}
|
|
@Override
|
public CONFIG_DATA_DICTIONARY update() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("更新Bean时ID不能为空");
|
}
|
dao.execute(getUpdateSql(),BEAN_VALUES);
|
return this;
|
}
|
|
public CONFIG_DATA_DICTIONARY 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_DICTIONARY 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("CATEGORYID");
|
BEAN_VALUES.put("categoryid",obj);
|
this.setCategoryid(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("DATAKEY");
|
BEAN_VALUES.put("datakey",obj);
|
this.setDatakey(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("DATAVALUE");
|
BEAN_VALUES.put("datavalue",obj);
|
this.setDatavalue(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("BEIZ");
|
BEAN_VALUES.put("beiz",obj);
|
this.setBeiz(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("ORDERNUM");
|
BEAN_VALUES.put("ordernum",obj);
|
this.setOrdernum(ConvertUtil.obj2Integer(obj));
|
obj = rs.getObject("USESTATE");
|
BEAN_VALUES.put("usestate",obj);
|
this.setUsestate(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 CONFIG_DATA_DICTIONARY newInstance(){
|
return new CONFIG_DATA_DICTIONARY();
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|