refactor(ai): 重构AI模块文件处理和模型管理功能
- 修改AbstractFileClient移除域名拼接逻辑 - 将getModel接口改为getEnabledModels批量获取已启用模型 - 更新AiSampleMapper查询语句改用LEFT JOIN并添加筛选条件 - 移除application-local.yaml中的file-server配置项 - 添加ImgJsonSerializer组件处理图片URL序列化 - 优化AiSampleServiceImpl文件上传逻辑 - 调整分页参数验证注解格式
This commit is contained in:
@@ -26,7 +26,7 @@ public class PageParam implements Serializable {
|
||||
/**
|
||||
* 页码,从 1 开始", example = "1
|
||||
*/
|
||||
@NotNull(message = "页码不能为空")
|
||||
@NotNull(message = "页码不能为空" )
|
||||
@Min(value = 1, message = "页码最小值为 1")
|
||||
private Integer pageNo = 1;
|
||||
|
||||
|
||||
@@ -1,64 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
||||
*
|
||||
* https://www.mall4j.com/
|
||||
*
|
||||
* 未经允许,不可做商业用途!
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.tashow.cloud.common.util.serializer;
|
||||
package com.tashow.cloud.common.serializer;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lanhai
|
||||
* 图片URL序列化器
|
||||
* 自动为相对路径的图片添加文件服务器前缀
|
||||
*/
|
||||
@Component
|
||||
public class ImgJsonSerializer extends JsonSerializer<String> {
|
||||
|
||||
/* @Autowired
|
||||
private Qiniu qiniu;
|
||||
@Autowired
|
||||
private ImgUploadUtil imgUploadUtil;*/
|
||||
@Value("${file-server}")
|
||||
private String fileServer;
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
/*if (StrUtil.isBlank(value)) {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
gen.writeString(StrUtil.EMPTY);
|
||||
return;
|
||||
}
|
||||
String[] imgs = value.split(StrUtil.COMMA);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String resourceUrl = "";
|
||||
String rule="^((http[s]{0,1})://)";
|
||||
Pattern pattern= Pattern.compile(rule);
|
||||
if (Objects.equals(imgUploadUtil.getUploadType(), 2)) {
|
||||
resourceUrl = qiniu.getResourcesUrl();
|
||||
} else if (Objects.equals(imgUploadUtil.getUploadType(), 1)) {
|
||||
resourceUrl = imgUploadUtil.getResourceUrl();
|
||||
}
|
||||
String rule = "^((http[s]{0,1})://)";
|
||||
Pattern pattern = Pattern.compile(rule);
|
||||
|
||||
resourceUrl = fileServer;
|
||||
|
||||
for (String img : imgs) {
|
||||
Matcher matcher = pattern.matcher(img);
|
||||
//若图片以http或https开头,直接返回
|
||||
if (matcher.find()){
|
||||
if (matcher.find()) {
|
||||
sb.append(img).append(StrUtil.COMMA);
|
||||
}else {
|
||||
} else {
|
||||
sb.append(resourceUrl).append(img).append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
sb.deleteCharAt(sb.length()-1);
|
||||
gen.writeString(sb.toString());*/
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
gen.writeString(sb.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user