📄 codeservice.java
字号:
package com.pegasus.framework.sys.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import com.pegasus.framework.dao.IBasicDAO;
import com.pegasus.framework.exception.BusinessException;
import com.pegasus.framework.service.impl.BasicService;
import com.pegasus.framework.sys.dao.ICodeDAO;
import com.pegasus.framework.sys.pojo.vo.Code;
import com.pegasus.framework.sys.service.ICodeService;
public class CodeService extends BasicService implements java.io.Serializable, ICodeService {
protected ICodeDAO codeDAO;
/**
* @return
*/
protected IBasicDAO getBasicDAO() {
return (IBasicDAO) getCodeDAO();
}
/**
* @return Returns the codeDAO.
*/
public ICodeDAO getCodeDAO() {
return codeDAO;
}
/**
* @param codeDAO The codeDAO to set.
*/
public void setCodeDAO(ICodeDAO codeDAO) {
this.codeDAO = codeDAO;
}
/**
* @param codeid .
* @return code list
* @throws Exception .
*/
public List<Code> getCodeList(String indexId) throws BusinessException {
return getCodeList(indexId, null);
}
public Map<String,Code> getCodeMapByName(String indexId) throws BusinessException {
Map<String,Code> result = new HashMap<String,Code>();
List<Code> codeList = getCodeList(indexId);
if(!codeList.isEmpty()) {
for(Code code : codeList) {
result.put(code.getName(),code);
}
}
return result;
}
/**
* @param codeid .
* @param query .
* @return .
* @throws Exception .
*/
public List<Code> getCodeList(String indexId, Criterion query) throws BusinessException {
Criterion where = Expression.eq("codeId", indexId);
if (query != null) {
where = Restrictions.and(where, query);
}
Order orderby = Order.asc("orderNo");
List criList = new ArrayList();
criList.add(where);
List orderList = new ArrayList();
orderList.add(orderby);
List<Code> list = query(criList, orderList, null);
return list;
}
/**
* @param codeid .
* @param title .
* @return .
* @throws Exception .
*/
public Code getCodeByName(String indexId, String name) throws BusinessException {
Criterion where = Expression.eq("codeId", indexId);
Criterion where1 = Expression.eq("name", name);
List criList = new ArrayList();
criList.add(where);
criList.add(where1);
List list = query(criList, null, null);
Code data = null;
if (!list.isEmpty()) {
data = (Code) list.get(0);
}
return data;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -