From 37e6e5881636bc309dcb076c973d315307aa203a Mon Sep 17 00:00:00 2001 From: luorijun Date: Sat, 10 May 2025 15:00:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20LocalDateTime=20=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=20orm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +- cmd/gen/main.go | 2 +- pkg/orm/localdatetime.go | 85 +++++++++++++++++++ pkg/orm/orm.go | 9 +- web/core/types.go | 88 -------------------- web/handlers/bill.go | 5 +- web/handlers/channel.go | 5 +- web/handlers/resource.go | 13 +-- web/models/admin.gen.go | 30 +++---- web/models/admin_role.gen.go | 18 ++-- web/models/admin_role_link.gen.go | 14 ++-- web/models/admin_role_permission_link.gen.go | 14 ++-- web/models/announcement.gen.go | 22 ++--- web/models/bill.gen.go | 32 +++---- web/models/channel.gen.go | 36 ++++---- web/models/client.gen.go | 32 +++---- web/models/client_permission_link.gen.go | 14 ++-- web/models/coupon.gen.go | 24 +++--- web/models/logs_request.gen.go | 24 +++--- web/models/node.gen.go | 32 +++---- web/models/permission.gen.go | 16 ++-- web/models/product.gen.go | 20 ++--- web/models/proxy.gen.go | 20 ++--- web/models/refund.gen.go | 20 ++--- web/models/resource.gen.go | 20 ++--- web/models/resource_psr.gen.go | 14 ++-- web/models/resource_pss.gen.go | 22 ++--- web/models/trade.gen.go | 36 ++++---- web/models/user.gen.go | 44 +++++----- web/models/user_role.gen.go | 18 ++-- web/models/user_role_link.gen.go | 14 ++-- web/models/user_role_permission_link.gen.go | 14 ++-- web/models/whitelist.gen.go | 16 ++-- web/services/auth.go | 4 +- web/services/channel.go | 10 +-- web/services/channel_test.go | 28 +++---- web/services/resource.go | 4 +- web/services/transaction.go | 6 +- web/web.go | 5 +- 39 files changed, 414 insertions(+), 425 deletions(-) create mode 100644 pkg/orm/localdatetime.go diff --git a/README.md b/README.md index 75f154b..b3396bc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ ## todo -- 支付宝使用实际 appid - 长效业务接入 - 页面 账户总览 - 页面 提取记录 @@ -10,13 +9,6 @@ - 支付回调处理 - 保存 session 到数据库 -### 重构 - -- 将 LocalDateTime 迁移到 orm -- globals 合并到 services 或者反之 -- 自定义的服务错误没有必要,可以统一在 handler 层使用包装的 fiber.Error -- 增加 domain 层,缓解同包字段过长的问题 - ### 下阶段 - 代理数据表的 secret 字段 aes 加密存储 @@ -31,6 +23,7 @@ ### 长期 +- 将 orm 和 rds 迁移到 web/globals 中 - 业务代码和测试代码共用的控制变量可以优化为环境变量 - 考虑统计接口调用频率并通过接口展示 - 考虑登录时曾经输入过验证码的用户,登录成功后允许一段时间内免输验证码 diff --git a/cmd/gen/main.go b/cmd/gen/main.go index 5bfb302..a5f8a46 100644 --- a/cmd/gen/main.go +++ b/cmd/gen/main.go @@ -34,7 +34,7 @@ func main() { common := []gen.ModelOpt{ gen.FieldModify(func(field gen.Field) gen.Field { if field.Type == "time.Time" { - field.Type = "core.LocalDateTime" + field.Type = "orm.LocalDateTime" } return field }), diff --git a/pkg/orm/localdatetime.go b/pkg/orm/localdatetime.go new file mode 100644 index 0000000..0d184ba --- /dev/null +++ b/pkg/orm/localdatetime.go @@ -0,0 +1,85 @@ +package orm + +import ( + "database/sql" + "database/sql/driver" + "time" +) + +type LocalDateTime time.Time + +var formats = []string{ + "2006-01-02 15:04:05.999999999-07:00", + "2006-01-02T15:04:05.999999999-07:00", + "2006-01-02 15:04:05.999999999", + "2006-01-02T15:04:05.999999999", + "2006-01-02 15:04:05", + "2006-01-02T15:04:05", + "2006-01-02 15:04", + "2006-01-02T15:04", + "2006-01-02", +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt *LocalDateTime) Scan(value interface{}) (err error) { + var t time.Time + + if strValue, ok := value.(string); ok { + var timeValue time.Time + for _, format := range formats { + timeValue, err = time.Parse(format, strValue) + if err == nil { + t = timeValue + break + } + } + t = timeValue + } else { + nullTime := &sql.NullTime{} + err = nullTime.Scan(value) + if err != nil { + return err + } + if nullTime == nil { + return nil + } + t = nullTime.Time + } + *ldt = LocalDateTime(time.Date( + t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local, + )) + return +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt LocalDateTime) Value() (driver.Value, error) { + return time.Time(ldt).Local(), nil +} + +// GormDataType gorm common data type +// +//goland:noinspection GoMixedReceiverTy +//goland:noinspection GoMixedReceiverTypes +func (ldt LocalDateTime) GormDataType() string { + return "ldt" +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt LocalDateTime) GobEncode() ([]byte, error) { + return time.Time(ldt).GobEncode() +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt *LocalDateTime) GobDecode(b []byte) error { + return (*time.Time)(ldt).GobDecode(b) +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt LocalDateTime) MarshalJSON() ([]byte, error) { + return time.Time(ldt).MarshalJSON() +} + +//goland:noinspection GoMixedReceiverTypes +func (ldt *LocalDateTime) UnmarshalJSON(b []byte) error { + return (*time.Time)(ldt).UnmarshalJSON(b) +} diff --git a/pkg/orm/orm.go b/pkg/orm/orm.go index c8086af..1918204 100644 --- a/pkg/orm/orm.go +++ b/pkg/orm/orm.go @@ -2,15 +2,13 @@ package orm import ( "fmt" - "log/slog" - "platform/pkg/env" - "platform/web/queries" - "gorm.io/driver/postgres" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/gorm" "gorm.io/gorm/schema" + "log/slog" + "platform/pkg/env" ) var DB *gorm.DB @@ -42,9 +40,6 @@ func Init() { conn.SetMaxIdleConns(10) conn.SetMaxOpenConns(100) - // 初始化查询工具 - queries.SetDefault(db) - DB = db } diff --git a/web/core/types.go b/web/core/types.go index 822a5f7..5a48d22 100644 --- a/web/core/types.go +++ b/web/core/types.go @@ -1,11 +1,5 @@ package core -import ( - "database/sql" - "database/sql/driver" - "time" -) - // region page type PageReq struct { @@ -46,85 +40,3 @@ type PageResp struct { } // endregion - -// region LocalDateTime - -type LocalDateTime time.Time - -var formats = []string{ - "2006-01-02 15:04:05.999999999-07:00", - "2006-01-02T15:04:05.999999999-07:00", - "2006-01-02 15:04:05.999999999", - "2006-01-02T15:04:05.999999999", - "2006-01-02 15:04:05", - "2006-01-02T15:04:05", - "2006-01-02 15:04", - "2006-01-02T15:04", - "2006-01-02", -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt *LocalDateTime) Scan(value interface{}) (err error) { - var t time.Time - - if strValue, ok := value.(string); ok { - var timeValue time.Time - for _, format := range formats { - timeValue, err = time.Parse(format, strValue) - if err == nil { - t = timeValue - break - } - } - t = timeValue - } else { - nullTime := &sql.NullTime{} - err = nullTime.Scan(value) - if err != nil { - return err - } - if nullTime == nil { - return nil - } - t = nullTime.Time - } - *ldt = LocalDateTime(time.Date( - t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local, - )) - return -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt LocalDateTime) Value() (driver.Value, error) { - return time.Time(ldt).Local(), nil -} - -// GormDataType gorm common data type -// -//goland:noinspection GoMixedReceiverTy -//goland:noinspection GoMixedReceiverTypes -func (ldt LocalDateTime) GormDataType() string { - return "ldt" -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt LocalDateTime) GobEncode() ([]byte, error) { - return time.Time(ldt).GobEncode() -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt *LocalDateTime) GobDecode(b []byte) error { - return (*time.Time)(ldt).GobDecode(b) -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt LocalDateTime) MarshalJSON() ([]byte, error) { - return time.Time(ldt).MarshalJSON() -} - -//goland:noinspection GoMixedReceiverTypes -func (ldt *LocalDateTime) UnmarshalJSON(b []byte) error { - return (*time.Time)(ldt).UnmarshalJSON(b) -} - -// endregion diff --git a/web/handlers/bill.go b/web/handlers/bill.go index 4446e05..8dd0810 100644 --- a/web/handlers/bill.go +++ b/web/handlers/bill.go @@ -1,6 +1,7 @@ package handlers import ( + "platform/pkg/orm" "platform/web/auth" "platform/web/core" q "platform/web/queries" @@ -41,10 +42,10 @@ func ListBill(c *fiber.Ctx) error { do.Where(q.Bill.Type.Eq(int32(*req.Type))) } if req.CreateAfter != nil { - do.Where(q.Bill.CreatedAt.Gte(core.LocalDateTime(*req.CreateAfter))) + do.Where(q.Bill.CreatedAt.Gte(orm.LocalDateTime(*req.CreateAfter))) } if req.CreateBefore != nil { - do.Where(q.Bill.CreatedAt.Lte(core.LocalDateTime(*req.CreateBefore))) + do.Where(q.Bill.CreatedAt.Lte(orm.LocalDateTime(*req.CreateBefore))) } if req.BillNo != nil && *req.BillNo != "" { do.Where(q.Bill.BillNo.Eq(*req.BillNo)) diff --git a/web/handlers/channel.go b/web/handlers/channel.go index fa3ea0d..035c0ce 100644 --- a/web/handlers/channel.go +++ b/web/handlers/channel.go @@ -2,6 +2,7 @@ package handlers import ( "fmt" + "platform/pkg/orm" "platform/web/auth" "platform/web/core" channel2 "platform/web/domains/channel" @@ -47,10 +48,10 @@ func ListChannels(c *fiber.Ctx) error { } if req.ExpireAfter != nil { - cond.Where(q.Channel.Expiration.Gte(core.LocalDateTime(*req.ExpireAfter))) + cond.Where(q.Channel.Expiration.Gte(orm.LocalDateTime(*req.ExpireAfter))) } if req.ExpireBefore != nil { - cond.Where(q.Channel.Expiration.Lte(core.LocalDateTime(*req.ExpireBefore))) + cond.Where(q.Channel.Expiration.Lte(orm.LocalDateTime(*req.ExpireBefore))) } // 查询数据 diff --git a/web/handlers/resource.go b/web/handlers/resource.go index 73655b0..39c4a28 100644 --- a/web/handlers/resource.go +++ b/web/handlers/resource.go @@ -1,6 +1,7 @@ package handlers import ( + "platform/pkg/orm" "platform/pkg/u" "platform/web/auth" "platform/web/core" @@ -53,16 +54,16 @@ func ListResourcePss(c *fiber.Ctx) error { do.Where(q.ResourcePss.As(q.Resource.Pss.Name()).Type.Eq(int32(*req.Type))) } if req.CreateAfter != nil { - do.Where(q.Resource.CreatedAt.Gte(core.LocalDateTime(*req.CreateAfter))) + do.Where(q.Resource.CreatedAt.Gte(orm.LocalDateTime(*req.CreateAfter))) } if req.CreateBefore != nil { - do.Where(q.Resource.CreatedAt.Lte(core.LocalDateTime(*req.CreateBefore))) + do.Where(q.Resource.CreatedAt.Lte(orm.LocalDateTime(*req.CreateBefore))) } if req.ExpireAfter != nil { - do.Where(q.ResourcePss.As(q.Resource.Pss.Name()).Expire.Gte(core.LocalDateTime(*req.ExpireAfter))) + do.Where(q.ResourcePss.As(q.Resource.Pss.Name()).Expire.Gte(orm.LocalDateTime(*req.ExpireAfter))) } if req.ExpireBefore != nil { - do.Where(q.ResourcePss.As(q.Resource.Pss.Name()).Expire.Lte(core.LocalDateTime(*req.ExpireBefore))) + do.Where(q.ResourcePss.As(q.Resource.Pss.Name()).Expire.Lte(orm.LocalDateTime(*req.ExpireBefore))) } resource, err := q.Resource.Where(do). @@ -118,13 +119,13 @@ func AllResource(c *fiber.Ctx) error { q.Resource.Active.Is(true), q.Resource.Where( pss.Type.Eq(int32(resource2.PssTypeTime)), - pss.Expire.Gte(core.LocalDateTime(time.Now())), + pss.Expire.Gte(orm.LocalDateTime(time.Now())), ).Or( pss.Type.Eq(int32(resource2.PssTypeCount)), pss.Quota.GtCol(pss.Used), ), q.Resource.Where( - pss.DailyLast.Lt(core.LocalDateTime(u.Today())), + pss.DailyLast.Lt(orm.LocalDateTime(u.Today())), ).Or( pss.DailyUsed.LtCol(pss.DailyLimit), ), diff --git a/web/models/admin.gen.go b/web/models/admin.gen.go index 3057c97..99528f7 100644 --- a/web/models/admin.gen.go +++ b/web/models/admin.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,20 +14,20 @@ const TableNameAdmin = "admin" // Admin mapped from table type Admin struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:管理员ID" json:"id"` // 管理员ID - Username string `gorm:"column:username;not null;comment:用户名" json:"username"` // 用户名 - Password string `gorm:"column:password;not null;comment:密码" json:"password"` // 密码 - Name string `gorm:"column:name;comment:真实姓名" json:"name"` // 真实姓名 - Avatar string `gorm:"column:avatar;comment:头像URL" json:"avatar"` // 头像URL - Phone string `gorm:"column:phone;comment:手机号码" json:"phone"` // 手机号码 - Email string `gorm:"column:email;comment:邮箱" json:"email"` // 邮箱 - Status int32 `gorm:"column:status;not null;default:1;comment:状态:0-禁用,1-正常" json:"status"` // 状态:0-禁用,1-正常 - LastLogin core.LocalDateTime `gorm:"column:last_login;comment:最后登录时间" json:"last_login"` // 最后登录时间 - LastLoginHost string `gorm:"column:last_login_host;comment:最后登录地址" json:"last_login_host"` // 最后登录地址 - LastLoginAgent string `gorm:"column:last_login_agent;comment:最后登录代理" json:"last_login_agent"` // 最后登录代理 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:管理员ID" json:"id"` // 管理员ID + Username string `gorm:"column:username;not null;comment:用户名" json:"username"` // 用户名 + Password string `gorm:"column:password;not null;comment:密码" json:"password"` // 密码 + Name string `gorm:"column:name;comment:真实姓名" json:"name"` // 真实姓名 + Avatar string `gorm:"column:avatar;comment:头像URL" json:"avatar"` // 头像URL + Phone string `gorm:"column:phone;comment:手机号码" json:"phone"` // 手机号码 + Email string `gorm:"column:email;comment:邮箱" json:"email"` // 邮箱 + Status int32 `gorm:"column:status;not null;default:1;comment:状态:0-禁用,1-正常" json:"status"` // 状态:0-禁用,1-正常 + LastLogin orm.LocalDateTime `gorm:"column:last_login;comment:最后登录时间" json:"last_login"` // 最后登录时间 + LastLoginHost string `gorm:"column:last_login_host;comment:最后登录地址" json:"last_login_host"` // 最后登录地址 + LastLoginAgent string `gorm:"column:last_login_agent;comment:最后登录代理" json:"last_login_agent"` // 最后登录代理 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Admin's table name diff --git a/web/models/admin_role.gen.go b/web/models/admin_role.gen.go index d1dd1e4..b383981 100644 --- a/web/models/admin_role.gen.go +++ b/web/models/admin_role.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,14 +14,14 @@ const TableNameAdminRole = "admin_role" // AdminRole mapped from table type AdminRole struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:管理员角色ID" json:"id"` // 管理员角色ID - Name string `gorm:"column:name;not null;comment:角色名称" json:"name"` // 角色名称 - Description string `gorm:"column:description;comment:角色描述" json:"description"` // 角色描述 - Active bool `gorm:"column:active;default:true;comment:是否激活" json:"active"` // 是否激活 - Sort int32 `gorm:"column:sort;comment:排序" json:"sort"` // 排序 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:管理员角色ID" json:"id"` // 管理员角色ID + Name string `gorm:"column:name;not null;comment:角色名称" json:"name"` // 角色名称 + Description string `gorm:"column:description;comment:角色描述" json:"description"` // 角色描述 + Active bool `gorm:"column:active;default:true;comment:是否激活" json:"active"` // 是否激活 + Sort int32 `gorm:"column:sort;comment:排序" json:"sort"` // 排序 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName AdminRole's table name diff --git a/web/models/admin_role_link.gen.go b/web/models/admin_role_link.gen.go index 1cf1a31..c239c76 100644 --- a/web/models/admin_role_link.gen.go +++ b/web/models/admin_role_link.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,12 +14,12 @@ const TableNameAdminRoleLink = "admin_role_link" // AdminRoleLink mapped from table type AdminRoleLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID - AdminID int32 `gorm:"column:admin_id;not null;comment:管理员ID" json:"admin_id"` // 管理员ID - RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID + AdminID int32 `gorm:"column:admin_id;not null;comment:管理员ID" json:"admin_id"` // 管理员ID + RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName AdminRoleLink's table name diff --git a/web/models/admin_role_permission_link.gen.go b/web/models/admin_role_permission_link.gen.go index 1278eae..e558a1a 100644 --- a/web/models/admin_role_permission_link.gen.go +++ b/web/models/admin_role_permission_link.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,12 +14,12 @@ const TableNameAdminRolePermissionLink = "admin_role_permission_link" // AdminRolePermissionLink mapped from table type AdminRolePermissionLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID - RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID - PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID + RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID + PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName AdminRolePermissionLink's table name diff --git a/web/models/announcement.gen.go b/web/models/announcement.gen.go index 18d42e3..5242ea1 100644 --- a/web/models/announcement.gen.go +++ b/web/models/announcement.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,16 +14,16 @@ const TableNameAnnouncement = "announcement" // Announcement mapped from table type Announcement struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:公告ID" json:"id"` // 公告ID - Title string `gorm:"column:title;not null;comment:公告标题" json:"title"` // 公告标题 - Content string `gorm:"column:content;comment:公告内容" json:"content"` // 公告内容 - Type int32 `gorm:"column:type;not null;default:1;comment:公告类型:1-普通公告" json:"type"` // 公告类型:1-普通公告 - Pin bool `gorm:"column:pin;not null;comment:是否置顶" json:"pin"` // 是否置顶 - Status int32 `gorm:"column:status;not null;default:1;comment:公告状态:0-禁用,1-正常" json:"status"` // 公告状态:0-禁用,1-正常 - Sort int32 `gorm:"column:sort;not null;comment:公告排序" json:"sort"` // 公告排序 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:公告ID" json:"id"` // 公告ID + Title string `gorm:"column:title;not null;comment:公告标题" json:"title"` // 公告标题 + Content string `gorm:"column:content;comment:公告内容" json:"content"` // 公告内容 + Type int32 `gorm:"column:type;not null;default:1;comment:公告类型:1-普通公告" json:"type"` // 公告类型:1-普通公告 + Pin bool `gorm:"column:pin;not null;comment:是否置顶" json:"pin"` // 是否置顶 + Status int32 `gorm:"column:status;not null;default:1;comment:公告状态:0-禁用,1-正常" json:"status"` // 公告状态:0-禁用,1-正常 + Sort int32 `gorm:"column:sort;not null;comment:公告排序" json:"sort"` // 公告排序 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Announcement's table name diff --git a/web/models/bill.gen.go b/web/models/bill.gen.go index 214358c..ecadb91 100644 --- a/web/models/bill.gen.go +++ b/web/models/bill.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,21 +14,21 @@ const TableNameBill = "bill" // Bill mapped from table type Bill struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:账单ID" json:"id"` // 账单ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - TradeID int32 `gorm:"column:trade_id;comment:订单ID" json:"trade_id"` // 订单ID - ResourceID int32 `gorm:"column:resource_id;comment:套餐ID" json:"resource_id"` // 套餐ID - RefundID int32 `gorm:"column:refund_id;comment:退款ID" json:"refund_id"` // 退款ID - BillNo string `gorm:"column:bill_no;not null;comment:易读账单号" json:"bill_no"` // 易读账单号 - Info string `gorm:"column:info;comment:产品可读信息" json:"info"` // 产品可读信息 - Type int32 `gorm:"column:type;not null;comment:账单类型:1-消费,2-退款,3-充值" json:"type"` // 账单类型:1-消费,2-退款,3-充值 - Amount float64 `gorm:"column:amount;not null;comment:账单金额" json:"amount"` // 账单金额 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 - Trade *Trade `gorm:"foreignKey:TradeID" json:"trade"` - Refund *Refund `gorm:"foreignKey:RefundID" json:"refund"` - Resource *Resource `gorm:"foreignKey:ResourceID" json:"resource"` + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:账单ID" json:"id"` // 账单ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + TradeID int32 `gorm:"column:trade_id;comment:订单ID" json:"trade_id"` // 订单ID + ResourceID int32 `gorm:"column:resource_id;comment:套餐ID" json:"resource_id"` // 套餐ID + RefundID int32 `gorm:"column:refund_id;comment:退款ID" json:"refund_id"` // 退款ID + BillNo string `gorm:"column:bill_no;not null;comment:易读账单号" json:"bill_no"` // 易读账单号 + Info string `gorm:"column:info;comment:产品可读信息" json:"info"` // 产品可读信息 + Type int32 `gorm:"column:type;not null;comment:账单类型:1-消费,2-退款,3-充值" json:"type"` // 账单类型:1-消费,2-退款,3-充值 + Amount float64 `gorm:"column:amount;not null;comment:账单金额" json:"amount"` // 账单金额 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + Trade *Trade `gorm:"foreignKey:TradeID" json:"trade"` + Refund *Refund `gorm:"foreignKey:RefundID" json:"refund"` + Resource *Resource `gorm:"foreignKey:ResourceID" json:"resource"` } // TableName Bill's table name diff --git a/web/models/channel.gen.go b/web/models/channel.gen.go index e75629f..fe8c654 100644 --- a/web/models/channel.gen.go +++ b/web/models/channel.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,23 +14,23 @@ const TableNameChannel = "channel" // Channel mapped from table type Channel struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:通道ID" json:"id"` // 通道ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - ProxyID int32 `gorm:"column:proxy_id;not null;comment:代理ID" json:"proxy_id"` // 代理ID - NodeID int32 `gorm:"column:node_id;comment:节点ID" json:"node_id"` // 节点ID - ProxyHost string `gorm:"column:proxy_host;not null;comment:代理地址" json:"proxy_host"` // 代理地址 - ProxyPort int32 `gorm:"column:proxy_port;not null;comment:转发端口" json:"proxy_port"` // 转发端口 - NodeHost string `gorm:"column:node_host;comment:节点地址" json:"node_host"` // 节点地址 - Protocol int32 `gorm:"column:protocol;comment:协议类型:1-http,2-https,3-socks5" json:"protocol"` // 协议类型:1-http,2-https,3-socks5 - AuthIP bool `gorm:"column:auth_ip;not null;comment:IP认证" json:"auth_ip"` // IP认证 - UserHost string `gorm:"column:user_host;comment:用户地址" json:"user_host"` // 用户地址 - AuthPass bool `gorm:"column:auth_pass;not null;comment:密码认证" json:"auth_pass"` // 密码认证 - Username string `gorm:"column:username;comment:用户名" json:"username"` // 用户名 - Password string `gorm:"column:password;comment:密码" json:"password"` // 密码 - Expiration core.LocalDateTime `gorm:"column:expiration;not null;comment:过期时间" json:"expiration"` // 过期时间 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:通道ID" json:"id"` // 通道ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + ProxyID int32 `gorm:"column:proxy_id;not null;comment:代理ID" json:"proxy_id"` // 代理ID + NodeID int32 `gorm:"column:node_id;comment:节点ID" json:"node_id"` // 节点ID + ProxyHost string `gorm:"column:proxy_host;not null;comment:代理地址" json:"proxy_host"` // 代理地址 + ProxyPort int32 `gorm:"column:proxy_port;not null;comment:转发端口" json:"proxy_port"` // 转发端口 + NodeHost string `gorm:"column:node_host;comment:节点地址" json:"node_host"` // 节点地址 + Protocol int32 `gorm:"column:protocol;comment:协议类型:1-http,2-https,3-socks5" json:"protocol"` // 协议类型:1-http,2-https,3-socks5 + AuthIP bool `gorm:"column:auth_ip;not null;comment:IP认证" json:"auth_ip"` // IP认证 + UserHost string `gorm:"column:user_host;comment:用户地址" json:"user_host"` // 用户地址 + AuthPass bool `gorm:"column:auth_pass;not null;comment:密码认证" json:"auth_pass"` // 密码认证 + Username string `gorm:"column:username;comment:用户名" json:"username"` // 用户名 + Password string `gorm:"column:password;comment:密码" json:"password"` // 密码 + Expiration orm.LocalDateTime `gorm:"column:expiration;not null;comment:过期时间" json:"expiration"` // 过期时间 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Channel's table name diff --git a/web/models/client.gen.go b/web/models/client.gen.go index f452487..6ce6926 100644 --- a/web/models/client.gen.go +++ b/web/models/client.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,21 +14,21 @@ const TableNameClient = "client" // Client mapped from table type Client struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:客户端ID" json:"id"` // 客户端ID - ClientID string `gorm:"column:client_id;not null;comment:OAuth2客户端标识符" json:"client_id"` // OAuth2客户端标识符 - ClientSecret string `gorm:"column:client_secret;not null;comment:OAuth2客户端密钥" json:"client_secret"` // OAuth2客户端密钥 - RedirectURI string `gorm:"column:redirect_uri;comment:OAuth2 重定向URI" json:"redirect_uri"` // OAuth2 重定向URI - GrantCode bool `gorm:"column:grant_code;not null;comment:允许授权码授予" json:"grant_code"` // 允许授权码授予 - GrantClient bool `gorm:"column:grant_client;not null;comment:允许客户端凭证授予" json:"grant_client"` // 允许客户端凭证授予 - GrantRefresh bool `gorm:"column:grant_refresh;not null;comment:允许刷新令牌授予" json:"grant_refresh"` // 允许刷新令牌授予 - GrantPassword bool `gorm:"column:grant_password;not null;comment:允许密码授予" json:"grant_password"` // 允许密码授予 - Spec int32 `gorm:"column:spec;not null;comment:安全规范:1-native,2-browser,3-web,4-trusted" json:"spec"` // 安全规范:1-native,2-browser,3-web,4-trusted - Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称 - Icon string `gorm:"column:icon;comment:图标URL" json:"icon"` // 图标URL - Status int32 `gorm:"column:status;not null;default:1;comment:状态:0-禁用,1-正常" json:"status"` // 状态:0-禁用,1-正常 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:客户端ID" json:"id"` // 客户端ID + ClientID string `gorm:"column:client_id;not null;comment:OAuth2客户端标识符" json:"client_id"` // OAuth2客户端标识符 + ClientSecret string `gorm:"column:client_secret;not null;comment:OAuth2客户端密钥" json:"client_secret"` // OAuth2客户端密钥 + RedirectURI string `gorm:"column:redirect_uri;comment:OAuth2 重定向URI" json:"redirect_uri"` // OAuth2 重定向URI + GrantCode bool `gorm:"column:grant_code;not null;comment:允许授权码授予" json:"grant_code"` // 允许授权码授予 + GrantClient bool `gorm:"column:grant_client;not null;comment:允许客户端凭证授予" json:"grant_client"` // 允许客户端凭证授予 + GrantRefresh bool `gorm:"column:grant_refresh;not null;comment:允许刷新令牌授予" json:"grant_refresh"` // 允许刷新令牌授予 + GrantPassword bool `gorm:"column:grant_password;not null;comment:允许密码授予" json:"grant_password"` // 允许密码授予 + Spec int32 `gorm:"column:spec;not null;comment:安全规范:1-native,2-browser,3-web,4-trusted" json:"spec"` // 安全规范:1-native,2-browser,3-web,4-trusted + Name string `gorm:"column:name;not null;comment:名称" json:"name"` // 名称 + Icon string `gorm:"column:icon;comment:图标URL" json:"icon"` // 图标URL + Status int32 `gorm:"column:status;not null;default:1;comment:状态:0-禁用,1-正常" json:"status"` // 状态:0-禁用,1-正常 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Client's table name diff --git a/web/models/client_permission_link.gen.go b/web/models/client_permission_link.gen.go index 2efcdbc..ed53236 100644 --- a/web/models/client_permission_link.gen.go +++ b/web/models/client_permission_link.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,12 +14,12 @@ const TableNameClientPermissionLink = "client_permission_link" // ClientPermissionLink mapped from table type ClientPermissionLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID - ClientID int32 `gorm:"column:client_id;not null;comment:客户端ID" json:"client_id"` // 客户端ID - PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID + ClientID int32 `gorm:"column:client_id;not null;comment:客户端ID" json:"client_id"` // 客户端ID + PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName ClientPermissionLink's table name diff --git a/web/models/coupon.gen.go b/web/models/coupon.gen.go index add2f7c..083cf97 100644 --- a/web/models/coupon.gen.go +++ b/web/models/coupon.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,17 +14,17 @@ const TableNameCoupon = "coupon" // Coupon mapped from table type Coupon struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:优惠券ID" json:"id"` // 优惠券ID - UserID int32 `gorm:"column:user_id;comment:用户ID" json:"user_id"` // 用户ID - Code string `gorm:"column:code;not null;comment:优惠券代码" json:"code"` // 优惠券代码 - Remark string `gorm:"column:remark;comment:优惠券备注" json:"remark"` // 优惠券备注 - Amount float64 `gorm:"column:amount;not null;comment:优惠券金额" json:"amount"` // 优惠券金额 - MinAmount float64 `gorm:"column:min_amount;not null;comment:最低消费金额" json:"min_amount"` // 最低消费金额 - Status int32 `gorm:"column:status;not null;comment:优惠券状态:0-未使用,1-已使用,2-已过期" json:"status"` // 优惠券状态:0-未使用,1-已使用,2-已过期 - ExpireAt core.LocalDateTime `gorm:"column:expire_at;comment:过期时间" json:"expire_at"` // 过期时间 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:优惠券ID" json:"id"` // 优惠券ID + UserID int32 `gorm:"column:user_id;comment:用户ID" json:"user_id"` // 用户ID + Code string `gorm:"column:code;not null;comment:优惠券代码" json:"code"` // 优惠券代码 + Remark string `gorm:"column:remark;comment:优惠券备注" json:"remark"` // 优惠券备注 + Amount float64 `gorm:"column:amount;not null;comment:优惠券金额" json:"amount"` // 优惠券金额 + MinAmount float64 `gorm:"column:min_amount;not null;comment:最低消费金额" json:"min_amount"` // 最低消费金额 + Status int32 `gorm:"column:status;not null;comment:优惠券状态:0-未使用,1-已使用,2-已过期" json:"status"` // 优惠券状态:0-未使用,1-已使用,2-已过期 + ExpireAt orm.LocalDateTime `gorm:"column:expire_at;comment:过期时间" json:"expire_at"` // 过期时间 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Coupon's table name diff --git a/web/models/logs_request.gen.go b/web/models/logs_request.gen.go index c3f17fc..2d65160 100644 --- a/web/models/logs_request.gen.go +++ b/web/models/logs_request.gen.go @@ -4,23 +4,23 @@ package models -import "platform/web/core" +import "platform/pkg/orm" const TableNameLogsRequest = "logs_request" // LogsRequest mapped from table type LogsRequest struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:访问日志ID" json:"id"` // 访问日志ID - Identity int32 `gorm:"column:identity;comment:访客身份:0-游客,1-用户,2-管理员,3-公共服务,4-安全服务,5-内部服务" json:"identity"` // 访客身份:0-游客,1-用户,2-管理员,3-公共服务,4-安全服务,5-内部服务 - Visitor int32 `gorm:"column:visitor;comment:访客ID" json:"visitor"` // 访客ID - IP string `gorm:"column:ip;not null;comment:IP地址" json:"ip"` // IP地址 - Ua string `gorm:"column:ua;comment:用户代理" json:"ua"` // 用户代理 - Method string `gorm:"column:method;not null;comment:请求方法" json:"method"` // 请求方法 - Path string `gorm:"column:path;not null;comment:请求路径" json:"path"` // 请求路径 - Latency string `gorm:"column:latency;comment:请求延迟" json:"latency"` // 请求延迟 - Status int32 `gorm:"column:status;not null;comment:响应状态码" json:"status"` // 响应状态码 - Error string `gorm:"column:error;comment:错误信息" json:"error"` // 错误信息 - Time core.LocalDateTime `gorm:"column:time;default:CURRENT_TIMESTAMP;comment:请求时间" json:"time"` // 请求时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:访问日志ID" json:"id"` // 访问日志ID + Identity int32 `gorm:"column:identity;comment:访客身份:0-游客,1-用户,2-管理员,3-公共服务,4-安全服务,5-内部服务" json:"identity"` // 访客身份:0-游客,1-用户,2-管理员,3-公共服务,4-安全服务,5-内部服务 + Visitor int32 `gorm:"column:visitor;comment:访客ID" json:"visitor"` // 访客ID + IP string `gorm:"column:ip;not null;comment:IP地址" json:"ip"` // IP地址 + Ua string `gorm:"column:ua;comment:用户代理" json:"ua"` // 用户代理 + Method string `gorm:"column:method;not null;comment:请求方法" json:"method"` // 请求方法 + Path string `gorm:"column:path;not null;comment:请求路径" json:"path"` // 请求路径 + Latency string `gorm:"column:latency;comment:请求延迟" json:"latency"` // 请求延迟 + Status int32 `gorm:"column:status;not null;comment:响应状态码" json:"status"` // 响应状态码 + Error string `gorm:"column:error;comment:错误信息" json:"error"` // 错误信息 + Time orm.LocalDateTime `gorm:"column:time;default:CURRENT_TIMESTAMP;comment:请求时间" json:"time"` // 请求时间 } // TableName LogsRequest's table name diff --git a/web/models/node.gen.go b/web/models/node.gen.go index 3d49e98..90f1375 100644 --- a/web/models/node.gen.go +++ b/web/models/node.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,21 +14,21 @@ const TableNameNode = "node" // Node mapped from table type Node struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:节点ID" json:"id"` // 节点ID - ProxyID int32 `gorm:"column:proxy_id;comment:代理ID" json:"proxy_id"` // 代理ID - Version int32 `gorm:"column:version;not null;comment:节点版本" json:"version"` // 节点版本 - Name string `gorm:"column:name;not null;comment:节点名称" json:"name"` // 节点名称 - Host string `gorm:"column:host;not null;comment:节点地址" json:"host"` // 节点地址 - Isp int32 `gorm:"column:isp;not null;comment:运营商:0-未知,1-电信,2-联通,3-移动" json:"isp"` // 运营商:0-未知,1-电信,2-联通,3-移动 - Prov string `gorm:"column:prov;not null;comment:省份" json:"prov"` // 省份 - City string `gorm:"column:city;not null;comment:城市" json:"city"` // 城市 - ProxyPort int32 `gorm:"column:proxy_port;comment:代理端口" json:"proxy_port"` // 代理端口 - Status int32 `gorm:"column:status;not null;comment:节点状态:0-离线,1-正常" json:"status"` // 节点状态:0-离线,1-正常 - Rtt int32 `gorm:"column:rtt;comment:延迟" json:"rtt"` // 延迟 - Loss int32 `gorm:"column:loss;comment:丢包率" json:"loss"` // 丢包率 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:节点ID" json:"id"` // 节点ID + ProxyID int32 `gorm:"column:proxy_id;comment:代理ID" json:"proxy_id"` // 代理ID + Version int32 `gorm:"column:version;not null;comment:节点版本" json:"version"` // 节点版本 + Name string `gorm:"column:name;not null;comment:节点名称" json:"name"` // 节点名称 + Host string `gorm:"column:host;not null;comment:节点地址" json:"host"` // 节点地址 + Isp int32 `gorm:"column:isp;not null;comment:运营商:0-未知,1-电信,2-联通,3-移动" json:"isp"` // 运营商:0-未知,1-电信,2-联通,3-移动 + Prov string `gorm:"column:prov;not null;comment:省份" json:"prov"` // 省份 + City string `gorm:"column:city;not null;comment:城市" json:"city"` // 城市 + ProxyPort int32 `gorm:"column:proxy_port;comment:代理端口" json:"proxy_port"` // 代理端口 + Status int32 `gorm:"column:status;not null;comment:节点状态:0-离线,1-正常" json:"status"` // 节点状态:0-离线,1-正常 + Rtt int32 `gorm:"column:rtt;comment:延迟" json:"rtt"` // 延迟 + Loss int32 `gorm:"column:loss;comment:丢包率" json:"loss"` // 丢包率 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Node's table name diff --git a/web/models/permission.gen.go b/web/models/permission.gen.go index ed9c068..7b023ff 100644 --- a/web/models/permission.gen.go +++ b/web/models/permission.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,13 +14,13 @@ const TableNamePermission = "permission" // Permission mapped from table type Permission struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:权限ID" json:"id"` // 权限ID - ParentID int32 `gorm:"column:parent_id;comment:父权限ID" json:"parent_id"` // 父权限ID - Name string `gorm:"column:name;not null;comment:权限名称" json:"name"` // 权限名称 - Description string `gorm:"column:description;comment:权限描述" json:"description"` // 权限描述 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:权限ID" json:"id"` // 权限ID + ParentID int32 `gorm:"column:parent_id;comment:父权限ID" json:"parent_id"` // 父权限ID + Name string `gorm:"column:name;not null;comment:权限名称" json:"name"` // 权限名称 + Description string `gorm:"column:description;comment:权限描述" json:"description"` // 权限描述 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Permission's table name diff --git a/web/models/product.gen.go b/web/models/product.gen.go index 9f91e75..1d87ab5 100644 --- a/web/models/product.gen.go +++ b/web/models/product.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,15 +14,15 @@ const TableNameProduct = "product" // Product mapped from table type Product struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:产品ID" json:"id"` // 产品ID - Code string `gorm:"column:code;not null;comment:产品代码" json:"code"` // 产品代码 - Name string `gorm:"column:name;not null;comment:产品名称" json:"name"` // 产品名称 - Description string `gorm:"column:description;comment:产品描述" json:"description"` // 产品描述 - Sort int32 `gorm:"column:sort;not null;comment:排序" json:"sort"` // 排序 - Status int32 `gorm:"column:status;not null;default:1;comment:产品状态:0-禁用,1-正常" json:"status"` // 产品状态:0-禁用,1-正常 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:产品ID" json:"id"` // 产品ID + Code string `gorm:"column:code;not null;comment:产品代码" json:"code"` // 产品代码 + Name string `gorm:"column:name;not null;comment:产品名称" json:"name"` // 产品名称 + Description string `gorm:"column:description;comment:产品描述" json:"description"` // 产品描述 + Sort int32 `gorm:"column:sort;not null;comment:排序" json:"sort"` // 排序 + Status int32 `gorm:"column:status;not null;default:1;comment:产品状态:0-禁用,1-正常" json:"status"` // 产品状态:0-禁用,1-正常 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Product's table name diff --git a/web/models/proxy.gen.go b/web/models/proxy.gen.go index 7b5bc93..ba429a0 100644 --- a/web/models/proxy.gen.go +++ b/web/models/proxy.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,15 +14,15 @@ const TableNameProxy = "proxy" // Proxy mapped from table type Proxy struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:代理服务ID" json:"id"` // 代理服务ID - Version int32 `gorm:"column:version;not null;comment:代理服务版本" json:"version"` // 代理服务版本 - Name string `gorm:"column:name;not null;comment:代理服务名称" json:"name"` // 代理服务名称 - Host string `gorm:"column:host;not null;comment:代理服务地址" json:"host"` // 代理服务地址 - Type int32 `gorm:"column:type;not null;comment:代理服务类型:1-三方,2-自有" json:"type"` // 代理服务类型:1-三方,2-自有 - Secret string `gorm:"column:secret;comment:代理服务密钥" json:"secret"` // 代理服务密钥 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:代理服务ID" json:"id"` // 代理服务ID + Version int32 `gorm:"column:version;not null;comment:代理服务版本" json:"version"` // 代理服务版本 + Name string `gorm:"column:name;not null;comment:代理服务名称" json:"name"` // 代理服务名称 + Host string `gorm:"column:host;not null;comment:代理服务地址" json:"host"` // 代理服务地址 + Type int32 `gorm:"column:type;not null;comment:代理服务类型:1-三方,2-自有" json:"type"` // 代理服务类型:1-三方,2-自有 + Secret string `gorm:"column:secret;comment:代理服务密钥" json:"secret"` // 代理服务密钥 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Proxy's table name diff --git a/web/models/refund.gen.go b/web/models/refund.gen.go index 53cff3c..aee565c 100644 --- a/web/models/refund.gen.go +++ b/web/models/refund.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,15 +14,15 @@ const TableNameRefund = "refund" // Refund mapped from table type Refund struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:退款ID" json:"id"` // 退款ID - TradeID int32 `gorm:"column:trade_id;not null;comment:订单ID" json:"trade_id"` // 订单ID - ProductID int32 `gorm:"column:product_id;comment:产品ID" json:"product_id"` // 产品ID - Amount float64 `gorm:"column:amount;not null;comment:退款金额" json:"amount"` // 退款金额 - Reason string `gorm:"column:reason;comment:退款原因" json:"reason"` // 退款原因 - Status int32 `gorm:"column:status;not null;comment:退款状态:0-待处理,1-已退款,2-已拒绝" json:"status"` // 退款状态:0-待处理,1-已退款,2-已拒绝 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:退款ID" json:"id"` // 退款ID + TradeID int32 `gorm:"column:trade_id;not null;comment:订单ID" json:"trade_id"` // 订单ID + ProductID int32 `gorm:"column:product_id;comment:产品ID" json:"product_id"` // 产品ID + Amount float64 `gorm:"column:amount;not null;comment:退款金额" json:"amount"` // 退款金额 + Reason string `gorm:"column:reason;comment:退款原因" json:"reason"` // 退款原因 + Status int32 `gorm:"column:status;not null;comment:退款状态:0-待处理,1-已退款,2-已拒绝" json:"status"` // 退款状态:0-待处理,1-已退款,2-已拒绝 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Refund's table name diff --git a/web/models/resource.gen.go b/web/models/resource.gen.go index 0dca40f..c03a49d 100644 --- a/web/models/resource.gen.go +++ b/web/models/resource.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,15 +14,15 @@ const TableNameResource = "resource" // Resource mapped from table type Resource struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:套餐ID" json:"id"` // 套餐ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - ResourceNo string `gorm:"column:resource_no;comment:套餐编号" json:"resource_no"` // 套餐编号 - Active bool `gorm:"column:active;not null;default:true;comment:套餐状态" json:"active"` // 套餐状态 - Type int32 `gorm:"column:type;not null;comment:套餐类型:1-动态,2-隧道,3-独享" json:"type"` // 套餐类型:1-动态,2-隧道,3-独享 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 - Pss *ResourcePss `gorm:"foreignKey:ResourceID;references:ID" json:"pss"` + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:套餐ID" json:"id"` // 套餐ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + ResourceNo string `gorm:"column:resource_no;comment:套餐编号" json:"resource_no"` // 套餐编号 + Active bool `gorm:"column:active;not null;default:true;comment:套餐状态" json:"active"` // 套餐状态 + Type int32 `gorm:"column:type;not null;comment:套餐类型:1-动态,2-隧道,3-独享" json:"type"` // 套餐类型:1-动态,2-隧道,3-独享 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + Pss *ResourcePss `gorm:"foreignKey:ResourceID;references:ID" json:"pss"` } // TableName Resource's table name diff --git a/web/models/resource_psr.gen.go b/web/models/resource_psr.gen.go index 1fff74c..524582f 100644 --- a/web/models/resource_psr.gen.go +++ b/web/models/resource_psr.gen.go @@ -4,18 +4,18 @@ package models -import "platform/web/core" +import "platform/pkg/orm" const TableNameResourcePsr = "resource_psr" // ResourcePsr mapped from table type ResourcePsr struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID - ResourceID int32 `gorm:"column:resource_id;not null;comment:套餐ID" json:"resource_id"` // 套餐ID - Live int32 `gorm:"column:live;comment:轮换周期(秒)" json:"live"` // 轮换周期(秒) - Conn int32 `gorm:"column:conn;comment:最大连接数" json:"conn"` // 最大连接数 - Expire core.LocalDateTime `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间 - Used bool `gorm:"column:used;comment:是否已使用" json:"used"` // 是否已使用 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID + ResourceID int32 `gorm:"column:resource_id;not null;comment:套餐ID" json:"resource_id"` // 套餐ID + Live int32 `gorm:"column:live;comment:轮换周期(秒)" json:"live"` // 轮换周期(秒) + Conn int32 `gorm:"column:conn;comment:最大连接数" json:"conn"` // 最大连接数 + Expire orm.LocalDateTime `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间 + Used bool `gorm:"column:used;comment:是否已使用" json:"used"` // 是否已使用 } // TableName ResourcePsr's table name diff --git a/web/models/resource_pss.gen.go b/web/models/resource_pss.gen.go index 28876f6..70d28ac 100644 --- a/web/models/resource_pss.gen.go +++ b/web/models/resource_pss.gen.go @@ -4,22 +4,22 @@ package models -import "platform/web/core" +import "platform/pkg/orm" const TableNameResourcePss = "resource_pss" // ResourcePss mapped from table type ResourcePss struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID - ResourceID int32 `gorm:"column:resource_id;not null;comment:套餐ID" json:"resource_id"` // 套餐ID - Type int32 `gorm:"column:type;comment:套餐类型:1-包时,2-包量" json:"type"` // 套餐类型:1-包时,2-包量 - Live int32 `gorm:"column:live;comment:可用时长(秒)" json:"live"` // 可用时长(秒) - Expire core.LocalDateTime `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间 - Quota int32 `gorm:"column:quota;comment:配额数量" json:"quota"` // 配额数量 - Used int32 `gorm:"column:used;not null;comment:已用数量" json:"used"` // 已用数量 - DailyLimit int32 `gorm:"column:daily_limit;not null;comment:每日限制" json:"daily_limit"` // 每日限制 - DailyUsed int32 `gorm:"column:daily_used;not null;comment:今日已用数量" json:"daily_used"` // 今日已用数量 - DailyLast core.LocalDateTime `gorm:"column:daily_last;comment:今日最后使用时间" json:"daily_last"` // 今日最后使用时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:ID" json:"id"` // ID + ResourceID int32 `gorm:"column:resource_id;not null;comment:套餐ID" json:"resource_id"` // 套餐ID + Type int32 `gorm:"column:type;comment:套餐类型:1-包时,2-包量" json:"type"` // 套餐类型:1-包时,2-包量 + Live int32 `gorm:"column:live;comment:可用时长(秒)" json:"live"` // 可用时长(秒) + Expire orm.LocalDateTime `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间 + Quota int32 `gorm:"column:quota;comment:配额数量" json:"quota"` // 配额数量 + Used int32 `gorm:"column:used;not null;comment:已用数量" json:"used"` // 已用数量 + DailyLimit int32 `gorm:"column:daily_limit;not null;comment:每日限制" json:"daily_limit"` // 每日限制 + DailyUsed int32 `gorm:"column:daily_used;not null;comment:今日已用数量" json:"daily_used"` // 今日已用数量 + DailyLast orm.LocalDateTime `gorm:"column:daily_last;comment:今日最后使用时间" json:"daily_last"` // 今日最后使用时间 } // TableName ResourcePss's table name diff --git a/web/models/trade.gen.go b/web/models/trade.gen.go index 082b3d2..6c95c7e 100644 --- a/web/models/trade.gen.go +++ b/web/models/trade.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,23 +14,23 @@ const TableNameTrade = "trade" // Trade mapped from table type Trade struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:订单ID" json:"id"` // 订单ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - InnerNo string `gorm:"column:inner_no;not null;comment:内部订单号" json:"inner_no"` // 内部订单号 - OuterNo string `gorm:"column:outer_no;comment:外部订单号" json:"outer_no"` // 外部订单号 - Type int32 `gorm:"column:type;not null;comment:订单类型:1-购买产品,2-充值余额" json:"type"` // 订单类型:1-购买产品,2-充值余额 - Subject string `gorm:"column:subject;not null;comment:订单主题" json:"subject"` // 订单主题 - Remark string `gorm:"column:remark;comment:订单备注" json:"remark"` // 订单备注 - Amount float64 `gorm:"column:amount;not null;comment:订单总金额" json:"amount"` // 订单总金额 - Payment float64 `gorm:"column:payment;not null;comment:支付金额" json:"payment"` // 支付金额 - Method int32 `gorm:"column:method;not null;comment:支付方式:1-支付宝,2-微信" json:"method"` // 支付方式:1-支付宝,2-微信 - Status int32 `gorm:"column:status;not null;comment:订单状态:0-待支付,1-已支付,2-已取消,3-已退款" json:"status"` // 订单状态:0-待支付,1-已支付,2-已取消,3-已退款 - PayURL string `gorm:"column:pay_url;comment:支付链接" json:"pay_url"` // 支付链接 - PaidAt core.LocalDateTime `gorm:"column:paid_at;comment:支付时间" json:"paid_at"` // 支付时间 - CancelAt core.LocalDateTime `gorm:"column:cancel_at;comment:取消时间" json:"cancel_at"` // 取消时间 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:订单ID" json:"id"` // 订单ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + InnerNo string `gorm:"column:inner_no;not null;comment:内部订单号" json:"inner_no"` // 内部订单号 + OuterNo string `gorm:"column:outer_no;comment:外部订单号" json:"outer_no"` // 外部订单号 + Type int32 `gorm:"column:type;not null;comment:订单类型:1-购买产品,2-充值余额" json:"type"` // 订单类型:1-购买产品,2-充值余额 + Subject string `gorm:"column:subject;not null;comment:订单主题" json:"subject"` // 订单主题 + Remark string `gorm:"column:remark;comment:订单备注" json:"remark"` // 订单备注 + Amount float64 `gorm:"column:amount;not null;comment:订单总金额" json:"amount"` // 订单总金额 + Payment float64 `gorm:"column:payment;not null;comment:支付金额" json:"payment"` // 支付金额 + Method int32 `gorm:"column:method;not null;comment:支付方式:1-支付宝,2-微信" json:"method"` // 支付方式:1-支付宝,2-微信 + Status int32 `gorm:"column:status;not null;comment:订单状态:0-待支付,1-已支付,2-已取消,3-已退款" json:"status"` // 订单状态:0-待支付,1-已支付,2-已取消,3-已退款 + PayURL string `gorm:"column:pay_url;comment:支付链接" json:"pay_url"` // 支付链接 + PaidAt orm.LocalDateTime `gorm:"column:paid_at;comment:支付时间" json:"paid_at"` // 支付时间 + CancelAt orm.LocalDateTime `gorm:"column:cancel_at;comment:取消时间" json:"cancel_at"` // 取消时间 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Trade's table name diff --git a/web/models/user.gen.go b/web/models/user.gen.go index 1804e7f..a4a294a 100644 --- a/web/models/user.gen.go +++ b/web/models/user.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,27 +14,27 @@ const TableNameUser = "user" // User mapped from table type User struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:用户ID" json:"id"` // 用户ID - AdminID int32 `gorm:"column:admin_id;comment:管理员ID" json:"admin_id"` // 管理员ID - Phone string `gorm:"column:phone;not null;comment:手机号码" json:"phone"` // 手机号码 - Username string `gorm:"column:username;comment:用户名" json:"username"` // 用户名 - Email string `gorm:"column:email" json:"email"` - Password string `gorm:"column:password;comment:用户密码" json:"password"` // 用户密码 - Name string `gorm:"column:name;comment:真实姓名" json:"name"` // 真实姓名 - Avatar string `gorm:"column:avatar;comment:头像URL" json:"avatar"` // 头像URL - Status int32 `gorm:"column:status;not null;default:1;comment:用户状态:0-禁用,1-正常" json:"status"` // 用户状态:0-禁用,1-正常 - Balance float64 `gorm:"column:balance;not null;comment:账户余额" json:"balance"` // 账户余额 - IDType int32 `gorm:"column:id_type;not null;comment:认证类型:0-未认证,1-个人认证,2-企业认证" json:"id_type"` // 认证类型:0-未认证,1-个人认证,2-企业认证 - IDNo string `gorm:"column:id_no;comment:身份证号或营业执照号" json:"id_no"` // 身份证号或营业执照号 - IDToken string `gorm:"column:id_token;comment:身份验证标识" json:"id_token"` // 身份验证标识 - ContactQQ string `gorm:"column:contact_qq;comment:QQ联系方式" json:"contact_qq"` // QQ联系方式 - ContactWechat string `gorm:"column:contact_wechat;comment:微信联系方式" json:"contact_wechat"` // 微信联系方式 - LastLogin core.LocalDateTime `gorm:"column:last_login;comment:最后登录时间" json:"last_login"` // 最后登录时间 - LastLoginHost string `gorm:"column:last_login_host;comment:最后登录地址" json:"last_login_host"` // 最后登录地址 - LastLoginAgent string `gorm:"column:last_login_agent;comment:最后登录代理" json:"last_login_agent"` // 最后登录代理 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:用户ID" json:"id"` // 用户ID + AdminID int32 `gorm:"column:admin_id;comment:管理员ID" json:"admin_id"` // 管理员ID + Phone string `gorm:"column:phone;not null;comment:手机号码" json:"phone"` // 手机号码 + Username string `gorm:"column:username;comment:用户名" json:"username"` // 用户名 + Email string `gorm:"column:email" json:"email"` + Password string `gorm:"column:password;comment:用户密码" json:"password"` // 用户密码 + Name string `gorm:"column:name;comment:真实姓名" json:"name"` // 真实姓名 + Avatar string `gorm:"column:avatar;comment:头像URL" json:"avatar"` // 头像URL + Status int32 `gorm:"column:status;not null;default:1;comment:用户状态:0-禁用,1-正常" json:"status"` // 用户状态:0-禁用,1-正常 + Balance float64 `gorm:"column:balance;not null;comment:账户余额" json:"balance"` // 账户余额 + IDType int32 `gorm:"column:id_type;not null;comment:认证类型:0-未认证,1-个人认证,2-企业认证" json:"id_type"` // 认证类型:0-未认证,1-个人认证,2-企业认证 + IDNo string `gorm:"column:id_no;comment:身份证号或营业执照号" json:"id_no"` // 身份证号或营业执照号 + IDToken string `gorm:"column:id_token;comment:身份验证标识" json:"id_token"` // 身份验证标识 + ContactQQ string `gorm:"column:contact_qq;comment:QQ联系方式" json:"contact_qq"` // QQ联系方式 + ContactWechat string `gorm:"column:contact_wechat;comment:微信联系方式" json:"contact_wechat"` // 微信联系方式 + LastLogin orm.LocalDateTime `gorm:"column:last_login;comment:最后登录时间" json:"last_login"` // 最后登录时间 + LastLoginHost string `gorm:"column:last_login_host;comment:最后登录地址" json:"last_login_host"` // 最后登录地址 + LastLoginAgent string `gorm:"column:last_login_agent;comment:最后登录代理" json:"last_login_agent"` // 最后登录代理 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName User's table name diff --git a/web/models/user_role.gen.go b/web/models/user_role.gen.go index 85935e2..678ad58 100644 --- a/web/models/user_role.gen.go +++ b/web/models/user_role.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,14 +14,14 @@ const TableNameUserRole = "user_role" // UserRole mapped from table type UserRole struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:角色ID" json:"id"` // 角色ID - Name string `gorm:"column:name;not null;comment:角色名称" json:"name"` // 角色名称 - Description string `gorm:"column:description;comment:角色描述" json:"description"` // 角色描述 - Active bool `gorm:"column:active;default:true;comment:是否激活" json:"active"` // 是否激活 - Sort int32 `gorm:"column:sort;comment:排序" json:"sort"` // 排序 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:角色ID" json:"id"` // 角色ID + Name string `gorm:"column:name;not null;comment:角色名称" json:"name"` // 角色名称 + Description string `gorm:"column:description;comment:角色描述" json:"description"` // 角色描述 + Active bool `gorm:"column:active;default:true;comment:是否激活" json:"active"` // 是否激活 + Sort int32 `gorm:"column:sort;comment:排序" json:"sort"` // 排序 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName UserRole's table name diff --git a/web/models/user_role_link.gen.go b/web/models/user_role_link.gen.go index 5217917..4ba0ac0 100644 --- a/web/models/user_role_link.gen.go +++ b/web/models/user_role_link.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,12 +14,12 @@ const TableNameUserRoleLink = "user_role_link" // UserRoleLink mapped from table type UserRoleLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName UserRoleLink's table name diff --git a/web/models/user_role_permission_link.gen.go b/web/models/user_role_permission_link.gen.go index dd42268..1f38952 100644 --- a/web/models/user_role_permission_link.gen.go +++ b/web/models/user_role_permission_link.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,12 +14,12 @@ const TableNameUserRolePermissionLink = "user_role_permission_link" // UserRolePermissionLink mapped from table type UserRolePermissionLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID - RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID - PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:关联ID" json:"id"` // 关联ID + RoleID int32 `gorm:"column:role_id;not null;comment:角色ID" json:"role_id"` // 角色ID + PermissionID int32 `gorm:"column:permission_id;not null;comment:权限ID" json:"permission_id"` // 权限ID + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName UserRolePermissionLink's table name diff --git a/web/models/whitelist.gen.go b/web/models/whitelist.gen.go index 6d5eb87..e8735ed 100644 --- a/web/models/whitelist.gen.go +++ b/web/models/whitelist.gen.go @@ -5,7 +5,7 @@ package models import ( - "platform/web/core" + "platform/pkg/orm" "gorm.io/gorm" ) @@ -14,13 +14,13 @@ const TableNameWhitelist = "whitelist" // Whitelist mapped from table type Whitelist struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:白名单ID" json:"id"` // 白名单ID - UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID - Host string `gorm:"column:host;not null;comment:IP地址" json:"host"` // IP地址 - Remark string `gorm:"column:remark;comment:备注" json:"remark"` // 备注 - CreatedAt core.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 - UpdatedAt core.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 - DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 + ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:白名单ID" json:"id"` // 白名单ID + UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID + Host string `gorm:"column:host;not null;comment:IP地址" json:"host"` // IP地址 + Remark string `gorm:"column:remark;comment:备注" json:"remark"` // 备注 + CreatedAt orm.LocalDateTime `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 + UpdatedAt orm.LocalDateTime `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 + DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 } // TableName Whitelist's table name diff --git a/web/services/auth.go b/web/services/auth.go index 96ed243..a29575d 100644 --- a/web/services/auth.go +++ b/web/services/auth.go @@ -3,8 +3,8 @@ package services import ( "context" "errors" + "platform/pkg/orm" auth2 "platform/web/auth" - "platform/web/core" client2 "platform/web/domains/client" m "platform/web/models" q "platform/web/queries" @@ -122,7 +122,7 @@ func (s *authService) OauthPassword(ctx context.Context, _ *m.Client, data *Gran } // 更新用户的登录时间 - user.LastLogin = core.LocalDateTime(time.Now()) + user.LastLogin = orm.LocalDateTime(time.Now()) user.LastLoginHost = ip user.LastLoginAgent = agent if err := tx.User.Omit(q.User.AdminID).Save(user); err != nil { diff --git a/web/services/channel.go b/web/services/channel.go index d0600f6..4be0f85 100644 --- a/web/services/channel.go +++ b/web/services/channel.go @@ -42,10 +42,10 @@ type ResourceInfo struct { Live int32 DailyLimit int32 DailyUsed int32 - DailyLast core.LocalDateTime + DailyLast orm.LocalDateTime Quota int32 Used int32 - Expire core.LocalDateTime + Expire orm.LocalDateTime } // region RemoveChannel @@ -362,7 +362,7 @@ func findChannels(q *q.Query, proxies []*m.Proxy) (channels []*m.Channel, err er q.Channel.ProxyPort). Where( q.Channel.ProxyID.In(proxyIds...), - q.Channel.Expiration.Gt(core.LocalDateTime(time.Now()))). + q.Channel.Expiration.Gt(orm.LocalDateTime(time.Now()))). Group( q.Channel.ProxyPort, q.Channel.ProxyID). @@ -520,7 +520,7 @@ func calcChannels( ProxyHost: proxy.Host, ProxyPort: int32(port), Protocol: int32(protocol), - Expiration: core.LocalDateTime(expiration), + Expiration: orm.LocalDateTime(expiration), } switch authType { @@ -575,7 +575,7 @@ func calcChannels( func updateResource(rid string, resource *ResourceInfo, count int, now time.Time) (err error) { toUpdate := m.ResourcePss{ Used: resource.Used + int32(count), - DailyLast: core.LocalDateTime(now), + DailyLast: orm.LocalDateTime(now), } var last = time.Time(resource.DailyLast) if now.Year() != last.Year() || now.Month() != last.Month() || now.Day() != last.Day() { diff --git a/web/services/channel_test.go b/web/services/channel_test.go index 27082fe..636a488 100644 --- a/web/services/channel_test.go +++ b/web/services/channel_test.go @@ -4,9 +4,9 @@ import ( "context" "encoding/json" "fmt" + "platform/pkg/orm" "platform/pkg/testutil" "platform/web/auth" - "platform/web/core" g "platform/web/globals" "platform/web/models" "reflect" @@ -110,7 +110,7 @@ func Test_cache(t *testing.T) { // 准备测试数据 now := time.Now() - expiration := core.LocalDateTime(now.Add(24 * time.Hour)) + expiration := orm.LocalDateTime(now.Add(24 * time.Hour)) testChannels := []*models.Channel{ { @@ -342,7 +342,7 @@ func Test_channelService_CreateChannel(t *testing.T) { ResourceID: 1, Type: 1, Live: 180, - Expire: core.LocalDateTime(time.Now().AddDate(1, 0, 0)), + Expire: orm.LocalDateTime(time.Now().AddDate(1, 0, 0)), DailyLimit: 10000, } db.Exec("delete from resource_pss where true") @@ -845,7 +845,7 @@ func Test_channelService_CreateChannel(t *testing.T) { ResourceID: 2, Type: 1, Live: 180, - Expire: core.LocalDateTime(time.Now().AddDate(1, 0, 0)), + Expire: orm.LocalDateTime(time.Now().AddDate(1, 0, 0)), DailyLimit: 10000, } db.Create(resourcePss2) @@ -915,7 +915,7 @@ func Test_channelService_CreateChannel(t *testing.T) { ProxyID: 1, ProxyPort: int32(i + 10000), UserID: 101, - Expiration: core.LocalDateTime(expr), + Expiration: orm.LocalDateTime(expr), } } db.CreateInBatches(channels, 1000) @@ -1041,9 +1041,9 @@ func Test_channelService_RemoveChannels(t *testing.T) { // 创建通道 channels := []models.Channel{ - {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, } // 保存预设数据 @@ -1155,9 +1155,9 @@ func Test_channelService_RemoveChannels(t *testing.T) { // 创建通道 channels := []models.Channel{ - {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 3, UserID: 101, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, } // 保存预设数据 @@ -1269,9 +1269,9 @@ func Test_channelService_RemoveChannels(t *testing.T) { // 创建通道 channels := []models.Channel{ - {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, - {ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: core.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 1, UserID: 101, ProxyID: 1, ProxyPort: 10001, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 2, UserID: 101, ProxyID: 1, ProxyPort: 10002, Protocol: 1, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, + {ID: 3, UserID: 102, ProxyID: 2, ProxyPort: 10001, Protocol: 3, Expiration: orm.LocalDateTime(time.Now().Add(24 * time.Hour))}, } // 保存预设数据 diff --git a/web/services/resource.go b/web/services/resource.go index 0b59a02..cfe4f5b 100644 --- a/web/services/resource.go +++ b/web/services/resource.go @@ -5,8 +5,8 @@ import ( "database/sql" "encoding/json" "fmt" + "platform/pkg/orm" "platform/pkg/rds" - "platform/web/core" bill2 "platform/web/domains/bill" resource2 "platform/web/domains/resource" trade2 "platform/web/domains/trade" @@ -251,7 +251,7 @@ func createResource(q *q.Query, data *CreateResourceData, uid int32) (*m.Resourc Type: data.Type, Live: data.Live, Quota: data.Quota, - Expire: core.LocalDateTime(time.Now().Add(time.Duration(data.Expire) * 24 * time.Hour)), + Expire: orm.LocalDateTime(time.Now().Add(time.Duration(data.Expire) * 24 * time.Hour)), DailyLimit: data.DailyLimit, }, } diff --git a/web/services/transaction.go b/web/services/transaction.go index 658a5d8..3a12b90 100644 --- a/web/services/transaction.go +++ b/web/services/transaction.go @@ -7,8 +7,8 @@ import ( "log/slog" "net/http" "platform/pkg/env" + "platform/pkg/orm" "platform/pkg/u" - "platform/web/core" bill2 "platform/web/domains/bill" coupon2 "platform/web/domains/coupon" trade2 "platform/web/domains/trade" @@ -283,7 +283,7 @@ func (s *transactionService) CompleteTransaction(ctx context.Context, q *q.Query trade.Status = int32(trade2.StatusSuccess) trade.OuterNo = transId trade.Payment = payment - trade.PaidAt = core.LocalDateTime(paidAt) + trade.PaidAt = orm.LocalDateTime(paidAt) trade.PayURL = "" _, err = q.Trade.WithContext(ctx).Updates(trade) if err != nil { @@ -335,7 +335,7 @@ func (s *transactionService) FinishTransaction(ctx context.Context, q *q.Query, Select(q.Trade.Status, q.Trade.CancelAt, q.Trade.PayURL). Updates(m.Trade{ Status: int32(trade2.StatusCanceled), - CancelAt: core.LocalDateTime(time), + CancelAt: orm.LocalDateTime(time), PayURL: "", }) if err != nil { diff --git a/web/web.go b/web/web.go index 6bc92f7..ff2963c 100644 --- a/web/web.go +++ b/web/web.go @@ -9,8 +9,8 @@ import ( "log/slog" "net/http" _ "net/http/pprof" + "platform/pkg/orm" "platform/web/auth" - "platform/web/core" g "platform/web/globals" m "platform/web/models" q "platform/web/queries" @@ -50,6 +50,7 @@ func (s *Server) Run() error { g.InitWechatPay() g.InitAliyun() g.InitValidator() + q.SetDefault(orm.DB) // config s.fiber = fiber.New(fiber.Config{ @@ -150,7 +151,7 @@ func useLogger() fiber.Handler { Latency: latency, Status: int32(c.Response().StatusCode()), Error: errStr, - Time: core.LocalDateTime(reqTime), + Time: orm.LocalDateTime(reqTime), } if authType != auth.PayloadNone { item.Identity = int32(authType)