Search in sources :

Example 1 with PermissionDTO

use of com.goodskill.web.dto.PermissionDTO in project goodsKill by techa03.

the class AdminController method permissionTree.

@RequestMapping(value = "/permissionTree", method = GET, produces = { "application/json;charset=UTF-8" })
@ResponseBody
public ResponseDTO permissionTree(@RequestParam(name = "page", required = false, defaultValue = "0") int offset, @RequestParam(name = "limit", required = false, defaultValue = "10") int limit) {
    Page<Permission> page = new Page<>(offset, limit);
    IPage<Permission> pageInfo = permissionService.page(page);
    List<Permission> permissions = pageInfo.getRecords();
    List<PermissionDTO> permissionDTOList = new ArrayList<>();
    for (Permission permission : permissions) {
        PermissionDTO permissionDto = new PermissionDTO();
        permissionDto.setId(permission.getPermissionId().toString());
        if (permission.getParentPermissionId() != null) {
            permissionDto.setPId(permission.getParentPermissionId().toString());
        }
        permissionDto.setName(permission.getPermissionName());
        permissionDTOList.add(permissionDto);
    }
    ResponseDTO<PermissionDTO> responseDto = new ResponseDTO<>();
    responseDto.setData(permissionDTOList.toArray(new PermissionDTO[permissionDTOList.size()]));
    responseDto.setCount((int) pageInfo.getTotal());
    return responseDto;
}
Also used : PermissionDTO(com.goodskill.web.dto.PermissionDTO) ResponseDTO(com.goodskill.web.dto.ResponseDTO) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Aggregations

IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 PermissionDTO (com.goodskill.web.dto.PermissionDTO)1 ResponseDTO (com.goodskill.web.dto.ResponseDTO)1 ArrayList (java.util.ArrayList)1