feat(aicompanion): 重构AI陪聊DO并新增文本数组处理器
- 将personalityTags字段由Object改为List<String>并引入TextArrayTypeHandler - 在DO中增加deleted逻辑删除字段并启用autoResultMap - 简化SaveReqVO,移除创建/更新时间字段并补充prologue等字段描述 - 新增.gitignore忽略/.omc/目录
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.yolo.keyboard.framework.mybatis.core.type;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PostgreSQL text[] 数组类型处理器
|
||||
* 将 Java List<String> 与 PostgreSQL text[] 互相转换
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@MappedJdbcTypes(JdbcType.ARRAY)
|
||||
@MappedTypes(List.class)
|
||||
public class TextArrayTypeHandler extends BaseTypeHandler<List<String>> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, List<String> parameter, JdbcType jdbcType) throws SQLException {
|
||||
Connection conn = ps.getConnection();
|
||||
Array array = conn.createArrayOf("text", parameter.toArray(new String[0]));
|
||||
ps.setArray(i, array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return toList(rs.getArray(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return toList(rs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return toList(cs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
private List<String> toList(Array array) throws SQLException {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
String[] strings = (String[]) array.getArray();
|
||||
return Arrays.asList(strings);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user