feat(aicompanion): 重构AI陪聊DO并新增文本数组处理器
- 将personalityTags字段由Object改为List<String>并引入TextArrayTypeHandler - 在DO中增加deleted逻辑删除字段并启用autoResultMap - 简化SaveReqVO,移除创建/更新时间字段并补充prologue等字段描述 - 新增.gitignore忽略/.omc/目录
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -52,3 +52,4 @@ application-my.yaml
|
|||||||
|
|
||||||
/yolo-ui-app/unpackage/
|
/yolo-ui-app/unpackage/
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
/.omc/
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class KeyboardAiCompanionPageReqVO extends PageParam {
|
|||||||
private String introText;
|
private String introText;
|
||||||
|
|
||||||
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
||||||
private Object personalityTags;
|
private List<String> personalityTags;
|
||||||
|
|
||||||
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
||||||
private String speakingStyle;
|
private String speakingStyle;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class KeyboardAiCompanionRespVO {
|
|||||||
|
|
||||||
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
||||||
@ExcelProperty("角色性格标签数组(如:温柔、黏人、治愈)")
|
@ExcelProperty("角色性格标签数组(如:温柔、黏人、治愈)")
|
||||||
private Object personalityTags;
|
private List<String> personalityTags;
|
||||||
|
|
||||||
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
||||||
@ExcelProperty("角色说话风格(如:撒娇型、理性型、活泼型)")
|
@ExcelProperty("角色说话风格(如:撒娇型、理性型、活泼型)")
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class KeyboardAiCompanionSaveReqVO {
|
|||||||
private String introText;
|
private String introText;
|
||||||
|
|
||||||
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
@Schema(description = "角色性格标签数组(如:温柔、黏人、治愈)")
|
||||||
private Object personalityTags;
|
private List<String> personalityTags;
|
||||||
|
|
||||||
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
@Schema(description = "角色说话风格(如:撒娇型、理性型、活泼型)")
|
||||||
private String speakingStyle;
|
private String speakingStyle;
|
||||||
@@ -60,14 +60,6 @@ public class KeyboardAiCompanionSaveReqVO {
|
|||||||
@Schema(description = "角色热度评分,用于推荐排序")
|
@Schema(description = "角色热度评分,用于推荐排序")
|
||||||
private Integer popularityScore;
|
private Integer popularityScore;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotNull(message = "创建时间不能为空")
|
|
||||||
private LocalDateTime createdAt;
|
|
||||||
|
|
||||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotNull(message = "更新时间不能为空")
|
|
||||||
private LocalDateTime updatedAt;
|
|
||||||
|
|
||||||
@Schema(description = "开场白")
|
@Schema(description = "开场白")
|
||||||
private String prologue;
|
private String prologue;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.yolo.keyboard.dal.dataobject.aicompanion;
|
package com.yolo.keyboard.dal.dataobject.aicompanion;
|
||||||
|
|
||||||
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;import lombok.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.yolo.keyboard.framework.mybatis.core.type.TextArrayTypeHandler;
|
||||||
|
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +14,7 @@ import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
|||||||
*
|
*
|
||||||
* @author ziin
|
* @author ziin
|
||||||
*/
|
*/
|
||||||
@TableName("keyboard_ai_companion")
|
@TableName(value = "keyboard_ai_companion", autoResultMap = true)
|
||||||
@KeySequence("keyboard_ai_companion_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
@KeySequence("keyboard_ai_companion_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@@ -58,7 +60,8 @@ public class KeyboardAiCompanionDO {
|
|||||||
/**
|
/**
|
||||||
* 角色性格标签数组(如:温柔、黏人、治愈)
|
* 角色性格标签数组(如:温柔、黏人、治愈)
|
||||||
*/
|
*/
|
||||||
private Object personalityTags;
|
@TableField(typeHandler = TextArrayTypeHandler.class)
|
||||||
|
private List<String> personalityTags;
|
||||||
/**
|
/**
|
||||||
* 角色说话风格(如:撒娇型、理性型、活泼型)
|
* 角色说话风格(如:撒娇型、理性型、活泼型)
|
||||||
*/
|
*/
|
||||||
@@ -103,6 +106,10 @@ public class KeyboardAiCompanionDO {
|
|||||||
* 音频Id
|
* 音频Id
|
||||||
*/
|
*/
|
||||||
private String voiceId;
|
private String voiceId;
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Byte deleted;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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