package com.yihu.hos.system.dao; import com.yihu.hos.web.framework.dao.SQLGeneralDAO; import com.yihu.hos.web.framework.model.Result; import com.yihu.hos.system.dao.intf.ISystemParamDao; import com.yihu.hos.system.model.SystemParam; import org.springframework.stereotype.Repository; import org.springframework.util.StringUtils; import java.util.List; import java.util.Map; /** * Created by chenweida on 2016/1/19. */ @Repository("systemParamDao") public class SystemParamDao extends SQLGeneralDAO implements ISystemParamDao { @Override public Result getParamList(Map params) throws Exception { StringBuilder sb = new StringBuilder("from SystemParam t where 1=1 "); if (!StringUtils.isEmpty(params.get("name"))) { sb.append(" and (t.paramKey like '%" + params.get("name") + "%' or t.paramValue like '%" + params.get("name") + "%')"); } return super.getDataGridResult(sb.toString(), Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("rows").toString())); } @Override public SystemParam getParamByKey(String paramKey) throws Exception { List sParams = (List) super.hibernateTemplate.find("from SystemParam s where s.paramKey = ?", paramKey); if (sParams != null && sParams.size() > 0) { return sParams.get(0); } return null; } @Override public SystemParam getParamByKeyWithOutId(String paramKey, String id) throws Exception { List sParams = (List) super.hibernateTemplate.find("from SystemParam s where s.paramKey=? and s.id!=?", paramKey, id); if (sParams != null && sParams.size() > 0) { return sParams.get(0); } return null; } }