数据模型使用指针类型字段以避免空值自动更新的问题
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"log/slog"
|
||||
"platform/pkg/env"
|
||||
"platform/pkg/logs"
|
||||
"platform/pkg/u"
|
||||
client2 "platform/web/domains/client"
|
||||
proxy2 "platform/web/domains/proxy"
|
||||
m "platform/web/models"
|
||||
@@ -48,13 +49,13 @@ func main() {
|
||||
Name: "7a17e8b4-cdc3-4500-bf16-4a665991a7f6",
|
||||
Host: "110.40.82.248",
|
||||
Type: int32(proxy2.TypeSelfHosted),
|
||||
Secret: "api:123456",
|
||||
Secret: u.P("api:123456"),
|
||||
}, &m.Proxy{
|
||||
Version: 1,
|
||||
Name: "58e03f38-4cef-429c-8bb8-530142d0a745",
|
||||
Host: "123.6.147.241",
|
||||
Type: int32(proxy2.TypeThirdParty),
|
||||
Secret: "api:123456",
|
||||
Secret: u.P("api:123456"),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -26,6 +26,8 @@ func main() {
|
||||
g = gen.NewGenerator(gen.Config{
|
||||
OutPath: "web/queries",
|
||||
ModelPkgPath: "models",
|
||||
FieldNullable: true,
|
||||
FieldSignable: true,
|
||||
FieldWithTypeTag: true,
|
||||
Mode: gen.WithDefaultQuery | gen.WithoutContext,
|
||||
})
|
||||
@@ -34,10 +36,12 @@ func main() {
|
||||
// 公共参数
|
||||
common := []gen.ModelOpt{
|
||||
gen.FieldModify(func(field gen.Field) gen.Field {
|
||||
if field.Type == "time.Time" {
|
||||
switch {
|
||||
case field.Type == "*time.Time":
|
||||
field.Type = "*orm.LocalDateTime"
|
||||
case field.Type == "time.Time":
|
||||
field.Type = "orm.LocalDateTime"
|
||||
}
|
||||
if strings.Contains(field.Tags(), "numeric") {
|
||||
case strings.Contains(field.Tags(), "numeric"):
|
||||
field.Type = "decimal.Decimal"
|
||||
}
|
||||
return field
|
||||
|
||||
Reference in New Issue
Block a user