Browse Source

add:向量信息添加操作日志

zhongwei
luyie 2 months ago
parent
commit
25f5bef5fe
  1. 32
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/DataOperateType.java
  2. 26
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java
  3. 99
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamLogController.java
  4. 44
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamLogEntity.java
  5. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamLogMapper.java
  6. 22
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamLogService.java
  7. 76
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamLogServiceImpl.java
  8. 12
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

32
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/DataOperateType.java

@ -0,0 +1,32 @@
package com.hnac.gglm.bigmodel.maintenance.constants;
import lombok.Getter;
/**
* @Author: ypj
* @Date: 2024/9/23 14:18
*/
@Getter
public enum DataOperateType {
CREATE("CREATE", "新增"),
UPDATE("UPDATE", "更新"),
RESET("RESET", "重置"),
DELETE("DELETE", "删除"),
SYNCHRONIZATION("SYNCHRONIZATION", "同步");
private final String code;
private final String msg;
DataOperateType(String code, String msg) {
this.code = code;
this.msg = msg;
}
public static DataOperateType getInstance(String code) {
for (DataOperateType dataOperateType : DataOperateType.values()) {
if (dataOperateType.getCode().equals(code)) {
return dataOperateType;
}
}
return null;
}
}

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

@ -3,7 +3,10 @@ package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService;
import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.hzinfo.api.annotation.ApiInterface; import com.hnac.hzinfo.api.annotation.ApiInterface;
@ -33,6 +36,7 @@ import java.util.Map;
@Slf4j @Slf4j
public class VectorParamController { public class VectorParamController {
private final VectorParamService vectorParamService; private final VectorParamService vectorParamService;
private final VectorParamLogService vectorParamLogService;
@GetMapping("/listPage") @GetMapping("/listPage")
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@ -52,21 +56,37 @@ public class VectorParamController {
@ApiOperation(value = "保存向量参数配置") @ApiOperation(value = "保存向量参数配置")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R save(@RequestBody VectorParamEntity req) { public R save(@RequestBody VectorParamEntity req) {
return R.status(vectorParamService.save(req)); Boolean result = vectorParamService.save(req);
if (result) {
vectorParamLogService.create(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.CREATE.getCode()).build());
}
return R.status(result);
} }
@DeleteMapping("/remove") @DeleteMapping("/remove")
@ApiOperation(value = "删除向量参数配置") @ApiOperation(value = "删除向量参数配置")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamService.removeByIds(Func.toLongList(",", ids))); Boolean result = vectorParamService.removeByIds(Func.toLongList(",", ids));
if (result) {
vectorParamLogService.delete(Func.toLongList(",", ids));
}
return R.status(result);
} }
@PutMapping("/update") @PutMapping("/update")
@ApiOperation(value = "编辑向量参数配置") @ApiOperation(value = "编辑向量参数配置")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R update(@RequestBody VectorParamEntity req) { public R update(@RequestBody VectorParamEntity req) {
return R.status(vectorParamService.updateById(req)); Boolean result = vectorParamService.updateById(req);
if (result) {
vectorParamLogService.edit(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.UPDATE.getCode()).build());
}
return R.status(result);
} }
@GetMapping("/getAuthorization") @GetMapping("/getAuthorization")

99
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamLogController.java

@ -0,0 +1,99 @@
package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
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.*;
/**
* @Author: ypj
* @Date: 2024/9/23 13:50
*/
@RestController
@RequestMapping("/vector/log")
@Api(value = "向量参数配置日志", tags = "向量参数配置日志")
@AllArgsConstructor
@Slf4j
public class VectorParamLogController {
private final VectorParamLogService vectorParamLogService;
@GetMapping("/listPage")
@ApiOperation(value = "分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<VectorParamLogEntity>> listPage(Query query, VectorParamLogEntity req) {
return R.data(vectorParamLogService.page(Condition.getPage(query), Condition.getQueryWrapper(new VectorParamLogEntity(), req)));
}
@GetMapping("/detail")
@ApiOperation(value = "查看详情")
@ApiOperationSupport(order = 2)
public R<VectorParamLogEntity> detail(@RequestParam @ApiParam("主键ID") Long id) {
return R.data(vectorParamLogService.getById(id));
}
@GetMapping("/save")
@ApiOperation(value = "保存向量参数配置日志")
@ApiOperationSupport(order = 3)
public R save(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.save(req));
}
@GetMapping("/remove")
@ApiOperation(value = "删除向量参数配置日志")
@ApiOperationSupport(order = 4)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamLogService.removeByIds(Func.toLongList(",", ids)));
}
@PutMapping("/update")
@ApiOperation(value = "编辑向量参数配置日志")
@ApiOperationSupport(order = 5)
public R update(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.updateById(req));
}
@PostMapping("/create")
@ApiOperation(value = "创建向量参数配置操作记录")
@ApiOperationSupport(order = 6)
public R create(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.create(req));
}
@PostMapping("/edit")
@ApiOperation(value = "编辑向量参数配置操作记录")
@ApiOperationSupport(order = 7)
public R edit(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.edit(req));
}
@PostMapping("/reset")
@ApiOperation(value = "重置向量参数配置操作记录")
@ApiOperationSupport(order = 8)
public R reset(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.reset(req));
}
@PostMapping("/delete")
@ApiOperation(value = "删除向量参数配置操作记录")
@ApiOperationSupport(order = 9)
public R delete(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamLogService.delete(Func.toLongList(",", ids)));
}
@PostMapping("/synchronization")
@ApiOperation(value = "同步向量参数配置操作记录")
@ApiOperationSupport(order = 10)
public R synchronization(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.synchronization(req));
}
}

