Merge branch 'dev' of https://gitee.com/dromara/Jpom into dev

This commit is contained in:
Eleven 2021-08-29 20:03:52 +08:00
commit 5b2a404b15
7 changed files with 49 additions and 42 deletions

View File

@ -11,6 +11,7 @@ import io.jpom.common.forward.NodeUrl;
import io.jpom.common.interceptor.OptLog;
import io.jpom.model.data.NodeModel;
import io.jpom.model.data.OutGivingModel;
import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.model.log.UserOperateLogV1;
import io.jpom.plugin.ClassFeature;
import io.jpom.plugin.Feature;
@ -21,6 +22,7 @@ import io.jpom.service.node.OutGivingServer;
import io.jpom.service.node.manage.ProjectInfoService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -133,9 +135,8 @@ public class ProjectManageControl extends BaseServerController {
if (monitorService.checkProject(nodeModel.getId(), id)) {
return JsonMessage.getString(405, "当前项目存在监控项,不能直接删除");
}
if (buildService.checkNodeProjectId(nodeModel.getId(), id)) {
return JsonMessage.getString(405, "当前项目存在构建项,不能直接删除");
}
boolean releaseMethod = buildService.checkReleaseMethod(nodeModel.getId() + StrUtil.COLON + id, BuildReleaseMethod.Project);
Assert.state(!releaseMethod, "当前项目存在构建项,不能直接删除");
}
return NodeForward.request(nodeModel, getRequest(), NodeUrl.Manage_DeleteProject).toString();
}

View File

@ -4,12 +4,15 @@ import cn.jiangzeyin.common.JsonMessage;
import cn.jiangzeyin.common.validator.ValidatorItem;
import cn.jiangzeyin.common.validator.ValidatorRule;
import io.jpom.common.BaseServerController;
import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.plugin.ClassFeature;
import io.jpom.plugin.Feature;
import io.jpom.plugin.MethodFeature;
import io.jpom.service.dblog.BuildInfoService;
import io.jpom.service.node.ssh.SshService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -25,14 +28,19 @@ import javax.annotation.Resource;
@Feature(cls = ClassFeature.SSH)
public class SshEditController extends BaseServerController {
@Resource
private SshService sshService;
@Resource
private SshService sshService;
@RequestMapping(value = "del.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id) {
sshService.deleteItem(id);
return JsonMessage.getString(200, "操作成功");
}
@Resource
private BuildInfoService buildInfoService;
@RequestMapping(value = "del.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem(value = ValidatorRule.NOT_BLANK) String id) {
boolean checkSsh = buildInfoService.checkReleaseMethod(id, BuildReleaseMethod.Ssh);
Assert.state(!checkSsh, "当前ssh存在构建项不能删除");
sshService.deleteItem(id);
return JsonMessage.getString(200, "操作成功");
}
}

View File

@ -15,6 +15,7 @@ import io.jpom.model.data.NodeModel;
import io.jpom.model.data.OutGivingModel;
import io.jpom.model.data.OutGivingNodeProject;
import io.jpom.model.data.UserModel;
import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.model.log.UserOperateLogV1;
import io.jpom.plugin.ClassFeature;
import io.jpom.plugin.Feature;
@ -24,6 +25,7 @@ import io.jpom.service.node.OutGivingServer;
import io.jpom.util.StringUtil;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -197,9 +199,8 @@ public class OutGivingController extends BaseServerController {
@Feature(method = MethodFeature.DEL)
public String del(String id) throws IOException {
// 判断构建
if (buildService.checkOutGiving(id)) {
return JsonMessage.getString(400, "当前分发存在构建项,不能删除");
}
boolean releaseMethod = buildService.checkReleaseMethod(id, BuildReleaseMethod.Outgiving);
Assert.state(!releaseMethod, "当前分发存在构建项,不能删除");
OutGivingModel outGivingServerItem = outGivingServer.getItem(id);
if (outGivingServerItem.isOutGivingProject()) {
UserModel userModel = getUser();

View File

@ -85,20 +85,6 @@ public class BuildInfoService extends BaseDbService<BuildInfoModel> {
return null;
}
/**
* 判断是否存在 节点和项目关联
*
* @param nodeId 节点ID
* @param projectId 项目ID
* @return true 关联
*/
public boolean checkNodeProjectId(String nodeId, String projectId) {
BuildInfoModel buildInfoModel = new BuildInfoModel();
buildInfoModel.setReleaseMethodDataId(nodeId + ":" + projectId);
buildInfoModel.setReleaseMethod(BuildReleaseMethod.Project.getCode());
return super.exists(buildInfoModel);
}
/**
* 判断是否存在 节点关联
*
@ -113,15 +99,15 @@ public class BuildInfoService extends BaseDbService<BuildInfoModel> {
}
/**
* 判断是否存在 发关联
* 判断是否存在 关联
*
* @param outGivingId 分发ID
* @param dataId 数据ID
* @return true 关联
*/
public boolean checkOutGiving(String outGivingId) {
public boolean checkReleaseMethod(String dataId, BuildReleaseMethod releaseMethod) {
BuildInfoModel buildInfoModel = new BuildInfoModel();
buildInfoModel.setReleaseMethodDataId(outGivingId);
buildInfoModel.setReleaseMethod(BuildReleaseMethod.Outgiving.getCode());
buildInfoModel.setReleaseMethodDataId(dataId);
buildInfoModel.setReleaseMethod(releaseMethod.getCode());
return super.exists(buildInfoModel);
}
}

View File

@ -15,6 +15,8 @@ import java.io.File;
/**
* svn 工具
* <p>
* https://www.cnblogs.com/lekko/p/6005382.html
*
* @author bwcx_jzy
* @date 2019/8/6
@ -38,6 +40,21 @@ public class SvnKitUtil {
FSRepositoryFactory.setup();
}
private static final DefaultSVNOptions OPTIONS = SVNWCUtil.createDefaultOptions(true);
/**
* 对SVNKit连接进行认证并获取连接
*
* @param username 用户名
* @param pwd 密码
* @param sshFilePath OpenSSH密钥
*/
public SVNClientManager getAuthClient(String username, String pwd, String sshFilePath) {
File dir = SVNWCUtil.getDefaultConfigurationDirectory();
ISVNAuthenticationManager AUTH = SVNWCUtil.createDefaultAuthenticationManager(dir, username, pwd.toCharArray(), new File(sshFilePath), new char[]{}, true);
return SVNClientManager.newInstance(OPTIONS, AUTH);
}
/**
* 判断当前仓库url是否匹配
*
@ -50,9 +67,8 @@ public class SvnKitUtil {
*/
private static Boolean checkUrl(File wcDir, String url, String userName, String userPwd) throws SVNException {
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, userPwd.toCharArray());
DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
// 实例化客户端管理类
SVNClientManager clientManager = SVNClientManager.newInstance(options, authManager);
SVNClientManager clientManager = SVNClientManager.newInstance(OPTIONS, authManager);
try {
// 通过客户端管理类获得updateClient类的实例
SVNWCClient wcClient = clientManager.getWCClient();

View File

@ -70,11 +70,6 @@
"id": "buildList",
"title": "构建列表"
},
{
"id": "buildListOld",
"title": "构建列表old"
},
{
"id": "buildHistory",
"title": "构建历史"

View File

@ -116,7 +116,7 @@ request.interceptors.response.use(
} else {
notification.error({
message: status,
description: statusText,
description: (statusText || "") + (data || ""),
duration: 2,
});
}