article_draft.go
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 填写文章时保存的草稿
type ArticleDraft struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Template int `json:"template"` // 填写内容时用的样板0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 文章内容
AuthorId int64 `json:"authorId"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Section []*ArticleSection `json:"section"` // 分段内容
}
type ArticleDraftRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleDraft, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleDraft, error)
}
func (m *ArticleDraft) GetCover() string {
if len(m.Images) > 0 {
return m.Images[0].Url
}
for _, sec := range m.Section {
if sec.ParagraphType == ParagraphTypeImages && len(sec.Images) > 0 {
return sec.Images[0]
}
}
return ""
}