From b21c799ba28980235c0e20f51f024f96a28b1b15 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 15 Oct 2020 17:37:49 +0800 Subject: [PATCH 01/10] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?):=20jar=E5=8C=85=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiTestJarConfigController.java | 50 ++ .../api/service/ApiTestJarConfigService.java | 130 +++ .../base/domain/ApiTestJarConfig.java | 27 + .../base/domain/ApiTestJarConfigExample.java | 810 ++++++++++++++++++ .../base/mapper/ApiTestJarConfigMapper.java | 30 + .../base/mapper/ApiTestJarConfigMapper.xml | 275 ++++++ .../db/migration/V30__api_test_jar.sql | 12 + .../src/main/resources/generatorConfig.xml | 4 +- .../api/test/components/jar/JarConfig.vue | 79 ++ .../api/test/components/jar/JarConfigFrom.vue | 187 ++++ .../api/test/components/jar/JarConfigList.vue | 67 ++ .../business/components/project/MsProject.vue | 10 +- frontend/src/i18n/en-US.js | 6 + frontend/src/i18n/zh-CN.js | 6 + frontend/src/i18n/zh-TW.js | 42 +- 15 files changed, 1714 insertions(+), 21 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/api/controller/ApiTestJarConfigController.java create mode 100644 backend/src/main/java/io/metersphere/api/service/ApiTestJarConfigService.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfig.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfigExample.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.xml create mode 100644 backend/src/main/resources/db/migration/V30__api_test_jar.sql create mode 100644 frontend/src/business/components/api/test/components/jar/JarConfig.vue create mode 100644 frontend/src/business/components/api/test/components/jar/JarConfigFrom.vue create mode 100644 frontend/src/business/components/api/test/components/jar/JarConfigList.vue diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestJarConfigController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestJarConfigController.java new file mode 100644 index 0000000000..b6aaf79dd0 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestJarConfigController.java @@ -0,0 +1,50 @@ +package io.metersphere.api.controller; + +import io.metersphere.api.service.ApiTestJarConfigService; +import io.metersphere.base.domain.ApiTestJarConfig; +import io.metersphere.commons.constants.RoleConstants; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping(value = "/api/jar") +@RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) +public class ApiTestJarConfigController { + + @Resource + ApiTestJarConfigService apiTestJarConfigService; + + @GetMapping("/list/{projectId}") + public List list(@PathVariable String projectId) { + return apiTestJarConfigService.list(projectId); + } + + @GetMapping("/get/{id}") + public ApiTestJarConfig get(@PathVariable String id) { + return apiTestJarConfigService.get(id); + } + + @PostMapping(value = "/add", consumes = {"multipart/form-data"}) + @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER,}, logical = Logical.OR) + public String add(@RequestPart("request") ApiTestJarConfig request, @RequestPart(value = "file") MultipartFile file) { + return apiTestJarConfigService.add(request, file); + } + + @PostMapping(value = "/update", consumes = {"multipart/form-data"}) + @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER,}, logical = Logical.OR) + public void update(@RequestPart("request") ApiTestJarConfig request, @RequestPart(value = "file", required = false) MultipartFile file) { + apiTestJarConfigService.update(request, file); + } + + @GetMapping("/delete/{id}") + @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER,}, logical = Logical.OR) + public void delete(@PathVariable String id) { + apiTestJarConfigService.delete(id); + } + +} diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestJarConfigService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestJarConfigService.java new file mode 100644 index 0000000000..4058e582bc --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestJarConfigService.java @@ -0,0 +1,130 @@ +package io.metersphere.api.service; + +import io.metersphere.base.domain.ApiTestJarConfig; +import io.metersphere.base.domain.ApiTestJarConfigExample; +import io.metersphere.base.mapper.ApiTestJarConfigMapper; +import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.i18n.Translator; +import org.apache.commons.lang3.StringUtils; +import org.aspectj.util.FileUtil; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.*; +import java.util.List; +import java.util.UUID; + +@Service +@Transactional(rollbackFor = Exception.class) +public class ApiTestJarConfigService { + + private static final String JAR_FILE_DIR = "/opt/metersphere/data/jar"; + + @Resource + private ApiTestJarConfigMapper apiTestJarConfigMapper; + + public List list(String projectId) { + ApiTestJarConfigExample example = new ApiTestJarConfigExample(); + example.createCriteria().andProjectIdEqualTo(projectId); + return apiTestJarConfigMapper.selectByExample(example); + } + + public ApiTestJarConfig get(String id) { + return apiTestJarConfigMapper.selectByPrimaryKey(id); + } + + public void delete(String id) { + ApiTestJarConfig apiTestJarConfig = apiTestJarConfigMapper.selectByPrimaryKey(id); + deleteJarFile(apiTestJarConfig.getPath()); + apiTestJarConfigMapper.deleteByPrimaryKey(id); + } + + public void update(ApiTestJarConfig apiTestJarConfig, MultipartFile file) { + checkExist(apiTestJarConfig); + apiTestJarConfig.setOwner(SessionUtils.getUser().getId()); + apiTestJarConfig.setUpdateTime(System.currentTimeMillis()); + String deletePath = apiTestJarConfig.getPath(); + if (file != null) { + apiTestJarConfig.setFileName(file.getOriginalFilename()); + apiTestJarConfig.setPath(getJarPath(apiTestJarConfig, file)); + } + apiTestJarConfigMapper.updateByPrimaryKey(apiTestJarConfig); + if (file != null) { + deleteJarFile(deletePath); + createJarFiles(apiTestJarConfig.getProjectId(), file); + } + } + + public String add(ApiTestJarConfig apiTestJarConfig, MultipartFile file) { + apiTestJarConfig.setId(UUID.randomUUID().toString()); + apiTestJarConfig.setOwner(SessionUtils.getUser().getId()); + checkExist(apiTestJarConfig); + apiTestJarConfig.setCreateTime(System.currentTimeMillis()); + apiTestJarConfig.setUpdateTime(System.currentTimeMillis()); + apiTestJarConfig.setPath(getJarPath(apiTestJarConfig, file)); + apiTestJarConfig.setFileName(file.getOriginalFilename()); + apiTestJarConfigMapper.insert(apiTestJarConfig); + createJarFiles(apiTestJarConfig.getProjectId(), file); + return apiTestJarConfig.getId(); + } + + public void deleteJarFiles(String testId) { + File file = new File(JAR_FILE_DIR + "/" + testId); + FileUtil.deleteContents(file); + if (file.exists()) { + file.delete(); + } + } + + public void deleteJarFile(String path) { + File file = new File(path); + if (file.exists()) { + file.delete(); + } + } + + public String getJarPath(ApiTestJarConfig apiTestJarConfig, MultipartFile file) { + return JAR_FILE_DIR + "/" + apiTestJarConfig.getProjectId() + "/" + file.getOriginalFilename(); + } + + private String createJarFiles(String projectId, MultipartFile jar) { + if (jar == null) { + return null; + } + String dir = JAR_FILE_DIR + "/" + projectId; + File testDir = new File(dir); + if (!testDir.exists()) { + testDir.mkdirs(); + } + String filePath = testDir + "/" + jar.getOriginalFilename(); + File file = new File(filePath); + try (InputStream in = jar.getInputStream(); OutputStream out = new FileOutputStream(file)) { + file.createNewFile(); + FileUtil.copyStream(in, out); + } catch (IOException e) { + LogUtil.error(e); + MSException.throwException(Translator.get("upload_fail")); + } + return filePath; + } + + + private void checkExist(ApiTestJarConfig jarConfig) { + if (jarConfig.getName() != null) { + ApiTestJarConfigExample example = new ApiTestJarConfigExample(); + ApiTestJarConfigExample.Criteria criteria = example.createCriteria(); + criteria.andNameEqualTo(jarConfig.getName()) + .andProjectIdEqualTo(jarConfig.getProjectId()); + if (StringUtils.isNotBlank(jarConfig.getId())) { + criteria.andIdNotEqualTo(jarConfig.getId()); + } + if (apiTestJarConfigMapper.selectByExample(example).size() > 0) { + MSException.throwException(Translator.get("api_test_jarConfig_already_exists")); + } + } + } +} diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfig.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfig.java new file mode 100644 index 0000000000..00a315b3c3 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfig.java @@ -0,0 +1,27 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class ApiTestJarConfig implements Serializable { + private String id; + + private String name; + + private String fileName; + + private String owner; + + private String path; + + private String projectId; + + private String description; + + private Long createTime; + + private Long updateTime; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfigExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfigExample.java new file mode 100644 index 0000000000..3c150cb696 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestJarConfigExample.java @@ -0,0 +1,810 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiTestJarConfigExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiTestJarConfigExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return 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 andFileNameIsNull() { + addCriterion("file_name is null"); + return (Criteria) this; + } + + public Criteria andFileNameIsNotNull() { + addCriterion("file_name is not null"); + return (Criteria) this; + } + + public Criteria andFileNameEqualTo(String value) { + addCriterion("file_name =", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotEqualTo(String value) { + addCriterion("file_name <>", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameGreaterThan(String value) { + addCriterion("file_name >", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameGreaterThanOrEqualTo(String value) { + addCriterion("file_name >=", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLessThan(String value) { + addCriterion("file_name <", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLessThanOrEqualTo(String value) { + addCriterion("file_name <=", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameLike(String value) { + addCriterion("file_name like", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotLike(String value) { + addCriterion("file_name not like", value, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameIn(List values) { + addCriterion("file_name in", values, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotIn(List values) { + addCriterion("file_name not in", values, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameBetween(String value1, String value2) { + addCriterion("file_name between", value1, value2, "fileName"); + return (Criteria) this; + } + + public Criteria andFileNameNotBetween(String value1, String value2) { + addCriterion("file_name not between", value1, value2, "fileName"); + return (Criteria) this; + } + + public Criteria andOwnerIsNull() { + addCriterion("`owner` is null"); + return (Criteria) this; + } + + public Criteria andOwnerIsNotNull() { + addCriterion("`owner` is not null"); + return (Criteria) this; + } + + public Criteria andOwnerEqualTo(String value) { + addCriterion("`owner` =", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerNotEqualTo(String value) { + addCriterion("`owner` <>", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerGreaterThan(String value) { + addCriterion("`owner` >", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerGreaterThanOrEqualTo(String value) { + addCriterion("`owner` >=", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerLessThan(String value) { + addCriterion("`owner` <", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerLessThanOrEqualTo(String value) { + addCriterion("`owner` <=", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerLike(String value) { + addCriterion("`owner` like", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerNotLike(String value) { + addCriterion("`owner` not like", value, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerIn(List values) { + addCriterion("`owner` in", values, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerNotIn(List values) { + addCriterion("`owner` not in", values, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerBetween(String value1, String value2) { + addCriterion("`owner` between", value1, value2, "owner"); + return (Criteria) this; + } + + public Criteria andOwnerNotBetween(String value1, String value2) { + addCriterion("`owner` not between", value1, value2, "owner"); + return (Criteria) this; + } + + public Criteria andPathIsNull() { + addCriterion("`path` is null"); + return (Criteria) this; + } + + public Criteria andPathIsNotNull() { + addCriterion("`path` is not null"); + return (Criteria) this; + } + + public Criteria andPathEqualTo(String value) { + addCriterion("`path` =", value, "path"); + return (Criteria) this; + } + + public Criteria andPathNotEqualTo(String value) { + addCriterion("`path` <>", value, "path"); + return (Criteria) this; + } + + public Criteria andPathGreaterThan(String value) { + addCriterion("`path` >", value, "path"); + return (Criteria) this; + } + + public Criteria andPathGreaterThanOrEqualTo(String value) { + addCriterion("`path` >=", value, "path"); + return (Criteria) this; + } + + public Criteria andPathLessThan(String value) { + addCriterion("`path` <", value, "path"); + return (Criteria) this; + } + + public Criteria andPathLessThanOrEqualTo(String value) { + addCriterion("`path` <=", value, "path"); + return (Criteria) this; + } + + public Criteria andPathLike(String value) { + addCriterion("`path` like", value, "path"); + return (Criteria) this; + } + + public Criteria andPathNotLike(String value) { + addCriterion("`path` not like", value, "path"); + return (Criteria) this; + } + + public Criteria andPathIn(List values) { + addCriterion("`path` in", values, "path"); + return (Criteria) this; + } + + public Criteria andPathNotIn(List values) { + addCriterion("`path` not in", values, "path"); + return (Criteria) this; + } + + public Criteria andPathBetween(String value1, String value2) { + addCriterion("`path` between", value1, value2, "path"); + return (Criteria) this; + } + + public Criteria andPathNotBetween(String value1, String value2) { + addCriterion("`path` not between", value1, value2, "path"); + 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 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 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 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; + + 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; + } + + 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); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.java new file mode 100644 index 0000000000..d5f294805a --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.java @@ -0,0 +1,30 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.ApiTestJarConfig; +import io.metersphere.base.domain.ApiTestJarConfigExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface ApiTestJarConfigMapper { + long countByExample(ApiTestJarConfigExample example); + + int deleteByExample(ApiTestJarConfigExample example); + + int deleteByPrimaryKey(String id); + + int insert(ApiTestJarConfig record); + + int insertSelective(ApiTestJarConfig record); + + List selectByExample(ApiTestJarConfigExample example); + + ApiTestJarConfig selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") ApiTestJarConfig record, @Param("example") ApiTestJarConfigExample example); + + int updateByExample(@Param("record") ApiTestJarConfig record, @Param("example") ApiTestJarConfigExample example); + + int updateByPrimaryKeySelective(ApiTestJarConfig record); + + int updateByPrimaryKey(ApiTestJarConfig record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.xml new file mode 100644 index 0000000000..fdb59c3665 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestJarConfigMapper.xml @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + 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`, file_name, `owner`, `path`, project_id, description, create_time, update_time + + + + + delete from api_test_jar_config + where id = #{id,jdbcType=VARCHAR} + + + delete from api_test_jar_config + + + + + + insert into api_test_jar_config (id, `name`, file_name, + `owner`, `path`, project_id, + description, create_time, update_time + ) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{fileName,jdbcType=VARCHAR}, + #{owner,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT} + ) + + + insert into api_test_jar_config + + + id, + + + `name`, + + + file_name, + + + `owner`, + + + `path`, + + + project_id, + + + description, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{fileName,jdbcType=VARCHAR}, + + + #{owner,jdbcType=VARCHAR}, + + + #{path,jdbcType=VARCHAR}, + + + #{projectId,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + + + + + + update api_test_jar_config + + + id = #{record.id,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + file_name = #{record.fileName,jdbcType=VARCHAR}, + + + `owner` = #{record.owner,jdbcType=VARCHAR}, + + + `path` = #{record.path,jdbcType=VARCHAR}, + + + project_id = #{record.projectId,jdbcType=VARCHAR}, + + + description = #{record.description,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + + + + + + + + update api_test_jar_config + set id = #{record.id,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + file_name = #{record.fileName,jdbcType=VARCHAR}, + `owner` = #{record.owner,jdbcType=VARCHAR}, + `path` = #{record.path,jdbcType=VARCHAR}, + project_id = #{record.projectId,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT} + + + + + + update api_test_jar_config + + + `name` = #{name,jdbcType=VARCHAR}, + + + file_name = #{fileName,jdbcType=VARCHAR}, + + + `owner` = #{owner,jdbcType=VARCHAR}, + + + `path` = #{path,jdbcType=VARCHAR}, + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + where id = #{id,jdbcType=VARCHAR} + + + update api_test_jar_config + set `name` = #{name,jdbcType=VARCHAR}, + file_name = #{fileName,jdbcType=VARCHAR}, + `owner` = #{owner,jdbcType=VARCHAR}, + `path` = #{path,jdbcType=VARCHAR}, + project_id = #{projectId,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/resources/db/migration/V30__api_test_jar.sql b/backend/src/main/resources/db/migration/V30__api_test_jar.sql new file mode 100644 index 0000000000..687d684501 --- /dev/null +++ b/backend/src/main/resources/db/migration/V30__api_test_jar.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS `api_test_jar_config` ( + `id` varchar(50) NOT NULL COMMENT 'ID', + `name` varchar(64) NOT NULL COMMENT 'Name', + `file_name` varchar(64) NOT NULL COMMENT 'File name', + `owner` varchar(50) NOT NULL COMMENT 'User ID', + `path` varchar(255) NOT NULL COMMENT 'File path', + `project_id` varchar(50) NOT NULL COMMENT 'Project ID this jar belongs to', + `description` varchar(255) DEFAULT NULL COMMENT 'description', + `create_time` bigint(13) NOT NULL COMMENT 'Create timestamp', + `update_time` bigint(13) NOT NULL COMMENT 'Update timestamp', + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; \ No newline at end of file diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index df4684a270..2f1492c870 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -64,8 +64,8 @@ - -
+
+ diff --git a/frontend/src/business/components/api/test/components/jar/JarConfig.vue b/frontend/src/business/components/api/test/components/jar/JarConfig.vue new file mode 100644 index 0000000000..2ee3b72139 --- /dev/null +++ b/frontend/src/business/components/api/test/components/jar/JarConfig.vue @@ -0,0 +1,79 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/jar/JarConfigFrom.vue b/frontend/src/business/components/api/test/components/jar/JarConfigFrom.vue new file mode 100644 index 0000000000..2698d8c221 --- /dev/null +++ b/frontend/src/business/components/api/test/components/jar/JarConfigFrom.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/frontend/src/business/components/api/test/components/jar/JarConfigList.vue b/frontend/src/business/components/api/test/components/jar/JarConfigList.vue new file mode 100644 index 0000000000..04b3108a46 --- /dev/null +++ b/frontend/src/business/components/api/test/components/jar/JarConfigList.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/frontend/src/business/components/project/MsProject.vue b/frontend/src/business/components/project/MsProject.vue index 911a9e16ad..708f2cda63 100644 --- a/frontend/src/business/components/project/MsProject.vue +++ b/frontend/src/business/components/project/MsProject.vue @@ -37,8 +37,10 @@ @@ -76,6 +78,7 @@ + @@ -95,10 +98,12 @@ import MsTableOperatorButton from "../common/components/MsTableOperatorButton"; import ApiEnvironmentConfig from "../api/test/components/ApiEnvironmentConfig"; import TemplateComponent from "../track/plan/view/comonents/report/TemplateComponent/TemplateComponent"; import {ApiEvent, LIST_CHANGE, PerformanceEvent, TrackEvent} from "@/business/components/common/head/ListEvent"; +import MsJarConfig from "../api/test/components/jar/JarConfig"; export default { name: "MsProject", components: { + MsJarConfig, TemplateComponent, ApiEnvironmentConfig, MsTableOperatorButton, @@ -275,6 +280,9 @@ export default { }, openEnvironmentConfig(project) { this.$refs.environmentConfig.open(project.id); + }, + openJarConfig(project) { + this.$refs.jarConfig.open(project.id); } } } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 0fa27d7b0d..995b4cbc98 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -423,6 +423,12 @@ export default { export_config: "Export", enable_validate_tip: "No request available", copy: "Copy Test", + jar_config: { + title: "The Jar Package Management", + jar_file: "Jar package", + file_exist: "The name already exists in the project", + upload_limit_size: "Upload file size cannot exceed 30MB!", + }, environment: { name: "Environment Name", socket: "Socket", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 6ca3aa5277..a271a07e3b 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -424,6 +424,12 @@ export default { export_config: "导出", enable_validate_tip: "没有可用请求", copy: "复制测试", + jar_config: { + title: "jar包管理", + jar_file: "jar包", + file_exist: "该项目下已存在改jar包", + upload_limit_size: "上传文件大小不能超过 30MB!", + }, environment: { name: "环境名称", socket: "环境域名", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 0619038219..3ea8fb6ada 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -424,6 +424,12 @@ export default { export_config: "導出", enable_validate_tip: "沒有可用請求", copy: "復制測試", + jar_config: { + title: "jar包管理", + jar_file: "jar包", + file_exist: "該項目下已存在改jar包", + upload_limit_size: "上傳文件大小不能超過 30MB!", + }, environment: { name: "環境名稱", socket: "環境域名", @@ -575,24 +581,24 @@ export default { dataSource_cannot_be_empty: "SQL請求數據源不能為空", result_variable: "存儲結果", variable_names: "按列存儲", + }, + tcp: { + server: "服務器名或IP", + port: "端口", + connect: "連接(ms)", + response: "響應(ms)", + re_use_connection: "Re-use connection", + no_delay: "設置無延遲", + close_connection: "關閉連接", + so_linger: "SO LINGER", + eol_byte: "行尾(EOL)字節值", + request: "要發送的文本", + username: "用戶名", + password: "密碼", + login: "登錄設置", + server_cannot_be_empty: "服務器名或IP不能為空", } }, - tcp: { - server: "服務器名或IP", - port: "端口", - connect: "連接(ms)", - response: "響應(ms)", - re_use_connection: "Re-use connection", - no_delay: "設置無延遲", - close_connection: "關閉連接", - so_linger: "SO LINGER", - eol_byte: "行尾(EOL)字節值", - request: "要發送的文本", - username: "用戶名", - password: "密碼", - login: "登錄設置", - server_cannot_be_empty: "服務器名或IP不能為空", - }, api_import: { label: "導入", title: "接口測試導入", @@ -796,7 +802,7 @@ export default { reviewed_by_me: "待我評審", creator: "創建人", done: "已評用例", - result_distribution: "結果分佈" + result_distribution: "結果分布" }, comment: { no_comment: "暫無評論", @@ -902,7 +908,7 @@ export default { close_success: "關閉成功", preview: "預覽", please_choose_current_owner: "請選擇處理人", - tapd_current_owner: "Tapd平台處理人:", + tapd_current_owner: "Tapd平臺處理人:", } }, test_resource_pool: { From 8b2fdaad7cc20e9b9adc11a0802a81911b80e501 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 19 Oct 2020 18:07:38 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8E=E4=BF=AE=E6=94=B9=E5=B7=B2=E5=AD=98=E5=9C=A8=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=89=80=E5=B1=9E=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=E6=9C=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/performance/test/EditPerformanceTestPlan.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue index 29096c205c..8eebd7108d 100644 --- a/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue +++ b/frontend/src/business/components/performance/test/EditPerformanceTestPlan.vue @@ -125,6 +125,8 @@ export default { this.isReadOnly = true; } this.getTest(this.$route.params.testId); + }, + activated() { this.listProjects(); }, mounted() { From 1b4047386ee6a6090d1b67ce666d3191a99a7f7b Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Mon, 19 Oct 2020 18:48:56 +0800 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20=E6=B6=88=E6=81=AF=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/controller/NoticeController.java | 2 +- .../notice/domain/MessageDetail.java | 1 - .../notice/service/NoticeService.java | 43 ++++++++++++++++--- .../track/service/TestCaseReviewService.java | 8 ++++ .../V34__modify_message_task_webhook.sql | 1 + .../organization/TaskNotification.vue | 14 +++--- 6 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 backend/src/main/resources/db/migration/V34__modify_message_task_webhook.sql diff --git a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java index fdfe68436c..7696b2ba0f 100644 --- a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java +++ b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java @@ -32,7 +32,7 @@ public class NoticeController { } @GetMapping("/search/message") - public List searchMessage() { + public MessageSettingDetail searchMessage() { return noticeService.searchMessage(); } diff --git a/backend/src/main/java/io/metersphere/notice/domain/MessageDetail.java b/backend/src/main/java/io/metersphere/notice/domain/MessageDetail.java index 45f40beabf..2550cbc864 100644 --- a/backend/src/main/java/io/metersphere/notice/domain/MessageDetail.java +++ b/backend/src/main/java/io/metersphere/notice/domain/MessageDetail.java @@ -9,7 +9,6 @@ import java.util.List; @Data public class MessageDetail extends MessageTask { private List userIds = new ArrayList<>(); - private List userNames = new ArrayList<>(); private List events = new ArrayList<>(); private String taskType; private String webhook; diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java index 658001a1db..a46f49964e 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -8,6 +8,7 @@ import io.metersphere.base.mapper.MessageTaskMapper; import io.metersphere.base.mapper.NoticeMapper; import io.metersphere.notice.controller.request.MessageRequest; import io.metersphere.notice.controller.request.NoticeRequest; +import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.domain.MessageSettingDetail; import io.metersphere.notice.domain.NoticeDetail; import org.apache.commons.collections4.CollectionUtils; @@ -16,7 +17,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.UUID; +import java.util.stream.Collectors; import static io.metersphere.commons.constants.NoticeConstants.EXECUTE_FAILED; import static io.metersphere.commons.constants.NoticeConstants.EXECUTE_SUCCESSFUL; @@ -86,7 +89,7 @@ public class NoticeService { } public void saveMessageTask(MessageRequest messageRequest) { - String identification=UUID.randomUUID().toString(); + String identification = UUID.randomUUID().toString(); messageRequest.getMessageDetail().forEach(list -> { list.getEvents().forEach(n -> { list.getUserIds().forEach(m -> { @@ -106,12 +109,42 @@ public class NoticeService { } - public List searchMessage() { + public MessageSettingDetail searchMessage() { MessageTaskExample messageTaskExample = new MessageTaskExample(); messageTaskExample.createCriteria(); - List messageTasks = new ArrayList<>(); - List messageSettingDetail = new ArrayList<>(); - messageTasks = messageTaskMapper.selectByExample(messageTaskExample); + List messageTaskLists = new ArrayList<>(); + List userIds = new ArrayList<>(); + List events = new ArrayList<>(); + MessageSettingDetail messageSettingDetail = new MessageSettingDetail(); + MessageDetail messageDetail = new MessageDetail(); + List MessageDetailList = new ArrayList<>(); + messageTaskLists = messageTaskMapper.selectByExample(messageTaskExample); + Map> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e))); + MessageTaskMap.forEach((k, v) -> { + for (MessageTask m : v) { + userIds.add(m.getId()); + events.add(m.getEvent()); + messageDetail.setTaskType(m.getTaskType()); + messageDetail.setWebhook(m.getWebhook()); + messageDetail.setIdentification(m.getIdentification()); + messageDetail.setType(m.getType()); + } + messageDetail.setEvents(events); + messageDetail.setUserIds(userIds); + MessageDetailList.add(messageDetail); + }); + List jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("jenkinsTask")).collect(Collectors.toList()); + List testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("testPlanTask")).collect(Collectors.toList()); + List reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("reviewTask")).collect(Collectors.toList()); + List defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals("defect")).collect(Collectors.toList()); + messageSettingDetail.setJenkinsTask(jenkinsTask); + messageSettingDetail.setTestCasePlanTask(testCasePlanTask); + messageSettingDetail.setReviewTask(reviewTask); + messageSettingDetail.setDefectTask(defectTask); return messageSettingDetail; } + + private static String fetchGroupKey(MessageTask user) { + return user.getTaskType() + "#" + user.getIdentification(); + } } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 5c61abc8a3..cfa95c4f88 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -15,8 +15,11 @@ import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.member.QueryMemberRequest; +import io.metersphere.notice.domain.MessageDetail; +import io.metersphere.notice.domain.MessageSettingDetail; import io.metersphere.notice.service.DingTaskService; import io.metersphere.notice.service.MailService; +import io.metersphere.notice.service.NoticeService; import io.metersphere.notice.service.WxChatTaskService; import io.metersphere.service.UserService; import io.metersphere.track.dto.TestCaseReviewDTO; @@ -77,6 +80,8 @@ public class TestCaseReviewService { DingTaskService dingTaskService; @Resource WxChatTaskService wxChatTaskService; + @Resource + NoticeService noticeService; public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) { checkCaseReviewExist(reviewRequest); @@ -105,6 +110,9 @@ public class TestCaseReviewService { reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name()); testCaseReviewMapper.insert(reviewRequest); String context = getReviewContext(reviewRequest, "create"); + MessageSettingDetail messageSettingDetail = noticeService.searchMessage(); + List reviewTasklist = messageSettingDetail.getReviewTask(); + try { if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) { dingTaskService.sendDingTask(context, userIds); diff --git a/backend/src/main/resources/db/migration/V34__modify_message_task_webhook.sql b/backend/src/main/resources/db/migration/V34__modify_message_task_webhook.sql new file mode 100644 index 0000000000..7257542a37 --- /dev/null +++ b/backend/src/main/resources/db/migration/V34__modify_message_task_webhook.sql @@ -0,0 +1 @@ +alter table message_task modify webhook varchar(255) null comment 'webhook地址'; \ No newline at end of file diff --git a/frontend/src/business/components/settings/organization/TaskNotification.vue b/frontend/src/business/components/settings/organization/TaskNotification.vue index fac0df555f..1ce4d535b8 100644 --- a/frontend/src/business/components/settings/organization/TaskNotification.vue +++ b/frontend/src/business/components/settings/organization/TaskNotification.vue @@ -26,7 +26,7 @@ > @@ -20,7 +20,6 @@ return { visible: false, result: {}, - projectId: "", currentConfig: {}, configs: [] } @@ -32,9 +31,8 @@ }, }, methods: { - open(projectId) { + open() { this.visible = true; - this.projectId = projectId; this.getJarConfigs(); listenGoBack(this.close); }, @@ -49,15 +47,14 @@ return; } } - let url = config.id ? "/api/jar/update" : "/api/jar/add"; - config.projectId = this.projectId; + let url = config.id ? "/jar/update" : "/jar/add"; this.result = this.$fileUpload(url, file, null, config, () => { this.$success(this.$t('commons.save_success')); this.getJarConfigs(); }); }, getJarConfigs() { - this.result = this.$get("/api/jar/list/" + this.projectId, response => { + this.result = this.$get("/jar/list/all", response => { this.configs = response.data; this.currentConfig = {}; }) diff --git a/frontend/src/business/components/api/test/components/jar/JarConfigList.vue b/frontend/src/business/components/api/test/components/jar/JarConfigList.vue index 04b3108a46..2632b7b29a 100644 --- a/frontend/src/business/components/api/test/components/jar/JarConfigList.vue +++ b/frontend/src/business/components/api/test/components/jar/JarConfigList.vue @@ -9,13 +9,16 @@ - - - + + + + + @@ -27,41 +30,66 @@ diff --git a/frontend/src/business/components/project/MsProject.vue b/frontend/src/business/components/project/MsProject.vue index 708f2cda63..b8d704f425 100644 --- a/frontend/src/business/components/project/MsProject.vue +++ b/frontend/src/business/components/project/MsProject.vue @@ -39,8 +39,8 @@ diff --git a/frontend/src/business/components/settings/router.js b/frontend/src/business/components/settings/router.js index 08c5d7842f..5ecf108d03 100644 --- a/frontend/src/business/components/settings/router.js +++ b/frontend/src/business/components/settings/router.js @@ -32,6 +32,11 @@ export default { component: () => import('@/business/components/settings/system/SystemParameterSetting'), meta: {system: true, title: 'commons.system_parameter_setting'} }, + // todo1 { + // path: 'systemjarsetting', + // component: () => import('@/business/components/settings/system/JarConfigSetting'), + // meta: {system: true, title: 'api_test.jar_config.title'} + // }, ...requireContext.keys().map(key => requireContext(key).system),...requireContext.keys().map(key => requireContext(key).license), { path: 'organizationmember', diff --git a/frontend/src/business/components/settings/system/JarConfigSetting.vue b/frontend/src/business/components/settings/system/JarConfigSetting.vue index c8d469b2da..b25a66176b 100644 --- a/frontend/src/business/components/settings/system/JarConfigSetting.vue +++ b/frontend/src/business/components/settings/system/JarConfigSetting.vue @@ -2,32 +2,12 @@
- - - - - - - - - - - - - - - - - - + highlight-current-row> @@ -36,11 +16,10 @@ + @@ -49,75 +28,34 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue b/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue index 0b42cda26a..1f66f1abb7 100644 --- a/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue +++ b/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue @@ -1,13 +1,195 @@ diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 995b4cbc98..bc96871321 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -118,6 +118,7 @@ export default { please_upload: 'Please upload file', reference_documentation: "Reference documentation", already_exists: 'The name already exists', + modifier: 'Modifier', date: { select_date: 'Select date', start_date: 'Start date', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index a271a07e3b..72d5ec669f 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -118,6 +118,7 @@ export default { cannot_be_null: '不能为空', required: "{0}是必填的", already_exists: '名称不能重复', + modifier: '修改人', date: { select_date: '选择日期', start_date: '开始日期', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 3ea8fb6ada..1528a84f42 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -118,6 +118,7 @@ export default { cannot_be_null: '不能為空', required: "{0}是必填的", already_exists: '名稱不能重復', + modifier: '修改人', date: { select_date: '選擇日期', start_date: '開始日期', From 764567d5f8e20f05cd036b7d1e7b33611a5ba657 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 20 Oct 2020 12:58:00 +0800 Subject: [PATCH 08/10] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V30__api_test_jar.sql | 8 +- .../business/components/settings/router.js | 5 - .../settings/system/JarConfigSetting.vue | 119 ----------- .../settings/system/edit/JarConfigEdit.vue | 195 ------------------ 4 files changed, 1 insertion(+), 326 deletions(-) delete mode 100644 frontend/src/business/components/settings/system/JarConfigSetting.vue delete mode 100644 frontend/src/business/components/settings/system/edit/JarConfigEdit.vue diff --git a/backend/src/main/resources/db/migration/V30__api_test_jar.sql b/backend/src/main/resources/db/migration/V30__api_test_jar.sql index 6d1b020a21..b6bc46c2e6 100644 --- a/backend/src/main/resources/db/migration/V30__api_test_jar.sql +++ b/backend/src/main/resources/db/migration/V30__api_test_jar.sql @@ -10,10 +10,4 @@ CREATE TABLE IF NOT EXISTS `jar_config` ( `create_time` bigint(13) NOT NULL COMMENT 'Create timestamp', `update_time` bigint(13) NOT NULL COMMENT 'Update timestamp', PRIMARY KEY (`id`) -) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; - --- CREATE TABLE IF NOT EXISTS `jar_config_resource` ( todo1 --- `resource_id` varchar(64) NOT NULL, --- `jar_config_id` varchar(64) NOT NULL, --- UNIQUE KEY `jar_config_resource_unique_key` (`resource_id`, `jar_config_id`) --- ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='Jar config relevance table'; \ No newline at end of file +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; \ No newline at end of file diff --git a/frontend/src/business/components/settings/router.js b/frontend/src/business/components/settings/router.js index 5ecf108d03..08c5d7842f 100644 --- a/frontend/src/business/components/settings/router.js +++ b/frontend/src/business/components/settings/router.js @@ -32,11 +32,6 @@ export default { component: () => import('@/business/components/settings/system/SystemParameterSetting'), meta: {system: true, title: 'commons.system_parameter_setting'} }, - // todo1 { - // path: 'systemjarsetting', - // component: () => import('@/business/components/settings/system/JarConfigSetting'), - // meta: {system: true, title: 'api_test.jar_config.title'} - // }, ...requireContext.keys().map(key => requireContext(key).system),...requireContext.keys().map(key => requireContext(key).license), { path: 'organizationmember', diff --git a/frontend/src/business/components/settings/system/JarConfigSetting.vue b/frontend/src/business/components/settings/system/JarConfigSetting.vue deleted file mode 100644 index b25a66176b..0000000000 --- a/frontend/src/business/components/settings/system/JarConfigSetting.vue +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - diff --git a/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue b/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue deleted file mode 100644 index 1f66f1abb7..0000000000 --- a/frontend/src/business/components/settings/system/edit/JarConfigEdit.vue +++ /dev/null @@ -1,195 +0,0 @@ - - - - - From 6de79df31f62cb55709caeabcd7c26ee659cffe2 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 20 Oct 2020 13:46:19 +0800 Subject: [PATCH 09/10] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95)?= =?UTF-8?q?:=20=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/components/body/ApiBodyFileUpload.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/business/components/api/test/components/body/ApiBodyFileUpload.vue b/frontend/src/business/components/api/test/components/body/ApiBodyFileUpload.vue index 909b314ea9..c86aa57fd5 100644 --- a/frontend/src/business/components/api/test/components/body/ApiBodyFileUpload.vue +++ b/frontend/src/business/components/api/test/components/body/ApiBodyFileUpload.vue @@ -46,7 +46,10 @@ handleRemove(file) { this.$refs.upload.handleRemove(file); for (let i = 0; i < this.parameter.files.length; i++) { - if (file.file.name === this.parameter.files[i].file.name) { + let fileName = file.file ? file.file.name : file.name; + let paramFileName = this.parameter.files[i].file ? + this.parameter.files[i].file.name : this.parameter.files[i].name; + if (fileName === paramFileName) { this.parameter.files.splice(i, 1); this.$refs.upload.handleRemove(file); break; From 73218f5f23533905c0b40ffd2c99ccd3bc360e00 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 20 Oct 2020 14:15:07 +0800 Subject: [PATCH 10/10] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?:=20=E7=82=B9=E5=87=BB=E9=9D=A2=E5=8C=85=E5=B1=91=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E7=94=A8=E4=BE=8B=EF=BC=8C=E6=88=91=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/plan/view/comonents/TestPlanTestCaseList.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue index d04dc6ab9a..22a88bf199 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue @@ -5,7 +5,7 @@