feat(项目设置): 添加、修改存储库以及测试存储库链接的功能开发
This commit is contained in:
parent
835beb3b49
commit
4041bdc37b
|
@ -10,19 +10,41 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class FileMetadataRepository implements Serializable {
|
||||
@Schema(title = "文件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_metadata_repository.id.not_blank}", groups = {Updated.class})
|
||||
@Size(min = 1, max = 50, message = "{file_metadata_repository.id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String id;
|
||||
@Schema(description = "文件ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_metadata_repository.file_metadata_id.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 50, message = "{file_metadata_repository.file_metadata_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String fileMetadataId;
|
||||
|
||||
@Schema(title = "储存库")
|
||||
private byte[] gitInfo;
|
||||
@Schema(description = "分支", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_metadata_repository.branch.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 255, message = "{file_metadata_repository.branch.length_range}", groups = {Created.class, Updated.class})
|
||||
private String branch;
|
||||
|
||||
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_metadata_repository.repository_url.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 255, message = "{file_metadata_repository.repository_url.length_range}", groups = {Created.class, Updated.class})
|
||||
private String repositoryUrl;
|
||||
|
||||
@Schema(description = "token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_metadata_repository.token.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 1000, message = "{file_metadata_repository.token.length_range}", groups = {Created.class, Updated.class})
|
||||
private String token;
|
||||
|
||||
@Schema(description = "提交ID")
|
||||
private String commitId;
|
||||
|
||||
@Schema(description = "提交信息")
|
||||
private String commitMessage;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Column {
|
||||
id("id", "id", "VARCHAR", false),
|
||||
gitInfo("git_info", "gitInfo", "LONGVARBINARY", false);
|
||||
fileMetadataId("file_metadata_id", "fileMetadataId", "VARCHAR", false),
|
||||
branch("branch", "branch", "VARCHAR", false),
|
||||
repositoryUrl("repository_url", "repositoryUrl", "VARCHAR", false),
|
||||
token("token", "token", "VARCHAR", false),
|
||||
commitId("commit_id", "commitId", "VARCHAR", false),
|
||||
commitMessage("commit_message", "commitMessage", "LONGVARCHAR", false);
|
||||
|
||||
private static final String BEGINNING_DELIMITER = "`";
|
||||
|
||||
|
|
|
@ -104,73 +104,353 @@ public class FileMetadataRepositoryExample {
|
|||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
public Criteria andFileMetadataIdIsNull() {
|
||||
addCriterion("file_metadata_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
public Criteria andFileMetadataIdIsNotNull() {
|
||||
addCriterion("file_metadata_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
public Criteria andFileMetadataIdEqualTo(String value) {
|
||||
addCriterion("file_metadata_id =", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
public Criteria andFileMetadataIdNotEqualTo(String value) {
|
||||
addCriterion("file_metadata_id <>", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
public Criteria andFileMetadataIdGreaterThan(String value) {
|
||||
addCriterion("file_metadata_id >", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
public Criteria andFileMetadataIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("file_metadata_id >=", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
public Criteria andFileMetadataIdLessThan(String value) {
|
||||
addCriterion("file_metadata_id <", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
public Criteria andFileMetadataIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("file_metadata_id <=", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
public Criteria andFileMetadataIdLike(String value) {
|
||||
addCriterion("file_metadata_id like", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
public Criteria andFileMetadataIdNotLike(String value) {
|
||||
addCriterion("file_metadata_id not like", value, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
public Criteria andFileMetadataIdIn(List<String> values) {
|
||||
addCriterion("file_metadata_id in", values, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
public Criteria andFileMetadataIdNotIn(List<String> values) {
|
||||
addCriterion("file_metadata_id not in", values, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
public Criteria andFileMetadataIdBetween(String value1, String value2) {
|
||||
addCriterion("file_metadata_id between", value1, value2, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
public Criteria andFileMetadataIdNotBetween(String value1, String value2) {
|
||||
addCriterion("file_metadata_id not between", value1, value2, "fileMetadataId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchIsNull() {
|
||||
addCriterion("branch is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchIsNotNull() {
|
||||
addCriterion("branch is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchEqualTo(String value) {
|
||||
addCriterion("branch =", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchNotEqualTo(String value) {
|
||||
addCriterion("branch <>", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchGreaterThan(String value) {
|
||||
addCriterion("branch >", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("branch >=", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchLessThan(String value) {
|
||||
addCriterion("branch <", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchLessThanOrEqualTo(String value) {
|
||||
addCriterion("branch <=", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchLike(String value) {
|
||||
addCriterion("branch like", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchNotLike(String value) {
|
||||
addCriterion("branch not like", value, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchIn(List<String> values) {
|
||||
addCriterion("branch in", values, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchNotIn(List<String> values) {
|
||||
addCriterion("branch not in", values, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchBetween(String value1, String value2) {
|
||||
addCriterion("branch between", value1, value2, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andBranchNotBetween(String value1, String value2) {
|
||||
addCriterion("branch not between", value1, value2, "branch");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlIsNull() {
|
||||
addCriterion("repository_url is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlIsNotNull() {
|
||||
addCriterion("repository_url is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlEqualTo(String value) {
|
||||
addCriterion("repository_url =", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlNotEqualTo(String value) {
|
||||
addCriterion("repository_url <>", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlGreaterThan(String value) {
|
||||
addCriterion("repository_url >", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("repository_url >=", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlLessThan(String value) {
|
||||
addCriterion("repository_url <", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlLessThanOrEqualTo(String value) {
|
||||
addCriterion("repository_url <=", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlLike(String value) {
|
||||
addCriterion("repository_url like", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlNotLike(String value) {
|
||||
addCriterion("repository_url not like", value, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlIn(List<String> values) {
|
||||
addCriterion("repository_url in", values, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlNotIn(List<String> values) {
|
||||
addCriterion("repository_url not in", values, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlBetween(String value1, String value2) {
|
||||
addCriterion("repository_url between", value1, value2, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUrlNotBetween(String value1, String value2) {
|
||||
addCriterion("repository_url not between", value1, value2, "repositoryUrl");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenIsNull() {
|
||||
addCriterion("token is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenIsNotNull() {
|
||||
addCriterion("token is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenEqualTo(String value) {
|
||||
addCriterion("token =", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenNotEqualTo(String value) {
|
||||
addCriterion("token <>", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenGreaterThan(String value) {
|
||||
addCriterion("token >", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("token >=", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenLessThan(String value) {
|
||||
addCriterion("token <", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenLessThanOrEqualTo(String value) {
|
||||
addCriterion("token <=", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenLike(String value) {
|
||||
addCriterion("token like", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenNotLike(String value) {
|
||||
addCriterion("token not like", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenIn(List<String> values) {
|
||||
addCriterion("token in", values, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenNotIn(List<String> values) {
|
||||
addCriterion("token not in", values, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenBetween(String value1, String value2) {
|
||||
addCriterion("token between", value1, value2, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTokenNotBetween(String value1, String value2) {
|
||||
addCriterion("token not between", value1, value2, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdIsNull() {
|
||||
addCriterion("commit_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdIsNotNull() {
|
||||
addCriterion("commit_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdEqualTo(String value) {
|
||||
addCriterion("commit_id =", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdNotEqualTo(String value) {
|
||||
addCriterion("commit_id <>", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdGreaterThan(String value) {
|
||||
addCriterion("commit_id >", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("commit_id >=", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdLessThan(String value) {
|
||||
addCriterion("commit_id <", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("commit_id <=", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdLike(String value) {
|
||||
addCriterion("commit_id like", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdNotLike(String value) {
|
||||
addCriterion("commit_id not like", value, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdIn(List<String> values) {
|
||||
addCriterion("commit_id in", values, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdNotIn(List<String> values) {
|
||||
addCriterion("commit_id not in", values, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdBetween(String value1, String value2) {
|
||||
addCriterion("commit_id between", value1, value2, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCommitIdNotBetween(String value1, String value2) {
|
||||
addCriterion("commit_id not between", value1, value2, "commitId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package io.metersphere.project.domain;
|
||||
|
||||
import io.metersphere.validation.groups.Created;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.metersphere.validation.groups.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileModuleRepository implements Serializable {
|
||||
|
@ -18,26 +15,32 @@ public class FileModuleRepository implements Serializable {
|
|||
@Size(min = 1, max = 50, message = "{file_module_repository.file_module_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String fileModuleId;
|
||||
|
||||
@Schema(description = "所属平台;GitHub/Gitlab/Gitee")
|
||||
@Schema(description = "所属平台;GitHub/Gitlab/Gitee", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_module_repository.platform.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 10, message = "{file_module_repository.platform.length_range}", groups = {Created.class, Updated.class})
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "存储库地址")
|
||||
private String repositoryPath;
|
||||
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_module_repository.url.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 255, message = "{file_module_repository.url.length_range}", groups = {Created.class, Updated.class})
|
||||
private String url;
|
||||
|
||||
@Schema(description = "存储库Token;platform为Gitee时必填")
|
||||
private String repositoryUserName;
|
||||
@Schema(description = "存储库Token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_module_repository.token.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 255, message = "{file_module_repository.token.length_range}", groups = {Created.class, Updated.class})
|
||||
private String token;
|
||||
|
||||
@Schema(description = "存储库Token")
|
||||
private String repositoryToken;
|
||||
@Schema(description = "用户名;platform为Gitee时必填")
|
||||
private String userName;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Column {
|
||||
fileModuleId("file_module_id", "fileModuleId", "VARCHAR", false),
|
||||
platform("platform", "platform", "VARCHAR", false),
|
||||
repositoryPath("repository_path", "repositoryPath", "VARCHAR", false),
|
||||
repositoryUserName("repository_user_name", "repositoryUserName", "VARCHAR", false),
|
||||
repositoryToken("repository_token", "repositoryToken", "VARCHAR", false);
|
||||
url("url", "url", "VARCHAR", false),
|
||||
token("token", "token", "VARCHAR", false),
|
||||
userName("user_name", "userName", "VARCHAR", false);
|
||||
|
||||
private static final String BEGINNING_DELIMITER = "`";
|
||||
|
||||
|
|
|
@ -244,213 +244,213 @@ public class FileModuleRepositoryExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathIsNull() {
|
||||
addCriterion("repository_path is null");
|
||||
public Criteria andUrlIsNull() {
|
||||
addCriterion("url is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathIsNotNull() {
|
||||
addCriterion("repository_path is not null");
|
||||
public Criteria andUrlIsNotNull() {
|
||||
addCriterion("url is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathEqualTo(String value) {
|
||||
addCriterion("repository_path =", value, "repositoryPath");
|
||||
public Criteria andUrlEqualTo(String value) {
|
||||
addCriterion("url =", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathNotEqualTo(String value) {
|
||||
addCriterion("repository_path <>", value, "repositoryPath");
|
||||
public Criteria andUrlNotEqualTo(String value) {
|
||||
addCriterion("url <>", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathGreaterThan(String value) {
|
||||
addCriterion("repository_path >", value, "repositoryPath");
|
||||
public Criteria andUrlGreaterThan(String value) {
|
||||
addCriterion("url >", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("repository_path >=", value, "repositoryPath");
|
||||
public Criteria andUrlGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("url >=", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathLessThan(String value) {
|
||||
addCriterion("repository_path <", value, "repositoryPath");
|
||||
public Criteria andUrlLessThan(String value) {
|
||||
addCriterion("url <", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathLessThanOrEqualTo(String value) {
|
||||
addCriterion("repository_path <=", value, "repositoryPath");
|
||||
public Criteria andUrlLessThanOrEqualTo(String value) {
|
||||
addCriterion("url <=", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathLike(String value) {
|
||||
addCriterion("repository_path like", value, "repositoryPath");
|
||||
public Criteria andUrlLike(String value) {
|
||||
addCriterion("url like", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathNotLike(String value) {
|
||||
addCriterion("repository_path not like", value, "repositoryPath");
|
||||
public Criteria andUrlNotLike(String value) {
|
||||
addCriterion("url not like", value, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathIn(List<String> values) {
|
||||
addCriterion("repository_path in", values, "repositoryPath");
|
||||
public Criteria andUrlIn(List<String> values) {
|
||||
addCriterion("url in", values, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathNotIn(List<String> values) {
|
||||
addCriterion("repository_path not in", values, "repositoryPath");
|
||||
public Criteria andUrlNotIn(List<String> values) {
|
||||
addCriterion("url not in", values, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathBetween(String value1, String value2) {
|
||||
addCriterion("repository_path between", value1, value2, "repositoryPath");
|
||||
public Criteria andUrlBetween(String value1, String value2) {
|
||||
addCriterion("url between", value1, value2, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryPathNotBetween(String value1, String value2) {
|
||||
addCriterion("repository_path not between", value1, value2, "repositoryPath");
|
||||
public Criteria andUrlNotBetween(String value1, String value2) {
|
||||
addCriterion("url not between", value1, value2, "url");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameIsNull() {
|
||||
addCriterion("repository_user_name is null");
|
||||
public Criteria andTokenIsNull() {
|
||||
addCriterion("token is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameIsNotNull() {
|
||||
addCriterion("repository_user_name is not null");
|
||||
public Criteria andTokenIsNotNull() {
|
||||
addCriterion("token is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameEqualTo(String value) {
|
||||
addCriterion("repository_user_name =", value, "repositoryUserName");
|
||||
public Criteria andTokenEqualTo(String value) {
|
||||
addCriterion("token =", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameNotEqualTo(String value) {
|
||||
addCriterion("repository_user_name <>", value, "repositoryUserName");
|
||||
public Criteria andTokenNotEqualTo(String value) {
|
||||
addCriterion("token <>", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameGreaterThan(String value) {
|
||||
addCriterion("repository_user_name >", value, "repositoryUserName");
|
||||
public Criteria andTokenGreaterThan(String value) {
|
||||
addCriterion("token >", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("repository_user_name >=", value, "repositoryUserName");
|
||||
public Criteria andTokenGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("token >=", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameLessThan(String value) {
|
||||
addCriterion("repository_user_name <", value, "repositoryUserName");
|
||||
public Criteria andTokenLessThan(String value) {
|
||||
addCriterion("token <", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("repository_user_name <=", value, "repositoryUserName");
|
||||
public Criteria andTokenLessThanOrEqualTo(String value) {
|
||||
addCriterion("token <=", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameLike(String value) {
|
||||
addCriterion("repository_user_name like", value, "repositoryUserName");
|
||||
public Criteria andTokenLike(String value) {
|
||||
addCriterion("token like", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameNotLike(String value) {
|
||||
addCriterion("repository_user_name not like", value, "repositoryUserName");
|
||||
public Criteria andTokenNotLike(String value) {
|
||||
addCriterion("token not like", value, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameIn(List<String> values) {
|
||||
addCriterion("repository_user_name in", values, "repositoryUserName");
|
||||
public Criteria andTokenIn(List<String> values) {
|
||||
addCriterion("token in", values, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameNotIn(List<String> values) {
|
||||
addCriterion("repository_user_name not in", values, "repositoryUserName");
|
||||
public Criteria andTokenNotIn(List<String> values) {
|
||||
addCriterion("token not in", values, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameBetween(String value1, String value2) {
|
||||
addCriterion("repository_user_name between", value1, value2, "repositoryUserName");
|
||||
public Criteria andTokenBetween(String value1, String value2) {
|
||||
addCriterion("token between", value1, value2, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryUserNameNotBetween(String value1, String value2) {
|
||||
addCriterion("repository_user_name not between", value1, value2, "repositoryUserName");
|
||||
public Criteria andTokenNotBetween(String value1, String value2) {
|
||||
addCriterion("token not between", value1, value2, "token");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenIsNull() {
|
||||
addCriterion("repository_token is null");
|
||||
public Criteria andUserNameIsNull() {
|
||||
addCriterion("user_name is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenIsNotNull() {
|
||||
addCriterion("repository_token is not null");
|
||||
public Criteria andUserNameIsNotNull() {
|
||||
addCriterion("user_name is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenEqualTo(String value) {
|
||||
addCriterion("repository_token =", value, "repositoryToken");
|
||||
public Criteria andUserNameEqualTo(String value) {
|
||||
addCriterion("user_name =", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenNotEqualTo(String value) {
|
||||
addCriterion("repository_token <>", value, "repositoryToken");
|
||||
public Criteria andUserNameNotEqualTo(String value) {
|
||||
addCriterion("user_name <>", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenGreaterThan(String value) {
|
||||
addCriterion("repository_token >", value, "repositoryToken");
|
||||
public Criteria andUserNameGreaterThan(String value) {
|
||||
addCriterion("user_name >", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("repository_token >=", value, "repositoryToken");
|
||||
public Criteria andUserNameGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("user_name >=", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenLessThan(String value) {
|
||||
addCriterion("repository_token <", value, "repositoryToken");
|
||||
public Criteria andUserNameLessThan(String value) {
|
||||
addCriterion("user_name <", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenLessThanOrEqualTo(String value) {
|
||||
addCriterion("repository_token <=", value, "repositoryToken");
|
||||
public Criteria andUserNameLessThanOrEqualTo(String value) {
|
||||
addCriterion("user_name <=", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenLike(String value) {
|
||||
addCriterion("repository_token like", value, "repositoryToken");
|
||||
public Criteria andUserNameLike(String value) {
|
||||
addCriterion("user_name like", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenNotLike(String value) {
|
||||
addCriterion("repository_token not like", value, "repositoryToken");
|
||||
public Criteria andUserNameNotLike(String value) {
|
||||
addCriterion("user_name not like", value, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenIn(List<String> values) {
|
||||
addCriterion("repository_token in", values, "repositoryToken");
|
||||
public Criteria andUserNameIn(List<String> values) {
|
||||
addCriterion("user_name in", values, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenNotIn(List<String> values) {
|
||||
addCriterion("repository_token not in", values, "repositoryToken");
|
||||
public Criteria andUserNameNotIn(List<String> values) {
|
||||
addCriterion("user_name not in", values, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenBetween(String value1, String value2) {
|
||||
addCriterion("repository_token between", value1, value2, "repositoryToken");
|
||||
public Criteria andUserNameBetween(String value1, String value2) {
|
||||
addCriterion("user_name between", value1, value2, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andRepositoryTokenNotBetween(String value1, String value2) {
|
||||
addCriterion("repository_token not between", value1, value2, "repositoryToken");
|
||||
public Criteria andUserNameNotBetween(String value1, String value2) {
|
||||
addCriterion("user_name not between", value1, value2, "userName");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public interface FileMetadataRepositoryMapper {
|
|||
|
||||
int deleteByExample(FileMetadataRepositoryExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
int deleteByPrimaryKey(String fileMetadataId);
|
||||
|
||||
int insert(FileMetadataRepository record);
|
||||
|
||||
|
@ -20,7 +20,7 @@ public interface FileMetadataRepositoryMapper {
|
|||
|
||||
List<FileMetadataRepository> selectByExample(FileMetadataRepositoryExample example);
|
||||
|
||||
FileMetadataRepository selectByPrimaryKey(String id);
|
||||
FileMetadataRepository selectByPrimaryKey(String fileMetadataId);
|
||||
|
||||
int updateByExampleSelective(@Param("record") FileMetadataRepository record, @Param("example") FileMetadataRepositoryExample example);
|
||||
|
||||
|
@ -32,6 +32,8 @@ public interface FileMetadataRepositoryMapper {
|
|||
|
||||
int updateByPrimaryKeyWithBLOBs(FileMetadataRepository record);
|
||||
|
||||
int updateByPrimaryKey(FileMetadataRepository record);
|
||||
|
||||
int batchInsert(@Param("list") List<FileMetadataRepository> list);
|
||||
|
||||
int batchInsertSelective(@Param("list") List<FileMetadataRepository> list, @Param("selective") FileMetadataRepository.Column ... selective);
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.project.mapper.FileMetadataRepositoryMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.project.domain.FileMetadataRepository">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<id column="file_metadata_id" jdbcType="VARCHAR" property="fileMetadataId" />
|
||||
<result column="branch" jdbcType="VARCHAR" property="branch" />
|
||||
<result column="repository_url" jdbcType="VARCHAR" property="repositoryUrl" />
|
||||
<result column="token" jdbcType="VARCHAR" property="token" />
|
||||
<result column="commit_id" jdbcType="VARCHAR" property="commitId" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.project.domain.FileMetadataRepository">
|
||||
<result column="git_info" jdbcType="LONGVARBINARY" property="gitInfo" />
|
||||
<result column="commit_message" jdbcType="LONGVARCHAR" property="commitMessage" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -66,10 +70,10 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
file_metadata_id, branch, repository_url, token, commit_id
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
git_info
|
||||
commit_message
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.project.domain.FileMetadataRepositoryExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
|
@ -107,11 +111,11 @@
|
|||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from file_metadata_repository
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
where file_metadata_id = #{fileMetadataId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from file_metadata_repository
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
where file_metadata_id = #{fileMetadataId,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.project.domain.FileMetadataRepositoryExample">
|
||||
delete from file_metadata_repository
|
||||
|
@ -120,25 +124,53 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.project.domain.FileMetadataRepository">
|
||||
insert into file_metadata_repository (id, git_info)
|
||||
values (#{id,jdbcType=VARCHAR}, #{gitInfo,jdbcType=LONGVARBINARY})
|
||||
insert into file_metadata_repository (file_metadata_id, branch, repository_url,
|
||||
token, commit_id, commit_message
|
||||
)
|
||||
values (#{fileMetadataId,jdbcType=VARCHAR}, #{branch,jdbcType=VARCHAR}, #{repositoryUrl,jdbcType=VARCHAR},
|
||||
#{token,jdbcType=VARCHAR}, #{commitId,jdbcType=VARCHAR}, #{commitMessage,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.project.domain.FileMetadataRepository">
|
||||
insert into file_metadata_repository
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
<if test="fileMetadataId != null">
|
||||
file_metadata_id,
|
||||
</if>
|
||||
<if test="gitInfo != null">
|
||||
git_info,
|
||||
<if test="branch != null">
|
||||
branch,
|
||||
</if>
|
||||
<if test="repositoryUrl != null">
|
||||
repository_url,
|
||||
</if>
|
||||
<if test="token != null">
|
||||
token,
|
||||
</if>
|
||||
<if test="commitId != null">
|
||||
commit_id,
|
||||
</if>
|
||||
<if test="commitMessage != null">
|
||||
commit_message,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
<if test="fileMetadataId != null">
|
||||
#{fileMetadataId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="gitInfo != null">
|
||||
#{gitInfo,jdbcType=LONGVARBINARY},
|
||||
<if test="branch != null">
|
||||
#{branch,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryUrl != null">
|
||||
#{repositoryUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="token != null">
|
||||
#{token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="commitId != null">
|
||||
#{commitId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="commitMessage != null">
|
||||
#{commitMessage,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
@ -151,11 +183,23 @@
|
|||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update file_metadata_repository
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
<if test="record.fileMetadataId != null">
|
||||
file_metadata_id = #{record.fileMetadataId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.gitInfo != null">
|
||||
git_info = #{record.gitInfo,jdbcType=LONGVARBINARY},
|
||||
<if test="record.branch != null">
|
||||
branch = #{record.branch,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.repositoryUrl != null">
|
||||
repository_url = #{record.repositoryUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.token != null">
|
||||
token = #{record.token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.commitId != null">
|
||||
commit_id = #{record.commitId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.commitMessage != null">
|
||||
commit_message = #{record.commitMessage,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
|
@ -164,15 +208,23 @@
|
|||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
update file_metadata_repository
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
git_info = #{record.gitInfo,jdbcType=LONGVARBINARY}
|
||||
set file_metadata_id = #{record.fileMetadataId,jdbcType=VARCHAR},
|
||||
branch = #{record.branch,jdbcType=VARCHAR},
|
||||
repository_url = #{record.repositoryUrl,jdbcType=VARCHAR},
|
||||
token = #{record.token,jdbcType=VARCHAR},
|
||||
commit_id = #{record.commitId,jdbcType=VARCHAR},
|
||||
commit_message = #{record.commitMessage,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update file_metadata_repository
|
||||
set id = #{record.id,jdbcType=VARCHAR}
|
||||
set file_metadata_id = #{record.fileMetadataId,jdbcType=VARCHAR},
|
||||
branch = #{record.branch,jdbcType=VARCHAR},
|
||||
repository_url = #{record.repositoryUrl,jdbcType=VARCHAR},
|
||||
token = #{record.token,jdbcType=VARCHAR},
|
||||
commit_id = #{record.commitId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -180,23 +232,49 @@
|
|||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.project.domain.FileMetadataRepository">
|
||||
update file_metadata_repository
|
||||
<set>
|
||||
<if test="gitInfo != null">
|
||||
git_info = #{gitInfo,jdbcType=LONGVARBINARY},
|
||||
<if test="branch != null">
|
||||
branch = #{branch,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryUrl != null">
|
||||
repository_url = #{repositoryUrl,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="token != null">
|
||||
token = #{token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="commitId != null">
|
||||
commit_id = #{commitId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="commitMessage != null">
|
||||
commit_message = #{commitMessage,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
where file_metadata_id = #{fileMetadataId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.project.domain.FileMetadataRepository">
|
||||
update file_metadata_repository
|
||||
set git_info = #{gitInfo,jdbcType=LONGVARBINARY}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
set branch = #{branch,jdbcType=VARCHAR},
|
||||
repository_url = #{repositoryUrl,jdbcType=VARCHAR},
|
||||
token = #{token,jdbcType=VARCHAR},
|
||||
commit_id = #{commitId,jdbcType=VARCHAR},
|
||||
commit_message = #{commitMessage,jdbcType=LONGVARCHAR}
|
||||
where file_metadata_id = #{fileMetadataId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.project.domain.FileMetadataRepository">
|
||||
update file_metadata_repository
|
||||
set branch = #{branch,jdbcType=VARCHAR},
|
||||
repository_url = #{repositoryUrl,jdbcType=VARCHAR},
|
||||
token = #{token,jdbcType=VARCHAR},
|
||||
commit_id = #{commitId,jdbcType=VARCHAR}
|
||||
where file_metadata_id = #{fileMetadataId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into file_metadata_repository
|
||||
(id, git_info)
|
||||
(file_metadata_id, branch, repository_url, token, commit_id, commit_message)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.gitInfo,jdbcType=LONGVARBINARY})
|
||||
(#{item.fileMetadataId,jdbcType=VARCHAR}, #{item.branch,jdbcType=VARCHAR}, #{item.repositoryUrl,jdbcType=VARCHAR},
|
||||
#{item.token,jdbcType=VARCHAR}, #{item.commitId,jdbcType=VARCHAR}, #{item.commitMessage,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
|
@ -209,11 +287,23 @@
|
|||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
<foreach collection="selective" item="column" separator=",">
|
||||
<if test="'id'.toString() == column.value">
|
||||
#{item.id,jdbcType=VARCHAR}
|
||||
<if test="'file_metadata_id'.toString() == column.value">
|
||||
#{item.fileMetadataId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'git_info'.toString() == column.value">
|
||||
#{item.gitInfo,jdbcType=LONGVARBINARY}
|
||||
<if test="'branch'.toString() == column.value">
|
||||
#{item.branch,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'repository_url'.toString() == column.value">
|
||||
#{item.repositoryUrl,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'token'.toString() == column.value">
|
||||
#{item.token,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'commit_id'.toString() == column.value">
|
||||
#{item.commitId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'commit_message'.toString() == column.value">
|
||||
#{item.commitMessage,jdbcType=LONGVARCHAR}
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
<resultMap id="BaseResultMap" type="io.metersphere.project.domain.FileModuleRepository">
|
||||
<id column="file_module_id" jdbcType="VARCHAR" property="fileModuleId" />
|
||||
<result column="platform" jdbcType="VARCHAR" property="platform" />
|
||||
<result column="repository_path" jdbcType="VARCHAR" property="repositoryPath" />
|
||||
<result column="repository_user_name" jdbcType="VARCHAR" property="repositoryUserName" />
|
||||
<result column="repository_token" jdbcType="VARCHAR" property="repositoryToken" />
|
||||
<result column="url" jdbcType="VARCHAR" property="url" />
|
||||
<result column="token" jdbcType="VARCHAR" property="token" />
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -67,7 +67,7 @@
|
|||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
file_module_id, platform, repository_path, repository_user_name, repository_token
|
||||
file_module_id, platform, url, token, user_name
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.project.domain.FileModuleRepositoryExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -100,10 +100,10 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.project.domain.FileModuleRepository">
|
||||
insert into file_module_repository (file_module_id, platform, repository_path,
|
||||
repository_user_name, repository_token)
|
||||
values (#{fileModuleId,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{repositoryPath,jdbcType=VARCHAR},
|
||||
#{repositoryUserName,jdbcType=VARCHAR}, #{repositoryToken,jdbcType=VARCHAR})
|
||||
insert into file_module_repository (file_module_id, platform, url,
|
||||
token, user_name)
|
||||
values (#{fileModuleId,jdbcType=VARCHAR}, #{platform,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR},
|
||||
#{token,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.project.domain.FileModuleRepository">
|
||||
insert into file_module_repository
|
||||
|
@ -114,14 +114,14 @@
|
|||
<if test="platform != null">
|
||||
platform,
|
||||
</if>
|
||||
<if test="repositoryPath != null">
|
||||
repository_path,
|
||||
<if test="url != null">
|
||||
url,
|
||||
</if>
|
||||
<if test="repositoryUserName != null">
|
||||
repository_user_name,
|
||||
<if test="token != null">
|
||||
token,
|
||||
</if>
|
||||
<if test="repositoryToken != null">
|
||||
repository_token,
|
||||
<if test="userName != null">
|
||||
user_name,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
|
@ -131,14 +131,14 @@
|
|||
<if test="platform != null">
|
||||
#{platform,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryPath != null">
|
||||
#{repositoryPath,jdbcType=VARCHAR},
|
||||
<if test="url != null">
|
||||
#{url,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryUserName != null">
|
||||
#{repositoryUserName,jdbcType=VARCHAR},
|
||||
<if test="token != null">
|
||||
#{token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryToken != null">
|
||||
#{repositoryToken,jdbcType=VARCHAR},
|
||||
<if test="userName != null">
|
||||
#{userName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
@ -157,14 +157,14 @@
|
|||
<if test="record.platform != null">
|
||||
platform = #{record.platform,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.repositoryPath != null">
|
||||
repository_path = #{record.repositoryPath,jdbcType=VARCHAR},
|
||||
<if test="record.url != null">
|
||||
url = #{record.url,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.repositoryUserName != null">
|
||||
repository_user_name = #{record.repositoryUserName,jdbcType=VARCHAR},
|
||||
<if test="record.token != null">
|
||||
token = #{record.token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.repositoryToken != null">
|
||||
repository_token = #{record.repositoryToken,jdbcType=VARCHAR},
|
||||
<if test="record.userName != null">
|
||||
user_name = #{record.userName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
|
@ -175,9 +175,9 @@
|
|||
update file_module_repository
|
||||
set file_module_id = #{record.fileModuleId,jdbcType=VARCHAR},
|
||||
platform = #{record.platform,jdbcType=VARCHAR},
|
||||
repository_path = #{record.repositoryPath,jdbcType=VARCHAR},
|
||||
repository_user_name = #{record.repositoryUserName,jdbcType=VARCHAR},
|
||||
repository_token = #{record.repositoryToken,jdbcType=VARCHAR}
|
||||
url = #{record.url,jdbcType=VARCHAR},
|
||||
token = #{record.token,jdbcType=VARCHAR},
|
||||
user_name = #{record.userName,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -188,14 +188,14 @@
|
|||
<if test="platform != null">
|
||||
platform = #{platform,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryPath != null">
|
||||
repository_path = #{repositoryPath,jdbcType=VARCHAR},
|
||||
<if test="url != null">
|
||||
url = #{url,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryUserName != null">
|
||||
repository_user_name = #{repositoryUserName,jdbcType=VARCHAR},
|
||||
<if test="token != null">
|
||||
token = #{token,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="repositoryToken != null">
|
||||
repository_token = #{repositoryToken,jdbcType=VARCHAR},
|
||||
<if test="userName != null">
|
||||
user_name = #{userName,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where file_module_id = #{fileModuleId,jdbcType=VARCHAR}
|
||||
|
@ -203,20 +203,18 @@
|
|||
<update id="updateByPrimaryKey" parameterType="io.metersphere.project.domain.FileModuleRepository">
|
||||
update file_module_repository
|
||||
set platform = #{platform,jdbcType=VARCHAR},
|
||||
repository_path = #{repositoryPath,jdbcType=VARCHAR},
|
||||
repository_user_name = #{repositoryUserName,jdbcType=VARCHAR},
|
||||
repository_token = #{repositoryToken,jdbcType=VARCHAR}
|
||||
url = #{url,jdbcType=VARCHAR},
|
||||
token = #{token,jdbcType=VARCHAR},
|
||||
user_name = #{userName,jdbcType=VARCHAR}
|
||||
where file_module_id = #{fileModuleId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into file_module_repository
|
||||
(file_module_id, platform, repository_path, repository_user_name, repository_token
|
||||
)
|
||||
(file_module_id, platform, url, token, user_name)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.fileModuleId,jdbcType=VARCHAR}, #{item.platform,jdbcType=VARCHAR}, #{item.repositoryPath,jdbcType=VARCHAR},
|
||||
#{item.repositoryUserName,jdbcType=VARCHAR}, #{item.repositoryToken,jdbcType=VARCHAR}
|
||||
)
|
||||
(#{item.fileModuleId,jdbcType=VARCHAR}, #{item.platform,jdbcType=VARCHAR}, #{item.url,jdbcType=VARCHAR},
|
||||
#{item.token,jdbcType=VARCHAR}, #{item.userName,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
|
@ -235,14 +233,14 @@
|
|||
<if test="'platform'.toString() == column.value">
|
||||
#{item.platform,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'repository_path'.toString() == column.value">
|
||||
#{item.repositoryPath,jdbcType=VARCHAR}
|
||||
<if test="'url'.toString() == column.value">
|
||||
#{item.url,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'repository_user_name'.toString() == column.value">
|
||||
#{item.repositoryUserName,jdbcType=VARCHAR}
|
||||
<if test="'token'.toString() == column.value">
|
||||
#{item.token,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'repository_token'.toString() == column.value">
|
||||
#{item.repositoryToken,jdbcType=VARCHAR}
|
||||
<if test="'user_name'.toString() == column.value">
|
||||
#{item.userName,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
|
|
|
@ -62,16 +62,20 @@ CREATE INDEX idx_file_metadata_id ON file_association (file_metadata_id);
|
|||
CREATE INDEX idx_project_id ON file_association (project_id);
|
||||
CREATE INDEX idx_source_id ON file_association (source_id);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS file_metadata_repository
|
||||
(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '文件ID',
|
||||
`git_info` LONGBLOB COMMENT '储存库',
|
||||
PRIMARY KEY (id)
|
||||
`file_metadata_id` VARCHAR(50) NOT NULL COMMENT '文件ID',
|
||||
`branch` VARCHAR(255) NOT NULL COMMENT '分支',
|
||||
`repository_url` VARCHAR(255) NOT NULL COMMENT '存储库地址',
|
||||
`token` VARCHAR(1000) NOT NULL COMMENT 'token',
|
||||
`commit_id` VARCHAR(255) COMMENT '提交ID',
|
||||
`commit_message` TEXT COMMENT '提交信息',
|
||||
PRIMARY KEY (file_metadata_id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
COMMENT = '文件基础信息大字段';
|
||||
COMMENT = '存储库文件信息拓展';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS file_metadata
|
||||
(
|
||||
|
@ -206,17 +210,19 @@ CREATE INDEX idx_latest ON project_version (latest);
|
|||
|
||||
CREATE TABLE IF NOT EXISTS file_module_repository
|
||||
(
|
||||
`file_module_id` VARCHAR(50) NOT NULL COMMENT 'file_module_id',
|
||||
`platform` VARCHAR(10) COMMENT '所属平台;GitHub/Gitlab/Gitee',
|
||||
`repository_path` VARCHAR(255) COMMENT '存储库地址',
|
||||
`repository_user_name` VARCHAR(255) COMMENT '存储库Token;platform为Gitee时必填',
|
||||
`repository_token` VARCHAR(255) COMMENT '存储库Token',
|
||||
`file_module_id` VARCHAR(50) NOT NULL COMMENT 'file_module_id',
|
||||
`platform` VARCHAR(10) NOT NULL COMMENT '所属平台;GitHub/Gitlab/Gitee',
|
||||
`url` VARCHAR(255) NOT NULL COMMENT '存储库地址',
|
||||
`token` VARCHAR(255) NOT NULL COMMENT '存储库Token',
|
||||
`user_name` VARCHAR(255) COMMENT '用户名;platform为Gitee时必填',
|
||||
PRIMARY KEY (file_module_id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
COMMENT = '文件存储库模块';
|
||||
|
||||
CREATE INDEX idx_token ON file_module_repository (token);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS custom_function_blob
|
||||
(
|
||||
|
|
|
@ -19,6 +19,13 @@ file_module.project_id.length_range=项目ID长度必须在{min}-{max}之间
|
|||
file_module.project_id.not_blank=项目ID不能为空
|
||||
file_module.name.length_range=名称长度必须在{min}-{max}之间
|
||||
file_module.name.not_blank=名称不能为空
|
||||
file_repository.not.exist=存储库不存在
|
||||
file_repository.platform.error=存储库类型不正确
|
||||
file_repository.id.not_blank=存储库ID不能为空
|
||||
file_repository.name.not_blank=存储库名称不能为空
|
||||
file_repository.type.not_blank=存储库类型不能为空
|
||||
file_repository.token.not_blank=存储库token不能为空
|
||||
file_repository.url.not_blank=存储库地址不能为空
|
||||
custom_field_template.id.not_blank=ID不能为空
|
||||
custom_field_template.field_id.length_range=字段ID长度必须在{min}-{max}之间
|
||||
custom_field_template.field_id.not_blank=字段ID不能为空
|
||||
|
|
|
@ -31,6 +31,13 @@ file_module.project_id.length_range=Project ID length must be between {min} and
|
|||
file_module.project_id.not_blank=Project ID is required
|
||||
file_module.name.length_range=Name length must be between {min} and {max}
|
||||
file_module.name.not_blank=Name is required
|
||||
file_repository.not.exist=Repository not exist
|
||||
file_repository.platform.error=Repository platform error
|
||||
file_repository.id.not_blank=Repository ID is required
|
||||
file_repository.name.not_blank=Repository name is required
|
||||
file_repository.type.not_blank=Repository type is required
|
||||
file_repository.token.not_blank=Repository token is required
|
||||
file_repository.url.not_blank=Repository url is required
|
||||
custom_field_template.id.not_blank=ID is required
|
||||
custom_field_template.field_id.length_range=Field ID length must be between {min} and {max}
|
||||
custom_field_template.field_id.not_blank=Field ID is required
|
||||
|
|
|
@ -31,6 +31,13 @@ file_module.project_id.length_range=项目ID长度必须在{min}-{max}之间
|
|||
file_module.project_id.not_blank=项目ID不能为空
|
||||
file_module.name.length_range=名称长度必须在{min}-{max}之间
|
||||
file_module.name.not_blank=名称不能为空
|
||||
file_repository.not.exist=存储库不存在
|
||||
file_repository.platform.error=存储库类型不正确
|
||||
file_repository.id.not_blank=存储库ID不能为空
|
||||
file_repository.name.not_blank=存储库名称不能为空
|
||||
file_repository.type.not_blank=存储库类型不能为空
|
||||
file_repository.token.not_blank=存储库token不能为空
|
||||
file_repository.url.not_blank=存储库地址不能为空
|
||||
custom_field_template.id.not_blank=ID不能为空
|
||||
custom_field_template.field_id.length_range=字段ID长度必须在{min}-{max}之间
|
||||
custom_field_template.field_id.not_blank=字段ID不能为空
|
||||
|
|
|
@ -31,6 +31,13 @@ file_module.project_id.length_range=項目ID長度必須在{min}-{max}之間
|
|||
file_module.project_id.not_blank=項目ID不能為空
|
||||
file_module.name.length_range=名稱長度必須在{min}-{max}之間
|
||||
file_module.name.not_blank=名稱不能為空
|
||||
file_repository.not.exist=存儲庫不存在
|
||||
file_repository.platform.error=存儲庫類型不正確
|
||||
file_repository.id.not_blank=存儲庫ID不能為空
|
||||
file_repository.name.not_blank=存儲庫名稱不能為空
|
||||
file_repository.type.not_blank=存儲庫類型不能為空
|
||||
file_repository.token.not_blank=存儲庫token不能為空
|
||||
file_repository.url.not_blank=存儲庫地址不能為空
|
||||
custom_field_template.id.not_blank=ID不能為空
|
||||
custom_field_template.field_id.length_range=字段ID長度必須在{min}-{max}之間
|
||||
custom_field_template.field_id.not_blank=字段ID不能為空
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package io.metersphere.project.controller;
|
||||
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryConnectRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryCreateRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryUpdateRequest;
|
||||
import io.metersphere.project.service.FileMetadataService;
|
||||
import io.metersphere.project.service.FileRepositoryService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.StorageType;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -35,9 +37,30 @@ public class FileRepositoryController {
|
|||
|
||||
|
||||
@GetMapping(value = "/file-type/{projectId}")
|
||||
@Operation(summary = "项目管理-文件管理-获取已存在的存储库文件类型")
|
||||
@Operation(summary = "项目管理-文件管理-存储库-获取已存在的存储库文件类型")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ)
|
||||
public List<String> getFileType(@PathVariable String projectId) {
|
||||
return fileMetadataService.getFileType(projectId, StorageType.GIT.name());
|
||||
}
|
||||
|
||||
@PostMapping("/add-repository")
|
||||
@Operation(summary = "项目管理-文件管理-存储库-添加存储库")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_ADD)
|
||||
public String add(@RequestBody @Validated FileRepositoryCreateRequest request) {
|
||||
return fileRepositoryService.addRepository(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/update-repository")
|
||||
@Operation(summary = "项目管理-文件管理-存储库-修改存储库")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_UPDATE)
|
||||
public boolean list(@RequestBody @Validated FileRepositoryUpdateRequest request) {
|
||||
fileRepositoryService.updateRepository(request, SessionUtils.getUserId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/connect")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ_ADD)
|
||||
public void connect(@RequestBody @Validated FileRepositoryConnectRequest request) {
|
||||
fileRepositoryService.connect(request.getUrl(), request.getToken(), request.getUserName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package io.metersphere.project.dto.filemanagement;
|
||||
|
||||
import io.metersphere.project.domain.FileModule;
|
||||
import io.metersphere.project.domain.FileModuleRepository;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileRepositoryLog {
|
||||
private String id;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private Long pos;
|
||||
|
||||
private String updateUser;
|
||||
|
||||
private String createUser;
|
||||
|
||||
private String moduleType;
|
||||
|
||||
private String platform;
|
||||
|
||||
private String url;
|
||||
|
||||
private String token;
|
||||
|
||||
private String userName;
|
||||
|
||||
public FileRepositoryLog(FileModule module, FileModuleRepository repository) {
|
||||
this.id = module.getId();
|
||||
this.projectId = module.getProjectId();
|
||||
this.name = module.getName();
|
||||
this.parentId = module.getParentId();
|
||||
this.createTime = module.getCreateTime();
|
||||
this.updateTime = module.getUpdateTime();
|
||||
this.pos = module.getPos();
|
||||
this.updateUser = module.getUpdateUser();
|
||||
this.createUser = module.getCreateUser();
|
||||
this.moduleType = module.getModuleType();
|
||||
this.platform = repository.getPlatform();
|
||||
this.url = repository.getUrl();
|
||||
this.token = repository.getToken();
|
||||
this.userName = repository.getUserName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.project.dto.filemanagement;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RepositoryQuery {
|
||||
private String fileMetadataId;
|
||||
private String filePath;
|
||||
private String commitId;
|
||||
private String projectId;
|
||||
private long updateTime;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package io.metersphere.project.dto.filemanagement.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileRepositoryConnectRequest {
|
||||
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "{file_repository.url.not_blank}")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "存储库token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "{file_repository.token.not_blank}")
|
||||
private String token;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String userName;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package io.metersphere.project.dto.filemanagement.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileRepositoryCreateRequest {
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{project.id.not_blank}")
|
||||
private String projectId;
|
||||
|
||||
@Schema(description = "模块名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_repository.name.not_blank}")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储库类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_repository.type.not_blank}")
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "存储库地址", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_repository.url.not_blank}")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "存储库token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "{file_repository.token.not_blank}")
|
||||
private String token;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String userName;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package io.metersphere.project.dto.filemanagement.request;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileRepositoryUpdateRequest {
|
||||
@Schema(description = "模块ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{file_repository.id.not_blank}")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "模块名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储库类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "存储库token", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String token;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String userName;
|
||||
}
|
||||
|
|
@ -14,4 +14,7 @@ public class FileUploadRequest {
|
|||
@Schema(description = "模块Id")
|
||||
@NotBlank(message = "{file_module.id.not_blank}")
|
||||
private String moduleId = ModuleConstants.DEFAULT_NODE_ID;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enable;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface ExtFileModuleMapper {
|
|||
|
||||
void deleteByIds(@Param("ids") List<String> deleteId);
|
||||
|
||||
Long getMaxPosByParentId(String parentId);
|
||||
Long getMaxPosByParentId(@Param("parentId") String parentId, @Param("fileType") String fileType);
|
||||
|
||||
List<String> selectIdsByProjectId(String projectId);
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
</delete>
|
||||
<select id="getMaxPosByParentId" resultType="java.lang.Long">
|
||||
SELECT max(pos) FROM file_module
|
||||
WHERE parent_id = #{0}
|
||||
WHERE parent_id = #{parentId}
|
||||
AND module_type = #{fileType}
|
||||
</select>
|
||||
<select id="selectChildrenIdsSortByPos" resultType="java.lang.String">
|
||||
SELECT id FROM file_module WHERE parent_id = #{0}
|
||||
|
|
|
@ -100,6 +100,12 @@ public class FileMetadataService {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkEnableFile(String fileType) {
|
||||
if (!StringUtils.equalsIgnoreCase(fileType, JAR_FILE_PREFIX)) {
|
||||
throw new MSException(Translator.get("file.not.jar"));
|
||||
}
|
||||
}
|
||||
|
||||
public String upload(FileUploadRequest request, String operator, MultipartFile uploadFile) throws Exception {
|
||||
//检查模块的合法性
|
||||
fileManagementService.checkModule(request.getModuleId(), ModuleConstants.NODE_TYPE_DEFAULT);
|
||||
|
@ -114,9 +120,15 @@ public class FileMetadataService {
|
|||
fileMetadata.setName(fileName);
|
||||
fileMetadata.setType(StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
//检查处理后的用户名合法性
|
||||
this.checkFileName(null, fileMetadata.getName(), request.getProjectId());
|
||||
|
||||
//如果开启了开关,检查是否是jar文件
|
||||
if (request.isEnable()) {
|
||||
this.checkEnableFile(fileMetadata.getType());
|
||||
}
|
||||
|
||||
fileMetadata.setId(IDGenerator.nextStr());
|
||||
fileMetadata.setStorage(StorageType.MINIO.name());
|
||||
fileMetadata.setProjectId(request.getProjectId());
|
||||
|
@ -229,9 +241,7 @@ public class FileMetadataService {
|
|||
updateExample.setTags(null);
|
||||
}
|
||||
if (request.getEnable() != null) {
|
||||
if (!StringUtils.equalsIgnoreCase(fileMetadata.getType(), JAR_FILE_PREFIX)) {
|
||||
throw new MSException(Translator.get("file.not.jar"));
|
||||
}
|
||||
this.checkEnableFile(fileMetadata.getType());
|
||||
updateExample.setEnable(request.getEnable());
|
||||
}
|
||||
updateExample.setUpdateUser(operator);
|
||||
|
@ -388,9 +398,7 @@ public class FileMetadataService {
|
|||
if (fileMetadata == null) {
|
||||
throw new MSException(Translator.get("file.not.exist"));
|
||||
}
|
||||
if (!StringUtils.equalsIgnoreCase(fileMetadata.getType(), JAR_FILE_PREFIX)) {
|
||||
throw new MSException(Translator.get("file.not.jar"));
|
||||
}
|
||||
this.checkEnableFile(fileMetadata.getType());
|
||||
FileMetadata updateModel = new FileMetadata();
|
||||
updateModel.setId(fileMetadata.getId());
|
||||
updateModel.setEnable(enable);
|
||||
|
|
|
@ -3,16 +3,17 @@ package io.metersphere.project.service;
|
|||
import io.metersphere.project.domain.FileModule;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.NodeSortDTO;
|
||||
import io.metersphere.project.dto.filemanagement.FileRepositoryLog;
|
||||
import io.metersphere.project.mapper.FileModuleMapper;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.system.dto.sdk.BaseModule;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.dto.builder.LogDTOBuilder;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.builder.LogDTOBuilder;
|
||||
import io.metersphere.system.dto.sdk.BaseModule;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -46,6 +47,23 @@ public class FileModuleLogService {
|
|||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
public void saveAddRepositoryLog(FileRepositoryLog repositoryLog, String operator) {
|
||||
Project project = projectMapper.selectByPrimaryKey(repositoryLog.getProjectId());
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(repositoryLog.getProjectId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.ADD.name())
|
||||
.module(OperationLogModule.PROJECT_FILE_MANAGEMENT)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path("/project/file/repository/add-repository")
|
||||
.sourceId(repositoryLog.getId())
|
||||
.content(repositoryLog.getName())
|
||||
.originalValue(JSON.toJSONBytes(repositoryLog))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
public void saveUpdateLog(FileModule module, String projectId, String operator) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
|
@ -60,7 +78,23 @@ public class FileModuleLogService {
|
|||
.originalValue(JSON.toJSONBytes(module))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
public void saveUpdateRepositoryLog(FileRepositoryLog fileRepositoryLog, String operator) {
|
||||
Project project = projectMapper.selectByPrimaryKey(fileRepositoryLog.getProjectId());
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(fileRepositoryLog.getProjectId())
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.UPDATE.name())
|
||||
.module(OperationLogModule.PROJECT_FILE_MANAGEMENT)
|
||||
.method(HttpMethodConstants.POST.name())
|
||||
.path("/project/file/repository/update-repository")
|
||||
.sourceId(fileRepositoryLog.getId())
|
||||
.content(fileRepositoryLog.getName())
|
||||
.originalValue(JSON.toJSONBytes(fileRepositoryLog))
|
||||
.createUser(operator)
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
|
@ -113,4 +147,5 @@ public class FileModuleLogService {
|
|||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,15 +35,15 @@ import java.util.stream.Collectors;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class FileModuleService extends ModuleTreeService implements CleanupProjectResourceService {
|
||||
@Resource
|
||||
private FileModuleLogService fileModuleLogService;
|
||||
protected FileModuleLogService fileModuleLogService;
|
||||
@Resource
|
||||
private FileModuleMapper fileModuleMapper;
|
||||
protected FileModuleMapper fileModuleMapper;
|
||||
@Resource
|
||||
private ExtFileModuleMapper extFileModuleMapper;
|
||||
protected ExtFileModuleMapper extFileModuleMapper;
|
||||
@Resource
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
protected SqlSessionFactory sqlSessionFactory;
|
||||
@Resource
|
||||
private FileManagementService fileManagementService;
|
||||
protected FileManagementService fileManagementService;
|
||||
|
||||
public List<BaseTreeNode> getTree(String projectId) {
|
||||
List<BaseTreeNode> fileModuleList = extFileModuleMapper.selectBaseByProjectId(projectId, ModuleConstants.NODE_TYPE_DEFAULT);
|
||||
|
@ -59,13 +59,13 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
public String add(FileModuleCreateRequest request, String operator) {
|
||||
FileModule fileModule = new FileModule();
|
||||
fileModule.setId(IDGenerator.nextStr());
|
||||
fileModule.setName(request.getName());
|
||||
fileModule.setName(request.getName().trim());
|
||||
fileModule.setParentId(request.getParentId());
|
||||
fileModule.setProjectId(request.getProjectId());
|
||||
this.checkDataValidity(fileModule);
|
||||
fileModule.setCreateTime(System.currentTimeMillis());
|
||||
fileModule.setUpdateTime(fileModule.getCreateTime());
|
||||
fileModule.setPos(this.countPos(request.getParentId()));
|
||||
fileModule.setPos(this.countPos(request.getParentId(), ModuleConstants.NODE_TYPE_DEFAULT));
|
||||
fileModule.setCreateUser(operator);
|
||||
fileModule.setUpdateUser(operator);
|
||||
fileModule.setModuleType(ModuleConstants.NODE_TYPE_DEFAULT);
|
||||
|
@ -76,8 +76,8 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
return fileModule.getId();
|
||||
}
|
||||
|
||||
private Long countPos(String parentId) {
|
||||
Long maxPos = extFileModuleMapper.getMaxPosByParentId(parentId);
|
||||
protected Long countPos(String parentId, String fileType) {
|
||||
Long maxPos = extFileModuleMapper.getMaxPosByParentId(parentId, fileType);
|
||||
if (maxPos == null) {
|
||||
return LIMIT_POS;
|
||||
} else {
|
||||
|
@ -88,7 +88,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
/**
|
||||
* 检查数据的合法性
|
||||
*/
|
||||
private void checkDataValidity(FileModule fileModule) {
|
||||
protected void checkDataValidity(FileModule fileModule) {
|
||||
FileModuleExample example = new FileModuleExample();
|
||||
if (!StringUtils.equals(fileModule.getParentId(), ModuleConstants.ROOT_NODE_PARENT_ID)) {
|
||||
//检查父ID是否存在
|
||||
|
@ -121,7 +121,7 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje
|
|||
}
|
||||
FileModule updateModule = new FileModule();
|
||||
updateModule.setId(request.getId());
|
||||
updateModule.setName(request.getName());
|
||||
updateModule.setName(request.getName().trim());
|
||||
updateModule.setParentId(module.getParentId());
|
||||
this.checkDataValidity(updateModule);
|
||||
updateModule.setUpdateTime(System.currentTimeMillis());
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.project.mapper.ExtFileModuleMapper;
|
||||
import io.metersphere.project.domain.FileModule;
|
||||
import io.metersphere.project.domain.FileModuleRepository;
|
||||
import io.metersphere.project.dto.filemanagement.FileRepositoryLog;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryCreateRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryUpdateRequest;
|
||||
import io.metersphere.project.mapper.FileModuleRepositoryMapper;
|
||||
import io.metersphere.project.utils.GitRepositoryUtil;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -14,17 +25,90 @@ import java.util.List;
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public class FileRepositoryService extends FileModuleService {
|
||||
|
||||
// @Resource
|
||||
// private FileModuleMapper fileModuleMapper;
|
||||
@Resource
|
||||
private ExtFileModuleMapper extFileModuleMapper;
|
||||
// @Resource
|
||||
// private FileManagementService fileManagementService;
|
||||
// @Resource
|
||||
// private SqlSessionFactory sqlSessionFactory;
|
||||
private FileModuleRepositoryMapper fileModuleRepositoryMapper;
|
||||
|
||||
public List<BaseTreeNode> getTree(String projectId) {
|
||||
List<BaseTreeNode> fileModuleList = extFileModuleMapper.selectBaseByProjectId(projectId, ModuleConstants.NODE_TYPE_GIT);
|
||||
return super.buildTreeAndCountResource(fileModuleList, false, Translator.get("default.module"));
|
||||
}
|
||||
|
||||
public String addRepository(FileRepositoryCreateRequest request, String operator) {
|
||||
this.connect(request.getUrl(), request.getToken(), request.getUserName());
|
||||
this.checkPlatForm(request.getPlatform());
|
||||
//记录模块节点数据
|
||||
FileModule fileModule = new FileModule();
|
||||
fileModule.setId(IDGenerator.nextStr());
|
||||
fileModule.setName(request.getName().trim());
|
||||
fileModule.setParentId(ModuleConstants.ROOT_NODE_PARENT_ID);
|
||||
fileModule.setProjectId(request.getProjectId());
|
||||
super.checkDataValidity(fileModule);
|
||||
fileModule.setCreateTime(System.currentTimeMillis());
|
||||
fileModule.setUpdateTime(fileModule.getCreateTime());
|
||||
fileModule.setPos(this.countPos(ModuleConstants.ROOT_NODE_PARENT_ID, ModuleConstants.NODE_TYPE_GIT));
|
||||
fileModule.setCreateUser(operator);
|
||||
fileModule.setUpdateUser(operator);
|
||||
fileModule.setModuleType(ModuleConstants.NODE_TYPE_DEFAULT);
|
||||
fileModuleMapper.insert(fileModule);
|
||||
|
||||
//记录模块仓库数据
|
||||
FileModuleRepository fileRepository = new FileModuleRepository();
|
||||
fileRepository.setFileModuleId(fileModule.getId());
|
||||
fileRepository.setUrl(request.getUrl());
|
||||
fileRepository.setPlatform(request.getPlatform());
|
||||
fileRepository.setToken(request.getToken());
|
||||
fileRepository.setUserName(request.getUserName());
|
||||
fileModuleRepositoryMapper.insert(fileRepository);
|
||||
|
||||
//记录日志
|
||||
fileModuleLogService.saveAddRepositoryLog(new FileRepositoryLog(fileModule, fileRepository), operator);
|
||||
return fileModule.getId();
|
||||
}
|
||||
|
||||
public void connect(String url, String token, String userName) {
|
||||
GitRepositoryUtil utils = new GitRepositoryUtil(url, userName, token);
|
||||
List<String> branches = utils.getBranches();
|
||||
if (CollectionUtils.isEmpty(branches)) {
|
||||
throw new MSException(Translator.get("file_repository.not.exist"));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRepository(FileRepositoryUpdateRequest request, String operator) {
|
||||
if (ObjectUtils.allNull(request.getName(), request.getPlatform(), request.getToken(), request.getUserName())) {
|
||||
return;
|
||||
}
|
||||
FileModule fileModule = fileModuleMapper.selectByPrimaryKey(request.getId());
|
||||
FileModuleRepository repository = fileModuleRepositoryMapper.selectByPrimaryKey(request.getId());
|
||||
if (ObjectUtils.anyNull(fileModule, repository)) {
|
||||
throw new MSException(Translator.get("file_repository.not.exist"));
|
||||
}
|
||||
this.connect(repository.getUrl(),
|
||||
request.getToken() == null ? repository.getToken() : request.getToken(),
|
||||
request.getUserName() == null ? repository.getUserName() : request.getUserName());
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
fileModule.setName(request.getName().trim());
|
||||
super.checkDataValidity(fileModule);
|
||||
}
|
||||
fileModule.setUpdateTime(System.currentTimeMillis());
|
||||
fileModule.setUpdateUser(operator);
|
||||
fileModuleMapper.updateByPrimaryKeySelective(fileModule);
|
||||
|
||||
if (request.getToken() != null || request.getUserName() != null) {
|
||||
if (request.getToken() != null) {
|
||||
repository.setToken(request.getToken());
|
||||
}
|
||||
if (request.getUserName() != null) {
|
||||
repository.setUserName(request.getUserName());
|
||||
}
|
||||
fileModuleRepositoryMapper.updateByPrimaryKeySelective(repository);
|
||||
}
|
||||
//记录日志
|
||||
fileModuleLogService.saveUpdateRepositoryLog(new FileRepositoryLog(fileModule, repository), operator);
|
||||
}
|
||||
|
||||
private void checkPlatForm(String platform) {
|
||||
if (!StringUtils.equalsAny(platform, ModuleConstants.NODE_TYPE_GITHUB, ModuleConstants.NODE_TYPE_GITEE, ModuleConstants.NODE_TYPE_GITLAB)) {
|
||||
throw new MSException(Translator.get("file_repository.platform.error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
package io.metersphere.project.utils;
|
||||
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class GitRepositoryUtil {
|
||||
private final String REF_SPACE = "+refs/heads/*:refs/heads/*";
|
||||
private final String DEFAULT_GIT_USERNAME = "PRIVATE-TOKEN";
|
||||
|
||||
private String repositoryUrl;
|
||||
private String userName;
|
||||
private String token;
|
||||
|
||||
private Git git;
|
||||
|
||||
public GitRepositoryUtil(String repositoryUrl, String userName, String token) {
|
||||
this.repositoryUrl = StringUtils.trim(repositoryUrl);
|
||||
if (StringUtils.isNotBlank(userName)) {
|
||||
this.userName = StringUtils.trim(userName);
|
||||
} else {
|
||||
this.userName = this.DEFAULT_GIT_USERNAME;
|
||||
}
|
||||
this.token = StringUtils.trim(token);
|
||||
LogUtils.info("初始化文件库完成. repositoryUrl:" + repositoryUrl + "; userName:" + userName + "; token:" + token);
|
||||
}
|
||||
|
||||
//以下方法先注释掉,用到了再打开
|
||||
|
||||
// public byte[] getSingleFile(String filePath, String commitId) throws Exception {
|
||||
// LogUtils.info("准备获取文件. repositoryUrl:" + repositoryUrl + "; filePath:" + filePath + "; commitId:" + commitId);
|
||||
// InMemoryRepository repo = this.getGitRepositoryInMemory(repositoryUrl, userName, token);
|
||||
// ObjectId fileCommitObjectId = repo.resolve(commitId);
|
||||
// ObjectId objectId = this.getTreeWork(repo, fileCommitObjectId, filePath).getObjectId(0);
|
||||
// ObjectLoader loader = repo.open(objectId);
|
||||
// byte[] returnBytes = loader.getBytes();
|
||||
// this.closeConnection(repo);
|
||||
// return returnBytes;
|
||||
// }
|
||||
|
||||
// public Map<String, byte[]> getFiles(List<RepositoryQuery> RepositoryQueryList) throws Exception {
|
||||
// Map<String, byte[]> returnMap = new HashMap<>();
|
||||
// if (CollectionUtils.isEmpty(RepositoryQueryList)) {
|
||||
// return returnMap;
|
||||
// }
|
||||
// Map<String, List<RepositoryQuery>> commitIdFilePathMap = RepositoryQueryList.stream().collect(Collectors.groupingBy(RepositoryQuery::getCommitId));
|
||||
// InMemoryRepository repo = this.getGitRepositoryInMemory(repositoryUrl, userName, token);
|
||||
// ObjectId fileCommitObjectId;
|
||||
// for (Map.Entry<String, List<RepositoryQuery>> commitFilePathEntry : commitIdFilePathMap.entrySet()) {
|
||||
// String commitId = commitFilePathEntry.getKey();
|
||||
// List<RepositoryQuery> itemRequestList = commitFilePathEntry.getValue();
|
||||
// for (RepositoryQuery RepositoryQuery : itemRequestList) {
|
||||
// String filePath = RepositoryQuery.getFilePath();
|
||||
// fileCommitObjectId = repo.resolve(commitId);
|
||||
// ObjectId objectId = this.getTreeWork(repo, fileCommitObjectId, filePath).getObjectId(0);
|
||||
// ObjectLoader loader = repo.open(objectId);
|
||||
// returnMap.put(RepositoryQuery.getFileMetadataId(), loader.getBytes());
|
||||
// }
|
||||
// this.closeConnection(repo);
|
||||
// }
|
||||
// LogUtils.info("准备批量获取文件结束. repositoryUrl:" + repositoryUrl);
|
||||
// return returnMap;
|
||||
// }
|
||||
|
||||
// public RemoteFileAttachInfo selectLastCommitIdByBranch(String branch, String filePath) {
|
||||
// RemoteFileAttachInfo attachInfo;
|
||||
// InMemoryRepository repo = null;
|
||||
// TreeWalk treeWalk = null;
|
||||
// try {
|
||||
// repo = this.getGitRepositoryInMemory(repositoryUrl, userName, token);
|
||||
// ObjectId lastCommitId = repo.resolve("refs/heads/" + branch);
|
||||
// if (lastCommitId != null) {
|
||||
// RevCommit commit = this.getRevTreeByRepositoryAndCommitId(repo, lastCommitId);
|
||||
// RevTree tree = commit.getTree();
|
||||
// treeWalk = new TreeWalk(repo);
|
||||
// treeWalk.addTree(tree);
|
||||
// treeWalk.setRecursive(true);
|
||||
// treeWalk.setFilter(PathFilter.create(filePath));
|
||||
// if (!treeWalk.next()) {
|
||||
// return null;
|
||||
// } else {
|
||||
// ObjectId objectId = treeWalk.getObjectId(0);
|
||||
// ObjectLoader loader = repo.open(objectId);
|
||||
// String fileLastCommitId = this.getFileLastCommitId(lastCommitId, filePath);
|
||||
// if (StringUtils.isEmpty(fileLastCommitId)) {
|
||||
// fileLastCommitId = lastCommitId.getName();
|
||||
// }
|
||||
// attachInfo = new RemoteFileAttachInfo(repositoryUrl, userName, token, branch, fileLastCommitId, filePath, commit.getFullMessage(), loader.getSize());
|
||||
// return attachInfo;
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// LogUtils.error("获取文件库文件报错!", e);
|
||||
// } finally {
|
||||
// if (treeWalk != null) {
|
||||
// treeWalk.close();
|
||||
// }
|
||||
// this.closeConnection(repo);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// private String getFileLastCommitId(ObjectId objectId, String filePath) throws Exception {
|
||||
// Iterable<RevCommit> logs = git.log().add(objectId).addPath(filePath).call();
|
||||
// String returnStr = StringUtils.EMPTY;
|
||||
// for (RevCommit rev : logs) {
|
||||
// returnStr = rev.getName();
|
||||
// }
|
||||
// return returnStr;
|
||||
// }
|
||||
|
||||
// private RevCommit getRevTreeByRepositoryAndCommitId(InMemoryRepository repo, ObjectId fileCommitId) throws IOException {
|
||||
// RevWalk revWalk = new RevWalk(repo);
|
||||
// return revWalk.parseCommit(fileCommitId);
|
||||
// }
|
||||
|
||||
// private InMemoryRepository getGitRepositoryInMemory(String repositoryUrl, String userName, String token) throws Exception {
|
||||
// DfsRepositoryDescription repoDesc = new DfsRepositoryDescription();
|
||||
// InMemoryRepository repo = new InMemoryRepository(repoDesc);
|
||||
// CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(userName, token);
|
||||
// git = new Git(repo);
|
||||
// git.fetch().setRemote(repositoryUrl).setRefSpecs(new RefSpec(REF_SPACE)).setCredentialsProvider(credentialsProvider).call();
|
||||
// repo.getObjectDatabase();
|
||||
// return repo;
|
||||
// }
|
||||
|
||||
// private TreeWalk getTreeWork(InMemoryRepository repo, ObjectId fileCommitObjectId, String filePath) throws Exception {
|
||||
// RevWalk revWalk = new RevWalk(repo);
|
||||
// RevCommit commit = revWalk.parseCommit(fileCommitObjectId);
|
||||
// RevTree tree = commit.getTree();
|
||||
// TreeWalk treeWalk = new TreeWalk(repo);
|
||||
// treeWalk.addTree(tree);
|
||||
// treeWalk.setRecursive(true);
|
||||
// treeWalk.setFilter(PathFilter.create(filePath));
|
||||
// return treeWalk;
|
||||
// }
|
||||
|
||||
private void closeConnection(Repository repo) {
|
||||
if (git != null) {
|
||||
git.close();
|
||||
}
|
||||
if (repo != null) {
|
||||
repo.close();
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getBranches() {
|
||||
List<String> returnList = new ArrayList<>();
|
||||
InMemoryRepository repo = null;
|
||||
try {
|
||||
Collection<Ref> refList;
|
||||
UsernamePasswordCredentialsProvider pro = new UsernamePasswordCredentialsProvider(userName, token);
|
||||
refList = Git.lsRemoteRepository().setRemote(repositoryUrl).setCredentialsProvider(pro).call();
|
||||
refList.forEach(item -> {
|
||||
returnList.add(item.getName());
|
||||
});
|
||||
} catch (Exception e) {
|
||||
LogUtils.error("获取文件库文件报错!", e);
|
||||
} finally {
|
||||
this.closeConnection(repo);
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
|
@ -73,7 +73,8 @@
|
|||
<!-- <table tableName="custom_function"/>-->
|
||||
<!-- <table tableName="fake_error"/>-->
|
||||
<!-- <table tableName="file_metadata"/>-->
|
||||
<table tableName="file_module"/>
|
||||
<table tableName="file_metadata_repository"/>
|
||||
<table tableName="file_module_repository"/>
|
||||
<!-- <table tableName="project"/>-->
|
||||
<!-- <table tableName="project_application"/>-->
|
||||
<!-- <table tableName="project_version"/>-->
|
||||
|
|
|
@ -5,7 +5,6 @@ import io.metersphere.project.dto.filemanagement.request.*;
|
|||
import io.metersphere.project.dto.filemanagement.response.FileInformationResponse;
|
||||
import io.metersphere.project.mapper.FileMetadataMapper;
|
||||
import io.metersphere.project.mapper.FileModuleMapper;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.service.FileModuleService;
|
||||
import io.metersphere.project.utils.FileManagementBaseUtils;
|
||||
import io.metersphere.project.utils.FileManagementRequestUtils;
|
||||
|
@ -17,9 +16,12 @@ import io.metersphere.sdk.util.JSON;
|
|||
import io.metersphere.sdk.util.TempFileUtils;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.dto.sdk.request.NodeMoveRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.CommonProjectService;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -47,7 +49,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class FileManagementControllerTests extends BaseTest {
|
||||
private static final String FILE_TEST_PROJECT_ID = "1507121382013";
|
||||
private static Project project;
|
||||
|
||||
private static List<BaseTreeNode> preliminaryTreeNodes = new ArrayList<>();
|
||||
|
@ -68,29 +69,18 @@ public class FileManagementControllerTests extends BaseTest {
|
|||
@Resource
|
||||
private FileMetadataMapper fileMetadataMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
private CommonProjectService commonProjectService;
|
||||
|
||||
@BeforeEach
|
||||
public void initTestData() {
|
||||
//文件管理专用项目
|
||||
if (project == null) {
|
||||
project = projectMapper.selectByPrimaryKey(FILE_TEST_PROJECT_ID);
|
||||
}
|
||||
if (project == null) {
|
||||
Project initProject = new Project();
|
||||
initProject.setId(FILE_TEST_PROJECT_ID);
|
||||
initProject.setNum(null);
|
||||
AddProjectRequest initProject = new AddProjectRequest();
|
||||
initProject.setOrganizationId("100001");
|
||||
initProject.setName("文件管理专用项目");
|
||||
initProject.setDescription("建国创建的文件管理专用项目");
|
||||
initProject.setCreateUser("admin");
|
||||
initProject.setUpdateUser("admin");
|
||||
initProject.setCreateTime(System.currentTimeMillis());
|
||||
initProject.setUpdateTime(System.currentTimeMillis());
|
||||
initProject.setEnable(true);
|
||||
initProject.setModuleSetting("[\"apiTest\",\"uiTest\"]");
|
||||
projectMapper.insertSelective(initProject);
|
||||
project = projectMapper.selectByPrimaryKey(initProject.getId());
|
||||
project = commonProjectService.add(initProject, "admin", "/organization-project/add", OperationLogModule.SETTING_ORGANIZATION_PROJECT);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
|
@ -407,8 +397,8 @@ public class FileManagementControllerTests extends BaseTest {
|
|||
}
|
||||
|
||||
//在来个jar文件
|
||||
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test-jar.jar")).getPath();
|
||||
file = new MockMultipartFile("file", "test-jar.jar", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath));
|
||||
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test-jar-1.jar")).getPath();
|
||||
file = new MockMultipartFile("file", "test-jar-1.jar", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath));
|
||||
paramMap = new LinkedMultiValueMap<>();
|
||||
paramMap.add("file", file);
|
||||
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
|
||||
|
@ -419,6 +409,18 @@ public class FileManagementControllerTests extends BaseTest {
|
|||
jarFileId = returnId;
|
||||
uploadedFileTypes.add("jar");
|
||||
|
||||
//在来个jar文件(状态开启)
|
||||
fileUploadRequest.setEnable(true);
|
||||
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/test-jar-2.jar")).getPath();
|
||||
file = new MockMultipartFile("file", "test-jar-2.jar", MediaType.APPLICATION_OCTET_STREAM_VALUE, FileManagementBaseUtils.getFileBytes(filePath));
|
||||
paramMap = new LinkedMultiValueMap<>();
|
||||
paramMap.add("file", file);
|
||||
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
|
||||
mvcResult = this.requestMultipartWithOkAndReturn(FileManagementRequestUtils.URL_FILE_UPLOAD, paramMap);
|
||||
returnId = JSON.parseObject(mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData().toString();
|
||||
checkLog(returnId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_UPLOAD);
|
||||
FILE_ID_PATH.put(returnId, filePath);
|
||||
fileUploadRequest.setEnable(false);
|
||||
|
||||
//小型图片文件,用于测试预览图下载
|
||||
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/1182937072541700.jpg")).getPath();
|
||||
|
@ -506,6 +508,15 @@ public class FileManagementControllerTests extends BaseTest {
|
|||
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
|
||||
this.requestMultipart(FileManagementRequestUtils.URL_FILE_UPLOAD, paramMap).andExpect(status().isBadRequest());
|
||||
|
||||
//上传非jar文件但是enable为true
|
||||
fileUploadRequest.setProjectId(project.getId());
|
||||
fileUploadRequest.setModuleId(ModuleConstants.DEFAULT_NODE_ID);
|
||||
fileUploadRequest.setEnable(true);
|
||||
paramMap = new LinkedMultiValueMap<>();
|
||||
paramMap.add("file", file);
|
||||
paramMap.add("request", JSON.toJSONString(fileUploadRequest));
|
||||
this.requestMultipart(FileManagementRequestUtils.URL_FILE_UPLOAD, paramMap).andExpect(status().is5xxServerError());
|
||||
fileUploadRequest.setEnable(false);
|
||||
//模块不存在
|
||||
fileUploadRequest.setModuleId(IDGenerator.nextStr());
|
||||
paramMap = new LinkedMultiValueMap<>();
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package io.metersphere.project.controller.filemanagement;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.domain.FileModule;
|
||||
import io.metersphere.project.domain.FileModuleRepository;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileMetadataTableRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryConnectRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryCreateRequest;
|
||||
import io.metersphere.project.dto.filemanagement.request.FileRepositoryUpdateRequest;
|
||||
import io.metersphere.project.dto.filemanagement.response.FileInformationResponse;
|
||||
import io.metersphere.project.mapper.FileMetadataMapper;
|
||||
import io.metersphere.project.mapper.FileModuleMapper;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.project.mapper.FileModuleRepositoryMapper;
|
||||
import io.metersphere.project.service.FileModuleService;
|
||||
import io.metersphere.project.utils.FileManagementRequestUtils;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
|
@ -14,7 +18,13 @@ import io.metersphere.sdk.constants.StorageType;
|
|||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.AddProjectRequest;
|
||||
import io.metersphere.system.dto.ProjectDTO;
|
||||
import io.metersphere.system.dto.sdk.BaseTreeNode;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.CommonProjectService;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
@ -26,13 +36,18 @@ import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class FileRepositoryControllerTest extends BaseTest {
|
||||
|
||||
private static final String FILE_TEST_PROJECT_ID = "1507121382013";
|
||||
private static Project project;
|
||||
private static ProjectDTO project;
|
||||
|
||||
private static final String GITEE_URL = "https://gitee.com/testformeterspere/gitee-test.git";
|
||||
private static final String GITEE_USERNAME = "testformetersphere";
|
||||
private static final String GITEE_TOKEN = "4548d369bb595738d726512742e4478f";
|
||||
|
||||
private static List<BaseTreeNode> repositoryTreeNodes = new ArrayList<>();
|
||||
|
||||
|
@ -42,7 +57,7 @@ public class FileRepositoryControllerTest extends BaseTest {
|
|||
|
||||
private static String reUploadFileId;
|
||||
|
||||
private static String picFileId;
|
||||
private static String repositoryId;
|
||||
private static String jarFileId;
|
||||
|
||||
@Resource
|
||||
|
@ -50,31 +65,22 @@ public class FileRepositoryControllerTest extends BaseTest {
|
|||
@Resource
|
||||
private FileModuleMapper fileModuleMapper;
|
||||
@Resource
|
||||
private FileModuleRepositoryMapper fileModuleRepositoryMapper;
|
||||
@Resource
|
||||
private FileMetadataMapper fileMetadataMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
private CommonProjectService commonProjectService;
|
||||
|
||||
@BeforeEach
|
||||
public void initTestData() {
|
||||
//文件管理专用项目
|
||||
if (project == null) {
|
||||
project = projectMapper.selectByPrimaryKey(FILE_TEST_PROJECT_ID);
|
||||
}
|
||||
if (project == null) {
|
||||
Project initProject = new Project();
|
||||
initProject.setId(FILE_TEST_PROJECT_ID);
|
||||
initProject.setNum(null);
|
||||
AddProjectRequest initProject = new AddProjectRequest();
|
||||
initProject.setOrganizationId("100001");
|
||||
initProject.setName("文件管理专用项目");
|
||||
initProject.setDescription("建国创建的文件管理专用项目");
|
||||
initProject.setCreateUser("admin");
|
||||
initProject.setUpdateUser("admin");
|
||||
initProject.setCreateTime(System.currentTimeMillis());
|
||||
initProject.setUpdateTime(System.currentTimeMillis());
|
||||
initProject.setName("文件管理存储库专用项目");
|
||||
initProject.setDescription("建国创建的文件管理存储库专用项目");
|
||||
initProject.setEnable(true);
|
||||
initProject.setModuleSetting("[\"apiTest\",\"uiTest\"]");
|
||||
projectMapper.insertSelective(initProject);
|
||||
project = projectMapper.selectByPrimaryKey(initProject.getId());
|
||||
project = commonProjectService.add(initProject, "admin", "/organization-project/add", OperationLogModule.SETTING_ORGANIZATION_PROJECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +122,191 @@ public class FileRepositoryControllerTest extends BaseTest {
|
|||
Assertions.assertTrue(fileTypes.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void repositoryConnectTest() throws Exception {
|
||||
FileRepositoryConnectRequest connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken(GITEE_TOKEN);
|
||||
connectRequest.setUrl(GITEE_URL);
|
||||
connectRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPostWithOk(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest);
|
||||
|
||||
//参数测试:没有token
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setUrl(GITEE_URL);
|
||||
connectRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().isBadRequest());
|
||||
|
||||
//参数测试:没有url
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken(GITEE_TOKEN);
|
||||
connectRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().isBadRequest());
|
||||
|
||||
//错误测试:错误的url
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken(GITEE_TOKEN);
|
||||
connectRequest.setUrl("https://gitee.com/testformeterspere-error/error-test.git");
|
||||
connectRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().is5xxServerError());
|
||||
//错误测试:错误的token
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken("error-token");
|
||||
connectRequest.setUrl(GITEE_URL);
|
||||
connectRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().is5xxServerError());
|
||||
//错误测试:没有userName
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken(GITEE_TOKEN);
|
||||
connectRequest.setUrl(GITEE_URL);
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().is5xxServerError());
|
||||
//错误测试:错误的userName
|
||||
connectRequest = new FileRepositoryConnectRequest();
|
||||
connectRequest.setToken(GITEE_TOKEN);
|
||||
connectRequest.setUrl(GITEE_URL);
|
||||
connectRequest.setUserName("errorUserName");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CONNECT, connectRequest).andExpect(status().is5xxServerError());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void moduleAddTest() throws Exception {
|
||||
FileRepositoryCreateRequest createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
MvcResult result = this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
|
||||
String returnStr = result.getResponse().getContentAsString();
|
||||
ResultHolder rh = JSON.parseObject(returnStr, ResultHolder.class);
|
||||
repositoryId = rh.getData().toString();
|
||||
this.checkFileRepository(repositoryId, createRequest.getProjectId(), createRequest.getName(), createRequest.getPlatform(), createRequest.getUrl(), createRequest.getToken(), createRequest.getUserName());
|
||||
this.checkLog(repositoryId, OperationLogType.ADD, FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE);
|
||||
//参数测试: 没有url
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().isBadRequest());
|
||||
//参数测试: 没有token
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().isBadRequest());
|
||||
//参数测试: 没有projectId
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().isBadRequest());
|
||||
//参数测试: 没有platform
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().isBadRequest());
|
||||
|
||||
//报错测试: 名称重复
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().is5xxServerError());
|
||||
//报错测试: platform不合法
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(IDGenerator.nextStr());
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().is5xxServerError());
|
||||
//报错测试: 上述的gitee仓库,不填写用户名
|
||||
createRequest = new FileRepositoryCreateRequest();
|
||||
createRequest.setProjectId(project.getId());
|
||||
createRequest.setPlatform(ModuleConstants.NODE_TYPE_GITEE);
|
||||
createRequest.setUrl(GITEE_URL);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andExpect(status().is5xxServerError());
|
||||
|
||||
//测试整体过程中没有修改数据成功
|
||||
this.checkFileRepository(repositoryId, createRequest.getProjectId(), createRequest.getName(), createRequest.getPlatform(), createRequest.getUrl(), createRequest.getToken(), createRequest.getUserName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
public void moduleUpdateTest() throws Exception {
|
||||
if (StringUtils.isEmpty(repositoryId)) {
|
||||
this.moduleAddTest();
|
||||
}
|
||||
|
||||
//修改文件名
|
||||
FileRepositoryUpdateRequest createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(repositoryId);
|
||||
createRequest.setName("Gitee存储库改个名字");
|
||||
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest);
|
||||
this.checkFileRepository(repositoryId, project.getId(), "Gitee存储库改个名字", ModuleConstants.NODE_TYPE_GITEE, GITEE_URL, GITEE_TOKEN, GITEE_USERNAME);
|
||||
this.checkLog(repositoryId, OperationLogType.UPDATE, FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE);
|
||||
//修改用户名
|
||||
FileModuleRepository updateModel = new FileModuleRepository();
|
||||
updateModel.setFileModuleId(repositoryId);
|
||||
updateModel.setUserName("提前修改用户名");
|
||||
fileModuleRepositoryMapper.updateByPrimaryKeySelective(updateModel);
|
||||
|
||||
createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(repositoryId);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest);
|
||||
this.checkFileRepository(repositoryId, project.getId(), "Gitee存储库改个名字", ModuleConstants.NODE_TYPE_GITEE, GITEE_URL, GITEE_TOKEN, GITEE_USERNAME);
|
||||
|
||||
//修改token
|
||||
updateModel = new FileModuleRepository();
|
||||
updateModel.setFileModuleId(repositoryId);
|
||||
updateModel.setToken("newToken");
|
||||
fileModuleRepositoryMapper.updateByPrimaryKeySelective(updateModel);
|
||||
createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(repositoryId);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest);
|
||||
this.checkFileRepository(repositoryId, project.getId(), "Gitee存储库改个名字", ModuleConstants.NODE_TYPE_GITEE, GITEE_URL, GITEE_TOKEN, GITEE_USERNAME);
|
||||
|
||||
//没有修改的
|
||||
createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(repositoryId);
|
||||
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest);
|
||||
this.checkFileRepository(repositoryId, project.getId(), "Gitee存储库改个名字", ModuleConstants.NODE_TYPE_GITEE, GITEE_URL, GITEE_TOKEN, GITEE_USERNAME);
|
||||
|
||||
//全部改回来
|
||||
createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(repositoryId);
|
||||
createRequest.setUserName(GITEE_USERNAME);
|
||||
createRequest.setToken(GITEE_TOKEN);
|
||||
createRequest.setName("Gitee存储库");
|
||||
this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest);
|
||||
this.checkFileRepository(repositoryId, project.getId(), "Gitee存储库", ModuleConstants.NODE_TYPE_GITEE, GITEE_URL, GITEE_TOKEN, GITEE_USERNAME);
|
||||
|
||||
//文件id不存在
|
||||
createRequest = new FileRepositoryUpdateRequest();
|
||||
createRequest.setId(IDGenerator.nextNum().toString());
|
||||
createRequest.setName("TEST-NAME");
|
||||
this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_UPDATE, createRequest).andExpect(status().is5xxServerError());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
public void repositoryListTest() throws Exception {
|
||||
|
@ -132,6 +323,29 @@ public class FileRepositoryControllerTest extends BaseTest {
|
|||
this.requestGetPermissionTest(PermissionConstants.PROJECT_FILE_MANAGEMENT_READ, String.format(FileManagementRequestUtils.URL_FILE_REPOSITORY_FILE_TYPE, DEFAULT_PROJECT_ID));
|
||||
}
|
||||
|
||||
private void checkFileRepository(String repositoryId, String projectId, String name, String platform, String url, String token, String userName) {
|
||||
FileModule module = fileModuleMapper.selectByPrimaryKey(repositoryId);
|
||||
FileModuleRepository repository = fileModuleRepositoryMapper.selectByPrimaryKey(repositoryId);
|
||||
if (StringUtils.isNotEmpty(projectId)) {
|
||||
Assertions.assertEquals(module.getProjectId(), projectId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
Assertions.assertEquals(module.getName(), name);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(platform)) {
|
||||
Assertions.assertEquals(repository.getPlatform(), platform);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(url)) {
|
||||
Assertions.assertEquals(repository.getUrl(), url);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
Assertions.assertEquals(repository.getToken(), token);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userName)) {
|
||||
Assertions.assertEquals(repository.getUserName(), userName);
|
||||
}
|
||||
}
|
||||
|
||||
private List<BaseTreeNode> getFileModuleTreeNode() throws Exception {
|
||||
MvcResult result = this.requestGetWithOkAndReturn(String.format(FileManagementRequestUtils.URL_FILE_REPOSITORY_LIST, project.getId()));
|
||||
String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
|
|
|
@ -48,5 +48,11 @@ public class FileManagementRequestUtils {
|
|||
public static final String URL_FILE_REPOSITORY_LIST = "/project/file/repository/list/%s";
|
||||
//存储库文件类型
|
||||
public static final String URL_FILE_REPOSITORY_FILE_TYPE = "/project/file/repository/file-type/%s";
|
||||
//测试连接存储库
|
||||
public static final String URL_FILE_REPOSITORY_CONNECT = "/project/file/repository/connect";
|
||||
//添加存储库
|
||||
public static final String URL_FILE_REPOSITORY_CREATE = "/project/file/repository/add-repository";
|
||||
//修改存储库
|
||||
public static final String URL_FILE_REPOSITORY_UPDATE = "/project/file/repository/update-repository";
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
这是用来做反例测试的
|
|
@ -30,7 +30,7 @@ public class OperationLogModule {
|
|||
public static final String PROJECT_PROJECT_JAR = "PROJECT_PROJECT_JAR";
|
||||
public static final String PROJECT_ENVIRONMENT_SETTING = "PROJECT_ENVIRONMENT_SETTING";
|
||||
public static final String PROJECT_PROJECT_MANAGER = "PROJECT_PROJECT_MANAGER";
|
||||
public static final String PROJECT_FILE_MANAGEMENT = "PROJECT_FILE_MANAGEMENT";
|
||||
public static final String PROJECT_FILE_MANAGEMENT = "PROJECT_MANAGEMENT_FILE_MANAGEMENT";
|
||||
public static final String PROJECT_TEMPLATE_MANAGEMENT = "PROJECT_TEMPLATE_MANAGEMENT";
|
||||
public static final String PROJECT_PROJECT_MEMBER = "PROJECT_PROJECT_MEMBER";
|
||||
public static final String PERSONAL_INFORMATION_PERSONAL_SETTINGS = "PERSONAL_INFORMATION_PERSONAL_SETTINGS";
|
||||
|
|
Loading…
Reference in New Issue