适配TinyInt
This commit is contained in:
@@ -11,21 +11,18 @@ import java.io.IOException;
|
||||
* @Description:
|
||||
* @date 2025-03-07 13:32
|
||||
*/
|
||||
public class TinyIntTypeAdapter extends TypeAdapter<Number> {
|
||||
public class TinyIntTypeAdapter extends TypeAdapter<Byte> {
|
||||
@Override
|
||||
public void write(JsonWriter out, Number value) throws IOException {
|
||||
public void write(JsonWriter out, Byte value) throws IOException {
|
||||
if (value == null) {
|
||||
out.nullValue();
|
||||
} else {
|
||||
out.value(value.intValue()); // 强制转换为整数
|
||||
out.value(value.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number read(JsonReader in) throws IOException {
|
||||
if (in.peek() == null) {
|
||||
return null;
|
||||
}
|
||||
return in.nextInt(); // 读取为整数
|
||||
public Byte read(JsonReader in) throws IOException {
|
||||
throw new UnsupportedOperationException("Unreadable");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.test.test.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fatboyindustrial.gsonjavatime.LocalDateTimeConverter;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.test.common.utils.DateUtils;
|
||||
import com.test.common.utils.JMeterUtil;
|
||||
import com.test.common.utils.MySQLExecutor;
|
||||
import com.test.common.utils.StringUtils;
|
||||
import com.test.common.utils.sql.TinyIntTypeAdapter;
|
||||
import com.test.test.domain.TestCase;
|
||||
import com.test.test.domain.TestCaseResult;
|
||||
import com.test.test.domain.TestCaseStep;
|
||||
@@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -258,14 +261,12 @@ public class TestCaseServiceImpl implements ITestCaseService
|
||||
SqlResult sqlResult = new SqlResult();
|
||||
sqlResult.setColumnNameList(columnNameList);
|
||||
sqlResult.setResultMapList(resultMapList);
|
||||
// Gson gson = new GsonBuilder()
|
||||
// .registerTypeAdapter(Integer.class, new TinyIntTypeAdapter())
|
||||
// .registerTypeAdapter(int.class, new TinyIntTypeAdapter())
|
||||
// .registerTypeAdapter(LocalDateTime.class, new LocalDateTimeConverter())
|
||||
// .create();
|
||||
// testCaseResult.setSqlResult(gson.toJson(sqlResult));
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
testCaseResult.setSqlResult(objectMapper.writeValueAsString(sqlResult));
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(Integer.class, new TinyIntTypeAdapter())
|
||||
.registerTypeAdapter(int.class, new TinyIntTypeAdapter())
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeConverter())
|
||||
.create();
|
||||
testCaseResult.setSqlResult(gson.toJson(sqlResult));
|
||||
// 处理参数提取
|
||||
Map<String, String> assignmentResultMap = new HashMap<>();
|
||||
String assignmentResult = this.dealDataSourceTestCaseStepAssignment(resultMapList, assignmentResultMap, assignment);
|
||||
|
||||
Reference in New Issue
Block a user