use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class ProjectServiceImpl method fillModuleInfo.
private void fillModuleInfo(List<Project> projects) {
List<Integer> projectIds = Lists.newArrayList();
for (Project project : projects) {
projectIds.add(project.getProjectId());
}
List<ProjectModule> projectModules = projectModuleService.getSimpleInfoByProjectIds(projectIds);
if (CollectionUtils.isEmpty(projectModules)) {
return;
}
ListMultimap<Integer, ProjectModule> projectId2ModulesMap = ArrayListMultimap.create();
for (ProjectModule module : projectModules) {
projectId2ModulesMap.put(module.getProjectId(), module);
}
for (Project project : projects) {
project.setProjectModules(projectId2ModulesMap.get(project.getProjectId()));
}
}
use of com.ibeiliao.deployment.admin.vo.project.Project in project Corgi by kevinYin.
the class CreateDeploymentController method index.
/**
* 创建上线单主页,xhtml 仅用于展示页面,ajax 调用 .do 接口获取参数
*
* @return
*/
@MenuResource("创建上线单主页")
@RequestMapping("create.xhtml")
public String index(HttpServletRequest request) {
// 读取用户可以访问的项目
long accountId = AdminContext.getAccountId();
List<Project> projects = projectService.queryAdminProjects(accountId, null, 0L, null, 1, MAX_DISPLAY_PROJECTS);
List<ProjectModule> modules = new LinkedList<>();
List<ProjectModule> projectModules = null;
// 读取每个项目的module
for (Project project : projects) {
List<ProjectModule> tmpModules = projectModuleService.getByProjectId(project.getProjectId());
modules.addAll(tmpModules);
}
request.setAttribute("projects", projects);
request.setAttribute("allModules", JSON.toJSON(modules));
int moduleId = 0;
int projectId = 0;
if (request.getParameter("moduleId") != null) {
moduleId = NumberUtils.toInt(request.getParameter("moduleId"), 0);
if (moduleId > 0) {
ProjectModule module = projectModuleService.getByModuleId(moduleId);
if (module != null) {
projectId = module.getProjectId();
}
}
logger.info("输入参数 moduleId: " + moduleId + ", projectId: " + projectId);
}
if (projectId <= 0 && projects.size() > 0) {
projectId = projects.get(0).getProjectId();
projectModules = projectModuleService.getByProjectId(projectId);
} else if (projectId > 0) {
projectModules = projectModuleService.getByProjectId(projectId);
} else {
projectModules = Collections.emptyList();
}
String repoUrl = "";
if (moduleId <= 0 && projectModules.size() > 0) {
moduleId = projectModules.get(0).getModuleId();
repoUrl = projectModules.get(0).getRepoUrl();
} else {
for (ProjectModule pm : projectModules) {
if (pm.getModuleId() == moduleId) {
repoUrl = pm.getRepoUrl();
break;
}
}
}
// 指定发布的module
request.setAttribute("moduleId", moduleId);
request.setAttribute("projectId", projectId);
request.setAttribute("projectModules", projectModules);
request.setAttribute("repoUrl", repoUrl);
request.setAttribute("envList", projectEnvService.findAllEnv());
return ("/deploy/create_deployment");
}
use of com.ibeiliao.deployment.admin.vo.project.Project 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, ","));
}
}
Aggregations