add platform plugin sdk
This commit is contained in:
parent
29ff912f9d
commit
ea2e973e79
|
@ -0,0 +1,156 @@
|
|||
package io.metersphere.plugin.platform.api;
|
||||
|
||||
import io.metersphere.plugin.platform.dto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 平台对接相关业务
|
||||
* @author jianxing.chen
|
||||
*/
|
||||
public interface Platform {
|
||||
|
||||
/**
|
||||
* 获取平台相关需求
|
||||
* 功能用例关联需求时调用
|
||||
* @param projectConfig 项目设置表单值
|
||||
* @return 需求列表
|
||||
*/
|
||||
List<DemandDTO> getDemands(String projectConfig);
|
||||
|
||||
/**
|
||||
* 创建缺陷并封装 MS 返回
|
||||
* 创建缺陷时调用
|
||||
* @param issuesRequest issueRequest
|
||||
* @return MS 缺陷
|
||||
*/
|
||||
MsIssueDTO addIssue(PlatformIssuesUpdateRequest issuesRequest);
|
||||
|
||||
/**
|
||||
* 项目设置中选项,从平台获取下拉框选项
|
||||
* frontend.json 中选项值配置了 optionMethod ,项目设置时调用
|
||||
* @return 返回下拉列表
|
||||
* 该接口后续版本将废弃,替换为 getFormOptions
|
||||
*/
|
||||
@Deprecated
|
||||
List<SelectOption> getProjectOptions(GetOptionRequest request);
|
||||
|
||||
/**
|
||||
* 项目设置和缺陷表单中,调用接口获取下拉框选项
|
||||
* 配置文件的表单中选项值配置了 optionMethod ,则调用获取表单的选项值
|
||||
* @return 返回下拉列表
|
||||
*/
|
||||
List<SelectOption> getFormOptions(GetOptionRequest request);
|
||||
|
||||
/**
|
||||
* 更新缺陷
|
||||
* 编辑缺陷时调用
|
||||
* @param request
|
||||
* @return MS 缺陷
|
||||
*/
|
||||
MsIssueDTO updateIssue(PlatformIssuesUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 删除缺陷平台缺陷
|
||||
* 删除缺陷时调用
|
||||
* @param id 平台的缺陷 ID
|
||||
*/
|
||||
void deleteIssue(String id);
|
||||
|
||||
/**
|
||||
* 校验服务集成配置
|
||||
* 服务集成点击校验时调用
|
||||
*/
|
||||
void validateIntegrationConfig();
|
||||
|
||||
/**
|
||||
* 校验项目配置
|
||||
* 项目设置成点击校验项目 key 时调用
|
||||
*/
|
||||
void validateProjectConfig(String projectConfig);
|
||||
|
||||
/**
|
||||
* 校验用户配置配置
|
||||
* 用户信息,校验第三方信息时调用
|
||||
*/
|
||||
void validateUserConfig(String userConfig);
|
||||
|
||||
/**
|
||||
* 支持附件上传
|
||||
* 编辑缺陷上传附件是会调用判断是否支持附件上传
|
||||
* 如果支持会调用 syncIssuesAttachment 上传缺陷到第三方平台
|
||||
*/
|
||||
boolean isAttachmentUploadSupport();
|
||||
|
||||
/**
|
||||
* 同步缺陷最新变更
|
||||
* 开源用户点击同步缺陷时调用
|
||||
*/
|
||||
SyncIssuesResult syncIssues(SyncIssuesRequest request);
|
||||
|
||||
/**
|
||||
* 同步项目下所有的缺陷
|
||||
* 企业版用户会调用同步缺陷
|
||||
*/
|
||||
void syncAllIssues(SyncAllIssuesRequest request);
|
||||
|
||||
/**
|
||||
* 获取附件内容
|
||||
* 同步缺陷中,同步附件时会调用
|
||||
* @param fileKey 文件关键字
|
||||
*/
|
||||
byte[] getAttachmentContent(String fileKey);
|
||||
|
||||
/**
|
||||
* 获取第三方平台缺陷的自定义字段
|
||||
* 需要 PluginMetaInfo 的 isThirdPartTemplateSupport 返回 true
|
||||
* @return
|
||||
*/
|
||||
List<PlatformCustomFieldItemDTO> getThirdPartCustomField(String projectConfig);
|
||||
|
||||
/**
|
||||
* Get请求的代理
|
||||
* 目前使用场景:富文本框中如果有图片是存储在第三方平台,MS 通过 url 访问
|
||||
* 这时如果第三方平台需要登入才能访问到静态资源,可以通过将富文本框图片内容构造如下格式访问
|
||||
* ![name](/resource/md/get/path?platform=Jira?project_id=&workspace_id=&path=)
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
Object proxyForGet(String path, Class responseEntityClazz);
|
||||
|
||||
/**
|
||||
* 同步 MS 缺陷附件到第三方平台
|
||||
* isAttachmentUploadSupport 返回为 true 时,同步和创建缺陷时会调用
|
||||
*/
|
||||
void syncIssuesAttachment(SyncIssuesAttachmentRequest request);
|
||||
|
||||
/**
|
||||
* 获取第三方平台的状态列表
|
||||
* 缺陷列表和编辑缺陷时会调用
|
||||
* @return
|
||||
*/
|
||||
List<PlatformStatusDTO> getStatusList(String projectConfig);
|
||||
|
||||
/**
|
||||
* 获取第三方平台的状态转移列表
|
||||
* 即编辑缺陷时的可选状态
|
||||
* 默认会调用 getStatusList,可重写覆盖
|
||||
* @param issueId
|
||||
* @return
|
||||
*/
|
||||
List<PlatformStatusDTO> getTransitions(String projectConfig, String issueId);
|
||||
|
||||
/**
|
||||
* 用例关联需求时调用
|
||||
* 可在第三方平台添加用例和需求的关联关系
|
||||
* @param request
|
||||
*/
|
||||
void handleDemandUpdate(DemandUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 用例批量关联需求时调用
|
||||
* 可在第三方平台添加用例和需求的关联关系
|
||||
* @param request
|
||||
*/
|
||||
void handleDemandUpdateBatch(DemandUpdateRequest request);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package io.metersphere.plugin.platform.api;
|
||||
|
||||
/**
|
||||
* 插件的基本信息
|
||||
* @author jianxing.chen
|
||||
*/
|
||||
public interface PluginMetaInfo {
|
||||
|
||||
/**
|
||||
* 该插件是否是开源的
|
||||
* 默认是
|
||||
* @return
|
||||
*/
|
||||
boolean isXpack();
|
||||
|
||||
/**
|
||||
* 返回插件的关键字
|
||||
* @return
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* 返回插件的名称
|
||||
* @return
|
||||
*/
|
||||
String getLabel();
|
||||
|
||||
/**
|
||||
* 返回前端渲染需要的数据
|
||||
* 默认会返回 resources下的 json/frontend.json
|
||||
* @return
|
||||
*/
|
||||
String getFrontendMetaData();
|
||||
|
||||
/**
|
||||
* 返回插件的版本
|
||||
* @return
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* 插件是否支持第三方模板
|
||||
* @return
|
||||
*/
|
||||
boolean isThirdPartTemplateSupport();
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class CustomFieldDTO implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String scene;
|
||||
|
||||
private String type;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Boolean system;
|
||||
|
||||
private Boolean global;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String createUser;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private Boolean thirdPart;
|
||||
|
||||
private String options;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class DemandDTO {
|
||||
protected String id;
|
||||
protected String name;
|
||||
protected String platform;
|
||||
protected List<? extends DemandDTO> children;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DemandUpdateRequest {
|
||||
|
||||
/**
|
||||
* 关联需求的用例信息
|
||||
* getDemandId 可以获取关联的需求ID
|
||||
* getOriginDemandId 可以获取修改前的需求ID
|
||||
*/
|
||||
private TestCaseDemandDTO testCase;
|
||||
|
||||
/**
|
||||
* 批量关联需求时会使用
|
||||
*/
|
||||
private List<TestCaseDemandDTO> testCaseList;
|
||||
|
||||
/**
|
||||
* 项目设置的配置项
|
||||
*/
|
||||
private String projectConfig;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class GetOptionRequest {
|
||||
/**
|
||||
* 项目设置的配置项
|
||||
*/
|
||||
private String projectConfig;
|
||||
/**
|
||||
* 对应插件中获取选项的方法名
|
||||
*/
|
||||
private String optionMethod;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class MsIssueDTO {
|
||||
|
||||
private String id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String status;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Long updateTime;
|
||||
|
||||
private String reporter;
|
||||
|
||||
private String lastmodify;
|
||||
|
||||
private String platform;
|
||||
|
||||
private String projectId;
|
||||
|
||||
private String creator;
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private Integer num;
|
||||
|
||||
private String platformStatus;
|
||||
|
||||
private String platformId;
|
||||
|
||||
private String description;
|
||||
|
||||
private String customFields;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlatformAttachment {
|
||||
private String fileName;
|
||||
private String fileKey;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PlatformCustomFieldItemDTO extends CustomFieldDTO {
|
||||
private Object value;
|
||||
private String key;
|
||||
private String customData;
|
||||
private Boolean required;
|
||||
private String defaultValue;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlatformIssuesDTO extends MsIssueDTO {
|
||||
private List<PlatformCustomFieldItemDTO> customFieldList;
|
||||
private List<PlatformAttachment> attachments = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlatformIssuesUpdateRequest extends PlatformIssuesDTO {
|
||||
|
||||
/**
|
||||
* 用户信息的第三方平台的配置项
|
||||
*/
|
||||
private String userPlatformUserConfig;
|
||||
/**
|
||||
* 项目设置的配置项
|
||||
*/
|
||||
private String projectConfig;
|
||||
/**
|
||||
* 改缺陷关联的附件集合
|
||||
*/
|
||||
private Set<String> msAttachmentNames;
|
||||
/**
|
||||
* 第三方平台缺陷的状态
|
||||
*/
|
||||
private PlatformStatusDTO transitions;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PlatformRequest {
|
||||
private String integrationConfig;
|
||||
private String workspaceId;
|
||||
private String userPlatformInfo;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class PlatformStatusDTO {
|
||||
protected String value;
|
||||
protected String label;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlatformUser {
|
||||
private List<String> roleId;
|
||||
private String name;
|
||||
private String user;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class SelectOption {
|
||||
public SelectOption(String text, String value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String text;
|
||||
private String value;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SyncAllIssuesRequest extends SyncIssuesRequest {
|
||||
/**
|
||||
* 项目设置的配置项
|
||||
*/
|
||||
private String projectConfig;
|
||||
/**
|
||||
* 缺陷模板所关联的自定义字段
|
||||
*/
|
||||
private String defaultCustomFields;
|
||||
/**
|
||||
* 需要同步的缺陷列表
|
||||
*/
|
||||
private List<PlatformIssuesDTO> issues;
|
||||
|
||||
private boolean pre;
|
||||
|
||||
private Long createTime;
|
||||
|
||||
private Consumer<Map> handleSyncFunc;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SyncAllIssuesResult extends SyncIssuesResult {
|
||||
private List<MsIssueDTO> updateIssues = new ArrayList<>();
|
||||
private Map<String, List<PlatformAttachment>> attachmentMap = new HashMap<>();
|
||||
/**
|
||||
* 保存当前查询到的缺陷的平台ID
|
||||
*/
|
||||
private List<String> allIds = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class SyncIssuesAttachmentRequest {
|
||||
/**
|
||||
* 平台 ID
|
||||
*/
|
||||
private String platformId;
|
||||
/**
|
||||
* 需要同步的附件
|
||||
*/
|
||||
private File file;
|
||||
/**
|
||||
* 操作类型是更新还是删除
|
||||
* 参考 AttachmentSyncType
|
||||
*/
|
||||
private String syncType;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SyncIssuesRequest {
|
||||
/**
|
||||
* 项目设置的配置项
|
||||
*/
|
||||
private String projectConfig;
|
||||
/**
|
||||
* 缺陷模板所关联的自定义字段
|
||||
*/
|
||||
private String defaultCustomFields;
|
||||
/**
|
||||
* 需要同步的缺陷列表
|
||||
*/
|
||||
private List<PlatformIssuesDTO> issues;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class SyncIssuesResult {
|
||||
private List<MsIssueDTO> updateIssues = new ArrayList<>();
|
||||
private List<MsIssueDTO> addIssues = new ArrayList<>();
|
||||
private Map<String, List<PlatformAttachment>> attachmentMap = new HashMap<>();
|
||||
private List<String> deleteIssuesIds = new ArrayList<>();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package io.metersphere.plugin.platform.dto;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestCaseDemandDTO extends TestCaseWithBLOBs {
|
||||
|
||||
/**
|
||||
* 修改前的需求ID
|
||||
* demandId 字段可获取修改后的ID
|
||||
*/
|
||||
private String originDemandId;
|
||||
}
|
Loading…
Reference in New Issue