|
@@ -102,7 +102,7 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { |
|
@@ -102,7 +102,7 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { |
|
102
|
//设置内容概要
|
102
|
//设置内容概要
|
|
103
|
|
103
|
|
|
104
|
// 截取内容 50个字
|
104
|
// 截取内容 50个字
|
|
105
|
- stringIndex := 0 //字符串长度
|
105
|
+ length := 0 //字符串长度
|
|
106
|
content := ""
|
106
|
content := ""
|
|
107
|
for i := range sectionList {
|
107
|
for i := range sectionList {
|
|
108
|
str := strings.TrimSpace(sectionList[i].Content)
|
108
|
str := strings.TrimSpace(sectionList[i].Content)
|
|
@@ -111,11 +111,12 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { |
|
@@ -111,11 +111,12 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { |
|
111
|
break
|
111
|
break
|
|
112
|
}
|
112
|
}
|
|
113
|
}
|
113
|
}
|
|
114
|
- stringIndex = len(content)
|
|
|
|
115
|
- if len(content) > 50 {
|
|
|
|
116
|
- stringIndex = 50
|
114
|
+ runeContent := []rune(content)
|
|
|
|
115
|
+ length = len(runeContent)
|
|
|
|
116
|
+ if length > 50 {
|
|
|
|
117
|
+ length = 50
|
|
117
|
}
|
118
|
}
|
|
118
|
- m.Summary = content[0:stringIndex]
|
119
|
+ m.Summary = string(runeContent[0:length])
|
|
119
|
}
|
120
|
}
|
|
120
|
|
121
|
|
|
121
|
func (m *Article) WhoCanRead(userId int64) bool {
|
122
|
func (m *Article) WhoCanRead(userId int64) bool {
|