From 7cba4604da7f3ef0ba756c596f9b64f62ac09fd9 Mon Sep 17 00:00:00 2001 From: q4speed Date: Tue, 26 May 2020 12:14:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/api/dto/APIReportResult.java | 2 + .../api/service/APIReportService.java | 29 +- .../base/domain/ApiTestReport.java | 2 - .../base/domain/ApiTestReportDetail.java | 15 + .../domain/ApiTestReportDetailExample.java | 340 ++++++++++++++++++ .../mapper/ApiTestReportDetailMapper.java | 36 ++ .../base/mapper/ApiTestReportDetailMapper.xml | 217 +++++++++++ .../base/mapper/ApiTestReportMapper.java | 6 - .../base/mapper/ApiTestReportMapper.xml | 71 +--- .../mapper/ext/ExtApiTestReportMapper.xml | 2 +- .../commons/utils/CompressUtils.java | 66 +++- .../io/metersphere/config/MybatisConfig.java | 2 + .../db/migration/V2__metersphere_ddl.sql | 67 ++-- 13 files changed, 730 insertions(+), 125 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetail.java create mode 100644 backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetailExample.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.xml diff --git a/backend/src/main/java/io/metersphere/api/dto/APIReportResult.java b/backend/src/main/java/io/metersphere/api/dto/APIReportResult.java index 30d6377e79..24ce8bff11 100644 --- a/backend/src/main/java/io/metersphere/api/dto/APIReportResult.java +++ b/backend/src/main/java/io/metersphere/api/dto/APIReportResult.java @@ -13,4 +13,6 @@ public class APIReportResult extends ApiTestReport { private String projectName; private String userName; + + private String content; } diff --git a/backend/src/main/java/io/metersphere/api/service/APIReportService.java b/backend/src/main/java/io/metersphere/api/service/APIReportService.java index 2f2b463245..56916e1bbe 100644 --- a/backend/src/main/java/io/metersphere/api/service/APIReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/APIReportService.java @@ -5,9 +5,8 @@ import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.DeleteAPIReportRequest; import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.api.jmeter.TestResult; -import io.metersphere.base.domain.ApiTest; -import io.metersphere.base.domain.ApiTestReport; -import io.metersphere.base.domain.ApiTestReportExample; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ApiTestReportDetailMapper; import io.metersphere.base.mapper.ApiTestReportMapper; import io.metersphere.base.mapper.ext.ExtApiTestReportMapper; import io.metersphere.commons.constants.APITestStatus; @@ -18,6 +17,7 @@ import io.metersphere.i18n.Translator; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.nio.charset.StandardCharsets; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.List; @@ -33,6 +33,8 @@ public class APIReportService { @Resource private ApiTestReportMapper apiTestReportMapper; @Resource + private ApiTestReportDetailMapper apiTestReportDetailMapper; + @Resource private ExtApiTestReportMapper extApiTestReportMapper; public List list(QueryAPIReportRequest request) { @@ -44,7 +46,12 @@ public class APIReportService { } public APIReportResult get(String reportId) { - return extApiTestReportMapper.get(reportId); + APIReportResult result = extApiTestReportMapper.get(reportId); + ApiTestReportDetail detail = apiTestReportDetailMapper.selectByPrimaryKey(reportId); + if (detail != null) { + result.setContent(new String(detail.getContent(), StandardCharsets.UTF_8)); + } + return result; } public List listByTestId(String testId) { @@ -52,6 +59,7 @@ public class APIReportService { } public void delete(DeleteAPIReportRequest request) { + apiTestReportDetailMapper.deleteByPrimaryKey(request.getId()); apiTestReportMapper.deleteByPrimaryKey(request.getId()); } @@ -59,6 +67,10 @@ public class APIReportService { ApiTestReportExample example = new ApiTestReportExample(); example.createCriteria().andTestIdEqualTo(testId); apiTestReportMapper.deleteByExample(example); + + ApiTestReportDetailExample detailExample = new ApiTestReportDetailExample(); + detailExample.createCriteria().andTestIdEqualTo(testId); + apiTestReportDetailMapper.deleteByExample(detailExample); } public void complete(TestResult result) { @@ -66,7 +78,14 @@ public class APIReportService { if (report == null) { MSException.throwException(Translator.get("api_report_is_null")); } - report.setContent(JSONObject.toJSONString(result)); + // report detail + ApiTestReportDetail detail = new ApiTestReportDetail(); + detail.setReportId(report.getId()); + detail.setTestId(report.getTestId()); + detail.setContent(JSONObject.toJSONString(result).getBytes(StandardCharsets.UTF_8)); + apiTestReportDetailMapper.insert(detail); + + // report report.setUpdateTime(System.currentTimeMillis()); report.setStatus(APITestStatus.Completed.name()); apiTestReportMapper.updateByPrimaryKeySelective(report); diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestReport.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestReport.java index 821d6fec6e..76dc6a3c33 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestReport.java @@ -21,7 +21,5 @@ public class ApiTestReport implements Serializable { private String userId; - private String content; - private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetail.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetail.java new file mode 100644 index 0000000000..6eb915899b --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetail.java @@ -0,0 +1,15 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class ApiTestReportDetail implements Serializable { + private String reportId; + + private String testId; + + private byte[] content; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetailExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetailExample.java new file mode 100644 index 0000000000..2bdf760dd3 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestReportDetailExample.java @@ -0,0 +1,340 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class ApiTestReportDetailExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public ApiTestReportDetailExample() { + 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 andReportIdIsNull() { + addCriterion("report_id is null"); + return (Criteria) this; + } + + public Criteria andReportIdIsNotNull() { + addCriterion("report_id is not null"); + return (Criteria) this; + } + + public Criteria andReportIdEqualTo(String value) { + addCriterion("report_id =", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotEqualTo(String value) { + addCriterion("report_id <>", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdGreaterThan(String value) { + addCriterion("report_id >", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdGreaterThanOrEqualTo(String value) { + addCriterion("report_id >=", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLessThan(String value) { + addCriterion("report_id <", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLessThanOrEqualTo(String value) { + addCriterion("report_id <=", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdLike(String value) { + addCriterion("report_id like", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotLike(String value) { + addCriterion("report_id not like", value, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdIn(List values) { + addCriterion("report_id in", values, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotIn(List values) { + addCriterion("report_id not in", values, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdBetween(String value1, String value2) { + addCriterion("report_id between", value1, value2, "reportId"); + return (Criteria) this; + } + + public Criteria andReportIdNotBetween(String value1, String value2) { + addCriterion("report_id not between", value1, value2, "reportId"); + return (Criteria) this; + } + + public Criteria andTestIdIsNull() { + addCriterion("test_id is null"); + return (Criteria) this; + } + + public Criteria andTestIdIsNotNull() { + addCriterion("test_id is not null"); + return (Criteria) this; + } + + public Criteria andTestIdEqualTo(String value) { + addCriterion("test_id =", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotEqualTo(String value) { + addCriterion("test_id <>", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdGreaterThan(String value) { + addCriterion("test_id >", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdGreaterThanOrEqualTo(String value) { + addCriterion("test_id >=", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLessThan(String value) { + addCriterion("test_id <", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLessThanOrEqualTo(String value) { + addCriterion("test_id <=", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdLike(String value) { + addCriterion("test_id like", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotLike(String value) { + addCriterion("test_id not like", value, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdIn(List values) { + addCriterion("test_id in", values, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotIn(List values) { + addCriterion("test_id not in", values, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdBetween(String value1, String value2) { + addCriterion("test_id between", value1, value2, "testId"); + return (Criteria) this; + } + + public Criteria andTestIdNotBetween(String value1, String value2) { + addCriterion("test_id not between", value1, value2, "testId"); + 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/ApiTestReportDetailMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.java new file mode 100644 index 0000000000..6ae36cc74e --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.java @@ -0,0 +1,36 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.ApiTestReportDetail; +import io.metersphere.base.domain.ApiTestReportDetailExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface ApiTestReportDetailMapper { + long countByExample(ApiTestReportDetailExample example); + + int deleteByExample(ApiTestReportDetailExample example); + + int deleteByPrimaryKey(String reportId); + + int insert(ApiTestReportDetail record); + + int insertSelective(ApiTestReportDetail record); + + List selectByExampleWithBLOBs(ApiTestReportDetailExample example); + + List selectByExample(ApiTestReportDetailExample example); + + ApiTestReportDetail selectByPrimaryKey(String reportId); + + int updateByExampleSelective(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example); + + int updateByExampleWithBLOBs(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example); + + int updateByExample(@Param("record") ApiTestReportDetail record, @Param("example") ApiTestReportDetailExample example); + + int updateByPrimaryKeySelective(ApiTestReportDetail record); + + int updateByPrimaryKeyWithBLOBs(ApiTestReportDetail record); + + int updateByPrimaryKey(ApiTestReportDetail record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.xml new file mode 100644 index 0000000000..86d5daa24d --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportDetailMapper.xml @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + 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} + + + + + + + + + + + report_id, test_id + + + content + + + + + + delete from api_test_report_detail + where report_id = #{reportId,jdbcType=VARCHAR} + + + delete from api_test_report_detail + + + + + + insert into api_test_report_detail (report_id, test_id, content + ) + values (#{reportId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARBINARY} + ) + + + insert into api_test_report_detail + + + report_id, + + + test_id, + + + content, + + + + + #{reportId,jdbcType=VARCHAR}, + + + #{testId,jdbcType=VARCHAR}, + + + #{content,jdbcType=LONGVARBINARY}, + + + + + + update api_test_report_detail + + + report_id = #{record.reportId,jdbcType=VARCHAR}, + + + test_id = #{record.testId,jdbcType=VARCHAR}, + + + content = #{record.content,jdbcType=LONGVARBINARY}, + + + + + + + + update api_test_report_detail + set report_id = #{record.reportId,jdbcType=VARCHAR}, + test_id = #{record.testId,jdbcType=VARCHAR}, + content = #{record.content,jdbcType=LONGVARBINARY} + + + + + + update api_test_report_detail + set report_id = #{record.reportId,jdbcType=VARCHAR}, + test_id = #{record.testId,jdbcType=VARCHAR} + + + + + + update api_test_report_detail + + + test_id = #{testId,jdbcType=VARCHAR}, + + + content = #{content,jdbcType=LONGVARBINARY}, + + + where report_id = #{reportId,jdbcType=VARCHAR} + + + update api_test_report_detail + set test_id = #{testId,jdbcType=VARCHAR}, + content = #{content,jdbcType=LONGVARBINARY} + where report_id = #{reportId,jdbcType=VARCHAR} + + + update api_test_report_detail + set test_id = #{testId,jdbcType=VARCHAR} + where report_id = #{reportId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.java index 083193942c..6888e61a55 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.java @@ -16,21 +16,15 @@ public interface ApiTestReportMapper { int insertSelective(ApiTestReport record); - List selectByExampleWithBLOBs(ApiTestReportExample example); - List selectByExample(ApiTestReportExample example); ApiTestReport selectByPrimaryKey(String id); int updateByExampleSelective(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example); - int updateByExampleWithBLOBs(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example); - int updateByExample(@Param("record") ApiTestReport record, @Param("example") ApiTestReportExample example); int updateByPrimaryKeySelective(ApiTestReport record); - int updateByPrimaryKeyWithBLOBs(ApiTestReport record); - int updateByPrimaryKey(ApiTestReport record); } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.xml index 7e32338505..1c04f203e1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestReportMapper.xml @@ -11,9 +11,6 @@ - - - @@ -75,25 +72,6 @@ id, test_id, name, description, create_time, update_time, status, user_id - - content - - - select - , - from api_test_report where id = #{id,jdbcType=VARCHAR} @@ -129,12 +105,10 @@ insert into api_test_report (id, test_id, name, description, create_time, update_time, - status, user_id, content - ) + status, user_id) values (#{id,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, - #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR} - ) + #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}) insert into api_test_report @@ -163,9 +137,6 @@ user_id, - - content, - @@ -192,9 +163,6 @@ #{userId,jdbcType=VARCHAR}, - - #{content,jdbcType=LONGVARCHAR}, - SELECT r.*, t.name AS test_name, project.name AS project_name, user.name AS user_name FROM api_test_report r JOIN api_test t ON r.test_id = t.id - JOIN project ON project.id = t.project_id + LEFT JOIN project ON project.id = t.project_id LEFT JOIN user ON user.id = r.user_id r.id = #{id} diff --git a/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java b/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java index 0324686b97..04017e0fb4 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/CompressUtils.java @@ -2,17 +2,15 @@ package io.metersphere.commons.utils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; +import java.util.zip.*; public class CompressUtils { /*** - * 压缩Zip + * Zip压缩 * - * @param data - * @return + * @param data 待压缩数据 + * @return 压缩后数据 */ public static Object zip(Object data) { if (!(data instanceof byte[])) { @@ -40,10 +38,10 @@ public class CompressUtils { } /*** - * 解压Zip + * Zip解压 * - * @param data - * @return + * @param data 待解压数据 + * @return 解压后数据 */ public static Object unzip(Object data) { if (!(data instanceof byte[])) { @@ -72,4 +70,54 @@ public class CompressUtils { } return b; } + + /** + * GZip压缩 + * + * @param data 待压缩数据 + * @return 压缩后数 + */ + public static Object compress(Object data) { + if (!(data instanceof byte[])) { + return data; + } + byte[] bytes = (byte[]) data; + try (ByteArrayOutputStream obj = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(obj)) { + gzip.write(bytes); + gzip.flush(); + gzip.finish(); + return obj.toByteArray(); + } catch (Exception e) { + LogUtil.error(e); + return data; + } + } + + /** + * GZip解压 + * + * @param data 待解压数据 + * @return 解压后数据 + */ + public static Object decompress(Object data) { + if (!(data instanceof byte[])) { + return data; + } + byte[] bytes = (byte[]) data; + if (bytes.length == 0) { + return bytes; + } + try (GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(bytes)); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + byte[] buffer = new byte[8192]; + int len; + while ((len = gis.read(buffer)) > 0) { + baos.write(buffer, 0, len); + } + baos.flush(); + return baos.toByteArray(); + } catch (Exception e) { + LogUtil.error(e); + return data; + } + } } diff --git a/backend/src/main/java/io/metersphere/config/MybatisConfig.java b/backend/src/main/java/io/metersphere/config/MybatisConfig.java index 0d8b6eba21..05b825e6ee 100644 --- a/backend/src/main/java/io/metersphere/config/MybatisConfig.java +++ b/backend/src/main/java/io/metersphere/config/MybatisConfig.java @@ -1,6 +1,7 @@ package io.metersphere.config; import com.github.pagehelper.PageInterceptor; +import io.metersphere.base.domain.ApiTestReportDetail; import io.metersphere.base.domain.FileContent; import io.metersphere.base.domain.TestResource; import io.metersphere.commons.utils.CompressUtils; @@ -41,6 +42,7 @@ public class MybatisConfig { MybatisInterceptor interceptor = new MybatisInterceptor(); List configList = new ArrayList<>(); configList.add(new MybatisInterceptorConfig(FileContent.class, "file", CompressUtils.class, "zip", "unzip")); + configList.add(new MybatisInterceptorConfig(ApiTestReportDetail.class, "content", CompressUtils.class, "compress", "decompress")); configList.add(new MybatisInterceptorConfig(TestResource.class, "configuration")); interceptor.setInterceptorConfigList(configList); return interceptor; diff --git a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql index a5b21bc7e2..c4771e9f6d 100644 --- a/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql +++ b/backend/src/main/resources/db/migration/V2__metersphere_ddl.sql @@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `file_content` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `file_metadata` ( `id` varchar(64) NOT NULL COMMENT 'File ID', @@ -15,10 +15,7 @@ CREATE TABLE IF NOT EXISTS `file_metadata` ( `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 - COLLATE = utf8mb4_general_ci; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin; CREATE TABLE `load_test` ( `id` varchar(50) NOT NULL COMMENT 'Test ID', @@ -34,15 +31,13 @@ CREATE TABLE `load_test` ( `test_resource_pool_id` varchar(50) DEFAULT NULL, `user_id` varchar(64) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `load_test_file` ( `test_id` varchar(64) DEFAULT NULL, `file_id` varchar(64) DEFAULT NULL, UNIQUE KEY `load_test_file_unique_key` (`test_id`, `file_id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='测试和文件的关联表'; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT ='测试和文件的关联表'; CREATE TABLE `load_test_report` ( `id` varchar(50) NOT NULL COMMENT 'Test report ID', @@ -54,14 +49,14 @@ CREATE TABLE `load_test_report` ( `status` varchar(64) NOT NULL COMMENT 'Status of this test run', `user_id` varchar(64) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `load_test_report_detail` ( `report_id` varchar(50) NOT NULL, `content` longtext, `part` bigint(11) NOT NULL, PRIMARY KEY (`report_id`,`part`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `load_test_report_log` ( `id` varchar(50) NOT NULL, @@ -71,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `load_test_report_log` ( `part` bigint(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `load_test_report_log_report_id_resource_name_index` (`report_id`,`resource_id`,`part`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `load_test_report_result` ( `id` varchar(50) NOT NULL, @@ -80,7 +75,7 @@ CREATE TABLE IF NOT EXISTS `load_test_report_result` ( `report_value` text , PRIMARY KEY (`id`), KEY `load_test_report_result_report_id_report_key_index` (`report_id`,`report_key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `organization` ( @@ -93,7 +88,7 @@ CREATE TABLE IF NOT EXISTS `organization` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `project` ( `id` varchar(50) NOT NULL COMMENT 'Project ID', @@ -106,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `project` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `role` ( `id` varchar(50) NOT NULL COMMENT 'Role ID', @@ -119,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `role` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `system_parameter` ( `param_key` varchar(64) CHARACTER SET utf8mb4 NOT NULL COMMENT 'Parameter name', @@ -130,7 +125,7 @@ CREATE TABLE IF NOT EXISTS `system_parameter` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_resource` ( `id` varchar(50) NOT NULL COMMENT 'Test resource ID', @@ -143,7 +138,7 @@ CREATE TABLE IF NOT EXISTS `test_resource` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_resource_pool` ( `id` varchar(50) NOT NULL COMMENT 'Test resource pool ID', @@ -157,7 +152,7 @@ CREATE TABLE IF NOT EXISTS `test_resource_pool` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `user` ( `id` varchar(50) COLLATE utf8mb4_bin NOT NULL COMMENT 'User ID', @@ -175,7 +170,7 @@ CREATE TABLE IF NOT EXISTS `user` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `user_role` ( `id` varchar(50) NOT NULL COMMENT 'ID of user''s role info', @@ -188,7 +183,7 @@ CREATE TABLE IF NOT EXISTS `user_role` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `workspace` ( `id` varchar(50) NOT NULL COMMENT 'Workspace ID ', @@ -201,7 +196,7 @@ CREATE TABLE IF NOT EXISTS `workspace` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; -- api start @@ -217,22 +212,19 @@ CREATE TABLE IF NOT EXISTS `api_test` ( `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 COLLATE=utf8mb4_general_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `api_test_file` ( `test_id` varchar(64) DEFAULT NULL, `file_id` varchar(64) DEFAULT NULL, UNIQUE KEY `api_test_file_unique_key` (`test_id`, `file_id`) -) - ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='Api test test file relevance table'; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT ='Api test test file relevance table'; CREATE TABLE IF NOT EXISTS `api_test_report` ( `id` varchar(50) NOT NULL COMMENT 'Test report ID', `test_id` varchar(50) NOT NULL COMMENT 'Test ID this test report belongs to', `name` varchar(64) NOT NULL COMMENT 'Test report name', `description` varchar(255) DEFAULT NULL COMMENT 'Test report name', - `content` longtext, `create_time` bigint(13) NOT NULL COMMENT 'Create timestamp', `update_time` bigint(13) NOT NULL COMMENT 'Update timestamp', `status` varchar(64) NOT NULL COMMENT 'Status of this test run', @@ -241,7 +233,14 @@ CREATE TABLE IF NOT EXISTS `api_test_report` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; + +CREATE TABLE IF NOT EXISTS `api_test_report_detail` ( + `report_id` varchar(64) NOT NULL COMMENT 'API Test Report ID', + `test_id` varchar(64) NOT NULL COMMENT 'Test ID', + `content` longblob COMMENT 'Report content', + PRIMARY KEY (`report_id`) +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin; -- api end @@ -266,7 +265,7 @@ CREATE TABLE IF NOT EXISTS `test_plan` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_case_node` ( @@ -281,7 +280,7 @@ CREATE TABLE IF NOT EXISTS `test_case_node` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_case` ( @@ -303,7 +302,7 @@ CREATE TABLE IF NOT EXISTS `test_case` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_plan_test_case` ( @@ -321,7 +320,7 @@ CREATE TABLE IF NOT EXISTS `test_plan_test_case` ( ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci; + COLLATE = utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_case_report_template` ( `id` varchar(50) NOT NULL, @@ -332,7 +331,7 @@ CREATE TABLE IF NOT EXISTS `test_case_report_template` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 - COLLATE=utf8mb4_general_ci; + COLLATE=utf8mb4_bin; CREATE TABLE IF NOT EXISTS `test_case_report` ( `id` varchar(50) NOT NULL, @@ -344,7 +343,7 @@ CREATE TABLE IF NOT EXISTS `test_case_report` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 - COLLATE=utf8mb4_general_ci; + COLLATE=utf8mb4_bin; -- track end