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_CATEGORY 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("categoryname", "String");
|
KEYS.put("ordernum", "Integer");
|
KEYS.put("usestate", "Integer");
|
KEYS.put("parentid", "String");
|
KEYS.put("categorykey", "String");
|
KEYS.put("beiz", "String");
|
}
|
public Map getColumnMap(){
|
return KEYS;
|
}
|
|
private String id;
|
private Boolean isSetted_id = false;;
|
|
private String categoryname;
|
private Boolean isSetted_categoryname = false;
|
private Integer ordernum;
|
private Boolean isSetted_ordernum = false;
|
private Integer usestate;
|
private Boolean isSetted_usestate = false;
|
private String parentid;
|
private Boolean isSetted_parentid = false;
|
private String categorykey;
|
private Boolean isSetted_categorykey = false;
|
private String beiz;
|
private Boolean isSetted_beiz = false;
|
|
private void initBeanValues(){
|
BEAN_VALUES = new HashMap<String, Object>();
|
BEAN_VALUES.put("id",id);
|
BEAN_VALUES.put("categoryname", null);
|
BEAN_VALUES.put("ordernum", null);
|
BEAN_VALUES.put("usestate", null);
|
BEAN_VALUES.put("parentid", null);
|
BEAN_VALUES.put("categorykey", null);
|
BEAN_VALUES.put("beiz", null);
|
}
|
|
public CONFIG_DATA_DICTIONARY_CATEGORY() {
|
initBeanValues();
|
}
|
|
public CONFIG_DATA_DICTIONARY_CATEGORY(String id) {
|
super();
|
this.id = id;
|
initBeanValues();
|
BEAN_VALUES.put("id",id);
|
}
|
|
/**
|
* 获取ID
|
*/
|
public String getId() {
|
return this.id;
|
}
|
/**
|
* 设置ID
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY 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_CATEGORY set ");
|
if (isSetted_categoryname) {
|
sBuffer.append("categoryname=:categoryname,");
|
}
|
if (isSetted_ordernum) {
|
sBuffer.append("ordernum=:ordernum,");
|
}
|
if (isSetted_usestate) {
|
sBuffer.append("usestate=:usestate,");
|
}
|
if (isSetted_parentid) {
|
sBuffer.append("parentid=:parentid,");
|
}
|
if (isSetted_categorykey) {
|
sBuffer.append("categorykey=:categorykey,");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz,");
|
}
|
String sql = sBuffer.toString();
|
return StringUtils.removeEnd(sql, ",") + " where id=:id";
|
}
|
|
|
@Override
|
public String getInsertSql() {
|
StringBuffer sBuffer = new StringBuffer("insert into CONFIG_DATA_DICTIONARY_CATEGORY(");
|
StringBuffer fileds = new StringBuffer("id,");
|
StringBuffer values = new StringBuffer(":id,");
|
fileds.append("categoryname,");
|
values.append(":categoryname,");
|
fileds.append("ordernum,");
|
values.append(":ordernum,");
|
fileds.append("usestate,");
|
values.append(":usestate,");
|
fileds.append("parentid,");
|
values.append(":parentid,");
|
fileds.append("categorykey,");
|
values.append(":categorykey,");
|
fileds.append("beiz,");
|
values.append(":beiz,");
|
sBuffer.append(StringUtils.removeEnd(fileds.toString(), ",") + ") values("+StringUtils.removeEnd(values.toString(), ",")+")");
|
return sBuffer.toString();
|
}
|
|
|
/**
|
* 获取分类名称<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getCategoryname() {
|
return categoryname;
|
}
|
/**
|
* 设置分类名称<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY setCategoryname(String categoryname) {
|
this.categoryname = categoryname;
|
this.isSetted_categoryname = true;
|
BEAN_VALUES.put("categoryname",categoryname);
|
return this;
|
}
|
/**
|
* 获取顺序号<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public Integer getOrdernum() {
|
return ordernum;
|
}
|
/**
|
* 设置顺序号<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY 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_CATEGORY setUsestate(Integer usestate) {
|
this.usestate = usestate;
|
this.isSetted_usestate = true;
|
BEAN_VALUES.put("usestate",usestate);
|
return this;
|
}
|
/**
|
* 获取上级编号<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getParentid() {
|
return parentid;
|
}
|
/**
|
* 设置上级编号<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY setParentid(String parentid) {
|
this.parentid = parentid;
|
this.isSetted_parentid = true;
|
BEAN_VALUES.put("parentid",parentid);
|
return this;
|
}
|
/**
|
* 获取分类标识<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getCategorykey() {
|
return categorykey;
|
}
|
/**
|
* 设置分类标识<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY setCategorykey(String categorykey) {
|
this.categorykey = categorykey;
|
this.isSetted_categorykey = true;
|
BEAN_VALUES.put("categorykey",categorykey);
|
return this;
|
}
|
/**
|
* 获取备注<BR/>
|
* 䣺2014-57-21 hh:05
|
*/
|
public String getBeiz() {
|
return beiz;
|
}
|
/**
|
* 设置备注<BR/>
|
* 2014-57-21 hh:05
|
*/
|
public CONFIG_DATA_DICTIONARY_CATEGORY setBeiz(String beiz) {
|
this.beiz = beiz;
|
this.isSetted_beiz = true;
|
BEAN_VALUES.put("beiz",beiz);
|
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_CATEGORY 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 == getParentid()){
|
throw new RuntimeException("PARENTIDֵΪnull");
|
}
|
return new CONFIG_DATA_DICTIONARY_CATEGORY(getParentid()).getInstanceById();
|
//return dao.queryForBean("select * from config_data_dictionary_category where ID=:parentid", new CONFIG_DATA_DICTIONARY_CATEGORY(this.getParentid()));
|
}
|
|
public List<CONFIG_DATA_DICTIONARY> getCONFIG_DATA_DICTIONARYList() {
|
if(null == getId()){
|
throw new RuntimeException("IDֵΪnull");
|
}
|
return dao.queryForList("select * from config_data_dictionary where CATEGORYID=:categoryid",this);
|
}
|
public List<CONFIG_DATA_DICTIONARY_CATEGORY> getCONFIG_DATA_DICTIONARY_CATEGORYList() {
|
if(null == getId()){
|
throw new RuntimeException("IDֵΪnull");
|
}
|
return dao.queryForList("select * from config_data_dictionary_category where PARENTID=:parentid",this);
|
}
|
|
@Override
|
public CONFIG_DATA_DICTIONARY_CATEGORY queryForBean() {
|
StringBuffer sBuffer = new StringBuffer("select * from CONFIG_DATA_DICTIONARY_CATEGORY where ");
|
if(isSetted_id){
|
sBuffer.append("id=:id and ");
|
}
|
if (isSetted_categoryname) {
|
sBuffer.append("categoryname=:categoryname and ");
|
}
|
if (isSetted_ordernum) {
|
sBuffer.append("ordernum=:ordernum and ");
|
}
|
if (isSetted_usestate) {
|
sBuffer.append("usestate=:usestate and ");
|
}
|
if (isSetted_parentid) {
|
sBuffer.append("parentid=:parentid and ");
|
}
|
if (isSetted_categorykey) {
|
sBuffer.append("categorykey=:categorykey and ");
|
}
|
if (isSetted_beiz) {
|
sBuffer.append("beiz=:beiz and ");
|
}
|
String sql = sBuffer.toString();
|
sql = StringUtils.removeEnd(sql, " and ");
|
return dao.queryForBean(sql,this);
|
}
|
|
@Override
|
public String getTableName() {
|
return "CONFIG_DATA_DICTIONARY_CATEGORY";
|
}
|
|
|
public Map getBeanValues(){
|
return this.BEAN_VALUES;
|
}
|
|
@Override
|
public CONFIG_DATA_DICTIONARY_CATEGORY insert() {
|
if (StringUtils.isBlank(id)) {
|
this.setId(StringUtil.getUUID());
|
}
|
dao.execute(getInsertSql(),BEAN_VALUES);
|
return this;
|
}
|
|
@Override
|
public CONFIG_DATA_DICTIONARY_CATEGORY update() {
|
if (StringUtils.isBlank(id)) {
|
throw new RuntimeException("更新Bean时ID不能为空");
|
}
|
dao.execute(getUpdateSql(),BEAN_VALUES);
|
return this;
|
}
|
|
public CONFIG_DATA_DICTIONARY_CATEGORY 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_CATEGORY 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("CATEGORYNAME");
|
BEAN_VALUES.put("categoryname",obj);
|
this.setCategoryname(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));
|
obj = rs.getObject("PARENTID");
|
BEAN_VALUES.put("parentid",obj);
|
this.setParentid(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("CATEGORYKEY");
|
BEAN_VALUES.put("categorykey",obj);
|
this.setCategorykey(ConvertUtil.obj2Str(obj));
|
obj = rs.getObject("BEIZ");
|
BEAN_VALUES.put("beiz",obj);
|
this.setBeiz(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_DICTIONARY_CATEGORY newInstance(){
|
return new CONFIG_DATA_DICTIONARY_CATEGORY();
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|