44
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamLogEntity.java

@ -0,0 +1,44 @@
package com.hnac.gglm.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;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
* @Author: ypj
* @Date: 2024/9/23 12:07
*/
@ApiModel("向量参数配置日志")
@TableName("gglm_vector_param_log")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class VectorParamLogEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("参数id")
@TableField("VECTOR_PARAM_ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long vectorParamId;
@ApiModelProperty("日志内容")
@TableField("CONTENT")
@QueryField(condition = SqlCondition.LIKE)
private String content;
@ApiModelProperty("日志类型,新增CREATE,更新UPDATE,重置RESET")
@TableField("TYPE")
@QueryField(condition = SqlCondition.EQUAL)
private String type;
}

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamLogMapper.java

@ -0,0 +1,13 @@
package com.hnac.gglm.bigmodel.maintenance.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
/**
* @Author: ypj
* @Date: 2024/9/23 13:59
*/
@DS("hznlm")
public interface VectorParamLogMapper extends BaseMapper<VectorParamLogEntity> {
}

22
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamLogService.java

@ -0,0 +1,22 @@
package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import java.util.List;
/**
* @Author: ypj
* @Date: 2024/9/23 13:56
*/
public interface VectorParamLogService extends IService<VectorParamLogEntity> {
Boolean create(VectorParamLogEntity req);
Boolean edit(VectorParamLogEntity req);
Boolean reset(VectorParamLogEntity req);
Boolean delete(List<Long> ids);
Boolean synchronization(VectorParamLogEntity req);
}

76
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamLogServiceImpl.java

@ -0,0 +1,76 @@
package com.hnac.gglm.bigmodel.maintenance.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamLogMapper;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @Author: ypj
* @Date: 2024/9/23 13:57
*/
@Service
@Slf4j
@AllArgsConstructor
@DS("hznlm")
public class VectorParamLogServiceImpl extends ServiceImpl<VectorParamLogMapper, VectorParamLogEntity> implements VectorParamLogService {
@Override
public Boolean create(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.CREATE.getCode());
return save(req);
}
@Override
public Boolean edit(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.UPDATE.getCode());
return save(req);
}
@Override
public Boolean reset(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.RESET.getCode());
return save(req);
}
@Override
public Boolean delete(List<Long> ids) {
ThreadPoolExecutor executor = new ThreadPoolExecutor(5, ids.size() > 5 ? ids.size() : 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
ids.forEach(id -> {
executor.execute(() -> {
save(VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.DELETE.getCode()).build());
});
});
return Boolean.TRUE;
}
@Override
public Boolean synchronization(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.SYNCHRONIZATION.getCode());
return save(req);
}
}

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

@ -12,8 +12,11 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.hnac.gglm.bigmodel.database.service.WeaviateService; import com.hnac.gglm.bigmodel.database.service.WeaviateService;
import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamMapper; import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamMapper;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService;
import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse; import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -40,6 +43,7 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
private static final String CLIENT_SIGN = "vector_param"; private static final String CLIENT_SIGN = "vector_param";
private final WeaviateService weaviateService; private final WeaviateService weaviateService;
private final VectorParamLogService vectorParamLogService;
@Override @Override
public String getAuthorization() { public String getAuthorization() {
@ -157,7 +161,13 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
} }
String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", ""); String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", "");
weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap); weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap);
return this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()))) {
return vectorParamLogService.synchronization(VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.SYNCHRONIZATION.getCode()).build());
} else {
return false;
}
} }
return true; return true;
} }

Loading…
Cancel
Save