Search in sources :

Example 11 with MenuResource

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);
}
Also used : ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv) RestResult(com.ibeiliao.deployment.admin.common.RestResult) GlobalSetting(com.ibeiliao.deployment.admin.vo.global.GlobalSetting) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with MenuResource

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, "");
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) AdminLoginUser(com.ibeiliao.deployment.admin.context.AdminLoginUser) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) AllowAnonymous(com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 13 with MenuResource

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");
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with MenuResource

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);
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with MenuResource

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, "重启失败");
    }
}
Also used : TransferRequest(com.ibeiliao.deployment.transfer.vo.TransferRequest) JavaTransferService(com.ibeiliao.deployment.transfer.service.JavaTransferService) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)17 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)14 RestResult (com.ibeiliao.deployment.admin.common.RestResult)8 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)5 Role (com.ibeiliao.deployment.admin.vo.account.Role)3 AdminLog (com.ibeiliao.deployment.admin.annotation.log.AdminLog)2 AccountRoleRelation (com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation)2 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)2 GlobalSetting (com.ibeiliao.deployment.admin.vo.global.GlobalSetting)2 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)2 ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)2 JavaTransferService (com.ibeiliao.deployment.transfer.service.JavaTransferService)2 TransferRequest (com.ibeiliao.deployment.transfer.vo.TransferRequest)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 AllowAnonymous (com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous)1 PageResult (com.ibeiliao.deployment.admin.common.PageResult)1 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1