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