build: 配置数据库大字段压缩

This commit is contained in:
CaptainB 2023-05-26 11:05:56 +08:00
parent 877289c576
commit 5230734a8a
3 changed files with 67 additions and 11 deletions

View File

@ -5,12 +5,8 @@ import com.github.pagehelper.PageInterceptor;
import com.zaxxer.hikari.HikariDataSource;
import io.metersphere.sdk.interceptor.MybatisInterceptor;
import io.metersphere.sdk.interceptor.UserDesensitizationInterceptor;
import io.metersphere.sdk.util.CompressUtils;
import io.metersphere.sdk.util.MybatisInterceptorConfig;
import io.metersphere.system.domain.AuthSource;
import io.metersphere.system.domain.TestResource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
@ -29,7 +25,6 @@ import java.util.Properties;
@EnableTransactionManagement
public class MybatisConfig {
@Bean
@ConditionalOnMissingBean
public PageInterceptor pageInterceptor() {
PageInterceptor pageInterceptor = new PageInterceptor();
Properties properties = new Properties();
@ -43,13 +38,14 @@ public class MybatisConfig {
}
@Bean
@ConditionalOnMissingBean
public MybatisInterceptor dbInterceptor() {
public MybatisInterceptor dbInterceptor(List<MybatisInterceptorConfig>[] interceptorConfigs) {
List<MybatisInterceptorConfig> mybatisInterceptorConfigs = new ArrayList<>();
for (List<MybatisInterceptorConfig> configList : interceptorConfigs) {
mybatisInterceptorConfigs.addAll(configList);
}
// 统一配置
MybatisInterceptor interceptor = new MybatisInterceptor();
List<MybatisInterceptorConfig> configList = new ArrayList<>();
configList.add(new MybatisInterceptorConfig(TestResource.class, "configuration", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(AuthSource.class, "configuration", CompressUtils.class, "zip", "unzip"));
interceptor.setInterceptorConfigList(configList);
interceptor.setInterceptorConfigList(mybatisInterceptorConfigs);
return interceptor;
}

View File

@ -0,0 +1,30 @@
package io.metersphere.sdk.config.interceptor;
import io.metersphere.project.domain.*;
import io.metersphere.sdk.util.CompressUtils;
import io.metersphere.sdk.util.MybatisInterceptorConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class ProjectCompressInterceptor {
@Bean
public List<MybatisInterceptorConfig> projectCompressConfigs() {
List<MybatisInterceptorConfig> configList = new ArrayList<>();
configList.add(new MybatisInterceptorConfig(FileModuleBlob.class, "repositoryDesc", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(ProjectExtend.class, "issueConfig", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FileMetadataBlob.class, "gitInfo", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FakeErrorBlob.class, "description", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(FakeErrorBlob.class, "content", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "script", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "result", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(CustomFunctionBlob.class, "params", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(CustomFieldTemplate.class, "defaultValue", CompressUtils.class, "zip", "unzip"));
return configList;
}
}

View File

@ -0,0 +1,30 @@
package io.metersphere.sdk.config.interceptor;
import io.metersphere.sdk.util.CompressUtils;
import io.metersphere.sdk.util.MybatisInterceptorConfig;
import io.metersphere.system.domain.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class SystemCompressInterceptor {
@Bean
public List<MybatisInterceptorConfig> systemCompressConfigs() {
List<MybatisInterceptorConfig> configList = new ArrayList<>();
configList.add(new MybatisInterceptorConfig(TestResource.class, "configuration", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(AuthSource.class, "configuration", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(NoviceStatistics.class, "dataOption", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(OperatingLog.class, "operContent", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(OperatingLog.class, "operParams", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formOption", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formScript", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(ServiceIntegration.class, "configuration", CompressUtils.class, "zip", "unzip"));
configList.add(new MybatisInterceptorConfig(UserExtend.class, "platformInfo", CompressUtils.class, "zip", "unzip"));
return configList;
}
}