浏览代码

Merge remote-tracking branch 'origin/feature/deepseek_rag_1.0' into debug

Roc 1 月之前
父节点
当前提交
ffedd2193a

+ 300 - 0
controllers/rag/abstract.go

@@ -0,0 +1,300 @@
+package rag
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/rag"
+	"eta/eta_api/models/rag/request"
+	"eta/eta_api/models/rag/response"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"strings"
+	"time"
+)
+
+// AbstractController
+// @Description: 摘要管理
+type AbstractController struct {
+	controllers.BaseAuthController
+}
+
+// List
+// @Title 列表
+// @Description 列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*rag.QuestionListListResp
+// @router /abstract/list [get]
+func (c *AbstractController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+	tagId, _ := c.GetInt("TagId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyWord != "" {
+		condition = fmt.Sprintf(` AND a.%s = ?`, rag.WechatArticleAbstractColumns.Content)
+		pars = append(pars, `%`+keyWord+`%`)
+	}
+
+	if tagId > 0 {
+		condition = fmt.Sprintf(` AND d.%s = ?`, rag.WechatPlatformTagMappingColumns.TagID)
+		pars = append(pars, tagId)
+	}
+
+	obj := new(rag.WechatArticleAbstract)
+	total, list, err := obj.GetPageListByTagAndPlatformCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	viewList := obj.WechatArticleAbstractItem(list)
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := response.AbstractListListResp{
+		List:   viewList,
+		Paging: page,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// 向量库删除
+// 摘要库删除
+// 批量加入到向量库
+
+// vector_key
+
+// Add
+// @Title 新增问题
+// @Description 新增问题
+// @Param	request	body request.AddQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/add [post]
+func (c *AbstractController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.AddQuestionReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	req.Content = strings.TrimSpace(req.Content)
+	if req.Content == "" {
+		br.Msg = "请输入问题"
+		br.IsSendEmail = false
+		return
+	}
+	item := &rag.Question{
+		QuestionId:      0,
+		QuestionContent: req.Content,
+		Sort:            0,
+		ModifyTime:      time.Now(),
+		CreateTime:      time.Now(),
+	}
+	err = item.Create()
+	if err != nil {
+		br.Msg = "添加失败"
+		br.ErrMsg = "添加失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加成功`
+}
+
+// Del
+// @Title 删除摘要
+// @Description 删除摘要
+// @Param	request	body request.DelAbstractReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/del [post]
+func (c *AbstractController) Del() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.DelAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := rag.WechatArticleAbstract{}
+	list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "问题不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+
+	if len(list) > 0 {
+		err = obj.DelByIdList(req.WechatArticleAbstractIdList)
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	//for _,v:=range list{
+	//	// todo 删除向量库
+	//}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}
+
+// VectorDel
+// @Title 删除摘要向量库
+// @Description 删除摘要向量库
+// @Param	request	body request.EditQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/vector/del [post]
+func (c *AbstractController) VectorDel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.DelAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := rag.WechatArticleAbstract{}
+	list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "问题不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	for _, item := range list {
+		// todo 删除向量库
+		item.VectorKey = ``
+		err = item.Update([]string{"vector_key", "modify_time"})
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}
+
+// AddVector
+// @Title 删除摘要向量库
+// @Description 删除摘要向量库
+// @Param	request	body request.EditQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/vector/add [post]
+func (c *AbstractController) AddVector() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.DelAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := rag.WechatArticleAbstract{}
+	list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "问题不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	for _, item := range list {
+		// todo 删除向量库
+		item.VectorKey = ``
+		err = item.Update([]string{"vector_key", "modify_time"})
+		if err != nil {
+			br.Msg = "删除失败"
+			br.ErrMsg = "删除失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加成功`
+}

+ 3 - 3
controllers/rag/question.go

@@ -184,9 +184,9 @@ func (c *QuestionController) Edit() {
 	br.Msg = `添加成功`
 }
 
-// Edit
-// @Title 新增问题
-// @Description 新增问题
+// Del
+// @Title 删除问题
+// @Description 删除问题
 // @Param	request	body request.EditQuestionReq true "type json string"
 // @Success 200 Ret=200 新增成功
 // @router /question/del [post]

+ 4 - 0
models/rag/request/wechat_platform.go

@@ -19,3 +19,7 @@ type EditQuestionReq struct {
 	QuestionId int    `description:"问题id"`
 	Content    string `description:"公众号名称"`
 }
+
+type DelAbstractReq struct {
+	WechatArticleAbstractIdList []int `description:"摘要id"`
+}

+ 11 - 0
models/rag/response/abstract.go

@@ -0,0 +1,11 @@
+package response
+
+import (
+	"eta/eta_api/models/rag"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type AbstractListListResp struct {
+	List   []rag.WechatArticleAbstractView
+	Paging *paging.PagingItem `description:"分页数据"`
+}

+ 125 - 9
models/rag/wechat_article_abstract.go

@@ -13,7 +13,7 @@ type WechatArticleAbstract struct {
 	WechatArticleId         int       `gorm:"column:wechat_article_id;type:int(9) UNSIGNED;comment:关联的微信报告id;default:0;" description:"关联的微信报告id"`
 	Content                 string    `gorm:"column:content;type:longtext;comment:摘要内容;" description:"content"` // 摘要内容
 	Version                 int       `gorm:"column:version;type:int(10) UNSIGNED;comment:版本号;default:1;" description:"版本号"`
-	VectorKey               string    `gorm:"column:vector_key;type:varchar(255);comment:向量key标识;" json:"vector_key"` // 向量key标识
+	VectorKey               string    `gorm:"column:vector_key;type:varchar(255);comment:向量key标识;" description:"向量key标识"`
 	ModifyTime              time.Time `gorm:"column:modify_time;type:datetime;default:NULL;" description:"modify_time"`
 	CreateTime              time.Time `gorm:"column:create_time;type:datetime;default:NULL;" description:"create_time"`
 }
@@ -52,12 +52,34 @@ func (m *WechatArticleAbstract) Update(updateCols []string) (err error) {
 	return
 }
 
+func (m *WechatArticleAbstract) Del() (err error) {
+	err = global.DbMap[utils.DbNameAI].Delete(&m).Error
+
+	return
+}
+
 func (m *WechatArticleAbstract) GetById(id int) (item *WechatArticleAbstract, err error) {
 	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", WechatArticleAbstractColumns.WechatArticleAbstractID), id).First(&item).Error
 
 	return
 }
 
+func (m *WechatArticleAbstract) GetByIdList(idList []int) (items []*WechatArticleAbstract, err error) {
+	err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s in (?) ", WechatArticleAbstractColumns.WechatArticleAbstractID), idList).Find(&items).Error
+
+	return
+}
+
+func (m *WechatArticleAbstract) DelByIdList(idList []int) (err error) {
+	if len(idList) <= 0 {
+		return
+	}
+	sqlStr := fmt.Sprintf(`delete from %s where %s in (?)`, m.TableName(), WechatArticleAbstractColumns.WechatArticleAbstractID)
+	err = global.DbMap[utils.DbNameAI].Exec(sqlStr, idList).Error
+
+	return
+}
+
 // GetByWechatArticleId
 // @Description: 根据报告id获取摘要
 // @author: Roc
@@ -72,14 +94,64 @@ func (m *WechatArticleAbstract) GetByWechatArticleId(id int) (item *WechatArticl
 	return
 }
 
-func (m *WechatArticleAbstract) GetListByPlatformCondition(field, condition string, pars []interface{}, startSize, pageSize int) (items []*WechatArticleAndPlatform, err error) {
+type WechatArticleAbstractView struct {
+	WechatArticleAbstractId int    `gorm:"column:wechat_article_abstract_id;type:int(9) UNSIGNED;primaryKey;not null;" description:"wechat_article_abstract_id"`
+	WechatArticleId         int    `gorm:"column:wechat_article_id;type:int(9) UNSIGNED;comment:关联的微信报告id;default:0;" description:"关联的微信报告id"`
+	Abstract                string `gorm:"column:abstract;type:longtext;comment:摘要内容;" description:"摘要内容"` //
+	Version                 int    `gorm:"column:version;type:int(10) UNSIGNED;comment:版本号;default:1;" description:"版本号"`
+	VectorKey               string `gorm:"column:vector_key;type:varchar(255);comment:向量key标识;" description:"向量key标识"`
+	ModifyTime              string `gorm:"column:modify_time;type:datetime;default:NULL;" description:"modify_time"`
+	CreateTime              string `gorm:"column:create_time;type:datetime;default:NULL;" description:"create_time"`
+	Title                   string `gorm:"column:title;type:varchar(255);comment:标题;" description:"标题"`
+	Link                    string `gorm:"column:link;type:varchar(255);comment:链接;" description:"链接"`
+	TagId                   int    `gorm:"column:tag_id;type:int(9) UNSIGNED;comment:品种id;default:0;" description:"品种id"`
+}
+
+type WechatArticleAbstractItem struct {
+	WechatArticleAbstractId int       `gorm:"column:wechat_article_abstract_id;type:int(9) UNSIGNED;primaryKey;not null;" description:"wechat_article_abstract_id"`
+	WechatArticleId         int       `gorm:"column:wechat_article_id;type:int(9) UNSIGNED;comment:关联的微信报告id;default:0;" description:"关联的微信报告id"`
+	Abstract                string    `gorm:"column:abstract;type:longtext;comment:摘要内容;" description:"摘要内容"` //
+	Version                 int       `gorm:"column:version;type:int(10) UNSIGNED;comment:版本号;default:1;" description:"版本号"`
+	VectorKey               string    `gorm:"column:vector_key;type:varchar(255);comment:向量key标识;" description:"向量key标识"`
+	ModifyTime              time.Time `gorm:"column:modify_time;type:datetime;default:NULL;" description:"modify_time"`
+	CreateTime              time.Time `gorm:"column:create_time;type:datetime;default:NULL;" description:"create_time"`
+	Title                   string    `gorm:"column:title;type:varchar(255);comment:标题;" description:"标题"`
+	Link                    string    `gorm:"column:link;type:varchar(255);comment:链接;" description:"链接"`
+	TagId                   int       `gorm:"column:tag_id;type:int(9) UNSIGNED;comment:品种id;default:0;" description:"品种id"`
+}
+
+func (m *WechatArticleAbstractItem) ToView() WechatArticleAbstractView {
+	return WechatArticleAbstractView{
+		WechatArticleAbstractId: m.WechatArticleAbstractId,
+		WechatArticleId:         m.WechatArticleId,
+		Abstract:                m.Abstract,
+		Version:                 m.Version,
+		VectorKey:               m.VectorKey,
+		ModifyTime:              utils.DateStrToDateTimeStr(m.ModifyTime),
+		CreateTime:              utils.DateStrToDateTimeStr(m.CreateTime),
+		Title:                   m.Title,
+		Link:                    m.Link,
+		TagId:                   m.TagId,
+	}
+}
+
+func (m *WechatArticleAbstract) WechatArticleAbstractItem(list []*WechatArticleAbstractItem) (wechatArticleViewList []WechatArticleAbstractView) {
+	wechatArticleViewList = make([]WechatArticleAbstractView, 0)
+
+	for _, v := range list {
+		wechatArticleViewList = append(wechatArticleViewList, v.ToView())
+	}
+	return
+}
+
+func (m *WechatArticleAbstract) GetListByPlatformCondition(field, condition string, pars []interface{}, startSize, pageSize int) (items []*WechatArticleAbstractItem, err error) {
 	if field == "" {
 		field = "*"
 	}
 	sqlStr := fmt.Sprintf(`SELECT %s FROM %s AS a 
-          JOIN wechat_platform AS b ON a.wechat_platform_id=b.wechat_platform_id
-          JOIN wechat_platform AS b ON a.wechat_platform_id=b.wechat_platform_id
-          WHERE 1=1 AND a.is_deleted=0 %s  order by a.article_create_time DESC,a.wechat_article_id DESC LIMIT ?,?`, field, m.TableName(), condition)
+          JOIN wechat_article AS b ON a.wechat_article_id=b.wechat_article_id
+          JOIN wechat_platform AS c ON b.wechat_platform_id=c.wechat_platform_id
+          WHERE 1=1 AND b.is_deleted=0 %s  order by a.modify_time DESC,a.wechat_article_abstract_id DESC LIMIT ?,?`, field, m.TableName(), condition)
 	pars = append(pars, startSize, pageSize)
 	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
 
@@ -89,8 +161,9 @@ func (m *WechatArticleAbstract) GetListByPlatformCondition(field, condition stri
 func (m *WechatArticleAbstract) GetCountByPlatformCondition(condition string, pars []interface{}) (total int, err error) {
 	var intNull sql.NullInt64
 	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s AS a 
-          JOIN wechat_platform AS b ON a.wechat_platform_id=b.wechat_platform_id 
-          WHERE 1=1 AND a.is_deleted=0 %s`, m.TableName(), condition)
+          JOIN wechat_article AS b ON a.wechat_article_id=b.wechat_article_id
+          JOIN wechat_platform AS c ON b.wechat_platform_id=c.wechat_platform_id
+          WHERE 1=1 AND b.is_deleted=0 %s`, m.TableName(), condition)
 	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
 	if err == nil && intNull.Valid {
 		total = int(intNull.Int64)
@@ -99,14 +172,57 @@ func (m *WechatArticleAbstract) GetCountByPlatformCondition(condition string, pa
 	return
 }
 
-func (m *WechatArticleAbstract) GetPageListByPlatformCondition(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*WechatArticleAndPlatform, err error) {
+func (m *WechatArticleAbstract) GetPageListByPlatformCondition(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*WechatArticleAbstractItem, err error) {
 
 	total, err = m.GetCountByPlatformCondition(condition, pars)
 	if err != nil {
 		return
 	}
 	if total > 0 {
-		items, err = m.GetListByPlatformCondition(`a.wechat_article_id,a.wechat_platform_id,a.fake_id,a.title,a.link,a.cover_url,a.description,a.country,a.province,a.city,a.article_create_time,a.modify_time,a.create_time,b.nickname,b.round_head_img`, condition, pars, startSize, pageSize)
+		items, err = m.GetListByPlatformCondition(`a.wechat_article_abstract_id,a.wechat_article_id,a.content AS abstract,a.version,a.vector_key,b.title,b.link,a.modify_time,a.create_time`, condition, pars, startSize, pageSize)
+	}
+
+	return
+}
+
+func (m *WechatArticleAbstract) GetListByTagAndPlatformCondition(field, condition string, pars []interface{}, startSize, pageSize int) (items []*WechatArticleAbstractItem, err error) {
+	if field == "" {
+		field = "*"
+	}
+	sqlStr := fmt.Sprintf(`SELECT %s FROM %s AS a 
+          JOIN wechat_article AS b ON a.wechat_article_id=b.wechat_article_id
+          JOIN wechat_platform AS c ON b.wechat_platform_id=c.wechat_platform_id
+          JOIN wechat_platform_tag_mapping AS d ON c.wechat_platform_id=d.wechat_platform_id
+          WHERE 1=1 AND b.is_deleted=0 %s  order by a.modify_time DESC,a.wechat_article_abstract_id DESC LIMIT ?,?`, field, m.TableName(), condition)
+	pars = append(pars, startSize, pageSize)
+	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
+
+	return
+}
+
+func (m *WechatArticleAbstract) GetCountByTagAndPlatformCondition(condition string, pars []interface{}) (total int, err error) {
+	var intNull sql.NullInt64
+	sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s AS a 
+          JOIN wechat_article AS b ON a.wechat_article_id=b.wechat_article_id
+          JOIN wechat_platform AS c ON b.wechat_platform_id=c.wechat_platform_id
+          JOIN wechat_platform_tag_mapping AS d ON c.wechat_platform_id=d.wechat_platform_id
+          WHERE 1=1 AND b.is_deleted=0 %s`, m.TableName(), condition)
+	err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
+	if err == nil && intNull.Valid {
+		total = int(intNull.Int64)
+	}
+
+	return
+}
+
+func (m *WechatArticleAbstract) GetPageListByTagAndPlatformCondition(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*WechatArticleAbstractItem, err error) {
+
+	total, err = m.GetCountByTagAndPlatformCondition(condition, pars)
+	if err != nil {
+		return
+	}
+	if total > 0 {
+		items, err = m.GetListByTagAndPlatformCondition(`a.wechat_article_abstract_id,a.wechat_article_id,a.content AS abstract,a.version,a.vector_key,a.modify_time,a.create_time,b.title,b.link,d.tag_id`, condition, pars, startSize, pageSize)
 	}
 
 	return

+ 45 - 0
routers/commentsRouter.go

@@ -8557,6 +8557,51 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"],
+        beego.ControllerComments{
+            Method: "Add",
+            Router: `/abstract/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"],
+        beego.ControllerComments{
+            Method: "Del",
+            Router: `/abstract/del`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/abstract/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"],
+        beego.ControllerComments{
+            Method: "AddVector",
+            Router: `/abstract/vector/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:AbstractController"],
+        beego.ControllerComments{
+            Method: "VectorDel",
+            Router: `/abstract/vector/del`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/rag:ChatWsController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/rag:ChatWsController"],
         beego.ControllerComments{
             Method: "ChatConnect",

+ 1 - 0
routers/router.go

@@ -77,6 +77,7 @@ func init() {
 				&rag.KbController{},
 				&rag.WechatPlatformController{},
 				&rag.QuestionController{},
+				&rag.AbstractController{},
 			),
 		),
 		web.NSNamespace("/banner",

+ 32 - 0
utils/common.go

@@ -2995,3 +2995,35 @@ func GormDateStrToDateTimeStr(originalString string) (formatStr string) {
 
 	return
 }
+
+// DateStrToDateStr
+// @Description: 将日期格式转正常显示的日期字符串
+// @author: Roc
+// @datetime 2025-03-07 11:24:19
+// @param date time.Time
+// @return formatStr string
+func DateStrToDateStr(date time.Time) (formatStr string) {
+	if date.IsZero() {
+		return
+	}
+	// 格式化时间
+	formatStr = date.Format(FormatDate)
+
+	return
+}
+
+// DateStrToDateTimeStr
+// @Description: 将日期格式转正常显示的日期时间字符串
+// @author: Roc
+// @datetime 2025-03-07 11:23:09
+// @param date time.Time
+// @return formatStr string
+func DateStrToDateTimeStr(date time.Time) (formatStr string) {
+	if date.IsZero() {
+		return
+	}
+	// 格式化时间
+	formatStr = date.Format(FormatDateTime)
+
+	return
+}

+ 2 - 0
utils/ws/latency_measurer.go

@@ -2,6 +2,7 @@ package ws
 
 import (
 	"errors"
+	"fmt"
 	"github.com/gorilla/websocket"
 	"sync"
 	"time"
@@ -87,6 +88,7 @@ func SetupLatencyMeasurement(conn *websocket.Conn) *LatencyMeasurer {
 	lm := NewLatencyMeasurer(5) // 使用最近5次测量的滑动窗口
 	conn.SetPongHandler(func(appData string) error {
 		lm.CalculateLatency()
+		fmt.Printf("触发了pong的应答")
 		return nil
 	})
 	return lm

+ 0 - 1
utils/ws/session.go

@@ -49,7 +49,6 @@ func (s *Session) readPump() {
 		// 处理消息
 		if err = manager.HandleMessage(s.UserId, s.Id, message); err != nil {
 			//写应答
-
 			_ = s.writeWithTimeout(err.Error())
 
 		}