Search in sources :

Example 6 with RestResult

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

the class ViewProjectController method getProject.

/**
 * 获取项目
 */
@RequestMapping("getProject")
@ResponseBody
@MenuResource("获取项目")
public RestResult getProject(int projectId) {
    Project project = new Project();
    if (projectId > 0) {
        project = projectService.getProject(projectId);
    }
    List<AdminAccount> adminAccounts = adminAccountService.listAll();
    GlobalSetting globalSetting = globalSettingService.getGlobalSetting();
    ProjectDetailInfo projectDetailInfo = new ProjectDetailInfo();
    projectDetailInfo.setProject(project);
    projectDetailInfo.setAllAccounts(adminAccounts);
    projectDetailInfo.setGlobalSetting(globalSetting);
    List<ProjectAccountRelation> accountRelations = projectAccountRelationService.getByProjectId(projectId);
    projectDetailInfo.setProjectAccountRelations(accountRelations);
    return new RestResult<>(projectDetailInfo);
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) GlobalSetting(com.ibeiliao.deployment.admin.vo.global.GlobalSetting) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with RestResult

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

the class ViewProjectController method transfer.

private RestResult<Object> transfer(int historyId, JavaTransferService javaTransferService) {
    TransferResult transferResult = javaTransferService.pushPackageToServer();
    int code = (transferResult.getSuccessType() == DeployResult.SUCCESS ? ApiCode.SUCCESS : ApiCode.FAILURE);
    String message = transferResult.getFailLog();
    if (StringUtils.isEmpty(message)) {
        message = transferResult.getSuccessType().toString();
    }
    deployHistoryService.finishStopRestart(historyId, transferResult.getSuccessType());
    logger.info("对服务器操作结果: {}, code: {}, message: {}", transferResult.getSuccessType(), code, message);
    return new RestResult<>(code, message);
}
Also used : RestResult(com.ibeiliao.deployment.admin.common.RestResult) TransferResult(com.ibeiliao.deployment.transfer.vo.TransferResult)

Example 8 with RestResult

use of com.ibeiliao.deployment.admin.common.RestResult 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 9 with RestResult

use of com.ibeiliao.deployment.admin.common.RestResult 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 10 with RestResult

use of com.ibeiliao.deployment.admin.common.RestResult 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)

Aggregations

RestResult (com.ibeiliao.deployment.admin.common.RestResult)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)8 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)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 AllowAnonymous (com.ibeiliao.deployment.admin.annotation.authority.AllowAnonymous)1 AdminLog (com.ibeiliao.deployment.admin.annotation.log.AdminLog)1 AdminLoginUser (com.ibeiliao.deployment.admin.context.AdminLoginUser)1 MenuItem (com.ibeiliao.deployment.admin.utils.resource.MenuItem)1 Role (com.ibeiliao.deployment.admin.vo.account.Role)1 Server (com.ibeiliao.deployment.admin.vo.server.Server)1 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)1 TransferResult (com.ibeiliao.deployment.transfer.vo.TransferResult)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1