| | |
| | | package com.ld.igds.view.service; |
| | | |
| | | import com.bstek.bdf2.core.orm.hibernate.HibernateDao; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.ld.igds.models.DicArea; |
| | | import com.ld.igds.models.DicFoodOrigin; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.hibernate.Session; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | return null; |
| | | } |
| | | return list.get(0); |
| | | } |
| | | |
| | | public void getDicArea(Page<DicFoodOrigin> page, Map<String,Object> param) throws Exception { |
| | | String hql = " from " + DicArea.class.getName() + " where 1=1"; |
| | | |
| | | Map<String, Object> args = new HashMap<String, Object>(); |
| | | |
| | | if (null != param) { |
| | | String str = (String) param.get("code"); |
| | | if (StringUtils.isNotEmpty(str)) { |
| | | hql += " and code like :code"; |
| | | args.put("code", "%" + str + "%"); |
| | | } |
| | | str = (String) param.get("name"); |
| | | if (StringUtils.isNotEmpty(str)) { |
| | | hql += " and name like :name"; |
| | | args.put("name", "%" + str + "%"); |
| | | } |
| | | |
| | | str = (String) param.get("disabledTag"); |
| | | if (StringUtils.isNotEmpty(str)) { |
| | | hql += " and disabledTag = :disabledTag"; |
| | | args.put("disabledTag", str); |
| | | } |
| | | |
| | | str = (String) param.get("key"); |
| | | if (StringUtils.isNoneEmpty(str)) { |
| | | hql += " and (name like :name or code like:code or simple like:simple) "; |
| | | args.put("name", "%" + str + "%"); |
| | | args.put("code", "%" + str + "%"); |
| | | args.put("simple", "%" + str.toUpperCase() + "%"); |
| | | } |
| | | } |
| | | |
| | | String coutHql = "select count(*) " + hql; |
| | | |
| | | hql += " order by code"; |
| | | |
| | | if (args.isEmpty()) { |
| | | this.pagingQuery(page, hql, coutHql); |
| | | } else { |
| | | this.pagingQuery(page, hql, coutHql, args); |
| | | } |
| | | } |
| | | } |