暂时取消压缩功能

This commit is contained in:
haifeng414 2020-02-20 12:29:19 +08:00
parent 5f6368d1b5
commit 8239567c9e
3 changed files with 14 additions and 18 deletions

View File

@ -15,14 +15,9 @@ public class CompressUtils {
* @return * @return
*/ */
public static Object zip(Object data) { public static Object zip(Object data) {
if (!(data instanceof byte[]) && !(data instanceof String)) { if (!(data instanceof byte[])) {
return data; return data;
} }
boolean isString = false;
if (data instanceof String) {
isString = true;
data = ((String) data).getBytes();
}
byte[] temp = (byte[]) data; byte[] temp = (byte[]) data;
byte[] b = (byte[]) data; byte[] b = (byte[]) data;
@ -41,9 +36,6 @@ public class CompressUtils {
LogUtil.error(ex); LogUtil.error(ex);
} }
if (isString) {
return new String(b);
}
return b; return b;
} }

View File

@ -3,14 +3,16 @@ package io.metersphere.commons.utils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
@Component @Component
public class DBCompressConfig implements MybatisInterceptorConfigHolder { public class DBCompressConfig implements MybatisInterceptorConfigHolder {
@Override @Override
public List<MybatisInterceptorConfig> interceptorConfig() { public List<MybatisInterceptorConfig> interceptorConfig() {
return Arrays.asList( // return Arrays.asList(
new MybatisInterceptorConfig("io.metersphere.base.domain.FileContent", "file", "io.metersphere.commons.utils.CompressUtils", "zip", "unzip") // new MybatisInterceptorConfig("io.metersphere.base.domain.FileContent", "file", "io.metersphere.commons.utils.CompressUtils", "zip", "unzip")
); // );
return Collections.emptyList();
} }
} }

View File

@ -3,6 +3,7 @@ package io.metersphere;
import io.metersphere.base.domain.User; import io.metersphere.base.domain.User;
import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.UserMapper;
import io.metersphere.commons.utils.CompressUtils;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -11,15 +12,16 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RunWith(SpringRunner.class) //@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) //@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ApplicationTests { public class ApplicationTests {
@Resource // @Resource
UserMapper userMapper; // UserMapper userMapper;
@Test @Test
public void test1() { public void test1() {
List<User> users = userMapper.selectByExample(null); final Object test = CompressUtils.zip("test".getBytes());
System.out.println(users); final Object unzip = CompressUtils.unzip(test);
System.out.println(new String((byte[]) unzip));
} }
} }