package com.vci.server.framework.systemConfig.specialchar;
|
|
|
import java.util.List;
|
|
import org.hibernate.HibernateException;
|
|
import com.vci.server.base.persistence.dao.BaseService;
|
import com.vci.server.base.persistence.dao.HibernateCallback;
|
import com.vci.server.base.persistence.dao.HibernateTemplate;
|
|
|
public class SpecialCharService extends BaseService {
|
|
//特殊字符 (操作模块)
|
private final String SPECIALCHAR = "特殊字符";
|
|
/**
|
*
|
* <p>Description:保存特殊字符 </p>
|
*
|
* @author sunbo
|
* @time 2012-5-25
|
* @param schar
|
*/
|
public void saveSpecialChar(final SpecialChar schar) {
|
new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
userEntity.setModule(SPECIALCHAR);
|
schar.setUserEntity(userEntity);
|
impl.save(schar);
|
return schar;
|
}
|
});
|
}
|
//更新特殊字符
|
public void updateSpecialChar(final SpecialChar schar) {
|
new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
SpecialChar curChar = impl.loadById(schar.getId());
|
curChar.setValue(schar.getValue());
|
userEntity.setModule(SPECIALCHAR);
|
curChar.setUserEntity(userEntity);
|
impl.saveOrUpdate(curChar);
|
return schar;
|
}
|
});
|
}
|
//根据ID删除特殊字符
|
public boolean deleteSpecialChar(final String id) {
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
SpecialChar curChar = impl.loadById(id);
|
userEntity.setModule(SPECIALCHAR);
|
curChar.setUserEntity(userEntity);
|
impl.delete(curChar);
|
return true;
|
}
|
});
|
}
|
|
public boolean deleteSpecialCharByParentId(final String id) {
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hql = "delete SpecialChar sc where sc.parentId =:id";
|
userEntity.setModule(SPECIALCHAR);
|
impl.deleteQueryObject(hql, "id", id, userEntity);
|
return true;
|
}
|
});
|
}
|
|
public boolean deleteSpecialCharByHql(final String[] ids) {
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hql = "delete SpecialChar where PLOID in (";
|
int len = ids.length;
|
for (int i = 0; i < len; i++) {
|
hql += "?";
|
if (i != len - 1) {
|
hql += ",";
|
}
|
}
|
hql += ")";
|
userEntity.setModule(SPECIALCHAR);
|
impl.deleteQueryObject(hql, ids, userEntity);
|
return true;
|
}
|
});
|
}
|
|
//获取所有的特殊字符
|
public List getSpecialCharList() {
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hsql = "from SpecialChar schar order by schar.value";
|
return impl.findEntities(hsql);
|
}
|
});
|
}
|
/**
|
*
|
* <p>Description:根据分类ID获得特殊字符 </p>
|
*
|
* @author sunbo
|
* @time 2012-5-25
|
* @param id
|
* @return
|
*/
|
public List getSepcialCharByClsfId(final String id) {
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hsql = "from SpecialChar schar where PLPARENTID = '" + id + "' order by schar.value";
|
if(id.equals("")){
|
hsql = "from SpecialChar schar order by schar.value";
|
}
|
return impl.findEntities(hsql);
|
}
|
});
|
}
|
|
/**
|
* 获得制定分类下指定值的对象
|
* @param id
|
* @param val
|
* @return
|
*/
|
public SpecialChar getSepcialCharByClsfIdAndVal(final String id, final String val) {
|
return (SpecialChar)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hsql = "from SpecialChar schar where PLPARENTID = ? and schar.value = ?";
|
String[] values = new String[2];
|
values[0] = id;
|
values[1] = val;
|
return impl.findEntity(hsql, values);
|
}
|
});
|
}
|
|
public SpecialChar getSepcialCharById(final String id) {
|
return (SpecialChar)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
return impl.getById(id);
|
}
|
});
|
}
|
|
|
/**
|
* 获得与已选择特殊字符相同的特殊字符个数
|
* @author liujw
|
* @param id
|
* @param val
|
* @return list
|
*/
|
public List getSameValueList(final String Id, final String val) {
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharDAOImpl impl = new SpecialCharDAOImpl();
|
String hsql = "from SpecialChar schar where schar.parentId = ? and schar.value = ? order by schar.value";
|
String[] values = new String[2];
|
values[0] = Id;
|
values[1] = val;
|
return impl.findEntites(hsql, values);
|
}
|
});
|
}
|
}
|