Example #1
0
  public PageBounds gainPageBounds() {
    if (this.no == null || this.no <= 0) setNo(1);
    if (this.size == null || this.size <= 0) setSize(Integer.MAX_VALUE - 1);

    if (StringUtils.isEmpty(this.sort)) {
      return new PageBounds(this.no, this.size);
    } else {
      return new PageBounds(this.no, this.size, Order.create(getSort(), getOrder()));
    }
  }
  /**
   * 查询单技能
   *
   * @param req
   * @param response
   * @param dataParm
   */
  @RequestMapping("abli/searchAblityById")
  public void searchTaskById(
      HttpServletRequest req, HttpServletResponse response, @RequestParam String dataParm) {
    if (logger.isDebugEnabled()) {
      logger.debug("UserAblityController---searchAblityById---begin");
    }

    try {
      super.getParm(req, response);

      if (!UserAgentUtils.isMobileOrTablet(req)) {
        super.writeJson(response, "9997", "无效设备", null, null);
      } else {
        Map paramMap = data.getDataset();

        Object page = paramMap.get("page"), // PAGE NUMBER
            pageSize = paramMap.get("pageSize"), // MAX ROWS RETURN
            sort = paramMap.get("sort"); // SORT INFO

        String sortString = sort == null ? "COMMENT_TIME.desc" : sort.toString(); // 评论排序
        int pageInt = Integer.parseInt(page.toString());
        int pageSizeInt = Integer.parseInt(pageSize.toString());

        Map resMap = new HashMap();
        List resList = null;

        // 分页查询,仅仅在第一页中加入技能数据,满足的记录数totalCount, 以及第一页的技能留言
        if (pageInt == 1) {
          resMap = userAblityService.searchAblityById(paramMap);
        }

        PageBounds pageBounds = new PageBounds(pageInt, pageSizeInt, Order.formString(sortString));

        resList =
            PubTool.getResultList(
                "UserAblityDAO.getAbliComments", paramMap, pageBounds, sqlSessionFactory);

        // 仅在第一页加入评论
        int totalCount = 0;
        if (PubTool.isListHasData(resList) && pageInt == 1) {
          totalCount = ((PageList) resList).getPaginator().getTotalCount();
        }
        resMap.put("totalCount", totalCount);

        super.writeJson(response, Code.SUCCESS, Code.SUCCESS_MSG, resMap, resList);
      }
    } catch (Exception e) {
      super.writeJson(response, "9992", "后台程序执行失败", null, null);
      logger.error("UserAblityController---searchAblityById---interface error: ", e);
    }
  }
  /**
   * 查询技能列表 1.查询用户发布的技能列表 -OPTIMAL 2.查询所有的技能列表 -DEFAULT 3.根据距离查询 LONGITUDE LATITUDE -REQUIRED
   *
   * @param req
   * @param response
   * @param dataParm
   */
  @RequestMapping("abli/searchAblityList")
  public void searchAblityList(
      HttpServletRequest req, HttpServletResponse response, @RequestParam String dataParm) {
    if (logger.isDebugEnabled()) {
      logger.debug("UserAblityController---searchAblityList---begin");
    }

    try {
      super.getParm(req, response);

      Map paramMap = data.getDataset();

      if (!UserAgentUtils.isMobileOrTablet(req)) {
        super.writeJson(response, "9997", "无效设备", null, null);
      } else {
        // DIST.desc,ABLI_BUY_COUNT.desc,ABLI_COMMMENT.desc,ABLI_POINT.desc,ABLI_LAST_UPDATE.desc
        String sortString = paramMap.get("sort").toString();
        int pageInt = Integer.parseInt(paramMap.get("page").toString()); // PAGE NUMBER
        int pageSizeInt = Integer.parseInt(paramMap.get("pageSize").toString()); // MAX ROWS RETURN

        PageBounds pageBounds = new PageBounds(pageInt, pageSizeInt, Order.formString(sortString));

        List resList =
            PubTool.getResultList(
                "UserAblityDAO.searchAblityList", paramMap, pageBounds, sqlSessionFactory);

        Map resMap = new HashMap();
        int totalCount = 0;
        if (PubTool.isListHasData(resList)) {
          totalCount = ((PageList) resList).getPaginator().getTotalCount();
          PubTool.reCalculateDistance(resList, paramMap, "ABLI_LONGITUDE", "ABLI_LATITUDE");
        }
        resMap.put("totalCount", totalCount);

        super.writeJson(response, Code.SUCCESS, Code.SUCCESS_MSG, resMap, resList);
      }
    } catch (Exception e) {
      super.writeJson(response, "9992", "后台程序执行失败", null, null);
      logger.error("UserAblityController---searchAblityList---interface error: ", e);
    }
  }