知识库检索
parent
d9507d32f3
commit
883925c287
@ -0,0 +1,20 @@
|
||||
package com.pjilisense.flxai.dao;
|
||||
|
||||
import com.pjilisense.flxai.base.dao.BaseDao;
|
||||
import com.pjilisense.flxai.entity.ChunksEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface ChunksDao extends BaseDao<ChunksEntity> {
|
||||
List<Map<String,Object>> queryCsv(Map<String, Object> map);
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.pjilisense.flxai.dao;
|
||||
|
||||
import com.pjilisense.flxai.base.dao.BaseDao;
|
||||
import com.pjilisense.flxai.entity.FileChunksEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface FileChunksDao extends BaseDao<FileChunksEntity> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.pjilisense.flxai.dao;
|
||||
|
||||
import com.pjilisense.flxai.base.dao.BaseDao;
|
||||
import com.pjilisense.flxai.entity.GlobalFilesEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Mapper
|
||||
public interface GlobalFilesDao extends BaseDao<GlobalFilesEntity> {
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.pjilisense.flxai.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "${comments}")
|
||||
public class ChunksDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private UUID id;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String text;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String abstractx;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private Map<String,Object> metadata;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime updatedAt;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String userId;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime accessedAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.pjilisense.flxai.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "${comments}")
|
||||
public class FileChunksDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String fileId;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private UUID chunkId;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.pjilisense.flxai.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "${comments}")
|
||||
public class GlobalFilesDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String hashId;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private Integer size;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
private Map<String,Object> metadata;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
@ApiModelProperty(value = "$column.comments")
|
||||
@JsonSerialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = com.pjilisense.flxai.wrapper.OffsetDateTimeDeserializer.class)
|
||||
private OffsetDateTime accessedAt;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.pjilisense.flxai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.pjilisense.flxai.handle.JsonbTypeHandler;
|
||||
import com.pjilisense.flxai.handle.UUIDTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("chunks")
|
||||
public class ChunksEntity {
|
||||
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
@TableField(typeHandler = UUIDTypeHandler.class)
|
||||
private UUID id;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String text;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
@TableField(value="abstract")
|
||||
private String abstractx;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
@TableField(value = "metadata", typeHandler = JsonbTypeHandler.class)
|
||||
private Map<String,Object> metadata;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private Integer index;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime createdAt;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime updatedAt;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime accessedAt;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.pjilisense.flxai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.pjilisense.flxai.handle.UUIDTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("file_chunks")
|
||||
public class FileChunksEntity {
|
||||
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String fileId;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
@TableField(typeHandler = UUIDTypeHandler.class)
|
||||
private UUID chunkId;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime createdAt;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.pjilisense.flxai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.pjilisense.flxai.handle.JsonbTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Data
|
||||
@TableName("global_files")
|
||||
public class GlobalFilesEntity {
|
||||
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String hashId;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String fileType;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private Integer size;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
@TableField(value = "metadata", typeHandler = JsonbTypeHandler.class)
|
||||
private Map<String,Object> metadata;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime createdAt;
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
private OffsetDateTime accessedAt;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.pjilisense.flxai.service;
|
||||
|
||||
import com.pjilisense.flxai.base.service.CrudService;
|
||||
import com.pjilisense.flxai.dto.ChunksDTO;
|
||||
import com.pjilisense.flxai.entity.ChunksEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
public interface ChunksService extends CrudService<ChunksEntity, ChunksDTO> {
|
||||
|
||||
List<Map<String,Object>> search(String userid,String text);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.pjilisense.flxai.service;
|
||||
|
||||
import com.pjilisense.flxai.base.service.CrudService;
|
||||
import com.pjilisense.flxai.dto.FileChunksDTO;
|
||||
import com.pjilisense.flxai.entity.FileChunksEntity;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
public interface FileChunksService extends CrudService<FileChunksEntity, FileChunksDTO> {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.pjilisense.flxai.service;
|
||||
|
||||
import com.pjilisense.flxai.base.service.CrudService;
|
||||
import com.pjilisense.flxai.dto.GlobalFilesDTO;
|
||||
import com.pjilisense.flxai.entity.GlobalFilesEntity;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
public interface GlobalFilesService extends CrudService<GlobalFilesEntity, GlobalFilesDTO> {
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.pjilisense.flxai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.pjilisense.flxai.base.service.impl.CrudServiceImpl;
|
||||
import com.pjilisense.flxai.dao.FileChunksDao;
|
||||
import com.pjilisense.flxai.dto.FileChunksDTO;
|
||||
import com.pjilisense.flxai.entity.FileChunksEntity;
|
||||
import com.pjilisense.flxai.service.FileChunksService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Service
|
||||
public class FileChunksServiceImpl extends CrudServiceImpl<FileChunksDao, FileChunksEntity, FileChunksDTO> implements FileChunksService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<FileChunksEntity> getWrapper(Map<String, Object> params){
|
||||
String id = (String)params.get("id");
|
||||
|
||||
QueryWrapper<FileChunksEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.pjilisense.flxai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.pjilisense.flxai.base.service.impl.CrudServiceImpl;
|
||||
import com.pjilisense.flxai.dao.GlobalFilesDao;
|
||||
import com.pjilisense.flxai.dto.GlobalFilesDTO;
|
||||
import com.pjilisense.flxai.entity.GlobalFilesEntity;
|
||||
import com.pjilisense.flxai.service.GlobalFilesService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments}
|
||||
*
|
||||
* @author liushujing liushujing@philisense.com
|
||||
* @since 1.0.0 2025-02-10
|
||||
*/
|
||||
@Service
|
||||
public class GlobalFilesServiceImpl extends CrudServiceImpl<GlobalFilesDao, GlobalFilesEntity, GlobalFilesDTO> implements GlobalFilesService {
|
||||
|
||||
@Override
|
||||
public QueryWrapper<GlobalFilesEntity> getWrapper(Map<String, Object> params){
|
||||
String id = (String)params.get("id");
|
||||
|
||||
QueryWrapper<GlobalFilesEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pjilisense.flxai.dao.ChunksDao">
|
||||
|
||||
<resultMap type="com.pjilisense.flxai.entity.ChunksEntity" id="chunksMap">
|
||||
<result property="id" column="id" typeHandler="com.pjilisense.flxai.handle.UUIDTypeHandler"/>
|
||||
<result property="text" column="text"/>
|
||||
<result property="abstractx" column="abstract"/>
|
||||
<result property="metadata" column="metadata" typeHandler="com.pjilisense.flxai.handle.JsonbTypeHandler"/>
|
||||
<result property="index" column="index"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime" />
|
||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime" />
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="accessedAt" column="accessed_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="java.util.Map" id="BaseResultMap">
|
||||
<result property="id" column="id" typeHandler="com.pjilisense.flxai.handle.UUIDTypeHandler"/>
|
||||
<result property="text" column="text"/>
|
||||
<result property="fid" column="fid"/>
|
||||
<result property="fname" column="fname" />
|
||||
</resultMap>
|
||||
|
||||
<select id="queryCsv" resultMap="BaseResultMap" parameterType="java.util.Map">
|
||||
select a.id ,a."text" ,f.id as fid ,f."name" as fname from chunks a left join file_chunks fc on fc.chunk_id =a.id
|
||||
left join files f on f.id =fc.file_id
|
||||
where f.file_type ='text/plain' and a.user_id =#{userid}
|
||||
<if test="wordList != null">
|
||||
AND
|
||||
<foreach collection="wordList" item="word" index="index" open="(" close=")" separator="or">
|
||||
a."text" like '%${word}%'
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pjilisense.flxai.dao.FileChunksDao">
|
||||
|
||||
<resultMap type="com.pjilisense.flxai.entity.FileChunksEntity" id="fileChunksMap">
|
||||
<result property="fileId" column="file_id"/>
|
||||
<result property="chunkId" column="chunk_id" typeHandler="com.pjilisense.flxai.handle.UUIDTypeHandler"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.pjilisense.flxai.dao.GlobalFilesDao">
|
||||
|
||||
<resultMap type="com.pjilisense.flxai.entity.GlobalFilesEntity" id="globalFilesMap">
|
||||
<result property="hashId" column="hash_id"/>
|
||||
<result property="fileType" column="file_type"/>
|
||||
<result property="size" column="size"/>
|
||||
<result property="url" column="url"/>
|
||||
<result property="metadata" column="metadata" typeHandler="com.pjilisense.flxai.handle.JsonbTypeHandler"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime"/>
|
||||
<result property="accessedAt" column="accessed_at" jdbcType="TIMESTAMP_WITH_TIMEZONE" javaType="java.time.OffsetDateTime"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue