Search in sources :

Example 1 with PageResult

use of com.ibeiliao.deployment.admin.common.PageResult in project Corgi by kevinYin.

the class ListAccountController method listAccount.

/**
 * 读取管理员列表
 * @param keyword 搜索的关键字
 * @param page 第几页
 * @param pageSize 每页多少
 * @return result.object=数据列表,数据列表不为null
 */
@RequestMapping("queryAccount")
@MenuResource("读取管理员列表")
@ResponseBody
public PageResult<List<AdminAccount>> listAccount(String keyword, int page, int pageSize, HttpServletRequest request) {
    List<AdminAccount> list = adminAccountService.listAccounts(keyword, page, pageSize);
    int total = adminAccountService.statAccount(keyword);
    for (AdminAccount account : list) {
        StringBuilder buf = new StringBuilder();
        List<AccountRoleRelation> tmpList = adminAccountService.listAccountRoles(account.getUid());
        for (AccountRoleRelation arr : tmpList) {
            Role role = roleService.getById(arr.getRoleId());
            if (role != null) {
                if (buf.length() > 0)
                    buf.append(",");
                buf.append(role.getRoleName());
            }
        }
        account.setRoleName(buf.toString());
    }
    PageResult<List<AdminAccount>> result = new PageResult<>(list);
    result.setCurrentPage(page);
    result.setPageSize(pageSize);
    result.setCount(total);
    return result;
}
Also used : Role(com.ibeiliao.deployment.admin.vo.account.Role) AccountRoleRelation(com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) List(java.util.List) PageResult(com.ibeiliao.deployment.admin.common.PageResult) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

PageResult (com.ibeiliao.deployment.admin.common.PageResult)1 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)1 AccountRoleRelation (com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation)1 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 List (java.util.List)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1