Пример #1
0
  @RequestMapping("/bd_quick_reply/table_data")
  public @ResponseBody Map<String, Object> list(BdQuickReplyDataTableQueryArgWapper arg) {
    Map<String, Object> result = new HashMap<>();
    PageInfo<QuickReply> quickReply = null;
    try {
      quickReply =
          quickReplyService.selectLikePage(
              arg.getSearchText(),
              arg.getPageNum(),
              arg.getLength(),
              "sort asc, " + arg.getOrderStr());
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }

    List<QuickReplyJson> data = new ArrayList<>();

    int index = 1;
    for (QuickReply info : quickReply.getList()) {
      data.add(new QuickReplyJson(index, info));
      index++;
    }

    result.put("draw", arg.getDraw());
    result.put("recordsTotal", data.size());
    result.put("recordsFiltered", data.size());
    result.put("data", data);

    return result;
  }
  /**
   * 分页获取我的最近浏览
   *
   * @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;
  }
Пример #3
0
 @ResponseBody
 @RequestMapping(value = "/loadData")
 public DataStore<Role> loadData(int page, int rows, Role role)
     throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
   PageInfo<Role> pageInfo = roleService.getPage(BeanUtils.describe(role), page, rows);
   return new DataStore<>(pageInfo.getTotal(), pageInfo.getList());
 }
Пример #4
0
 /**
  * 获取permission数据集合
  *
  * @author 尹逊志
  * @throws JsonProcessingException
  * @time 2015年4月13日下午10:29:36
  */
 @ResponseBody
 @RequestMapping(value = "/user/permissionList", method = RequestMethod.POST)
 public String getPermissonData(HttpServletRequest request, HttpServletResponse response)
     throws JsonProcessingException {
   String rows = request.getParameter("rows");
   String page = request.getParameter("page");
   if (rows == null) {
     rows = "20";
   }
   if (page == null) {
     page = "1";
   }
   String resource = "/mybatis-config-test.xml";
   InputStream is = UserController.class.getResourceAsStream(resource);
   SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
   SqlSession session = factory.openSession();
   String statement = "com.myproject.mybatis.user.permissionMapper.getAll";
   Map<String, Integer> map = new HashMap<String, Integer>();
   map.put("pageNum", Integer.parseInt(page));
   map.put("pageSize", Integer.parseInt(rows));
   PageHelper.startPage(Integer.parseInt(page), Integer.parseInt(rows));
   List<Permission> permissList = session.selectList(statement);
   PageInfo<Permission> pageInfo = new PageInfo<Permission>(permissList);
   session.commit();
   session.close();
   ResponseResult result = new ResponseResult();
   result.setTotal(pageInfo.getTotal());
   result.setRows(permissList);
   ObjectMapper mapper = new ObjectMapper();
   return mapper.writeValueAsString(result);
 }