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);
}
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;
}
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());
}
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);
}
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, "");
}
Aggregations