SystemParamDao.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.yihu.hos.system.dao;
  2. import com.yihu.hos.web.framework.dao.SQLGeneralDAO;
  3. import com.yihu.hos.web.framework.model.Result;
  4. import com.yihu.hos.system.dao.intf.ISystemParamDao;
  5. import com.yihu.hos.system.model.SystemParam;
  6. import org.springframework.stereotype.Repository;
  7. import org.springframework.util.StringUtils;
  8. import java.util.List;
  9. import java.util.Map;
  10. /**
  11. * Created by chenweida on 2016/1/19.
  12. */
  13. @Repository("systemParamDao")
  14. public class SystemParamDao extends SQLGeneralDAO implements ISystemParamDao {
  15. @Override
  16. public Result getParamList(Map<String, Object> params) throws Exception {
  17. StringBuilder sb = new StringBuilder("from SystemParam t where 1=1 ");
  18. if (!StringUtils.isEmpty(params.get("name"))) {
  19. sb.append(" and (t.paramKey like '%" + params.get("name") + "%' or t.paramValue like '%" + params.get("name") + "%')");
  20. }
  21. return super.getDataGridResult(sb.toString(), Integer.valueOf(params.get("page").toString()), Integer.valueOf(params.get("rows").toString()));
  22. }
  23. @Override
  24. public SystemParam getParamByKey(String paramKey) throws Exception {
  25. List<SystemParam> sParams = (List<SystemParam>) super.hibernateTemplate.find("from SystemParam s where s.paramKey = ?", paramKey);
  26. if (sParams != null && sParams.size() > 0) {
  27. return sParams.get(0);
  28. }
  29. return null;
  30. }
  31. @Override
  32. public SystemParam getParamByKeyWithOutId(String paramKey, String id) throws Exception {
  33. List<SystemParam> sParams = (List<SystemParam>) super.hibernateTemplate.find("from SystemParam s where s.paramKey=? and s.id!=?", paramKey, id);
  34. if (sParams != null && sParams.size() > 0) {
  35. return sParams.get(0);
  36. }
  37. return null;
  38. }
  39. }