Skip to content

Commit

Permalink
description处理
Browse files Browse the repository at this point in the history
  • Loading branch information
TruthHun committed Jan 5, 2024
1 parent 422fc37 commit 48582aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions biz/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func (s *DocumentAPIService) GetDocument(ctx context.Context, req *pb.GetDocumen
}

if desc := strings.TrimSpace(pbDoc.Description); desc == "" {
desc = doc.Title // 默认
textFile := strings.TrimLeft(strings.TrimSuffix(attchment.Path, filepath.Ext(attchment.Path)), "./") + "/content.txt"
if content, errRead := os.ReadFile(textFile); errRead == nil { // 读取文本内容,以提取关键字和摘要
contentStr := string(content)
Expand All @@ -251,8 +250,12 @@ func (s *DocumentAPIService) GetDocument(ctx context.Context, req *pb.GetDocumen
desc = contentStr
}
}
doc.Description = desc
fixedData["description"] = desc
if desc != "" {
pbDoc.Description = desc
fixedData["description"] = desc
} else {
pbDoc.Description = pbDoc.Title
}
}

if len(fixedData) > 0 {
Expand Down

0 comments on commit 48582aa

Please sign in to comment.