修复文章排序错误

pull/358/head
lifei6671 2018-07-18 17:43:52 +08:00
parent 2416af4528
commit 00b4ffac2a
1 changed files with 2 additions and 2 deletions

View File

@ -179,8 +179,8 @@ func (b *Blog) Save(cols ...string) error {
if b.OrderIndex <= 0 {
blog := NewBlog()
if err :=o.QueryTable(b.TableNameWithPrefix()).OrderBy("-blog_id").One(blog,"blog_id");err == nil{
b.OrderIndex = b.BlogId + 1;
if err := o.QueryTable(blog.TableNameWithPrefix()).OrderBy("-blog_id").Limit(1).One(blog,"blog_id");err == nil{
b.OrderIndex = blog.BlogId + 1;
}else{
c,_ := o.QueryTable(b.TableNameWithPrefix()).Count()
b.OrderIndex = int(c) + 1