コード例 #1
0
  public String queryCity() {

    if ((null != param) && (param.trim().length() > 0)
        || (null != cityIdName) && (cityIdName.trim().length() > 0)) {
      try {
        byte[] paramStr = param.getBytes("ISO-8859-1");
        param = new String(paramStr, "UTF-8");
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }
      cityList =
          cityDAO.queryForPage(
              "FROM CityEntity ct WHERE ct.cityName LIKE \'%"
                  + param
                  + "%\' AND ct.cityId LIKE \'%"
                  + cityIdName
                  + "%\'",
              page,
              limit);
      rowCount =
          cityDAO.queryRecordCount(
              "SELECT COUNT(*) FROM CityEntity ct WHERE ct.cityName LIKE \'%"
                  + param
                  + "%\' AND ct.cityId LIKE \'%"
                  + cityIdName
                  + "%\'");
      return SUCCESS;
    } else {
      cityList = cityDAO.queryForPage("FROM CityEntity", page, limit); // Hql,第几页,每页几条
      rowCount = cityDAO.queryRecordCount("SELECT count(*) FROM CityEntity");
      return SUCCESS;
    }
  }
コード例 #2
0
 public String deleteCity() {
   boolean result = cityDAO.delete(cityInfo);
   if (true == result) {
     success = true;
     setMessage("删除成功!!");
   } else {
     success = false;
     setMessage("删除失败!!");
   }
   return SUCCESS;
 }