fix version 1
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bsm/full/module/base/initial/internal/impl"
|
||||
"bsm/full/module/base/initial/internal/models"
|
||||
"git.apinb.com/bsm-sdk/core/vars"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
// GetConfigCache 获取配置缓存
|
||||
@@ -18,7 +19,11 @@ func GetConfigByCache(app, os string) ([]*models.InitialConfig, error) {
|
||||
}
|
||||
|
||||
err = impl.DBService.Where("app = ? AND (os = ? OR os = ?)", app, os, "ALL").
|
||||
Order("CASE WHEN os = '" + os + "' THEN 0 ELSE 1 END, id DESC").
|
||||
// 使用结构化排序并以占位符绑定 os,禁止把请求参数拼接进 ORDER BY
|
||||
Order(clause.OrderBy{Expression: clause.Expr{
|
||||
SQL: "CASE WHEN os = ? THEN 0 ELSE 1 END, id DESC",
|
||||
Vars: []any{os},
|
||||
}}).
|
||||
Find(&configs).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user