|
@@ -245,7 +245,7 @@ func (m *SpeechRecognitionTagMenu) UpdateSortByParentId(parentId, menuId, nowSor
|
|
// GetMaxSortByParentId 获取父级分类下最大Sort
|
|
// GetMaxSortByParentId 获取父级分类下最大Sort
|
|
func (m *SpeechRecognitionTagMenu) GetMaxSortByParentId(parentId int) (sort int, err error) {
|
|
func (m *SpeechRecognitionTagMenu) GetMaxSortByParentId(parentId int) (sort int, err error) {
|
|
// o := orm.NewOrm()
|
|
// o := orm.NewOrm()
|
|
- sql := fmt.Sprintf(`SELECT MAX(sort) AS sort FROM %s WHERE %s = ?`, m.TableName(), SpeechRecognitionTagMenuCols.ParentId)
|
|
|
|
|
|
+ sql := fmt.Sprintf(`SELECT COALESCE(MAX(sort), 0) AS sort FROM %s WHERE %s = ?`, m.TableName(), SpeechRecognitionTagMenuCols.ParentId)
|
|
//err = o.Raw(sql, parentId).QueryRow(&sort)
|
|
//err = o.Raw(sql, parentId).QueryRow(&sort)
|
|
err = global.DEFAULT_DmSQL.Raw(sql, parentId).Scan(&sort).Error
|
|
err = global.DEFAULT_DmSQL.Raw(sql, parentId).Scan(&sort).Error
|
|
return
|
|
return
|