package com.vci.server.framework.appConfig;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import org.hibernate.HibernateException;
|
import org.hibernate.type.Type;
|
|
import com.vci.common.objects.UserEntity;
|
import com.vci.server.base.persistence.dao.BaseService;
|
import com.vci.server.base.persistence.dao.HibernateCallback;
|
import com.vci.server.base.persistence.dao.HibernateTemplate;
|
/**
|
* AppConfigCategory DAO Service
|
*
|
*/
|
public class AppConfigCategoryService extends BaseService {
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
public AppConfigCategoryService(UserEntity userEntity){
|
super(userEntity);
|
}
|
|
/**
|
* 添加、保存 AppConfigCategory 对象
|
* @param object AppConfigCategory 对象
|
*/
|
public boolean saveAppConfigCategory(final AppConfigCategory object){
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
object.setUserEntity(userEntity);
|
impl.saveOrUpdate(object);
|
return true;
|
}
|
});
|
}
|
|
/**
|
* 修改、更新 AppConfigCategory 对象
|
* @param object AppConfigCategory 对象
|
*/
|
public boolean updateAppConfigCategory(final AppConfigCategory object){
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
object.setUserEntity(userEntity);
|
AppConfigCategory objGet = impl.getById(object.getId());
|
if(objGet == null){
|
impl.saveOrUpdate(object);
|
}else{
|
objGet.setUserEntity(userEntity);
|
objGet.setId(object.getId());
|
objGet.setName(object.getName());
|
objGet.setDesc(object.getDesc());
|
impl.saveOrUpdate(objGet);
|
}
|
return true;
|
}
|
});
|
}
|
|
/**
|
* 根据 ID 删除 AppConfigCategory 对象(批量)
|
* @param ids AppConfigCategory 对象的 ID 列表
|
*/
|
public boolean deleteAppConfigCategory(final String[] ids){
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
String hql = "delete AppConfigCategory p where p.id in (";
|
int len = ids.length;
|
for (int i = 0; i < len; i++) {
|
hql += "?";
|
if (i != len - 1) {
|
hql += ",";
|
}
|
}
|
hql += ")";
|
impl.deleteQueryObject(hql, ids, userEntity);
|
return true;
|
}
|
});
|
}
|
|
/**
|
* 返回全部的 AppConfigCategory 对象
|
*/
|
@SuppressWarnings("unchecked")
|
public List<AppConfigCategory> getAppConfigCategorys(){
|
return (List<AppConfigCategory>)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
return impl.loadAll();
|
}
|
});
|
}
|
|
/**
|
* 根据 ID 返回 AppConfigCategory 对象
|
* @param ids AppConfigCategory 对象的 ID 列表
|
*/
|
@SuppressWarnings("unchecked")
|
public AppConfigCategory getAppConfigCategoryById(final String id){
|
return (AppConfigCategory)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
String hql = "from AppConfigCategory t where t.id = ?";
|
return impl.findEntity(hql, new Object[]{id});
|
}
|
});
|
}
|
|
public AppConfigCategory getAppConfigCategoryByName(final String name){
|
return (AppConfigCategory)new HibernateTemplate().run(new HibernateCallback(){
|
public Object execute() throws HibernateException {
|
AppConfigCategoryDaoImpl impl = new AppConfigCategoryDaoImpl();
|
String hql = "from AppConfigCategory t where t.name = ?";
|
return impl.findEntity(hql, new Object[]{name});
|
}
|
});
|
}
|
}
|