From 531f007e2f7fae12bdad952b71fb092af4724b47 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Sat, 17 Sep 2022 12:05:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1009633 --user=王孝刚 接口定义支持自定义模板--添加自定义字段 https://www.tapd.cn/55049933/s/1244279 --- .../dto/definition/ApiDefinitionResult.java | 5 + .../definition/SaveApiDefinitionRequest.java | 7 +- .../api/service/ApiDefinitionService.java | 39 +- .../metersphere/base/domain/ApiTemplate.java | 19 + .../base/domain/ApiTemplateExample.java | 790 ++++++++++++++++++ .../base/domain/CustomFieldApi.java | 16 + .../base/domain/CustomFieldApiExample.java | 410 +++++++++ .../base/domain/CustomFieldApiKey.java | 12 + .../io/metersphere/base/domain/Project.java | 2 + .../base/domain/ProjectExample.java | 70 ++ .../base/mapper/ApiTemplateMapper.java | 31 + .../base/mapper/ApiTemplateMapper.xml | 280 +++++++ .../base/mapper/CustomFieldApiMapper.java | 38 + .../base/mapper/CustomFieldApiMapper.xml | 242 ++++++ .../metersphere/base/mapper/ProjectMapper.xml | 311 +++---- .../base/mapper/ext/ExtApiTemplateMapper.java | 12 + .../base/mapper/ext/ExtApiTemplateMapper.xml | 66 ++ .../base/mapper/ext/ExtProjectMapper.java | 4 +- .../base/mapper/ext/ExtProjectMapper.xml | 112 +-- .../commons/constants/OperLogModule.java | 1 + .../constants/PermissionConstants.java | 1 + .../commons/constants/TemplateConstants.java | 2 +- .../controller/ApiTemplateController.java | 60 ++ .../request/UpdateApiTemplateRequest.java | 12 + .../io/metersphere/dto/ApiTemplateDTO.java | 11 + .../service/ApiTemplateService.java | 235 ++++++ .../service/CustomFieldApiService.java | 57 ++ .../service/CustomFieldResourceService.java | 19 +- .../service/CustomFieldService.java | 8 +- .../metersphere/service/ProjectService.java | 13 + backend/src/main/java/io/metersphere/xpack | 2 +- backend/src/main/resources/permission.json | 5 + .../api/definition/ApiDefinition.vue | 6 +- .../api/definition/components/ApiConfig.vue | 680 +++++++-------- .../components/EditCompleteContainer.vue | 292 ++++--- .../components/complete/ApiBaseInfo.vue | 247 ++++++ .../complete/EditCompleteDubboApi.vue | 10 - .../complete/EditCompleteHTTPApi.vue | 124 --- .../complete/EditCompleteSQLApi.vue | 10 - .../complete/EditCompleteTCPApi.vue | 88 +- .../definition/components/mock/MockTab.vue | 92 +- .../components/project/menu/EditProject.vue | 37 +- .../project/template/ApiFieldTemplateEdit.vue | 313 +++++++ .../project/template/ApiTemplateList.vue | 196 +++++ .../project/template/TemplateSelect.vue | 3 + .../project/template/TemplateSetting.vue | 12 +- .../components/track/case/TestCase.vue | 2 +- .../track/case/components/TestCaseEdit.vue | 2 +- frontend/src/business/components/xpack | 2 +- frontend/src/common/js/custom_field.js | 18 + frontend/src/common/js/table-constants.js | 8 +- frontend/src/i18n/en-US.js | 7 +- frontend/src/i18n/zh-CN.js | 7 +- frontend/src/i18n/zh-TW.js | 7 +- frontend/src/network/custom-field-template.js | 16 + frontend/src/store/mutations.js | 1 + 56 files changed, 4183 insertions(+), 889 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTemplate.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTemplateExample.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/CustomFieldApi.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/CustomFieldApiExample.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/CustomFieldApiKey.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.xml create mode 100644 backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.xml create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTemplateMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTemplateMapper.xml create mode 100644 backend/src/main/java/io/metersphere/controller/ApiTemplateController.java create mode 100644 backend/src/main/java/io/metersphere/controller/request/UpdateApiTemplateRequest.java create mode 100644 backend/src/main/java/io/metersphere/dto/ApiTemplateDTO.java create mode 100644 backend/src/main/java/io/metersphere/service/ApiTemplateService.java create mode 100644 backend/src/main/java/io/metersphere/service/CustomFieldApiService.java create mode 100644 frontend/src/business/components/api/definition/components/complete/ApiBaseInfo.vue create mode 100644 frontend/src/business/components/project/template/ApiFieldTemplateEdit.vue create mode 100644 frontend/src/business/components/project/template/ApiTemplateList.vue diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionResult.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionResult.java index 45f1e1285d..5a4ce7fcff 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionResult.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionResult.java @@ -1,9 +1,12 @@ package io.metersphere.api.dto.definition; import io.metersphere.base.domain.ApiDefinitionWithBLOBs; +import io.metersphere.dto.CustomFieldDao; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Setter @Getter public class ApiDefinitionResult extends ApiDefinitionWithBLOBs { @@ -35,4 +38,6 @@ public class ApiDefinitionResult extends ApiDefinitionWithBLOBs { private Boolean versionEnable; private boolean updated; + + private List fields; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java index 7335923e2e..3a00e14509 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/SaveApiDefinitionRequest.java @@ -2,6 +2,7 @@ package io.metersphere.api.dto.definition; import io.metersphere.api.dto.definition.response.Response; import io.metersphere.base.domain.Schedule; +import io.metersphere.base.domain.ext.CustomFieldResource; import io.metersphere.plugin.core.MsTestElement; import lombok.Getter; import lombok.Setter; @@ -82,8 +83,12 @@ public class SaveApiDefinitionRequest { //发送信息给场景创建人 private Boolean scenarioCreator; - + //是否新建 private Boolean newCreate; + //自定义字段 + private List addFields; + private List editFields; + } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 2738a4aa0e..c105d2498a 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -32,6 +32,7 @@ import io.metersphere.api.exec.api.ApiExecuteService; import io.metersphere.api.exec.utils.ApiDefinitionExecResultUtil; import io.metersphere.api.parse.ApiImportParser; import io.metersphere.base.domain.*; +import io.metersphere.base.domain.ext.CustomFieldResource; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.*; import io.metersphere.commons.constants.*; @@ -42,10 +43,7 @@ import io.metersphere.commons.utils.*; import io.metersphere.controller.request.RelationshipEdgeRequest; import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ScheduleRequest; -import io.metersphere.dto.MsExecResponseDTO; -import io.metersphere.dto.ProjectConfig; -import io.metersphere.dto.RelationshipEdgeDTO; -import io.metersphere.dto.RunModeConfigDTO; +import io.metersphere.dto.*; import io.metersphere.i18n.Translator; import io.metersphere.job.sechedule.SwaggerUrlImportJob; import io.metersphere.log.utils.ReflexObjectUtil; @@ -172,6 +170,9 @@ public class ApiDefinitionService { @Resource private ApiScenarioReferenceIdMapper apiScenarioReferenceIdMapper; + @Resource + private CustomFieldApiService customFieldApiService; + private final ThreadLocal currentApiOrder = new ThreadLocal<>(); private final ThreadLocal currentApiCaseOrder = new ThreadLocal<>(); private static final String COPY = "Copy"; @@ -187,9 +188,19 @@ public class ApiDefinitionService { } else { buildProjectInfoWithoutProject(resList); } + buildCustomField(resList); return resList; } + private void buildCustomField(List data) { + if (CollectionUtils.isEmpty(data)) { + return; + } + Map> fieldMap = + customFieldApiService.getMapByResourceIds(data.stream().map(ApiDefinitionResult::getId).collect(Collectors.toList())); + data.forEach(i -> i.setFields(fieldMap.get(i.getId()))); + } + private void buildProjectInfoWithoutProject(List resList) { resList.forEach(i -> { Project project = projectMapper.selectByPrimaryKey(i.getProjectId()); @@ -469,7 +480,10 @@ public class ApiDefinitionService { esbApiParamService.deleteByResourceId(api.getId()); MockConfigService mockConfigService = CommonBeanFactory.getBean(MockConfigService.class); mockConfigService.deleteMockConfigByApiId(api.getId()); - relationshipEdgeService.delete(api.getId()); // 删除关系图 + // 删除自定义字段关联关系 + customFieldApiService.deleteByResourceId(api.getId()); + // 删除关系图 + relationshipEdgeService.delete(api.getId()); FileUtils.deleteBodyFiles(api.getId()); deleteFollows(api.getId()); }); @@ -495,7 +509,10 @@ public class ApiDefinitionService { // 删除附件关系 fileAssociationService.deleteByResourceIds(apiIds); MockConfigService mockConfigService = CommonBeanFactory.getBean(MockConfigService.class); - relationshipEdgeService.delete(apiIds); // 删除关系图 + // 删除自定义字段关联关系 + customFieldApiService.deleteByResourceIds(apiIds); + // 删除关系图 + relationshipEdgeService.delete(apiIds); for (String apiId : apiIds) { mockConfigService.deleteMockConfigByApiId(apiId); deleteFollows(apiId); @@ -754,6 +771,9 @@ public class ApiDefinitionService { // 存储附件关系 fileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationType.API.name()); + //保存自定义字段 + customFieldApiService.editFields(test.getId(), request.getEditFields()); + customFieldApiService.addFields(test.getId(), request.getAddFields()); return result; } @@ -881,6 +901,13 @@ public class ApiDefinitionService { // 存储附件关系 fileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationType.API.name()); + //保存自定义字段 + List addFields = request.getAddFields(); + if (CollectionUtils.isNotEmpty(addFields)) { + addFields.addAll(request.getEditFields()); + customFieldApiService.addFields(request.getId(), addFields); + } + return getById(test.getId()); } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTemplate.java b/backend/src/main/java/io/metersphere/base/domain/ApiTemplate.java new file mode 100644 index 0000000000..6f2a364193 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTemplate.java @@ -0,0 +1,19 @@ +package io.metersphere.base.domain; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ApiTemplate implements Serializable { + private static final long serialVersionUID = 1L; + private String id; + private String name; + private String description; + private Boolean system; + private Boolean global; + private Long createTime; + private Long updateTime; + private String createUser; + private String projectId; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTemplateExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTemplateExample.java new file mode 100644 index 0000000000..142e2ffee8 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTemplateExample.java @@ -0,0 +1,790 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiTemplateExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiTemplateExample() { + oredCriteria = new ArrayList(); + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public boolean isDistinct() { + return distinct; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andSystemIsNull() { + addCriterion("`system` is null"); + return (Criteria) this; + } + + public Criteria andSystemIsNotNull() { + addCriterion("`system` is not null"); + return (Criteria) this; + } + + public Criteria andSystemEqualTo(Boolean value) { + addCriterion("`system` =", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotEqualTo(Boolean value) { + addCriterion("`system` <>", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemGreaterThan(Boolean value) { + addCriterion("`system` >", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemGreaterThanOrEqualTo(Boolean value) { + addCriterion("`system` >=", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemLessThan(Boolean value) { + addCriterion("`system` <", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemLessThanOrEqualTo(Boolean value) { + addCriterion("`system` <=", value, "system"); + return (Criteria) this; + } + + public Criteria andSystemIn(List values) { + addCriterion("`system` in", values, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotIn(List values) { + addCriterion("`system` not in", values, "system"); + return (Criteria) this; + } + + public Criteria andSystemBetween(Boolean value1, Boolean value2) { + addCriterion("`system` between", value1, value2, "system"); + return (Criteria) this; + } + + public Criteria andSystemNotBetween(Boolean value1, Boolean value2) { + addCriterion("`system` not between", value1, value2, "system"); + return (Criteria) this; + } + + public Criteria andGlobalIsNull() { + addCriterion("`global` is null"); + return (Criteria) this; + } + + public Criteria andGlobalIsNotNull() { + addCriterion("`global` is not null"); + return (Criteria) this; + } + + public Criteria andGlobalEqualTo(Boolean value) { + addCriterion("`global` =", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotEqualTo(Boolean value) { + addCriterion("`global` <>", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalGreaterThan(Boolean value) { + addCriterion("`global` >", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalGreaterThanOrEqualTo(Boolean value) { + addCriterion("`global` >=", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalLessThan(Boolean value) { + addCriterion("`global` <", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalLessThanOrEqualTo(Boolean value) { + addCriterion("`global` <=", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalIn(List values) { + addCriterion("`global` in", values, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotIn(List values) { + addCriterion("`global` not in", values, "global"); + return (Criteria) this; + } + + public Criteria andGlobalBetween(Boolean value1, Boolean value2) { + addCriterion("`global` between", value1, value2, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotBetween(Boolean value1, Boolean value2) { + addCriterion("`global` not between", value1, value2, "global"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNull() { + addCriterion("project_id is null"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNotNull() { + addCriterion("project_id is not null"); + return (Criteria) this; + } + + public Criteria andProjectIdEqualTo(String value) { + addCriterion("project_id =", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotEqualTo(String value) { + addCriterion("project_id <>", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThan(String value) { + addCriterion("project_id >", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThanOrEqualTo(String value) { + addCriterion("project_id >=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThan(String value) { + addCriterion("project_id <", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThanOrEqualTo(String value) { + addCriterion("project_id <=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLike(String value) { + addCriterion("project_id like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotLike(String value) { + addCriterion("project_id not like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdIn(List values) { + addCriterion("project_id in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotIn(List values) { + addCriterion("project_id not in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdBetween(String value1, String value2) { + addCriterion("project_id between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotBetween(String value1, String value2) { + addCriterion("project_id not between", value1, value2, "projectId"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldApi.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApi.java new file mode 100644 index 0000000000..38c19f411d --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApi.java @@ -0,0 +1,16 @@ +package io.metersphere.base.domain; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomFieldApi extends CustomFieldApiKey implements Serializable { + private static final long serialVersionUID = 1L; + private String value; + private String textValue; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiExample.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiExample.java new file mode 100644 index 0000000000..f2e723e5ba --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiExample.java @@ -0,0 +1,410 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class CustomFieldApiExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public CustomFieldApiExample() { + oredCriteria = new ArrayList(); + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public boolean isDistinct() { + return distinct; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andResourceIdIsNull() { + addCriterion("resource_id is null"); + return (Criteria) this; + } + + public Criteria andResourceIdIsNotNull() { + addCriterion("resource_id is not null"); + return (Criteria) this; + } + + public Criteria andResourceIdEqualTo(String value) { + addCriterion("resource_id =", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotEqualTo(String value) { + addCriterion("resource_id <>", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThan(String value) { + addCriterion("resource_id >", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThanOrEqualTo(String value) { + addCriterion("resource_id >=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThan(String value) { + addCriterion("resource_id <", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThanOrEqualTo(String value) { + addCriterion("resource_id <=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLike(String value) { + addCriterion("resource_id like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotLike(String value) { + addCriterion("resource_id not like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdIn(List values) { + addCriterion("resource_id in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotIn(List values) { + addCriterion("resource_id not in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdBetween(String value1, String value2) { + addCriterion("resource_id between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotBetween(String value1, String value2) { + addCriterion("resource_id not between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNull() { + addCriterion("field_id is null"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNotNull() { + addCriterion("field_id is not null"); + return (Criteria) this; + } + + public Criteria andFieldIdEqualTo(String value) { + addCriterion("field_id =", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotEqualTo(String value) { + addCriterion("field_id <>", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThan(String value) { + addCriterion("field_id >", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThanOrEqualTo(String value) { + addCriterion("field_id >=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThan(String value) { + addCriterion("field_id <", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThanOrEqualTo(String value) { + addCriterion("field_id <=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLike(String value) { + addCriterion("field_id like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotLike(String value) { + addCriterion("field_id not like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdIn(List values) { + addCriterion("field_id in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotIn(List values) { + addCriterion("field_id not in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdBetween(String value1, String value2) { + addCriterion("field_id between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotBetween(String value1, String value2) { + addCriterion("field_id not between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andValueIsNull() { + addCriterion("`value` is null"); + return (Criteria) this; + } + + public Criteria andValueIsNotNull() { + addCriterion("`value` is not null"); + return (Criteria) this; + } + + public Criteria andValueEqualTo(String value) { + addCriterion("`value` =", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotEqualTo(String value) { + addCriterion("`value` <>", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThan(String value) { + addCriterion("`value` >", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThanOrEqualTo(String value) { + addCriterion("`value` >=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThan(String value) { + addCriterion("`value` <", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThanOrEqualTo(String value) { + addCriterion("`value` <=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLike(String value) { + addCriterion("`value` like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotLike(String value) { + addCriterion("`value` not like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueIn(List values) { + addCriterion("`value` in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueNotIn(List values) { + addCriterion("`value` not in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueBetween(String value1, String value2) { + addCriterion("`value` between", value1, value2, "value"); + return (Criteria) this; + } + + public Criteria andValueNotBetween(String value1, String value2) { + addCriterion("`value` not between", value1, value2, "value"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiKey.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiKey.java new file mode 100644 index 0000000000..54b802ff95 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldApiKey.java @@ -0,0 +1,12 @@ +package io.metersphere.base.domain; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CustomFieldApiKey implements Serializable { + private static final long serialVersionUID = 1L; + private String resourceId; + private String fieldId; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/Project.java b/backend/src/main/java/io/metersphere/base/domain/Project.java index c68b37d633..a0cb450498 100644 --- a/backend/src/main/java/io/metersphere/base/domain/Project.java +++ b/backend/src/main/java/io/metersphere/base/domain/Project.java @@ -41,6 +41,8 @@ public class Project implements Serializable { private Boolean versionEnable; + private String apiTemplateId; + private String issueConfig; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java b/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java index b37eed1942..ef77c9fcc2 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java @@ -1323,6 +1323,76 @@ public class ProjectExample { addCriterion("version_enable not between", value1, value2, "versionEnable"); return (Criteria) this; } + + public Criteria andApiTemplateIdIsNull() { + addCriterion("api_template_id is null"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdIsNotNull() { + addCriterion("api_template_id is not null"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdEqualTo(String value) { + addCriterion("api_template_id =", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdNotEqualTo(String value) { + addCriterion("api_template_id <>", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdGreaterThan(String value) { + addCriterion("api_template_id >", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdGreaterThanOrEqualTo(String value) { + addCriterion("api_template_id >=", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdLessThan(String value) { + addCriterion("api_template_id <", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdLessThanOrEqualTo(String value) { + addCriterion("api_template_id <=", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdLike(String value) { + addCriterion("api_template_id like", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdNotLike(String value) { + addCriterion("api_template_id not like", value, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdIn(List values) { + addCriterion("api_template_id in", values, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdNotIn(List values) { + addCriterion("api_template_id not in", values, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdBetween(String value1, String value2) { + addCriterion("api_template_id between", value1, value2, "apiTemplateId"); + return (Criteria) this; + } + + public Criteria andApiTemplateIdNotBetween(String value1, String value2) { + addCriterion("api_template_id not between", value1, value2, "apiTemplateId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.java new file mode 100644 index 0000000000..b9ed94aa92 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.java @@ -0,0 +1,31 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.ApiTemplate; +import io.metersphere.base.domain.ApiTemplateExample; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ApiTemplateMapper { + long countByExample(ApiTemplateExample example); + + int deleteByExample(ApiTemplateExample example); + + int deleteByPrimaryKey(String id); + + int insert(ApiTemplate record); + + int insertSelective(ApiTemplate record); + + List selectByExample(ApiTemplateExample example); + + ApiTemplate selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") ApiTemplate record, @Param("example") ApiTemplateExample example); + + int updateByExample(@Param("record") ApiTemplate record, @Param("example") ApiTemplateExample example); + + int updateByPrimaryKeySelective(ApiTemplate record); + + int updateByPrimaryKey(ApiTemplate record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.xml new file mode 100644 index 0000000000..569de81984 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTemplateMapper.xml @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id + , `name`, description, `system`, `global`, create_time, update_time, create_user, + project_id + + + + + delete + from api_template + where id = #{id,jdbcType=VARCHAR} + + + delete from api_template + + + + + + insert into api_template (id, `name`, description, + `system`, `global`, create_time, + update_time, create_user, project_id) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, + #{system,jdbcType=BIT}, #{global,jdbcType=BIT}, #{createTime,jdbcType=BIGINT}, + #{updateTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}) + + + insert into api_template + + + id, + + + `name`, + + + description, + + + `system`, + + + `global`, + + + create_time, + + + update_time, + + + create_user, + + + project_id, + + + + + #{id,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{system,jdbcType=BIT}, + + + #{global,jdbcType=BIT}, + + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + + + #{createUser,jdbcType=VARCHAR}, + + + #{projectId,jdbcType=VARCHAR}, + + + + + + update api_template + + + id = #{record.id,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + description = #{record.description,jdbcType=VARCHAR}, + + + `system` = #{record.system,jdbcType=BIT}, + + + `global` = #{record.global,jdbcType=BIT}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + + + create_user = #{record.createUser,jdbcType=VARCHAR}, + + + project_id = #{record.projectId,jdbcType=VARCHAR}, + + + + + + + + update api_template + set id = #{record.id,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + `system` = #{record.system,jdbcType=BIT}, + `global` = #{record.global,jdbcType=BIT}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR}, + project_id = #{record.projectId,jdbcType=VARCHAR} + + + + + + update api_template + + + `name` = #{name,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + `system` = #{system,jdbcType=BIT}, + + + `global` = #{global,jdbcType=BIT}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + create_user = #{createUser,jdbcType=VARCHAR}, + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update api_template + set `name` = #{name,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + `system` = #{system,jdbcType=BIT}, + `global` = #{global,jdbcType=BIT}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR}, + project_id = #{projectId,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.java b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.java new file mode 100644 index 0000000000..bdeeb49529 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.java @@ -0,0 +1,38 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.CustomFieldApi; +import io.metersphere.base.domain.CustomFieldApiExample; +import io.metersphere.base.domain.CustomFieldApiKey; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface CustomFieldApiMapper { + long countByExample(CustomFieldApiExample example); + + int deleteByExample(CustomFieldApiExample example); + + int deleteByPrimaryKey(CustomFieldApiKey key); + + int insert(CustomFieldApi record); + + int insertSelective(CustomFieldApi record); + + List selectByExampleWithBLOBs(CustomFieldApiExample example); + + List selectByExample(CustomFieldApiExample example); + + CustomFieldApi selectByPrimaryKey(CustomFieldApiKey key); + + int updateByExampleSelective(@Param("record") CustomFieldApi record, @Param("example") CustomFieldApiExample example); + + int updateByExampleWithBLOBs(@Param("record") CustomFieldApi record, @Param("example") CustomFieldApiExample example); + + int updateByExample(@Param("record") CustomFieldApi record, @Param("example") CustomFieldApiExample example); + + int updateByPrimaryKeySelective(CustomFieldApi record); + + int updateByPrimaryKeyWithBLOBs(CustomFieldApi record); + + int updateByPrimaryKey(CustomFieldApi record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.xml new file mode 100644 index 0000000000..42befb77f2 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldApiMapper.xml @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + resource_id + , field_id, `value` + + + text_value + + + + + + delete + from custom_field_api + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + delete from custom_field_api + + + + + + insert into custom_field_api (resource_id, field_id, `value`, + text_value) + values (#{resourceId,jdbcType=VARCHAR}, #{fieldId,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, + #{textValue,jdbcType=LONGVARCHAR}) + + + insert into custom_field_api + + + resource_id, + + + field_id, + + + `value`, + + + text_value, + + + + + #{resourceId,jdbcType=VARCHAR}, + + + #{fieldId,jdbcType=VARCHAR}, + + + #{value,jdbcType=VARCHAR}, + + + #{textValue,jdbcType=LONGVARCHAR}, + + + + + + update custom_field_api + + + resource_id = #{record.resourceId,jdbcType=VARCHAR}, + + + field_id = #{record.fieldId,jdbcType=VARCHAR}, + + + `value` = #{record.value,jdbcType=VARCHAR}, + + + text_value = #{record.textValue,jdbcType=LONGVARCHAR}, + + + + + + + + update custom_field_api + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR}, + text_value = #{record.textValue,jdbcType=LONGVARCHAR} + + + + + + update custom_field_api + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR} + + + + + + update custom_field_api + + + `value` = #{value,jdbcType=VARCHAR}, + + + text_value = #{textValue,jdbcType=LONGVARCHAR}, + + + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_api + set `value` = #{value,jdbcType=VARCHAR}, + text_value = #{textValue,jdbcType=LONGVARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_api + set `value` = #{value,jdbcType=VARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml index e3152c5e7d..ae61e2c475 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml @@ -20,6 +20,7 @@ + @@ -83,9 +84,10 @@ - id, workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key, + id + , workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key, zentao_id, azure_devops_id, case_template_id, issue_template_id, create_user, system_id, - azure_filter_id, platform, third_part_template, version_enable + azure_filter_id, platform, third_part_template, version_enable, api_template_id issue_config @@ -139,20 +141,21 @@ - insert into project (id, workspace_id, `name`, - description, create_time, update_time, - tapd_id, jira_key, zentao_id, - azure_devops_id, case_template_id, issue_template_id, - create_user, system_id, azure_filter_id, - platform, third_part_template, version_enable, - issue_config) - values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, - #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, - #{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR}, - #{azureDevopsId,jdbcType=VARCHAR}, #{caseTemplateId,jdbcType=VARCHAR}, #{issueTemplateId,jdbcType=VARCHAR}, - #{createUser,jdbcType=VARCHAR}, #{systemId,jdbcType=VARCHAR}, #{azureFilterId,jdbcType=VARCHAR}, - #{platform,jdbcType=VARCHAR}, #{thirdPartTemplate,jdbcType=BIT}, #{versionEnable,jdbcType=BIT}, - #{issueConfig,jdbcType=LONGVARCHAR}) + insert into project (id, workspace_id, `name`, + description, create_time, update_time, + tapd_id, jira_key, zentao_id, + azure_devops_id, case_template_id, issue_template_id, + create_user, system_id, azure_filter_id, + platform, third_part_template, version_enable, + api_template_id, issue_config) + values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, + #{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR}, + #{azureDevopsId,jdbcType=VARCHAR}, #{caseTemplateId,jdbcType=VARCHAR}, + #{issueTemplateId,jdbcType=VARCHAR}, + #{createUser,jdbcType=VARCHAR}, #{systemId,jdbcType=VARCHAR}, #{azureFilterId,jdbcType=VARCHAR}, + #{platform,jdbcType=VARCHAR}, #{thirdPartTemplate,jdbcType=BIT}, #{versionEnable,jdbcType=BIT}, + #{apiTemplateId,jdbcType=VARCHAR}, #{issueConfig,jdbcType=LONGVARCHAR}) insert into project @@ -193,27 +196,30 @@ issue_template_id, - - create_user, - - - system_id, - - - azure_filter_id, - - - platform, - - - third_part_template, - - - version_enable, - - - issue_config, - + + create_user, + + + system_id, + + + azure_filter_id, + + + platform, + + + third_part_template, + + + version_enable, + + + api_template_id, + + + issue_config, + @@ -252,27 +258,30 @@ #{issueTemplateId,jdbcType=VARCHAR}, - - #{createUser,jdbcType=VARCHAR}, - - - #{systemId,jdbcType=VARCHAR}, - - - #{azureFilterId,jdbcType=VARCHAR}, - - - #{platform,jdbcType=VARCHAR}, - - - #{thirdPartTemplate,jdbcType=BIT}, - - - #{versionEnable,jdbcType=BIT}, - - - #{issueConfig,jdbcType=LONGVARCHAR}, - + + #{createUser,jdbcType=VARCHAR}, + + + #{systemId,jdbcType=VARCHAR}, + + + #{azureFilterId,jdbcType=VARCHAR}, + + + #{platform,jdbcType=VARCHAR}, + + + #{thirdPartTemplate,jdbcType=BIT}, + + + #{versionEnable,jdbcType=BIT}, + + + #{apiTemplateId,jdbcType=VARCHAR}, + + + #{issueConfig,jdbcType=LONGVARCHAR}, + + select + + from api_template tcft + + + + + + + + and tcft.name LIKE CONCAT('%', #{request.name}, '%') + + + + and ( + tcft.workspace_id = #{request.workspaceId} + or ( + tcft.global = 1 and + not exists ( + select id + from api_template tcft_child + where tcft_child.name = tcft.name and tcft_child.global != 1 and tcft_child.workspace_id = + #{request.workspaceId} + ) + ) + ) + + + and ( + tcft.project_id = #{request.projectId} + or ( + tcft.global = 1 and + not exists ( + select id + from api_template tcft_child + where tcft_child.name = tcft.name and tcft_child.global != 1 and tcft_child.project_id = + #{request.projectId} + ) + ) + ) + + + + + + + + AND tcft.type IN + + #{value} + + + + + + + + + + + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java index f37562f6ac..e96db3861a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.java @@ -46,7 +46,9 @@ public interface ExtProjectMapper { List queryListByIds(@Param("ids") List ids); - void updateUseDefaultCaseTemplateProject(@Param("originId") String originId,@Param("templateId") String templateId,@Param("projectId") String projectId); + void updateUseDefaultCaseTemplateProject(@Param("originId") String originId, @Param("templateId") String templateId, @Param("projectId") String projectId); + + void updateUseDefaultApiTemplateProject(@Param("originId") String originId, @Param("templateId") String templateId, @Param("projectId") String projectId); List getThirdPartProjectIds(); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index 33175e9b7e..8cdcc6ccf3 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -198,68 +198,74 @@ WHERE project.id IN (SELECT id FROM (SELECT id - FROM project - WHERE workspace_id = #{workspaceId}) AS a) + FROM project + WHERE workspace_id = #{workspaceId}) AS a) - update project set case_template_id = #{templateId} + update project + set case_template_id = #{templateId} where (case_template_id = #{originId} or case_template_id is null or case_template_id = '') - and id = #{projectId} + and id = #{projectId} + + + update project + set api_template_id = #{templateId} + where (api_template_id = #{originId} or api_template_id is null or api_template_id = '') + and id = #{projectId}