コード例 #1
0
  /**
   * 分页获取我的最近浏览
   *
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/v1.0/resource/userview", method = RequestMethod.GET)
  @ResponseBody
  public ResultJSON getMyViewList(HttpServletRequest request, HttpServletResponse response) {
    // 返回json的结果对象
    ResultJSON result = new ResultJSON();
    // 异常
    CustomException exception = (CustomException) request.getAttribute(CustomException.request_key);
    // 当前登录用户id
    Long currentUserId = (Long) request.getAttribute("currentUserId");
    // 返回
    Object data = null;
    try {
      if (currentUserId != null && exception == null) {
        // 获取文件服务器的访问url
        String resServiceLocal = (String) request.getAttribute("resServiceLocal");
        String currentResPath = (String) request.getAttribute("currentResPath");

        long userId = currentUserId;
        long unifyTypeId = 0;
        int page = 1;
        int prePage = 10;

        String _unifyTypeId = request.getParameter("unifyTypeId");
        String _page = request.getParameter("page");
        String _prePage = request.getParameter("perPage");
        String fileFormat = request.getParameter("fileFormat");
        if (StringUtils.isNotEmpty(_unifyTypeId)) {
          unifyTypeId = Long.parseLong(_unifyTypeId);
        }
        if (StringUtils.isNotEmpty(_page)) {
          page = Integer.parseInt(_page);
        }
        if (StringUtils.isNotEmpty(_prePage)) {
          prePage = Integer.parseInt(_prePage);
        }

        // 获取结果
        PageInfo info =
            userLogService.getMyViewLogFroResource(userId, unifyTypeId, fileFormat, page, prePage);
        Pagination _p = new PageInfoToPagination().transfer(info.getList());
        // 获取缩略图的最终url
        JPrepareContentViewUtil.convertToPurpose_view(
            _p.getList(), resServiceLocal, currentResPath);
        data = _p;
        exception = CustomException.SUCCESS;
      } else {
        exception = CustomException.INVALIDACCESSTOKEN;
      }
    } catch (Exception e) {
      exception = CustomException.getCustomExceptionByCode(e.getMessage());
      // 如果是普通的异常
      e.printStackTrace();
    } finally {
      result.setCode(exception.getCode());
      result.setMessage(exception.getMessage());
      result.setData(data == null ? "" : data);
      result.setSign("");
    }
    return result;
  }
コード例 #2
0
  /**
   * 分页我获取的资源评论
   *
   * @param request
   * @param response
   * @return
   */
  @RequestMapping(value = "/v1.0/resource/userReviewComment", method = RequestMethod.GET)
  @ResponseBody
  public ResultJSON getMyReviewComment(HttpServletRequest request, HttpServletResponse response) {
    // 返回json的结果对象
    ResultJSON result = new ResultJSON();
    // 异常
    CustomException exception = (CustomException) request.getAttribute(CustomException.request_key);
    // 当前登录用户id
    Long currentUserId = (Long) request.getAttribute("currentUserId");
    // 返回
    Object data = null;
    try {
      if (currentUserId != null && exception == null) {
        // 获取文件服务器的访问url
        String resServiceLocal = (String) request.getAttribute("resServiceLocal");
        String currentResPath = (String) request.getAttribute("currentResPath");

        long userId = currentUserId;
        int reviewType = 0;
        int page = 1;
        int prePage = 10;

        String _reviewType = request.getParameter("reviewType");
        String _page = request.getParameter("page");
        String _prePage = request.getParameter("perPage");
        if (StringUtils.isNotEmpty(_reviewType)) {
          reviewType = Integer.parseInt(_reviewType);
        }
        if (StringUtils.isNotEmpty(_page)) {
          page = Integer.parseInt(_page);
        }
        if (StringUtils.isNotEmpty(_prePage)) {
          prePage = Integer.parseInt(_prePage);
        }
        Pagination page_result = assetService.getMyReviewComment(userId, reviewType, page, prePage);
        JPrepareContentViewUtil.convertToPurpose_Review(
            page_result.getList(), resServiceLocal, currentResPath);
        data = page_result;
        exception = CustomException.SUCCESS;
      } else {
        exception = CustomException.INVALIDACCESSTOKEN;
      }
    } catch (Exception e) {
      exception = CustomException.getCustomExceptionByCode(e.getMessage());
      // 如果是普通的异常
      if (exception.getStatus() == 500) {
        e.printStackTrace();
      }
    } finally {
      result.setCode(exception.getCode());
      result.setMessage(exception.getMessage());
      result.setData(data == null ? "" : data);
      result.setSign("");
    }
    return result;
  }