mybatis3 前台传数组 的处理

/**
     * 分页按条件查询权限列表
     * @param keywords
     * @return
     */
    @RequestMapping(value = "/getByCondition2", method = { RequestMethod.GET,
            RequestMethod.POST })
    public @ResponseBody String getByCondition2(String beginTime,
            String endTime,String privilegePersonsList,int startRow,int pageSize) {
        List<Integer> privilegePersonLongs= new ArrayList<Integer>();
        String[] split = privilegePersonsList.split(",");
        List<String> privilegePersons= Arrays.asList(split);
        
        if (privilegePersonLongs!=null) {
            List<DataPrivilege> list =service.selectByCondition(beginTime,endTime, ListUtil.fromStringToLongList(privilegePersons),startRow,pageSize);
            Page<DataPrivilege> page = new Page<DataPrivilege>(service.countByConditions());
            if (list.size() != 0) {
                ResultVO<DataPrivilege> result = new ResultVO<DataPrivilege>();
                result.setLists(list);
                result.setPage(page);
                return result.toString();
        } 
        }
        return "";
    }
    
    
    /**
     * 分页按条件查询权限列表
     * @param keywords
     * @return
     */
    @RequestMapping(value = "/getByCondition3", method = { RequestMethod.GET,
            RequestMethod.POST })
    public @ResponseBody String getByCondition3(String beginTime,
            String endTime,Integer[] privIds,int startRow,int pageSize) {
        List<Integer> privilegePersonLongs= new ArrayList<Integer>();
        if (privilegePersonLongs!=null) {
            List<DataPrivilege> list =service.selectByCondition(beginTime,endTime, Arrays.asList(privIds),startRow,pageSize);
            Page<DataPrivilege> page = new Page<DataPrivilege>(service.countByConditions());
            if (list.size() != 0) {
                ResultVO<DataPrivilege> result = new ResultVO<DataPrivilege>();
                result.setLists(list);
                result.setPage(page);
                return result.toString();
        } 
        }
        return "";
    }
    
    @RequestMapping(value="/getByCondition7", method={RequestMethod.GET,RequestMethod.POST})
    public @ResponseBody String getByCondition7(String beginTime,String endTime,
    @RequestParam(value="privilegePersons[]",required=false)List<Integer> privilegePersons,int startRow,int pageSize) {
    List<DataPrivilege> list =service.selectByCondition(beginTime,endTime,privilegePersons,startRow,pageSize);
    Page<DataPrivilege> page = new Page<DataPrivilege>(service.countByConditions());
    if (list.size() != 0) {
        ResultVO<DataPrivilege> result = new ResultVO<DataPrivilege>();
        result.setLists(list);
        result.setPage(page);
        return result.toString();
    }
    return "";
    }

---------------------------------------------------------------------------------------------------------------------------------------------------------------
http://localhost:8080/rolems/dataPrivilege/getByCondition2?&beginTime=2017-04-14 07:01:30&endTime=2017-04-18 17:01:30&startRow=0&pageSize=5&privilegePersonsList=0,1,2

http://localhost:8080/rolems/dataPrivilege/getByCondition7?&beginTime=2017-04-14 07:01:30&endTime=2017-04-18 17:01:30&startRow=0&pageSize=5&privilegePersons[]=0,1,2

http://localhost:8080/rolems/dataPrivilege/getByCondition3?&beginTime=2017-04-14 07:01:30&endTime=2017-04-18 17:01:30&startRow=0&pageSize=5&privIds=0,1,2

{
    "result": "0",
    "responseInfo": {
        "page": {
            "totalNum": 9,
            "pageNum": 1,
            "pageSize": 5,
            "startRow": 0,
            "pages": 2,
            "orderField": "",
            "direct": "DESC"
        },
        "lists": [
            {
                "createTime": "2017-04-14 10:01:30",
                "privilegePerson": 0,
                "personOrRole": 1,
                "isCreator": 0,
                "dataId": "100020170414100000001130000000"
            },
            {
                "createTime": "2017-04-14 10:01:30",
                "privilegePerson": 1,
                "personOrRole": 1,
                "isCreator": 0,
                "dataId": "100020170414100000001230000000"
            },
            {
                "createTime": "2017-04-14 10:01:30",
                "privilegePerson": 2,
                "personOrRole": 1,
                "isCreator": 0,
                "dataId": "100020170414100000001330000000"
            },
            {
                "createTime": "2017-04-15 09:49:46",
                "privilegePerson": 0,
                "personOrRole": 1,
                "isCreator": 0,
                "dataId": "100020170414100000001030000000"
            },
            {
                "createTime": "2017-04-15 09:49:46",
                "privilegePerson": 1,
                "personOrRole": 1,
                "isCreator": 0,
                "dataId": "100020170414100000001430000000"
            }
        ]
    }
}

 

posted @ 2017-04-19 19:54  Alamps  阅读(1130)  评论(0编辑  收藏  举报