Search in sources :

Example 6 with AdminAccount

use of com.ibeiliao.deployment.admin.vo.account.AdminAccount 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 AdminAccount

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

the class AuthorizationServiceImpl method hasAuthorization.

@Override
public boolean hasAuthorization(long accountId, String uri) {
    logger.info("权限判断 | accountId: {}, uri: {}", accountId, uri);
    // 注:javax.ws.rs.Path 里可能有正则表达式
    AdminAccount adminAccount = adminAccountService.getById(accountId);
    boolean pass = true;
    if (adminAccount == null) {
        logger.error("找不到管理员 | accountId: {}", accountId);
        pass = false;
    } else if (adminAccountService.isSuperAdmin(accountId)) {
        logger.info("超级管理员 | accountId: {}", accountId);
    } else {
        pass = matchUri(accountId, AppConstants.APP_ID_DEFAULT, uri);
    }
    logger.info("权限判断结果 | accountId: {}, uri:{}, pass: {}", accountId, uri, pass);
    return pass;
}
Also used : AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 8 with AdminAccount

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

the class DeployHistoryServiceImpl method createAndSaveRestart.

private DeployHistoryPO createAndSaveRestart(long accountId, String title, int serverId) {
    Server server = serverService.getById(serverId);
    AdminAccount account = adminAccountService.getById(accountId);
    Assert.notNull(server, "服务器不存在");
    Assert.notNull(account, "管理员不存在");
    ServerGroup serverGroup = serverGroupService.getById(server.getGroupId());
    ProjectModule module = projectModuleService.getByModuleId(serverGroup.getModuleId());
    DeployHistoryPO po = new DeployHistoryPO();
    po.setTagName("");
    po.setAccountId(accountId);
    po.setAuditorId(0);
    po.setTitle(title);
    po.setCreateTime(new Date());
    po.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
    po.setAuditTime(po.getCreateTime());
    po.setDeployServers(1);
    po.setProjectId(module.getProjectId());
    po.setModuleId(module.getModuleId());
    po.setModuleName(module.getModuleName());
    po.setVersionNo("");
    po.setIsRestart(Constants.TRUE);
    po.setEnvId(serverGroup.getEnvId());
    po.setRealName(account.getRealname());
    deployHistoryDao.insert(po);
    ServerDeployHistoryPO serverDeployHistoryPO = new ServerDeployHistoryPO();
    serverDeployHistoryPO.setHistoryId(po.getHistoryId());
    serverDeployHistoryPO.setServerId(serverId);
    serverDeployHistoryPO.setServerName(server.getServerName());
    serverDeployHistoryPO.setServerIp(server.getIp());
    serverDeployHistoryPO.setDeployStatus(ServerDeployResult.WAITING_FOR_DEPLOYMENT.getValue());
    serverDeployHistoryDao.insert(serverDeployHistoryPO);
    return deployHistoryDao.get(po.getHistoryId());
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 9 with AdminAccount

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

the class DeployHistoryServiceImpl method createRollbackOrder.

@Override
public void createRollbackOrder(int historyId, long accountId, boolean isRollBack) {
    DeployHistory deployHistory = getByHistoryId(historyId);
    if (deployHistory == null) {
        throw new IllegalArgumentException("发布记录不存在");
    }
    AdminAccount account = adminAccountService.getById(accountId);
    DeploymentOrder order = new DeploymentOrder();
    VOUtil.copy(deployHistory, order);
    order.setAccountId(accountId);
    order.setRealName(account.getRealname());
    List<ServerDeployHistory> serverDeployHistories = deployHistory.getServerDeployHistories();
    int[] serverId = new int[serverDeployHistories.size()];
    for (int i = 0; i < serverId.length; i++) {
        serverId[i] = serverDeployHistories.get(i).getServerId();
    }
    order.setServerId(serverId);
    order.setRollbackToDeployId(historyId);
    if (isRollBack) {
        order.setTitle("回滚到" + historyId + "的版本");
    } else {
        order.setTitle("重发" + historyId + "的版本");
    }
    createDeploymentOrder(order);
}
Also used : ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount) DeploymentOrder(com.ibeiliao.deployment.admin.vo.deploy.DeploymentOrder) ServerDeployHistory(com.ibeiliao.deployment.admin.vo.deploy.ServerDeployHistory) DeployHistory(com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)

Example 10 with AdminAccount

use of com.ibeiliao.deployment.admin.vo.account.AdminAccount 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)

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