合并分支 'test' 到 'master'
Test 查看合并请求 !5
正在显示
2 个修改的文件
包含
5 行增加
和
7 行删除
@@ -136,6 +136,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -136,6 +136,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
136 | default: | 136 | default: |
137 | tx = tx.Order("created_at desc") | 137 | tx = tx.Order("created_at desc") |
138 | } | 138 | } |
139 | + } else { | ||
140 | + tx = tx.Order("created_at desc") | ||
139 | } | 141 | } |
140 | if v, ok := queryOptions["ids"]; ok { | 142 | if v, ok := queryOptions["ids"]; ok { |
141 | tx = tx.Where("id in (?)", v) | 143 | tx = tx.Where("id in (?)", v) |
@@ -102,7 +102,6 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { | @@ -102,7 +102,6 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { | ||
102 | //设置内容概要 | 102 | //设置内容概要 |
103 | 103 | ||
104 | // 截取内容 50个字 | 104 | // 截取内容 50个字 |
105 | - runeNumber := 0 //字数 | ||
106 | stringIndex := 0 //字符串长度 | 105 | stringIndex := 0 //字符串长度 |
107 | content := "" | 106 | content := "" |
108 | for i := range sectionList { | 107 | for i := range sectionList { |
@@ -112,12 +111,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { | @@ -112,12 +111,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { | ||
112 | break | 111 | break |
113 | } | 112 | } |
114 | } | 113 | } |
115 | - for i := range content { | ||
116 | - if runeNumber > 50 { | ||
117 | - break | ||
118 | - } | ||
119 | - runeNumber += 1 | ||
120 | - stringIndex = i | 114 | + stringIndex = len(content) |
115 | + if len(content) > 50 { | ||
116 | + stringIndex = 50 | ||
121 | } | 117 | } |
122 | m.Summary = content[0:stringIndex] | 118 | m.Summary = content[0:stringIndex] |
123 | } | 119 | } |
-
请 注册 或 登录 后发表评论