Skip to content

Commit 40f77db

Browse files
authored
修复字典按ID排序而非sort排序问题 (flipped-aurora#1387)
直接使用Preload加载的字典值是按ID排序的,在前端展示时并非希望的sort排序
1 parent a4a240e commit 40f77db

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/service/system/sys_dictionary.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func (dictionaryService *DictionaryService) GetSysDictionary(Type string, Id uin
8787
} else {
8888
flag = *status
8989
}
90-
err = global.GVA_DB.Where("(type = ? OR id = ?) and status = ?", Type, Id, flag).Preload("SysDictionaryDetails", "status = ?", true).First(&sysDictionary).Error
90+
err = global.GVA_DB.Where("(type = ? OR id = ?) and status = ?", Type, Id, flag).Preload("SysDictionaryDetails", func(db *gorm.DB) *gorm.DB {
91+
return db.Where("status = ?", true).Order("sort")
92+
}).First(&sysDictionary).Error
9193
return
9294
}
9395

0 commit comments

Comments
 (0)