Search in sources :

Example 11 with AdminAccount

use of com.ibeiliao.deployment.admin.vo.account.AdminAccount in project Corgi by kevinYin.

the class ProjectServiceImpl method fillJoinerNamesIntoProject.

private void fillJoinerNamesIntoProject(List<Project> projects) {
    if (CollectionUtils.isEmpty(projects)) {
        return;
    }
    // 创建项目和账户关系
    ArrayList<Integer> projectIds = Lists.newArrayList();
    for (Project project : projects) {
        projectIds.add(project.getProjectId());
    }
    List<ProjectAccountRelation> relations = relationService.getByProjectIds(projectIds);
    Map<String, ProjectAccountRelation> acntProId2RelationMap = buildAccount2RelationMap(relations);
    ArrayList<Long> accountIds = Lists.newArrayList();
    for (ProjectAccountRelation relation : relations) {
        accountIds.add(relation.getAccountId());
    }
    ArrayListMultimap<Integer, Long> projectId2RelationPOsMap = ArrayListMultimap.create();
    for (ProjectAccountRelation relation : relations) {
        projectId2RelationPOsMap.put(relation.getProjectId(), relation.getAccountId());
    }
    // 账户和名字map
    List<AdminAccount> accountList = adminAccountService.findByAccountIds(accountIds);
    HashMap<Long, String> accountId2RealNameMap = Maps.newHashMap();
    for (AdminAccount account : accountList) {
        accountId2RealNameMap.put(account.getUid(), account.getRealname());
    }
    for (Project project : projects) {
        List<Long> joinerAccountIds = projectId2RelationPOsMap.get(project.getProjectId());
        List<String> projectJoiners = Lists.newArrayList();
        List<String> projectManagers = Lists.newArrayList();
        for (Long joinerAccountId : joinerAccountIds) {
            if (acntProId2RelationMap.get(joinerAccountId + "-" + project.getProjectId()).getIsAdmin() == Constants.TRUE) {
                projectManagers.add(accountId2RealNameMap.get(joinerAccountId));
            } else {
                projectJoiners.add(accountId2RealNameMap.get(joinerAccountId));
            }
        }
        project.setJoinerNames(StringUtils.join(projectJoiners, ","));
        project.setManagers(StringUtils.join(projectManagers, ","));
    }
}
Also used : AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectAccountRelation(com.ibeiliao.deployment.admin.vo.project.ProjectAccountRelation)

Aggregations

AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)11 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 AccountRoleRelation (com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation)2 Project (com.ibeiliao.deployment.admin.vo.project.Project)2 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 AllowAnonymous (com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous)1 AdminLog (com.ibeiliao.deployment.admin.annotation.log.AdminLog)1 PageResult (com.ibeiliao.deployment.admin.common.PageResult)1 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)1 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 DeploymentOrder (com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder)1 ServerDeployHistory (com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory)1 GlobalSetting (com.ibeiliao.deployment.admin.vo.global.GlobalSetting)1 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)1