feat: 升级 samber/do v1 → v2
This commit is contained in:
+5
-4
@@ -8,8 +8,9 @@ import (
|
||||
"git.fsdpf.net/go/condition"
|
||||
"git.fsdpf.net/go/contracts"
|
||||
"git.fsdpf.net/go/db"
|
||||
"git.fsdpf.net/go/db/exp"
|
||||
"git.fsdpf.net/go/utils"
|
||||
"github.com/samber/do"
|
||||
"github.com/samber/do/v2"
|
||||
"github.com/samber/lo"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
@@ -37,7 +38,7 @@ type OperationAccess struct {
|
||||
data map[string][]any
|
||||
}
|
||||
|
||||
func (o Operation) ToDBColumn(model contracts.Model, container *do.Injector) (column db.Expression, field reflect.StructField) {
|
||||
func (o Operation) ToDBColumn(model contracts.Model, container do.Injector) (column db.Expression, field reflect.StructField) {
|
||||
GetOrmConditions := do.MustInvoke[contracts.GetOrmConditions](container)
|
||||
|
||||
uuid := strings.ReplaceAll(o.Uuid, "-", "_")
|
||||
@@ -52,9 +53,9 @@ func (o Operation) ToDBColumn(model contracts.Model, container *do.Injector) (co
|
||||
}
|
||||
|
||||
if cond.IsEmpty() {
|
||||
column = db.Raw(pk + " as `u_" + uuid + "`")
|
||||
column = db.I(pk).As("u_" + uuid)
|
||||
} else {
|
||||
column = db.Raw("if(" + string(cond.ToSql(model)) + ", " + pk + ", 0) as `u_" + uuid + "`")
|
||||
column = exp.NewSQLFunctionExpression("IF", cond.ToSql(model), db.I(pk), 0).As("u_" + uuid)
|
||||
}
|
||||
|
||||
// 主键类型
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ var wsUpgrader = websocket.Upgrader{
|
||||
|
||||
func (this HttpStatusResponse) Get(path ...string) req.GlobalParams {
|
||||
if this.body == nil {
|
||||
return req.NewGlobalParam("", nil)
|
||||
return req.NewGlobalParams("", nil)
|
||||
}
|
||||
return this.body.Get(path...)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (this HttpStatusResponse) Send(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (this RawResponse) Get(path ...string) req.GlobalParams {
|
||||
return lo.Ternary(len(path) == 0, req.NewGlobalParam(string(this.raw), nil), req.NewGlobalParam(string(this.raw), nil).Get(strings.Join(path, ".")))
|
||||
return lo.Ternary(len(path) == 0, req.NewGlobalParams(string(this.raw), nil), req.NewGlobalParams(string(this.raw), nil).Get(strings.Join(path, ".")))
|
||||
}
|
||||
|
||||
func (this RawResponse) Send(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -72,7 +72,7 @@ func (this FileResponse) Get(path ...string) req.GlobalParams {
|
||||
"name": this.name,
|
||||
"disposition": this.disposition,
|
||||
}); err == nil {
|
||||
return lo.Ternary(len(path) == 0, req.NewGlobalParam(string(resp), nil), req.NewGlobalParam(string(resp), nil).Get(strings.Join(path, ".")))
|
||||
return lo.Ternary(len(path) == 0, req.NewGlobalParams(string(resp), nil), req.NewGlobalParams(string(resp), nil).Get(strings.Join(path, ".")))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user