Skip to content

Commit 00b4ffa

Browse files
committed
修复文章排序错误
1 parent 2416af4 commit 00b4ffa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

models/Blog.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func (b *Blog) Save(cols ...string) error {
179179

180180
if b.OrderIndex <= 0 {
181181
blog := NewBlog()
182-
if err :=o.QueryTable(b.TableNameWithPrefix()).OrderBy("-blog_id").One(blog,"blog_id");err == nil{
183-
b.OrderIndex = b.BlogId + 1;
182+
if err := o.QueryTable(blog.TableNameWithPrefix()).OrderBy("-blog_id").Limit(1).One(blog,"blog_id");err == nil{
183+
b.OrderIndex = blog.BlogId + 1;
184184
}else{
185185
c,_ := o.QueryTable(b.TableNameWithPrefix()).Count()
186186
b.OrderIndex = int(c) + 1

0 commit comments

Comments
 (0)