作者 yangfu

Merge branch 'dev' into test

... ... @@ -136,6 +136,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
default:
tx = tx.Order("created_at desc")
}
} else {
tx = tx.Order("created_at desc")
}
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
... ...
... ... @@ -102,7 +102,7 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
//设置内容概要
// 截取内容 50个字
stringIndex := 0 //字符串长度
length := 0 //字符串长度
content := ""
for i := range sectionList {
str := strings.TrimSpace(sectionList[i].Content)
... ... @@ -111,11 +111,12 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
break
}
}
stringIndex = len(content)
if len(content) > 50 {
stringIndex = 50
runeContent := []rune(content)
length = len(runeContent)
if length > 50 {
length = 50
}
m.Summary = content[0:stringIndex]
m.Summary = string(runeContent[0:length])
}
func (m *Article) WhoCanRead(userId int64) bool {
... ...