diff --git a/docs/docs.go b/docs/docs.go index 3c065c45..53de2fae 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -6178,6 +6178,10 @@ const docTemplate = `{ "description": "created time", "type": "integer" }, + "description": { + "description": "description", + "type": "string" + }, "display_name": { "description": "display_name", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 000624b4..3dba6fde 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -6166,6 +6166,10 @@ "description": "created time", "type": "integer" }, + "description": { + "description": "description", + "type": "string" + }, "display_name": { "description": "display_name", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b01b8555..1f6c958b 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -624,6 +624,9 @@ definitions: created_at: description: created time type: integer + description: + description: description + type: string display_name: description: display_name type: string diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.go index 3eb8d389..8e768ce0 100644 --- a/internal/schema/tag_schema.go +++ b/internal/schema/tag_schema.go @@ -108,6 +108,8 @@ type GetTagPageResp struct { DisplayName string `json:"display_name"` // excerpt Excerpt string `json:"excerpt"` + //description + Description string `json:"description"` // original text OriginalText string `json:"original_text"` // parsed_text @@ -127,7 +129,7 @@ type GetTagPageResp struct { } func (tr *GetTagPageResp) GetExcerpt() { - excerpt := strings.TrimSpace(tr.OriginalText) + excerpt := strings.TrimSpace(tr.ParsedText) idx := strings.Index(excerpt, "\n") if idx >= 0 { excerpt = excerpt[0:idx] diff --git a/internal/service/tag/tag_service.go b/internal/service/tag/tag_service.go index db28ef09..e27cbc7d 100644 --- a/internal/service/tag/tag_service.go +++ b/internal/service/tag/tag_service.go @@ -353,10 +353,10 @@ func (ts *TagService) GetTagWithPage(ctx context.Context, req *schema.GetTagWith resp := make([]*schema.GetTagPageResp, 0) for _, tag := range tags { - //excerpt := htmltext.FetchExcerpt(tag.ParsedText, "...", 240) - resp = append(resp, &schema.GetTagPageResp{ + item := &schema.GetTagPageResp{ TagID: tag.ID, SlugName: tag.SlugName, + Description: htmltext.FetchExcerpt(tag.ParsedText, "...", 240), DisplayName: tag.DisplayName, OriginalText: tag.OriginalText, ParsedText: tag.ParsedText, @@ -367,7 +367,10 @@ func (ts *TagService) GetTagWithPage(ctx context.Context, req *schema.GetTagWith UpdatedAt: tag.UpdatedAt.Unix(), Recommend: tag.Recommend, Reserved: tag.Reserved, - }) + } + item.GetExcerpt() + resp = append(resp, item) + } return pager.NewPageModel(total, resp), nil }