Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

zhongwei
ty 3 months ago
parent
commit
91e19ccf7e
  1. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java
  2. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java
  3. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java
  4. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  5. 17
      hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql

34
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java

@ -4,24 +4,30 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: ypj
* @Date: 2024/9/2 16:10
*/
@RestController
@RequestMapping("/vector/")
@RequestMapping("/vector")
@Api(value = "向量参数配置", tags = "向量参数配置")
@AllArgsConstructor
@Slf4j
public class VectorParamController {
private final VectorParamService vectorParamService;
@ -50,7 +56,7 @@ public class VectorParamController {
@ApiOperation(value = "删除向量参数配置")
@ApiOperationSupport(order = 4)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamService.removeByIds(Func.toLongList(",",ids)));
return R.status(vectorParamService.removeByIds(Func.toLongList(",", ids)));
}
@PutMapping("/update")
@ -60,5 +66,29 @@ public class VectorParamController {
return R.status(vectorParamService.updateById(req));
}
@GetMapping("/getAuthorization")
@ApiOperation(value = "获取向量参数配置授权信息")
@ApiOperationSupport(order = 6)
public R<String> getAuthorization() {
return R.data(vectorParamService.getAuthorization());
}
@GetMapping("/getUrlResponse")
@ApiOperation(value = "通过url获取向量参数数据")
@ApiOperationSupport(order = 7)
public R getUrlResponse(@RequestParam String url, @RequestHeader("Blade-Auth") String token) {
return R.data(vectorParamService.getUrlResponse(url, token));
}
@GetMapping("/getTestData")
@ApiOperation(value = "测试数据")
@ApiOperationSupport(order = 8)
@ApiInterface
public R getUrlByte() {
Map<String, String> data = new HashMap<>();
data.put("name", "测试数据");
data.put("url", "https://img.zcool.cn/community/01d9d85a8f9f2fa801206e0d0e0e9a.jpg@1280w_1l_2o_100sh.jpg");
data.put("data", "data");
return R.data(data);
}
}

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -19,17 +20,22 @@ public class VectorParamEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("参数名称")
@TableField("NAME")
private String name;
@ApiModelProperty("url")
@TableField("URL")
private String url;
@ApiModelProperty("项目前缀")
@TableField("PROJECT_PREFIX")
private String projectPrefix;
@ApiModelProperty("数据库表名")
@TableField("TABLE_NAME")
private String tableName;
@ApiModelProperty("向量键值对,json格式")
@TableField("ATTRIBUTE_MAP")
private String attributeMap;
}

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java

@ -3,11 +3,15 @@ package com.hnac.hzims.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import java.util.Map;
/**
* @Author: ypj
* @Date: 2024/09/02 15:11
*/
public interface VectorParamService extends IService<VectorParamEntity> {
String getAuthorization();
Map getUrlResponse(String url, String token);
}

26
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

@ -1,15 +1,41 @@
package com.hnac.hzims.bigmodel.maintenance.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.hzims.bigmodel.maintenance.mapper.VectorParamMapper;
import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
/**
* @Author: ypj
* @Date: 2024/9/2 16:14
*/
@Service
public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, VectorParamEntity> implements VectorParamService {
private static final String CLIENT_SIGN = "vector_param";
@Override
public String getAuthorization() {
return "Basic " + Base64.getEncoder().encodeToString(CLIENT_SIGN.getBytes(StandardCharsets.UTF_8));
}
@Override
public Map getUrlResponse(String url, String token) {
HttpResponse response = HttpRequest.get(url)
.header("Authorization", getAuthorization())
.header("Blade-Auth", token).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
return JsonUtil.toMap(response.body());
}
return null;
}
}

17
hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql

@ -0,0 +1,17 @@
CREATE TABLE `HZIMS_VECTOR_PARAM` (
`ID` bigint(20) NOT NULL COMMENT '主键ID',
`NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '名称',
`URL` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'URL',
`PROJECT_PREFIX` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目前缀',
`TABLE_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '数据库表名',
`ATTRIBUTE_MAP` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '向量键值对',
`TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID',
`STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态',
`CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
`CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
`CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
`UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除',
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '向量键值对信息' ROW_FORMAT = Dynamic;
Loading…
Cancel
Save