use of com.ibeiliao.deployment.admin.utils.resource.MenuResource in project Corgi by kevinYin.
the class ViewProjectController method projectDetail.
/**
* 查看项目详情
*/
@RequestMapping("projectDetail")
@ResponseBody
@MenuResource("项目详情")
public RestResult projectDetail(int projectId) {
Project project = projectService.getProject(projectId);
GlobalSetting globalSetting = globalSettingService.getGlobalSetting();
ProjectDetailInfo projectDetailInfo = new ProjectDetailInfo();
projectDetailInfo.setProject(project);
projectDetailInfo.setGlobalSetting(globalSetting);
List<ProjectEnv> allEnv = projectEnvService.findAllEnv();
projectDetailInfo.setProjectEnvs(allEnv);
List<ProjectModule> modules = projectModuleService.getByProjectId(projectId);
fillServerGroupIntoModule(modules);
fillJvmArgsIntoModule(modules);
projectDetailInfo.setModules(modules);
return new RestResult<>(projectDetailInfo);
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource in project Corgi by kevinYin.
the class WelcomeController method login.
/**
* 登录接口,sso登录时回调
* @param request
* @param response
* @param account
* @param password
* @return
*/
@RequestMapping("/login.do")
@MenuResource("授权登录")
@AllowAnonymous
@ResponseBody
public RestResult login(HttpServletRequest request, HttpServletResponse response, String account, String password) {
ParameterUtil.assertNotBlank(account, "账户不能为空");
ParameterUtil.assertNotBlank(password, "密码不能为空");
AdminAccount adminAccount = adminAccountService.getByAccount(account);
if (adminAccount == null) {
return new RestResult(ApiCode.FAILURE, "账号不存在");
}
if (!Objects.equals(encoder.encode(password), adminAccount.getPassword())) {
return new RestResult(ApiCode.FAILURE, "账号密码不正确");
}
AdminLoginUser loginUser = new AdminLoginUser();
loginUser.setAccountId(adminAccount.getUid());
loginUser.setAppId(AppConstants.APP_ID_DEFAULT);
AdminContext.saveToCookie(response, loginUser);
logger.info("登录成功 | uid: {}", adminAccount.getUid());
return new RestResult(ApiCode.SUCCESS, "");
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource 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.utils.resource.MenuResource in project Corgi by kevinYin.
the class ViewDeployHistoryController method getDeployHistory.
@RequestMapping("getDeployHistory")
@ResponseBody
@MenuResource("发布详情")
public RestResult<DeployHistory> getDeployHistory(int historyId) {
long accountId = AdminContext.getAccountId();
DeployHistory deployHistory = deployHistoryService.getByHistoryId(historyId);
if (deployHistory == null) {
return new RestResult<>(ApiCode.FAILURE, "找不到发布记录");
}
return new RestResult<>(deployHistory);
}
use of com.ibeiliao.deployment.admin.utils.resource.MenuResource in project Corgi by kevinYin.
the class ViewProjectController method restartServer.
/**
* 重启服务
*/
@RequestMapping("restartServer.do")
@ResponseBody
@MenuResource("重启服务")
public RestResult<Object> restartServer(int serverId) {
TransferRequest request;
try {
request = createTransferRequest(serverId, true);
Assert.isTrue(request.getModuleType() != ModuleType.STATIC.getValue(), "静态项目不能执行重启");
JavaTransferService javaTransferService = new JavaTransferService(request, DeployType.RESTART);
return transfer(request.getHistoryId(), javaTransferService);
} catch (Exception e) {
logger.info("重启失败, {}", e);
return new RestResult<>(ApiCode.FAILURE, "重启失败");
}
}
Aggregations