zwxi 9 月之前
父節點
當前提交
f5c49845ff
共有 2 個文件被更改,包括 68 次插入3 次删除
  1. 48 2
      controllers/ai/ai_summary.go
  2. 20 1
      models/ai_summary/ai_summary.go

+ 48 - 2
controllers/ai/ai_summary.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_api/models/ai_summary"
 	"eta/eta_api/models/aimod"
 	"eta/eta_api/models/sandbox"
+	saModel "eta/eta_api/models/semantic_analysis"
 	aiSummaryService "eta/eta_api/services/ai_summary"
 	"eta/eta_api/services/aiser"
 	"eta/eta_api/utils"
@@ -924,14 +925,34 @@ func (this *AiController) AiSummaryDetail() {
 
 	aiSummaryId, _ := this.GetInt("AiSummaryId")
 
-	detail, err := ai_summary.GetAiSummaryById(aiSummaryId)
+	detail, err := ai_summary.GetAiSummaryItemById(aiSummaryId)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Success = true
 		br.Msg = "获取沙盘信息失败"
 		br.ErrMsg = "获取沙盘信息失败,Err:" + err.Error()
 		return
 	}
+	resp := ai_summary.AiSummaryDetailResp{
+		AiSummaryItems: detail,
+	}
 
+	if detail.SaDocId >0 {
+		item := new(saModel.SaDoc)
+		e := item.GetItemById(detail.SaDocId)
+		if e != nil {
+			if e.Error() == utils.ErrNoRow() {
+				br.Msg = "文档已被删除, 请刷新页面"
+				return
+			}
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取文档信息失败, Err: " + e.Error()
+			return
+		}
+		resp.SaDocTitle = item.Title
+	}
+
+
+	br.Data = resp
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
@@ -990,15 +1011,22 @@ func (this *AiController) AddAiSummary() {
 		Sort:            maxSort + 1,
 	}
 
-	_, err = ai_summary.AddAiSummary(summary)
+	id, err := ai_summary.AddAiSummary(summary)
 	if err != nil {
 		br.Msg = "保存分类失败"
 		br.ErrMsg = "保存分类失败,Err:" + err.Error()
 		return
 	}
+
+	resp := ai_summary.AiSummaryAddResp{
+		AiSummaryId: int(id),
+		UniqueCode:  strconv.Itoa(req.ClassifyId) + "_" + strconv.Itoa(int(id)),
+	}
+
 	br.Ret = 200
 	br.Msg = "保存成功"
 	br.Success = true
+	br.Data = resp
 }
 
 // @Title 生成ai纪要
@@ -1030,7 +1058,25 @@ func (this *AiController) GenerateAiSummary() {
 		return
 	}
 	if req.SaDocId > 0 {
+		// 获取段落
+		sectionOB := new(saModel.SaDocSection)
+		sectionCond := fmt.Sprintf(` AND %s = ?`, saModel.SaDocSectionColumns.DocId)
+		sectionPars := make([]interface{}, 0)
+		sectionPars = append(sectionPars, req.SaDocId)
+		sectionList, e := sectionOB.GetItemsByCondition(sectionCond, sectionPars, []string{}, "")
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取段落信息失败, Err: " + e.Error()
+			return
+		}
+		secIds := make([]int, 0)
+		for _, s := range sectionList {
+			secIds = append(secIds, s.SaDocSectionId)
+		}
 
+		for _, v := range sectionList {
+			req.OriginContent += v.Content + "<br>"
+		}
 	}
 
 	if utils.Re == nil {

+ 20 - 1
models/ai_summary/ai_summary.go

@@ -48,7 +48,7 @@ func GetAiChatTopicList(sysUserId int) (item []*AiSummary, err error) {
 	return
 }
 
-// GetAiSummaryById 根据纪要id获取沙盘详情
+// GetAiSummaryById 根据纪要id获取详情
 func GetAiSummaryById(aiSummaryId int) (sandboxInfo *AiSummary, err error) {
 	o := orm.NewOrm()
 	sql := `select * from ai_summary where ai_summary_id = ? `
@@ -56,6 +56,15 @@ func GetAiSummaryById(aiSummaryId int) (sandboxInfo *AiSummary, err error) {
 	return
 }
 
+// GetAiSummaryById 根据纪要id获取详情
+func GetAiSummaryItemById(aiSummaryId int) (sandboxInfo *AiSummaryItems, err error) {
+	o := orm.NewOrm()
+	sql := `select * from ai_summary where ai_summary_id = ? `
+	err = o.Raw(sql, aiSummaryId).QueryRow(&sandboxInfo)
+	return
+}
+
+
 // DelAiSummaryById 根据纪要id删除纪要
 func DelAiSummaryById(aiSummaryId int) (err error) {
 	o := orm.NewOrm()
@@ -154,3 +163,13 @@ func GetAiSummaryMaxSort(classifyId int) (sort int, err error) {
 	err = o.Raw(sql, classifyId).QueryRow(&sort)
 	return
 }
+
+type AiSummaryAddResp struct {
+	AiSummaryId int
+	UniqueCode  string // 唯一编码
+}
+
+type AiSummaryDetailResp struct {
+	*AiSummaryItems
+	SaDocTitle string `description:"文档库标题"`
+}