예제 #1
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());
 }
예제 #2
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);
 }