📄 indexcategoryserviceimpl.java
字号:
package com.srit.gcz.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.srit.gcz.bean.IndexCategory;
import com.srit.gcz.bean.tree.TreeAttributeBean;
import com.srit.gcz.bean.tree.TreeDataBean;
import com.srit.gcz.bean.tree.TreeJsonBean;
import com.srit.gcz.dao.IndexCategoryDao;
import com.srit.gcz.service.IndexCategoryService;
import com.srit.gcz.util.SerialNum;
import com.srit.gcz.util.SysConstant;
/**
* 指标分类
* @Company 国研科技
* @author 陈鹏昊
* @date 2009-3-24
* @version 1.0
* @since 1.0
*/
public class IndexCategoryServiceImpl implements IndexCategoryService {
// Spring注入
private IndexCategoryDao indexCategoryDao;
public boolean save(IndexCategory bean) {
// 父节点是否含有子节点
if(indexCategoryDao.isHasChild(bean.getPid()) == 0){
indexCategoryDao.updateHasChild(bean.getPid(), 1);
}
// 设置唯一标示符
bean.setId(SerialNum.getSerialNum(SysConstant.TABLE_INDEX_CATEGORY));
indexCategoryDao.save(bean);
return true;
}
public boolean update(IndexCategory bean) {
return indexCategoryDao.update(bean);
}
public boolean delete(IndexCategory bean) {
// 父节点是否含有子节点
if(indexCategoryDao.isHasChild(bean.getPid()) == 1){
indexCategoryDao.updateHasChild(bean.getPid(), 0);
}
return indexCategoryDao.delete(bean.getId());
}
public List<TreeJsonBean> getSubCategoryTreeByID(int ID) {
List<TreeJsonBean> tjbs = new ArrayList<TreeJsonBean>();
TreeJsonBean tjb = null;
TreeAttributeBean tab = null;
TreeDataBean tdb = null;
for(IndexCategory tb : indexCategoryDao.getSubCategoryTreeByID(ID)){
tjb = new TreeJsonBean();
tab = new TreeAttributeBean();
tab.setId(tb.getId()+"");
tab.setRel(tb.getType()+"");
tjb.setAttributes(tab);
tdb = new TreeDataBean();
tdb.setTitle(tb.getName());
tjb.setData(tdb);
if(tb.getHasChild()==1){
tjb.setState("closed");
}
tjbs.add(tjb);
}
return tjbs;
}
public IndexCategory getIndexCategoryByID(int ID) {
return indexCategoryDao.getIndexCategoryByID(ID);
}
public void setIndexCategoryDao(IndexCategoryDao indexCategoryDao) {
this.indexCategoryDao = indexCategoryDao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -