package com.vci.server.framework.systemConfig.specialcharclsf;
|
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
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;
|
import com.vci.server.base.persistence.dao.JDBCCallback;
|
import com.vci.server.base.persistence.dao.JDBCRunType;
|
import com.vci.server.base.persistence.dao.JDBCTemplate;
|
import com.vci.server.framework.systemConfig.specialchar.SpecialCharDAOImpl;
|
|
|
/**
|
* 处理特殊字符分类的增、删、改、查操作
|
* @author Administrator
|
*
|
*/
|
public class SpecialCharClsfService extends BaseService{
|
|
//特殊字符分类(操作模块)
|
private final String SPECIALCHARCLSF = "com.vci.rmip.framework.client.systemConfig.specialCharacter.SpecialCharacterClsPanel";
|
/**
|
*
|
* <p>Description:保存特殊字符分类 </p>
|
* @author sunbo
|
* @time 2012-5-25
|
* @param clsf
|
*/
|
public void saveSpecialCharClsf(final SpecialCharClsf clsf) {
|
new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
userEntity.setModule(SPECIALCHARCLSF);
|
clsf.setUserEntity(userEntity);
|
impl.save(clsf);
|
return clsf;
|
}
|
});
|
}
|
/**
|
*
|
* <p>Description:更新特殊字符分类</p>
|
* @author sunbo
|
* @time 2012-5-25
|
* @param clsf
|
*/
|
public void updateSpecialCharClsf(final SpecialCharClsf clsf) {
|
new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
SpecialCharClsf curClsf = impl.loadById(clsf.getId());
|
curClsf.setName(clsf.getName());
|
curClsf.setDesc(clsf.getDesc());
|
userEntity.setModule(SPECIALCHARCLSF);
|
curClsf.setUserEntity(userEntity);
|
impl.saveOrUpdate(curClsf);
|
return clsf;
|
}
|
});
|
}
|
|
|
/**
|
* 获取所有特殊字符分类
|
* @return
|
*/
|
public List getSpecialCharClsfList(final int pageNo,final int pageSize) {
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
|
int V_PAGE_ROWNUM_START = (pageNo - 1) * pageSize;
|
int V_PAGE_ROWNUM_END = (pageNo ) * pageSize;
|
|
StringBuffer sb = new StringBuffer();
|
sb.append(" SELECT * ");
|
sb.append(" FROM (SELECT ROW_.*, ROWNUM RN ");
|
sb.append(" FROM (SELECT * FROM PLSPECCHARCLSF S ORDER BY S.PLNAME ");
|
sb.append(" )ROW_)");
|
sb.append(" WHERE RN <= ");
|
sb.append( V_PAGE_ROWNUM_END);
|
sb.append(" AND RN > ");
|
sb.append(V_PAGE_ROWNUM_START);
|
|
Object[] values = new Object[0];
|
List<SpecialCharClsf> list = impl.findEntites(sb.toString(), values, "S", SpecialCharClsf.class);
|
return list;
|
|
}
|
});
|
}
|
public List getbyChar(final String plscsfoId){
|
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
|
String sql = " from SpecialChar s where s.parentId='"+plscsfoId+"'";
|
return impl.findEntites(sql, new String[0]);
|
|
}
|
});
|
}
|
@SuppressWarnings("rawtypes")
|
public List getSpecialCharClsfList() {
|
return (List)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
|
String sql = " from SpecialCharClsf S ORDER BY S.name";
|
return impl.findEntites(sql, new String[0]);
|
|
}
|
});
|
}
|
|
/**
|
* 获取所有特殊字符分类总数
|
* @return
|
*/
|
public int getSpecialCharClsTotal() {
|
int res = 0;
|
String sql = "SELECT COUNT(*) FROM PLSPECCHARCLSF ";
|
res = (Integer)new JDBCTemplate().run(new JDBCCallback(
|
new HibernateTemplate().getSessionConnection(),
|
sql, JDBCRunType.SQL, 0, false, false,new Object[]{}) {
|
@Override
|
public Object execute(ResultSet rst) throws SQLException {
|
int ress = 0;
|
while(rst.next()){
|
ress = rst.getInt(1);
|
|
}
|
return ress;
|
}
|
});
|
return res;
|
}
|
|
|
/**
|
* 根据ID删除特殊字符分类
|
* @param id
|
* @return
|
*/
|
public boolean deleteSpecialCharClsfByHQL(final String id) {
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
SpecialCharClsf curClsf = impl.loadById(id);
|
curClsf.setUserEntity(userEntity);
|
impl.delete(curClsf);
|
return true;
|
}
|
});
|
}
|
/**
|
*
|
* <p>Description: 批量删除特殊字符分类</p>
|
*
|
* @author sunbo
|
* @time 2012-5-25
|
* @param ids
|
* @return
|
*/
|
public boolean deleteSpecialCharClsfByHQL(final String[] ids) {
|
return (Boolean)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
String hql = "delete SpecialCharClsf where PLOID in (";
|
int len = ids.length;
|
for (int i = 0; i < len; i++) {
|
hql += "?";
|
if (i != len - 1) {
|
hql += ",";
|
}
|
}
|
hql += ")";
|
userEntity.setModule(SPECIALCHARCLSF);
|
impl.createQuery(hql, ids);
|
|
SpecialCharDAOImpl charImpl = new SpecialCharDAOImpl();
|
String charHql = "delete SpecialChar sc where PLPARENTID in (";
|
|
for (int i = 0; i < len; i++) {
|
charHql += "?";
|
if (i != len - 1) {
|
charHql += ",";
|
}
|
}
|
charHql += ")";
|
charImpl.createQuery(charHql, ids);
|
return true;
|
}
|
});
|
}
|
|
/**
|
* 根据指定ID获取对应的分类信息
|
* @param id
|
* @return
|
*/
|
public SpecialCharClsf selectSpecialCharClsfById(final String id) {
|
return (SpecialCharClsf)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
return impl.loadById(id);
|
}
|
});
|
}
|
|
// /**
|
// * 根据指定ID,获取其子节点的分类信息
|
// * @param parentId
|
// * @return
|
// */
|
// public List selectSpecialCharClsfByParent(final String parentId) {
|
// return (List)new HibernateTemplate().run(new HibernateCallback() {
|
// public Object execute() throws HibernateException {
|
// SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
// String hsql = "from SpecialCharClsf clsf where PLPARENTID = :parentId order by clsf.name";
|
// return impl.findEntities(hsql, "parentId", parentId);
|
// }
|
// });
|
// }
|
|
/**
|
* 获得指定名称的分类
|
* @param name
|
* @return
|
*/
|
public SpecialCharClsf selectSpecialCharClsfByName(final String name) {
|
return (SpecialCharClsf)new HibernateTemplate().run(new HibernateCallback() {
|
public Object execute() throws HibernateException {
|
SpecialCharClsfDAOImpl impl = new SpecialCharClsfDAOImpl();
|
String hsql = "from SpecialCharClsf clsf where clsf.name = ?";
|
String[] values = new String[1];
|
values[0] = name;
|
return impl.findEntity(hsql, values);
|
}
|
});
|
}
|
}
|