web 服务框架
This commit is contained in:
36
web/models/admin.gen.go
Normal file
36
web/models/admin.gen.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAdmin = "admin"
|
||||
|
||||
// Admin mapped from table <admin>
|
||||
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:状态:1-正常,0-禁用" json:"status"` // 状态:1-正常,0-禁用
|
||||
LastLogin time.Time `gorm:"column:last_login;comment:最后登录时间" json:"last_login"` // 最后登录时间
|
||||
LastLoginAddr string `gorm:"column:last_login_addr;comment:最后登录地址" json:"last_login_addr"` // 最后登录地址
|
||||
LastLoginAgent string `gorm:"column:last_login_agent;comment:最后登录代理" json:"last_login_agent"` // 最后登录代理
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Admin) TableName() string {
|
||||
return TableNameAdmin
|
||||
}
|
||||
30
web/models/admin_role.gen.go
Normal file
30
web/models/admin_role.gen.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAdminRole = "admin_role"
|
||||
|
||||
// AdminRole mapped from table <admin_role>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*AdminRole) TableName() string {
|
||||
return TableNameAdminRole
|
||||
}
|
||||
28
web/models/admin_role_link.gen.go
Normal file
28
web/models/admin_role_link.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAdminRoleLink = "admin_role_link"
|
||||
|
||||
// AdminRoleLink mapped from table <admin_role_link>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*AdminRoleLink) TableName() string {
|
||||
return TableNameAdminRoleLink
|
||||
}
|
||||
28
web/models/admin_role_permission_link.gen.go
Normal file
28
web/models/admin_role_permission_link.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAdminRolePermissionLink = "admin_role_permission_link"
|
||||
|
||||
// AdminRolePermissionLink mapped from table <admin_role_permission_link>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*AdminRolePermissionLink) TableName() string {
|
||||
return TableNameAdminRolePermissionLink
|
||||
}
|
||||
34
web/models/bill.gen.go
Normal file
34
web/models/bill.gen.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameBill = "bill"
|
||||
|
||||
// Bill mapped from table <bill>
|
||||
type Bill struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:账单ID" json:"id"` // 账单ID
|
||||
OrderID int32 `gorm:"column:order_id;not null;comment:订单ID" json:"order_id"` // 订单ID
|
||||
UserID int32 `gorm:"column:user_id;not null;comment:用户ID" json:"user_id"` // 用户ID
|
||||
ProductID int32 `gorm:"column:product_id;comment:产品ID" json:"product_id"` // 产品ID
|
||||
Info string `gorm:"column:info;comment:产品可读信息" json:"info"` // 产品可读信息
|
||||
Count_ int32 `gorm:"column:count;comment:购买数量" json:"count"` // 购买数量
|
||||
Price float64 `gorm:"column:price;not null;comment:单价" json:"price"` // 单价
|
||||
Amount float64 `gorm:"column:amount;not null;comment:总金额" json:"amount"` // 总金额
|
||||
Payment float64 `gorm:"column:payment;not null;comment:支付金额" json:"payment"` // 支付金额
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName Bill's table name
|
||||
func (*Bill) TableName() string {
|
||||
return TableNameBill
|
||||
}
|
||||
36
web/models/channel.gen.go
Normal file
36
web/models/channel.gen.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameChannel = "channel"
|
||||
|
||||
// Channel mapped from table <channel>
|
||||
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
|
||||
NodeID int32 `gorm:"column:node_id;comment:节点ID" json:"node_id"` // 节点ID
|
||||
UserAddr string `gorm:"column:user_addr;not null;comment:用户地址" json:"user_addr"` // 用户地址
|
||||
NodePort int32 `gorm:"column:node_port;comment:节点端口" json:"node_port"` // 节点端口
|
||||
AuthIP bool `gorm:"column:auth_ip;not null;comment:IP认证" json:"auth_ip"` // IP认证
|
||||
AuthPass bool `gorm:"column:auth_pass;not null;comment:密码认证" json:"auth_pass"` // 密码认证
|
||||
Protocol string `gorm:"column:protocol;comment:协议" json:"protocol"` // 协议
|
||||
Username string `gorm:"column:username;comment:用户名" json:"username"` // 用户名
|
||||
Password string `gorm:"column:password;comment:密码" json:"password"` // 密码
|
||||
Expiration time.Time `gorm:"column:expiration;not null;comment:过期时间" json:"expiration"` // 过期时间
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Channel) TableName() string {
|
||||
return TableNameChannel
|
||||
}
|
||||
31
web/models/node.gen.go
Normal file
31
web/models/node.gen.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameNode = "node"
|
||||
|
||||
// Node mapped from table <node>
|
||||
type Node struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:节点ID" json:"id"` // 节点ID
|
||||
Name string `gorm:"column:name;not null;comment:节点名称" json:"name"` // 节点名称
|
||||
Version int32 `gorm:"column:version;not null;comment:节点版本" json:"version"` // 节点版本
|
||||
FwdPort int32 `gorm:"column:fwd_port;not null;comment:转发端口" json:"fwd_port"` // 转发端口
|
||||
Provider string `gorm:"column:provider;not null;comment:运营商" json:"provider"` // 运营商
|
||||
Location string `gorm:"column:location;not null;comment:位置" json:"location"` // 位置
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Node) TableName() string {
|
||||
return TableNameNode
|
||||
}
|
||||
29
web/models/permission.gen.go
Normal file
29
web/models/permission.gen.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNamePermission = "permission"
|
||||
|
||||
// Permission mapped from table <permission>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Permission) TableName() string {
|
||||
return TableNamePermission
|
||||
}
|
||||
31
web/models/product.gen.go
Normal file
31
web/models/product.gen.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameProduct = "product"
|
||||
|
||||
// Product mapped from table <product>
|
||||
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:产品状态:1-正常,0-禁用" json:"status"` // 产品状态:1-正常,0-禁用
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Product) TableName() string {
|
||||
return TableNameProduct
|
||||
}
|
||||
29
web/models/refund.gen.go
Normal file
29
web/models/refund.gen.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameRefund = "refund"
|
||||
|
||||
// Refund mapped from table <refund>
|
||||
type Refund struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:退款ID" json:"id"` // 退款ID
|
||||
OrderID int32 `gorm:"column:order_id;not null;comment:订单ID" json:"order_id"` // 订单ID
|
||||
ProductID int32 `gorm:"column:product_id;comment:产品ID" json:"product_id"` // 产品ID
|
||||
Amount float64 `gorm:"column:amount;not null;comment:退款金额" json:"amount"` // 退款金额
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Refund) TableName() string {
|
||||
return TableNameRefund
|
||||
}
|
||||
27
web/models/resource.gen.go
Normal file
27
web/models/resource.gen.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameResource = "resource"
|
||||
|
||||
// Resource mapped from table <resource>
|
||||
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
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName Resource's table name
|
||||
func (*Resource) TableName() string {
|
||||
return TableNameResource
|
||||
}
|
||||
28
web/models/resource_pps.gen.go
Normal file
28
web/models/resource_pps.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameResourcePps = "resource_pps"
|
||||
|
||||
// ResourcePps mapped from table <resource_pps>
|
||||
type ResourcePps 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
|
||||
Active bool `gorm:"column:active;not null;comment:是否启用" json:"active"` // 是否启用
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName ResourcePps's table name
|
||||
func (*ResourcePps) TableName() string {
|
||||
return TableNameResourcePps
|
||||
}
|
||||
32
web/models/resource_psr.gen.go
Normal file
32
web/models/resource_psr.gen.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameResourcePsr = "resource_psr"
|
||||
|
||||
// ResourcePsr mapped from table <resource_psr>
|
||||
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
|
||||
Active bool `gorm:"column:active;not null;comment:是否启用" json:"active"` // 是否启用
|
||||
Live int32 `gorm:"column:live;comment:轮换周期(秒)" json:"live"` // 轮换周期(秒)
|
||||
Conn int32 `gorm:"column:conn;comment:最大连接数" json:"conn"` // 最大连接数
|
||||
Expire time.Time `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间
|
||||
Used bool `gorm:"column:used;comment:是否已使用" json:"used"` // 是否已使用
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName ResourcePsr's table name
|
||||
func (*ResourcePsr) TableName() string {
|
||||
return TableNameResourcePsr
|
||||
}
|
||||
35
web/models/resource_pss.gen.go
Normal file
35
web/models/resource_pss.gen.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameResourcePss = "resource_pss"
|
||||
|
||||
// ResourcePss mapped from table <resource_pss>
|
||||
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
|
||||
Active bool `gorm:"column:active;not null;comment:是否启用" json:"active"` // 是否启用
|
||||
Type int32 `gorm:"column:type;comment:套餐类型:1-包时,2-包量" json:"type"` // 套餐类型:1-包时,2-包量
|
||||
Live int32 `gorm:"column:live;comment:可用时长(秒)" json:"live"` // 可用时长(秒)
|
||||
Quota int32 `gorm:"column:quota;comment:配额数量" json:"quota"` // 配额数量
|
||||
Used int32 `gorm:"column:used;comment:已用数量" json:"used"` // 已用数量
|
||||
Expire time.Time `gorm:"column:expire;comment:过期时间" json:"expire"` // 过期时间
|
||||
LimitDay int32 `gorm:"column:limit_day;comment:每日限额" json:"limit_day"` // 每日限额
|
||||
LastUsed time.Time `gorm:"column:last_used;comment:最后提取时间" json:"last_used"` // 最后提取时间
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间
|
||||
}
|
||||
|
||||
// TableName ResourcePss's table name
|
||||
func (*ResourcePss) TableName() string {
|
||||
return TableNameResourcePss
|
||||
}
|
||||
35
web/models/trade.gen.go
Normal file
35
web/models/trade.gen.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameTrade = "trade"
|
||||
|
||||
// Trade mapped from table <trade>
|
||||
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;not null;comment:外部订单号" json:"outer_no"` // 外部订单号
|
||||
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-已退款
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Trade) TableName() string {
|
||||
return TableNameTrade
|
||||
}
|
||||
43
web/models/user.gen.go
Normal file
43
web/models/user.gen.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameUser = "user"
|
||||
|
||||
// User mapped from table <user>
|
||||
type User struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||
AdminID int32 `gorm:"column:admin_id" json:"admin_id"`
|
||||
Phone string `gorm:"column:phone;not null" json:"phone"`
|
||||
Username string `gorm:"column:username" json:"username"`
|
||||
Email string `gorm:"column:email" json:"email"`
|
||||
Password string `gorm:"column:password" json:"password"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
Avatar string `gorm:"column:avatar" json:"avatar"`
|
||||
Status int32 `gorm:"column:status;not null;default:1" json:"status"`
|
||||
Balance float64 `gorm:"column:balance;not null" json:"balance"`
|
||||
IDType int32 `gorm:"column:id_type;not null" json:"id_type"`
|
||||
IDNo string `gorm:"column:id_no" json:"id_no"`
|
||||
IDToken string `gorm:"column:id_token" json:"id_token"`
|
||||
ContactQq string `gorm:"column:contact_qq" json:"contact_qq"`
|
||||
ContactWechat string `gorm:"column:contact_wechat" json:"contact_wechat"`
|
||||
LastLogin time.Time `gorm:"column:last_login" json:"last_login"`
|
||||
LastLoginAddr string `gorm:"column:last_login_addr" json:"last_login_addr"`
|
||||
LastLoginAgent string `gorm:"column:last_login_agent" json:"last_login_agent"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
|
||||
}
|
||||
|
||||
// TableName User's table name
|
||||
func (*User) TableName() string {
|
||||
return TableNameUser
|
||||
}
|
||||
30
web/models/user_role.gen.go
Normal file
30
web/models/user_role.gen.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameUserRole = "user_role"
|
||||
|
||||
// UserRole mapped from table <user_role>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*UserRole) TableName() string {
|
||||
return TableNameUserRole
|
||||
}
|
||||
28
web/models/user_role_link.gen.go
Normal file
28
web/models/user_role_link.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameUserRoleLink = "user_role_link"
|
||||
|
||||
// UserRoleLink mapped from table <user_role_link>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*UserRoleLink) TableName() string {
|
||||
return TableNameUserRoleLink
|
||||
}
|
||||
28
web/models/user_role_permission_link.gen.go
Normal file
28
web/models/user_role_permission_link.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameUserRolePermissionLink = "user_role_permission_link"
|
||||
|
||||
// UserRolePermissionLink mapped from table <user_role_permission_link>
|
||||
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 time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*UserRolePermissionLink) TableName() string {
|
||||
return TableNameUserRolePermissionLink
|
||||
}
|
||||
28
web/models/whitelist.gen.go
Normal file
28
web/models/whitelist.gen.go
Normal file
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameWhitelist = "whitelist"
|
||||
|
||||
// Whitelist mapped from table <whitelist>
|
||||
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
|
||||
Address string `gorm:"column:address;not null;comment:IP地址" json:"address"` // IP地址
|
||||
CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
|
||||
UpdatedAt time.Time `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
|
||||
func (*Whitelist) TableName() string {
|
||||
return TableNameWhitelist
|
||||
}
|
||||
371
web/queries/admin.gen.go
Normal file
371
web/queries/admin.gen.go
Normal file
@@ -0,0 +1,371 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newAdmin(db *gorm.DB, opts ...gen.DOOption) admin {
|
||||
_admin := admin{}
|
||||
|
||||
_admin.adminDo.UseDB(db, opts...)
|
||||
_admin.adminDo.UseModel(&models.Admin{})
|
||||
|
||||
tableName := _admin.adminDo.TableName()
|
||||
_admin.ALL = field.NewAsterisk(tableName)
|
||||
_admin.ID = field.NewInt32(tableName, "id")
|
||||
_admin.Username = field.NewString(tableName, "username")
|
||||
_admin.Password = field.NewString(tableName, "password")
|
||||
_admin.Name = field.NewString(tableName, "name")
|
||||
_admin.Avatar = field.NewString(tableName, "avatar")
|
||||
_admin.Phone = field.NewString(tableName, "phone")
|
||||
_admin.Email = field.NewString(tableName, "email")
|
||||
_admin.Status = field.NewInt32(tableName, "status")
|
||||
_admin.LastLogin = field.NewTime(tableName, "last_login")
|
||||
_admin.LastLoginAddr = field.NewString(tableName, "last_login_addr")
|
||||
_admin.LastLoginAgent = field.NewString(tableName, "last_login_agent")
|
||||
_admin.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_admin.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_admin.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_admin.fillFieldMap()
|
||||
|
||||
return _admin
|
||||
}
|
||||
|
||||
type admin struct {
|
||||
adminDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 管理员ID
|
||||
Username field.String // 用户名
|
||||
Password field.String // 密码
|
||||
Name field.String // 真实姓名
|
||||
Avatar field.String // 头像URL
|
||||
Phone field.String // 手机号码
|
||||
Email field.String // 邮箱
|
||||
Status field.Int32 // 状态:1-正常,0-禁用
|
||||
LastLogin field.Time // 最后登录时间
|
||||
LastLoginAddr field.String // 最后登录地址
|
||||
LastLoginAgent field.String // 最后登录代理
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a admin) Table(newTableName string) *admin {
|
||||
a.adminDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a admin) As(alias string) *admin {
|
||||
a.adminDo.DO = *(a.adminDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *admin) updateTableName(table string) *admin {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt32(table, "id")
|
||||
a.Username = field.NewString(table, "username")
|
||||
a.Password = field.NewString(table, "password")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.Avatar = field.NewString(table, "avatar")
|
||||
a.Phone = field.NewString(table, "phone")
|
||||
a.Email = field.NewString(table, "email")
|
||||
a.Status = field.NewInt32(table, "status")
|
||||
a.LastLogin = field.NewTime(table, "last_login")
|
||||
a.LastLoginAddr = field.NewString(table, "last_login_addr")
|
||||
a.LastLoginAgent = field.NewString(table, "last_login_agent")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *admin) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *admin) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 14)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["username"] = a.Username
|
||||
a.fieldMap["password"] = a.Password
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["avatar"] = a.Avatar
|
||||
a.fieldMap["phone"] = a.Phone
|
||||
a.fieldMap["email"] = a.Email
|
||||
a.fieldMap["status"] = a.Status
|
||||
a.fieldMap["last_login"] = a.LastLogin
|
||||
a.fieldMap["last_login_addr"] = a.LastLoginAddr
|
||||
a.fieldMap["last_login_agent"] = a.LastLoginAgent
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a admin) clone(db *gorm.DB) admin {
|
||||
a.adminDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a admin) replaceDB(db *gorm.DB) admin {
|
||||
a.adminDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type adminDo struct{ gen.DO }
|
||||
|
||||
func (a adminDo) Debug() *adminDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a adminDo) WithContext(ctx context.Context) *adminDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a adminDo) ReadDB() *adminDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a adminDo) WriteDB() *adminDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a adminDo) Session(config *gorm.Session) *adminDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a adminDo) Clauses(conds ...clause.Expression) *adminDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Returning(value interface{}, columns ...string) *adminDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a adminDo) Not(conds ...gen.Condition) *adminDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Or(conds ...gen.Condition) *adminDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Select(conds ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Where(conds ...gen.Condition) *adminDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Order(conds ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Distinct(cols ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a adminDo) Omit(cols ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a adminDo) Join(table schema.Tabler, on ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a adminDo) LeftJoin(table schema.Tabler, on ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminDo) RightJoin(table schema.Tabler, on ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminDo) Group(cols ...field.Expr) *adminDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a adminDo) Having(conds ...gen.Condition) *adminDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a adminDo) Limit(limit int) *adminDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a adminDo) Offset(offset int) *adminDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a adminDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *adminDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a adminDo) Unscoped() *adminDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a adminDo) Create(values ...*models.Admin) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a adminDo) CreateInBatches(values []*models.Admin, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a adminDo) Save(values ...*models.Admin) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a adminDo) First() (*models.Admin, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Admin), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminDo) Take() (*models.Admin, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Admin), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminDo) Last() (*models.Admin, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Admin), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminDo) Find() ([]*models.Admin, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*models.Admin), err
|
||||
}
|
||||
|
||||
func (a adminDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Admin, err error) {
|
||||
buf := make([]*models.Admin, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a adminDo) FindInBatches(result *[]*models.Admin, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a adminDo) Attrs(attrs ...field.AssignExpr) *adminDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a adminDo) Assign(attrs ...field.AssignExpr) *adminDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a adminDo) Joins(fields ...field.RelationField) *adminDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminDo) Preload(fields ...field.RelationField) *adminDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminDo) FirstOrInit() (*models.Admin, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Admin), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminDo) FirstOrCreate() (*models.Admin, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Admin), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminDo) FindByPage(offset int, limit int) (result []*models.Admin, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a adminDo) Delete(models ...*models.Admin) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *adminDo) withDO(do gen.Dao) *adminDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
347
web/queries/admin_role.gen.go
Normal file
347
web/queries/admin_role.gen.go
Normal file
@@ -0,0 +1,347 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newAdminRole(db *gorm.DB, opts ...gen.DOOption) adminRole {
|
||||
_adminRole := adminRole{}
|
||||
|
||||
_adminRole.adminRoleDo.UseDB(db, opts...)
|
||||
_adminRole.adminRoleDo.UseModel(&models.AdminRole{})
|
||||
|
||||
tableName := _adminRole.adminRoleDo.TableName()
|
||||
_adminRole.ALL = field.NewAsterisk(tableName)
|
||||
_adminRole.ID = field.NewInt32(tableName, "id")
|
||||
_adminRole.Name = field.NewString(tableName, "name")
|
||||
_adminRole.Description = field.NewString(tableName, "description")
|
||||
_adminRole.Active = field.NewBool(tableName, "active")
|
||||
_adminRole.Sort = field.NewInt32(tableName, "sort")
|
||||
_adminRole.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_adminRole.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_adminRole.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_adminRole.fillFieldMap()
|
||||
|
||||
return _adminRole
|
||||
}
|
||||
|
||||
type adminRole struct {
|
||||
adminRoleDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 管理员角色ID
|
||||
Name field.String // 角色名称
|
||||
Description field.String // 角色描述
|
||||
Active field.Bool // 是否激活
|
||||
Sort field.Int32 // 排序
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a adminRole) Table(newTableName string) *adminRole {
|
||||
a.adminRoleDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a adminRole) As(alias string) *adminRole {
|
||||
a.adminRoleDo.DO = *(a.adminRoleDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *adminRole) updateTableName(table string) *adminRole {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt32(table, "id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.Description = field.NewString(table, "description")
|
||||
a.Active = field.NewBool(table, "active")
|
||||
a.Sort = field.NewInt32(table, "sort")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *adminRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *adminRole) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 8)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["description"] = a.Description
|
||||
a.fieldMap["active"] = a.Active
|
||||
a.fieldMap["sort"] = a.Sort
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a adminRole) clone(db *gorm.DB) adminRole {
|
||||
a.adminRoleDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a adminRole) replaceDB(db *gorm.DB) adminRole {
|
||||
a.adminRoleDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type adminRoleDo struct{ gen.DO }
|
||||
|
||||
func (a adminRoleDo) Debug() *adminRoleDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a adminRoleDo) WithContext(ctx context.Context) *adminRoleDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) ReadDB() *adminRoleDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) WriteDB() *adminRoleDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Session(config *gorm.Session) *adminRoleDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Clauses(conds ...clause.Expression) *adminRoleDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Returning(value interface{}, columns ...string) *adminRoleDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Not(conds ...gen.Condition) *adminRoleDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Or(conds ...gen.Condition) *adminRoleDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Select(conds ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Where(conds ...gen.Condition) *adminRoleDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Order(conds ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Distinct(cols ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Omit(cols ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Join(table schema.Tabler, on ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Group(cols ...field.Expr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Having(conds ...gen.Condition) *adminRoleDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Limit(limit int) *adminRoleDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Offset(offset int) *adminRoleDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *adminRoleDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Unscoped() *adminRoleDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Create(values ...*models.AdminRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) CreateInBatches(values []*models.AdminRole, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a adminRoleDo) Save(values ...*models.AdminRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) First() (*models.AdminRole, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Take() (*models.AdminRole, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Last() (*models.AdminRole, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Find() ([]*models.AdminRole, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*models.AdminRole), err
|
||||
}
|
||||
|
||||
func (a adminRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.AdminRole, err error) {
|
||||
buf := make([]*models.AdminRole, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a adminRoleDo) FindInBatches(result *[]*models.AdminRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Attrs(attrs ...field.AssignExpr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Assign(attrs ...field.AssignExpr) *adminRoleDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Joins(fields ...field.RelationField) *adminRoleDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Preload(fields ...field.RelationField) *adminRoleDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRoleDo) FirstOrInit() (*models.AdminRole, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleDo) FirstOrCreate() (*models.AdminRole, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleDo) FindByPage(offset int, limit int) (result []*models.AdminRole, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a adminRoleDo) Delete(models ...*models.AdminRole) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *adminRoleDo) withDO(do gen.Dao) *adminRoleDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
339
web/queries/admin_role_link.gen.go
Normal file
339
web/queries/admin_role_link.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newAdminRoleLink(db *gorm.DB, opts ...gen.DOOption) adminRoleLink {
|
||||
_adminRoleLink := adminRoleLink{}
|
||||
|
||||
_adminRoleLink.adminRoleLinkDo.UseDB(db, opts...)
|
||||
_adminRoleLink.adminRoleLinkDo.UseModel(&models.AdminRoleLink{})
|
||||
|
||||
tableName := _adminRoleLink.adminRoleLinkDo.TableName()
|
||||
_adminRoleLink.ALL = field.NewAsterisk(tableName)
|
||||
_adminRoleLink.ID = field.NewInt32(tableName, "id")
|
||||
_adminRoleLink.AdminID = field.NewInt32(tableName, "admin_id")
|
||||
_adminRoleLink.RoleID = field.NewInt32(tableName, "role_id")
|
||||
_adminRoleLink.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_adminRoleLink.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_adminRoleLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_adminRoleLink.fillFieldMap()
|
||||
|
||||
return _adminRoleLink
|
||||
}
|
||||
|
||||
type adminRoleLink struct {
|
||||
adminRoleLinkDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 关联ID
|
||||
AdminID field.Int32 // 管理员ID
|
||||
RoleID field.Int32 // 角色ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a adminRoleLink) Table(newTableName string) *adminRoleLink {
|
||||
a.adminRoleLinkDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a adminRoleLink) As(alias string) *adminRoleLink {
|
||||
a.adminRoleLinkDo.DO = *(a.adminRoleLinkDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *adminRoleLink) updateTableName(table string) *adminRoleLink {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt32(table, "id")
|
||||
a.AdminID = field.NewInt32(table, "admin_id")
|
||||
a.RoleID = field.NewInt32(table, "role_id")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *adminRoleLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *adminRoleLink) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 6)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["admin_id"] = a.AdminID
|
||||
a.fieldMap["role_id"] = a.RoleID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a adminRoleLink) clone(db *gorm.DB) adminRoleLink {
|
||||
a.adminRoleLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a adminRoleLink) replaceDB(db *gorm.DB) adminRoleLink {
|
||||
a.adminRoleLinkDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type adminRoleLinkDo struct{ gen.DO }
|
||||
|
||||
func (a adminRoleLinkDo) Debug() *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) WithContext(ctx context.Context) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) ReadDB() *adminRoleLinkDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) WriteDB() *adminRoleLinkDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Session(config *gorm.Session) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Clauses(conds ...clause.Expression) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Returning(value interface{}, columns ...string) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Not(conds ...gen.Condition) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Or(conds ...gen.Condition) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Select(conds ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Where(conds ...gen.Condition) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Order(conds ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Distinct(cols ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Omit(cols ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Join(table schema.Tabler, on ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Group(cols ...field.Expr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Having(conds ...gen.Condition) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Limit(limit int) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Offset(offset int) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Unscoped() *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Create(values ...*models.AdminRoleLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) CreateInBatches(values []*models.AdminRoleLink, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a adminRoleLinkDo) Save(values ...*models.AdminRoleLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) First() (*models.AdminRoleLink, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Take() (*models.AdminRoleLink, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Last() (*models.AdminRoleLink, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Find() ([]*models.AdminRoleLink, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*models.AdminRoleLink), err
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.AdminRoleLink, err error) {
|
||||
buf := make([]*models.AdminRoleLink, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) FindInBatches(result *[]*models.AdminRoleLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Attrs(attrs ...field.AssignExpr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Assign(attrs ...field.AssignExpr) *adminRoleLinkDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Joins(fields ...field.RelationField) *adminRoleLinkDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Preload(fields ...field.RelationField) *adminRoleLinkDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) FirstOrInit() (*models.AdminRoleLink, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) FirstOrCreate() (*models.AdminRoleLink, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) FindByPage(offset int, limit int) (result []*models.AdminRoleLink, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a adminRoleLinkDo) Delete(models ...*models.AdminRoleLink) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *adminRoleLinkDo) withDO(do gen.Dao) *adminRoleLinkDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
339
web/queries/admin_role_permission_link.gen.go
Normal file
339
web/queries/admin_role_permission_link.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newAdminRolePermissionLink(db *gorm.DB, opts ...gen.DOOption) adminRolePermissionLink {
|
||||
_adminRolePermissionLink := adminRolePermissionLink{}
|
||||
|
||||
_adminRolePermissionLink.adminRolePermissionLinkDo.UseDB(db, opts...)
|
||||
_adminRolePermissionLink.adminRolePermissionLinkDo.UseModel(&models.AdminRolePermissionLink{})
|
||||
|
||||
tableName := _adminRolePermissionLink.adminRolePermissionLinkDo.TableName()
|
||||
_adminRolePermissionLink.ALL = field.NewAsterisk(tableName)
|
||||
_adminRolePermissionLink.ID = field.NewInt32(tableName, "id")
|
||||
_adminRolePermissionLink.RoleID = field.NewInt32(tableName, "role_id")
|
||||
_adminRolePermissionLink.PermissionID = field.NewInt32(tableName, "permission_id")
|
||||
_adminRolePermissionLink.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_adminRolePermissionLink.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_adminRolePermissionLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_adminRolePermissionLink.fillFieldMap()
|
||||
|
||||
return _adminRolePermissionLink
|
||||
}
|
||||
|
||||
type adminRolePermissionLink struct {
|
||||
adminRolePermissionLinkDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 关联ID
|
||||
RoleID field.Int32 // 角色ID
|
||||
PermissionID field.Int32 // 权限ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLink) Table(newTableName string) *adminRolePermissionLink {
|
||||
a.adminRolePermissionLinkDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLink) As(alias string) *adminRolePermissionLink {
|
||||
a.adminRolePermissionLinkDo.DO = *(a.adminRolePermissionLinkDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *adminRolePermissionLink) updateTableName(table string) *adminRolePermissionLink {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt32(table, "id")
|
||||
a.RoleID = field.NewInt32(table, "role_id")
|
||||
a.PermissionID = field.NewInt32(table, "permission_id")
|
||||
a.CreatedAt = field.NewTime(table, "created_at")
|
||||
a.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *adminRolePermissionLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *adminRolePermissionLink) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 6)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["role_id"] = a.RoleID
|
||||
a.fieldMap["permission_id"] = a.PermissionID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLink) clone(db *gorm.DB) adminRolePermissionLink {
|
||||
a.adminRolePermissionLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLink) replaceDB(db *gorm.DB) adminRolePermissionLink {
|
||||
a.adminRolePermissionLinkDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type adminRolePermissionLinkDo struct{ gen.DO }
|
||||
|
||||
func (a adminRolePermissionLinkDo) Debug() *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) WithContext(ctx context.Context) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) ReadDB() *adminRolePermissionLinkDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) WriteDB() *adminRolePermissionLinkDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Session(config *gorm.Session) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Clauses(conds ...clause.Expression) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Returning(value interface{}, columns ...string) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Not(conds ...gen.Condition) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Or(conds ...gen.Condition) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Select(conds ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Where(conds ...gen.Condition) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Order(conds ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Distinct(cols ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Omit(cols ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Join(table schema.Tabler, on ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Group(cols ...field.Expr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Having(conds ...gen.Condition) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Limit(limit int) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Offset(offset int) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Unscoped() *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Create(values ...*models.AdminRolePermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) CreateInBatches(values []*models.AdminRolePermissionLink, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a adminRolePermissionLinkDo) Save(values ...*models.AdminRolePermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) First() (*models.AdminRolePermissionLink, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Take() (*models.AdminRolePermissionLink, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Last() (*models.AdminRolePermissionLink, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Find() ([]*models.AdminRolePermissionLink, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*models.AdminRolePermissionLink), err
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.AdminRolePermissionLink, err error) {
|
||||
buf := make([]*models.AdminRolePermissionLink, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) FindInBatches(result *[]*models.AdminRolePermissionLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Attrs(attrs ...field.AssignExpr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Assign(attrs ...field.AssignExpr) *adminRolePermissionLinkDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Joins(fields ...field.RelationField) *adminRolePermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Preload(fields ...field.RelationField) *adminRolePermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) FirstOrInit() (*models.AdminRolePermissionLink, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) FirstOrCreate() (*models.AdminRolePermissionLink, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.AdminRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) FindByPage(offset int, limit int) (result []*models.AdminRolePermissionLink, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a adminRolePermissionLinkDo) Delete(models ...*models.AdminRolePermissionLink) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *adminRolePermissionLinkDo) withDO(do gen.Dao) *adminRolePermissionLinkDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
363
web/queries/bill.gen.go
Normal file
363
web/queries/bill.gen.go
Normal file
@@ -0,0 +1,363 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
|
||||
_bill := bill{}
|
||||
|
||||
_bill.billDo.UseDB(db, opts...)
|
||||
_bill.billDo.UseModel(&models.Bill{})
|
||||
|
||||
tableName := _bill.billDo.TableName()
|
||||
_bill.ALL = field.NewAsterisk(tableName)
|
||||
_bill.ID = field.NewInt32(tableName, "id")
|
||||
_bill.OrderID = field.NewInt32(tableName, "order_id")
|
||||
_bill.UserID = field.NewInt32(tableName, "user_id")
|
||||
_bill.ProductID = field.NewInt32(tableName, "product_id")
|
||||
_bill.Info = field.NewString(tableName, "info")
|
||||
_bill.Count_ = field.NewInt32(tableName, "count")
|
||||
_bill.Price = field.NewFloat64(tableName, "price")
|
||||
_bill.Amount = field.NewFloat64(tableName, "amount")
|
||||
_bill.Payment = field.NewFloat64(tableName, "payment")
|
||||
_bill.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_bill.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_bill.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_bill.fillFieldMap()
|
||||
|
||||
return _bill
|
||||
}
|
||||
|
||||
type bill struct {
|
||||
billDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 账单ID
|
||||
OrderID field.Int32 // 订单ID
|
||||
UserID field.Int32 // 用户ID
|
||||
ProductID field.Int32 // 产品ID
|
||||
Info field.String // 产品可读信息
|
||||
Count_ field.Int32 // 购买数量
|
||||
Price field.Float64 // 单价
|
||||
Amount field.Float64 // 总金额
|
||||
Payment field.Float64 // 支付金额
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (b bill) Table(newTableName string) *bill {
|
||||
b.billDo.UseTable(newTableName)
|
||||
return b.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (b bill) As(alias string) *bill {
|
||||
b.billDo.DO = *(b.billDo.As(alias).(*gen.DO))
|
||||
return b.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (b *bill) updateTableName(table string) *bill {
|
||||
b.ALL = field.NewAsterisk(table)
|
||||
b.ID = field.NewInt32(table, "id")
|
||||
b.OrderID = field.NewInt32(table, "order_id")
|
||||
b.UserID = field.NewInt32(table, "user_id")
|
||||
b.ProductID = field.NewInt32(table, "product_id")
|
||||
b.Info = field.NewString(table, "info")
|
||||
b.Count_ = field.NewInt32(table, "count")
|
||||
b.Price = field.NewFloat64(table, "price")
|
||||
b.Amount = field.NewFloat64(table, "amount")
|
||||
b.Payment = field.NewFloat64(table, "payment")
|
||||
b.CreatedAt = field.NewTime(table, "created_at")
|
||||
b.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
b.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
b.fillFieldMap()
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *bill) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := b.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (b *bill) fillFieldMap() {
|
||||
b.fieldMap = make(map[string]field.Expr, 12)
|
||||
b.fieldMap["id"] = b.ID
|
||||
b.fieldMap["order_id"] = b.OrderID
|
||||
b.fieldMap["user_id"] = b.UserID
|
||||
b.fieldMap["product_id"] = b.ProductID
|
||||
b.fieldMap["info"] = b.Info
|
||||
b.fieldMap["count"] = b.Count_
|
||||
b.fieldMap["price"] = b.Price
|
||||
b.fieldMap["amount"] = b.Amount
|
||||
b.fieldMap["payment"] = b.Payment
|
||||
b.fieldMap["created_at"] = b.CreatedAt
|
||||
b.fieldMap["updated_at"] = b.UpdatedAt
|
||||
b.fieldMap["deleted_at"] = b.DeletedAt
|
||||
}
|
||||
|
||||
func (b bill) clone(db *gorm.DB) bill {
|
||||
b.billDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return b
|
||||
}
|
||||
|
||||
func (b bill) replaceDB(db *gorm.DB) bill {
|
||||
b.billDo.ReplaceDB(db)
|
||||
return b
|
||||
}
|
||||
|
||||
type billDo struct{ gen.DO }
|
||||
|
||||
func (b billDo) Debug() *billDo {
|
||||
return b.withDO(b.DO.Debug())
|
||||
}
|
||||
|
||||
func (b billDo) WithContext(ctx context.Context) *billDo {
|
||||
return b.withDO(b.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (b billDo) ReadDB() *billDo {
|
||||
return b.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (b billDo) WriteDB() *billDo {
|
||||
return b.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (b billDo) Session(config *gorm.Session) *billDo {
|
||||
return b.withDO(b.DO.Session(config))
|
||||
}
|
||||
|
||||
func (b billDo) Clauses(conds ...clause.Expression) *billDo {
|
||||
return b.withDO(b.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Returning(value interface{}, columns ...string) *billDo {
|
||||
return b.withDO(b.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (b billDo) Not(conds ...gen.Condition) *billDo {
|
||||
return b.withDO(b.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Or(conds ...gen.Condition) *billDo {
|
||||
return b.withDO(b.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Select(conds ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Where(conds ...gen.Condition) *billDo {
|
||||
return b.withDO(b.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Order(conds ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Distinct(cols ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (b billDo) Omit(cols ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (b billDo) Join(table schema.Tabler, on ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (b billDo) LeftJoin(table schema.Tabler, on ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (b billDo) RightJoin(table schema.Tabler, on ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (b billDo) Group(cols ...field.Expr) *billDo {
|
||||
return b.withDO(b.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (b billDo) Having(conds ...gen.Condition) *billDo {
|
||||
return b.withDO(b.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (b billDo) Limit(limit int) *billDo {
|
||||
return b.withDO(b.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (b billDo) Offset(offset int) *billDo {
|
||||
return b.withDO(b.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (b billDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *billDo {
|
||||
return b.withDO(b.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (b billDo) Unscoped() *billDo {
|
||||
return b.withDO(b.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (b billDo) Create(values ...*models.Bill) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return b.DO.Create(values)
|
||||
}
|
||||
|
||||
func (b billDo) CreateInBatches(values []*models.Bill, batchSize int) error {
|
||||
return b.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (b billDo) Save(values ...*models.Bill) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return b.DO.Save(values)
|
||||
}
|
||||
|
||||
func (b billDo) First() (*models.Bill, error) {
|
||||
if result, err := b.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Bill), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (b billDo) Take() (*models.Bill, error) {
|
||||
if result, err := b.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Bill), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (b billDo) Last() (*models.Bill, error) {
|
||||
if result, err := b.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Bill), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (b billDo) Find() ([]*models.Bill, error) {
|
||||
result, err := b.DO.Find()
|
||||
return result.([]*models.Bill), err
|
||||
}
|
||||
|
||||
func (b billDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Bill, err error) {
|
||||
buf := make([]*models.Bill, 0, batchSize)
|
||||
err = b.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (b billDo) FindInBatches(result *[]*models.Bill, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return b.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (b billDo) Attrs(attrs ...field.AssignExpr) *billDo {
|
||||
return b.withDO(b.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (b billDo) Assign(attrs ...field.AssignExpr) *billDo {
|
||||
return b.withDO(b.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (b billDo) Joins(fields ...field.RelationField) *billDo {
|
||||
for _, _f := range fields {
|
||||
b = *b.withDO(b.DO.Joins(_f))
|
||||
}
|
||||
return &b
|
||||
}
|
||||
|
||||
func (b billDo) Preload(fields ...field.RelationField) *billDo {
|
||||
for _, _f := range fields {
|
||||
b = *b.withDO(b.DO.Preload(_f))
|
||||
}
|
||||
return &b
|
||||
}
|
||||
|
||||
func (b billDo) FirstOrInit() (*models.Bill, error) {
|
||||
if result, err := b.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Bill), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (b billDo) FirstOrCreate() (*models.Bill, error) {
|
||||
if result, err := b.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Bill), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (b billDo) FindByPage(offset int, limit int) (result []*models.Bill, count int64, err error) {
|
||||
result, err = b.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = b.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (b billDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = b.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = b.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (b billDo) Scan(result interface{}) (err error) {
|
||||
return b.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (b billDo) Delete(models ...*models.Bill) (result gen.ResultInfo, err error) {
|
||||
return b.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (b *billDo) withDO(do gen.Dao) *billDo {
|
||||
b.DO = *do.(*gen.DO)
|
||||
return b
|
||||
}
|
||||
371
web/queries/channel.gen.go
Normal file
371
web/queries/channel.gen.go
Normal file
@@ -0,0 +1,371 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newChannel(db *gorm.DB, opts ...gen.DOOption) channel {
|
||||
_channel := channel{}
|
||||
|
||||
_channel.channelDo.UseDB(db, opts...)
|
||||
_channel.channelDo.UseModel(&models.Channel{})
|
||||
|
||||
tableName := _channel.channelDo.TableName()
|
||||
_channel.ALL = field.NewAsterisk(tableName)
|
||||
_channel.ID = field.NewInt32(tableName, "id")
|
||||
_channel.UserID = field.NewInt32(tableName, "user_id")
|
||||
_channel.NodeID = field.NewInt32(tableName, "node_id")
|
||||
_channel.UserAddr = field.NewString(tableName, "user_addr")
|
||||
_channel.NodePort = field.NewInt32(tableName, "node_port")
|
||||
_channel.AuthIP = field.NewBool(tableName, "auth_ip")
|
||||
_channel.AuthPass = field.NewBool(tableName, "auth_pass")
|
||||
_channel.Protocol = field.NewString(tableName, "protocol")
|
||||
_channel.Username = field.NewString(tableName, "username")
|
||||
_channel.Password = field.NewString(tableName, "password")
|
||||
_channel.Expiration = field.NewTime(tableName, "expiration")
|
||||
_channel.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_channel.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_channel.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_channel.fillFieldMap()
|
||||
|
||||
return _channel
|
||||
}
|
||||
|
||||
type channel struct {
|
||||
channelDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 通道ID
|
||||
UserID field.Int32 // 用户ID
|
||||
NodeID field.Int32 // 节点ID
|
||||
UserAddr field.String // 用户地址
|
||||
NodePort field.Int32 // 节点端口
|
||||
AuthIP field.Bool // IP认证
|
||||
AuthPass field.Bool // 密码认证
|
||||
Protocol field.String // 协议
|
||||
Username field.String // 用户名
|
||||
Password field.String // 密码
|
||||
Expiration field.Time // 过期时间
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (c channel) Table(newTableName string) *channel {
|
||||
c.channelDo.UseTable(newTableName)
|
||||
return c.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (c channel) As(alias string) *channel {
|
||||
c.channelDo.DO = *(c.channelDo.As(alias).(*gen.DO))
|
||||
return c.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (c *channel) updateTableName(table string) *channel {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt32(table, "id")
|
||||
c.UserID = field.NewInt32(table, "user_id")
|
||||
c.NodeID = field.NewInt32(table, "node_id")
|
||||
c.UserAddr = field.NewString(table, "user_addr")
|
||||
c.NodePort = field.NewInt32(table, "node_port")
|
||||
c.AuthIP = field.NewBool(table, "auth_ip")
|
||||
c.AuthPass = field.NewBool(table, "auth_pass")
|
||||
c.Protocol = field.NewString(table, "protocol")
|
||||
c.Username = field.NewString(table, "username")
|
||||
c.Password = field.NewString(table, "password")
|
||||
c.Expiration = field.NewTime(table, "expiration")
|
||||
c.CreatedAt = field.NewTime(table, "created_at")
|
||||
c.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
c.fillFieldMap()
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *channel) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := c.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (c *channel) fillFieldMap() {
|
||||
c.fieldMap = make(map[string]field.Expr, 14)
|
||||
c.fieldMap["id"] = c.ID
|
||||
c.fieldMap["user_id"] = c.UserID
|
||||
c.fieldMap["node_id"] = c.NodeID
|
||||
c.fieldMap["user_addr"] = c.UserAddr
|
||||
c.fieldMap["node_port"] = c.NodePort
|
||||
c.fieldMap["auth_ip"] = c.AuthIP
|
||||
c.fieldMap["auth_pass"] = c.AuthPass
|
||||
c.fieldMap["protocol"] = c.Protocol
|
||||
c.fieldMap["username"] = c.Username
|
||||
c.fieldMap["password"] = c.Password
|
||||
c.fieldMap["expiration"] = c.Expiration
|
||||
c.fieldMap["created_at"] = c.CreatedAt
|
||||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||||
c.fieldMap["deleted_at"] = c.DeletedAt
|
||||
}
|
||||
|
||||
func (c channel) clone(db *gorm.DB) channel {
|
||||
c.channelDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c channel) replaceDB(db *gorm.DB) channel {
|
||||
c.channelDo.ReplaceDB(db)
|
||||
return c
|
||||
}
|
||||
|
||||
type channelDo struct{ gen.DO }
|
||||
|
||||
func (c channelDo) Debug() *channelDo {
|
||||
return c.withDO(c.DO.Debug())
|
||||
}
|
||||
|
||||
func (c channelDo) WithContext(ctx context.Context) *channelDo {
|
||||
return c.withDO(c.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (c channelDo) ReadDB() *channelDo {
|
||||
return c.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (c channelDo) WriteDB() *channelDo {
|
||||
return c.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (c channelDo) Session(config *gorm.Session) *channelDo {
|
||||
return c.withDO(c.DO.Session(config))
|
||||
}
|
||||
|
||||
func (c channelDo) Clauses(conds ...clause.Expression) *channelDo {
|
||||
return c.withDO(c.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Returning(value interface{}, columns ...string) *channelDo {
|
||||
return c.withDO(c.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (c channelDo) Not(conds ...gen.Condition) *channelDo {
|
||||
return c.withDO(c.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Or(conds ...gen.Condition) *channelDo {
|
||||
return c.withDO(c.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Select(conds ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Where(conds ...gen.Condition) *channelDo {
|
||||
return c.withDO(c.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Order(conds ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Distinct(cols ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (c channelDo) Omit(cols ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (c channelDo) Join(table schema.Tabler, on ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (c channelDo) LeftJoin(table schema.Tabler, on ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c channelDo) RightJoin(table schema.Tabler, on ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c channelDo) Group(cols ...field.Expr) *channelDo {
|
||||
return c.withDO(c.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (c channelDo) Having(conds ...gen.Condition) *channelDo {
|
||||
return c.withDO(c.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (c channelDo) Limit(limit int) *channelDo {
|
||||
return c.withDO(c.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (c channelDo) Offset(offset int) *channelDo {
|
||||
return c.withDO(c.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (c channelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *channelDo {
|
||||
return c.withDO(c.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (c channelDo) Unscoped() *channelDo {
|
||||
return c.withDO(c.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (c channelDo) Create(values ...*models.Channel) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Create(values)
|
||||
}
|
||||
|
||||
func (c channelDo) CreateInBatches(values []*models.Channel, batchSize int) error {
|
||||
return c.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (c channelDo) Save(values ...*models.Channel) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Save(values)
|
||||
}
|
||||
|
||||
func (c channelDo) First() (*models.Channel, error) {
|
||||
if result, err := c.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Channel), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c channelDo) Take() (*models.Channel, error) {
|
||||
if result, err := c.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Channel), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c channelDo) Last() (*models.Channel, error) {
|
||||
if result, err := c.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Channel), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c channelDo) Find() ([]*models.Channel, error) {
|
||||
result, err := c.DO.Find()
|
||||
return result.([]*models.Channel), err
|
||||
}
|
||||
|
||||
func (c channelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Channel, err error) {
|
||||
buf := make([]*models.Channel, 0, batchSize)
|
||||
err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (c channelDo) FindInBatches(result *[]*models.Channel, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return c.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (c channelDo) Attrs(attrs ...field.AssignExpr) *channelDo {
|
||||
return c.withDO(c.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (c channelDo) Assign(attrs ...field.AssignExpr) *channelDo {
|
||||
return c.withDO(c.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (c channelDo) Joins(fields ...field.RelationField) *channelDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Joins(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c channelDo) Preload(fields ...field.RelationField) *channelDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Preload(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c channelDo) FirstOrInit() (*models.Channel, error) {
|
||||
if result, err := c.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Channel), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c channelDo) FirstOrCreate() (*models.Channel, error) {
|
||||
if result, err := c.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Channel), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c channelDo) FindByPage(offset int, limit int) (result []*models.Channel, count int64, err error) {
|
||||
result, err = c.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = c.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (c channelDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = c.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = c.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (c channelDo) Scan(result interface{}) (err error) {
|
||||
return c.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (c channelDo) Delete(models ...*models.Channel) (result gen.ResultInfo, err error) {
|
||||
return c.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (c *channelDo) withDO(do gen.Dao) *channelDo {
|
||||
c.DO = *do.(*gen.DO)
|
||||
return c
|
||||
}
|
||||
255
web/queries/gen.go
Normal file
255
web/queries/gen.go
Normal file
@@ -0,0 +1,255 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"gorm.io/gen"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
)
|
||||
|
||||
var (
|
||||
Q = new(Query)
|
||||
Admin *admin
|
||||
AdminRole *adminRole
|
||||
AdminRoleLink *adminRoleLink
|
||||
AdminRolePermissionLink *adminRolePermissionLink
|
||||
Bill *bill
|
||||
Channel *channel
|
||||
Node *node
|
||||
Permission *permission
|
||||
Product *product
|
||||
Refund *refund
|
||||
Resource *resource
|
||||
ResourcePps *resourcePps
|
||||
ResourcePsr *resourcePsr
|
||||
ResourcePss *resourcePss
|
||||
Trade *trade
|
||||
User *user
|
||||
UserRole *userRole
|
||||
UserRoleLink *userRoleLink
|
||||
UserRolePermissionLink *userRolePermissionLink
|
||||
Whitelist *whitelist
|
||||
)
|
||||
|
||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
*Q = *Use(db, opts...)
|
||||
Admin = &Q.Admin
|
||||
AdminRole = &Q.AdminRole
|
||||
AdminRoleLink = &Q.AdminRoleLink
|
||||
AdminRolePermissionLink = &Q.AdminRolePermissionLink
|
||||
Bill = &Q.Bill
|
||||
Channel = &Q.Channel
|
||||
Node = &Q.Node
|
||||
Permission = &Q.Permission
|
||||
Product = &Q.Product
|
||||
Refund = &Q.Refund
|
||||
Resource = &Q.Resource
|
||||
ResourcePps = &Q.ResourcePps
|
||||
ResourcePsr = &Q.ResourcePsr
|
||||
ResourcePss = &Q.ResourcePss
|
||||
Trade = &Q.Trade
|
||||
User = &Q.User
|
||||
UserRole = &Q.UserRole
|
||||
UserRoleLink = &Q.UserRoleLink
|
||||
UserRolePermissionLink = &Q.UserRolePermissionLink
|
||||
Whitelist = &Q.Whitelist
|
||||
}
|
||||
|
||||
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Admin: newAdmin(db, opts...),
|
||||
AdminRole: newAdminRole(db, opts...),
|
||||
AdminRoleLink: newAdminRoleLink(db, opts...),
|
||||
AdminRolePermissionLink: newAdminRolePermissionLink(db, opts...),
|
||||
Bill: newBill(db, opts...),
|
||||
Channel: newChannel(db, opts...),
|
||||
Node: newNode(db, opts...),
|
||||
Permission: newPermission(db, opts...),
|
||||
Product: newProduct(db, opts...),
|
||||
Refund: newRefund(db, opts...),
|
||||
Resource: newResource(db, opts...),
|
||||
ResourcePps: newResourcePps(db, opts...),
|
||||
ResourcePsr: newResourcePsr(db, opts...),
|
||||
ResourcePss: newResourcePss(db, opts...),
|
||||
Trade: newTrade(db, opts...),
|
||||
User: newUser(db, opts...),
|
||||
UserRole: newUserRole(db, opts...),
|
||||
UserRoleLink: newUserRoleLink(db, opts...),
|
||||
UserRolePermissionLink: newUserRolePermissionLink(db, opts...),
|
||||
Whitelist: newWhitelist(db, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
Admin admin
|
||||
AdminRole adminRole
|
||||
AdminRoleLink adminRoleLink
|
||||
AdminRolePermissionLink adminRolePermissionLink
|
||||
Bill bill
|
||||
Channel channel
|
||||
Node node
|
||||
Permission permission
|
||||
Product product
|
||||
Refund refund
|
||||
Resource resource
|
||||
ResourcePps resourcePps
|
||||
ResourcePsr resourcePsr
|
||||
ResourcePss resourcePss
|
||||
Trade trade
|
||||
User user
|
||||
UserRole userRole
|
||||
UserRoleLink userRoleLink
|
||||
UserRolePermissionLink userRolePermissionLink
|
||||
Whitelist whitelist
|
||||
}
|
||||
|
||||
func (q *Query) Available() bool { return q.db != nil }
|
||||
|
||||
func (q *Query) clone(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Admin: q.Admin.clone(db),
|
||||
AdminRole: q.AdminRole.clone(db),
|
||||
AdminRoleLink: q.AdminRoleLink.clone(db),
|
||||
AdminRolePermissionLink: q.AdminRolePermissionLink.clone(db),
|
||||
Bill: q.Bill.clone(db),
|
||||
Channel: q.Channel.clone(db),
|
||||
Node: q.Node.clone(db),
|
||||
Permission: q.Permission.clone(db),
|
||||
Product: q.Product.clone(db),
|
||||
Refund: q.Refund.clone(db),
|
||||
Resource: q.Resource.clone(db),
|
||||
ResourcePps: q.ResourcePps.clone(db),
|
||||
ResourcePsr: q.ResourcePsr.clone(db),
|
||||
ResourcePss: q.ResourcePss.clone(db),
|
||||
Trade: q.Trade.clone(db),
|
||||
User: q.User.clone(db),
|
||||
UserRole: q.UserRole.clone(db),
|
||||
UserRoleLink: q.UserRoleLink.clone(db),
|
||||
UserRolePermissionLink: q.UserRolePermissionLink.clone(db),
|
||||
Whitelist: q.Whitelist.clone(db),
|
||||
}
|
||||
}
|
||||
|
||||
func (q *Query) ReadDB() *Query {
|
||||
return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
|
||||
}
|
||||
|
||||
func (q *Query) WriteDB() *Query {
|
||||
return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
|
||||
}
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
Admin: q.Admin.replaceDB(db),
|
||||
AdminRole: q.AdminRole.replaceDB(db),
|
||||
AdminRoleLink: q.AdminRoleLink.replaceDB(db),
|
||||
AdminRolePermissionLink: q.AdminRolePermissionLink.replaceDB(db),
|
||||
Bill: q.Bill.replaceDB(db),
|
||||
Channel: q.Channel.replaceDB(db),
|
||||
Node: q.Node.replaceDB(db),
|
||||
Permission: q.Permission.replaceDB(db),
|
||||
Product: q.Product.replaceDB(db),
|
||||
Refund: q.Refund.replaceDB(db),
|
||||
Resource: q.Resource.replaceDB(db),
|
||||
ResourcePps: q.ResourcePps.replaceDB(db),
|
||||
ResourcePsr: q.ResourcePsr.replaceDB(db),
|
||||
ResourcePss: q.ResourcePss.replaceDB(db),
|
||||
Trade: q.Trade.replaceDB(db),
|
||||
User: q.User.replaceDB(db),
|
||||
UserRole: q.UserRole.replaceDB(db),
|
||||
UserRoleLink: q.UserRoleLink.replaceDB(db),
|
||||
UserRolePermissionLink: q.UserRolePermissionLink.replaceDB(db),
|
||||
Whitelist: q.Whitelist.replaceDB(db),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
Admin *adminDo
|
||||
AdminRole *adminRoleDo
|
||||
AdminRoleLink *adminRoleLinkDo
|
||||
AdminRolePermissionLink *adminRolePermissionLinkDo
|
||||
Bill *billDo
|
||||
Channel *channelDo
|
||||
Node *nodeDo
|
||||
Permission *permissionDo
|
||||
Product *productDo
|
||||
Refund *refundDo
|
||||
Resource *resourceDo
|
||||
ResourcePps *resourcePpsDo
|
||||
ResourcePsr *resourcePsrDo
|
||||
ResourcePss *resourcePssDo
|
||||
Trade *tradeDo
|
||||
User *userDo
|
||||
UserRole *userRoleDo
|
||||
UserRoleLink *userRoleLinkDo
|
||||
UserRolePermissionLink *userRolePermissionLinkDo
|
||||
Whitelist *whitelistDo
|
||||
}
|
||||
|
||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
return &queryCtx{
|
||||
Admin: q.Admin.WithContext(ctx),
|
||||
AdminRole: q.AdminRole.WithContext(ctx),
|
||||
AdminRoleLink: q.AdminRoleLink.WithContext(ctx),
|
||||
AdminRolePermissionLink: q.AdminRolePermissionLink.WithContext(ctx),
|
||||
Bill: q.Bill.WithContext(ctx),
|
||||
Channel: q.Channel.WithContext(ctx),
|
||||
Node: q.Node.WithContext(ctx),
|
||||
Permission: q.Permission.WithContext(ctx),
|
||||
Product: q.Product.WithContext(ctx),
|
||||
Refund: q.Refund.WithContext(ctx),
|
||||
Resource: q.Resource.WithContext(ctx),
|
||||
ResourcePps: q.ResourcePps.WithContext(ctx),
|
||||
ResourcePsr: q.ResourcePsr.WithContext(ctx),
|
||||
ResourcePss: q.ResourcePss.WithContext(ctx),
|
||||
Trade: q.Trade.WithContext(ctx),
|
||||
User: q.User.WithContext(ctx),
|
||||
UserRole: q.UserRole.WithContext(ctx),
|
||||
UserRoleLink: q.UserRoleLink.WithContext(ctx),
|
||||
UserRolePermissionLink: q.UserRolePermissionLink.WithContext(ctx),
|
||||
Whitelist: q.Whitelist.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
|
||||
return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
|
||||
}
|
||||
|
||||
func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
|
||||
tx := q.db.Begin(opts...)
|
||||
return &QueryTx{Query: q.clone(tx), Error: tx.Error}
|
||||
}
|
||||
|
||||
type QueryTx struct {
|
||||
*Query
|
||||
Error error
|
||||
}
|
||||
|
||||
func (q *QueryTx) Commit() error {
|
||||
return q.db.Commit().Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) Rollback() error {
|
||||
return q.db.Rollback().Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) SavePoint(name string) error {
|
||||
return q.db.SavePoint(name).Error
|
||||
}
|
||||
|
||||
func (q *QueryTx) RollbackTo(name string) error {
|
||||
return q.db.RollbackTo(name).Error
|
||||
}
|
||||
351
web/queries/node.gen.go
Normal file
351
web/queries/node.gen.go
Normal file
@@ -0,0 +1,351 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newNode(db *gorm.DB, opts ...gen.DOOption) node {
|
||||
_node := node{}
|
||||
|
||||
_node.nodeDo.UseDB(db, opts...)
|
||||
_node.nodeDo.UseModel(&models.Node{})
|
||||
|
||||
tableName := _node.nodeDo.TableName()
|
||||
_node.ALL = field.NewAsterisk(tableName)
|
||||
_node.ID = field.NewInt32(tableName, "id")
|
||||
_node.Name = field.NewString(tableName, "name")
|
||||
_node.Version = field.NewInt32(tableName, "version")
|
||||
_node.FwdPort = field.NewInt32(tableName, "fwd_port")
|
||||
_node.Provider = field.NewString(tableName, "provider")
|
||||
_node.Location = field.NewString(tableName, "location")
|
||||
_node.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_node.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_node.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_node.fillFieldMap()
|
||||
|
||||
return _node
|
||||
}
|
||||
|
||||
type node struct {
|
||||
nodeDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 节点ID
|
||||
Name field.String // 节点名称
|
||||
Version field.Int32 // 节点版本
|
||||
FwdPort field.Int32 // 转发端口
|
||||
Provider field.String // 运营商
|
||||
Location field.String // 位置
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (n node) Table(newTableName string) *node {
|
||||
n.nodeDo.UseTable(newTableName)
|
||||
return n.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (n node) As(alias string) *node {
|
||||
n.nodeDo.DO = *(n.nodeDo.As(alias).(*gen.DO))
|
||||
return n.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (n *node) updateTableName(table string) *node {
|
||||
n.ALL = field.NewAsterisk(table)
|
||||
n.ID = field.NewInt32(table, "id")
|
||||
n.Name = field.NewString(table, "name")
|
||||
n.Version = field.NewInt32(table, "version")
|
||||
n.FwdPort = field.NewInt32(table, "fwd_port")
|
||||
n.Provider = field.NewString(table, "provider")
|
||||
n.Location = field.NewString(table, "location")
|
||||
n.CreatedAt = field.NewTime(table, "created_at")
|
||||
n.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
n.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
n.fillFieldMap()
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
func (n *node) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := n.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (n *node) fillFieldMap() {
|
||||
n.fieldMap = make(map[string]field.Expr, 9)
|
||||
n.fieldMap["id"] = n.ID
|
||||
n.fieldMap["name"] = n.Name
|
||||
n.fieldMap["version"] = n.Version
|
||||
n.fieldMap["fwd_port"] = n.FwdPort
|
||||
n.fieldMap["provider"] = n.Provider
|
||||
n.fieldMap["location"] = n.Location
|
||||
n.fieldMap["created_at"] = n.CreatedAt
|
||||
n.fieldMap["updated_at"] = n.UpdatedAt
|
||||
n.fieldMap["deleted_at"] = n.DeletedAt
|
||||
}
|
||||
|
||||
func (n node) clone(db *gorm.DB) node {
|
||||
n.nodeDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return n
|
||||
}
|
||||
|
||||
func (n node) replaceDB(db *gorm.DB) node {
|
||||
n.nodeDo.ReplaceDB(db)
|
||||
return n
|
||||
}
|
||||
|
||||
type nodeDo struct{ gen.DO }
|
||||
|
||||
func (n nodeDo) Debug() *nodeDo {
|
||||
return n.withDO(n.DO.Debug())
|
||||
}
|
||||
|
||||
func (n nodeDo) WithContext(ctx context.Context) *nodeDo {
|
||||
return n.withDO(n.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (n nodeDo) ReadDB() *nodeDo {
|
||||
return n.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (n nodeDo) WriteDB() *nodeDo {
|
||||
return n.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (n nodeDo) Session(config *gorm.Session) *nodeDo {
|
||||
return n.withDO(n.DO.Session(config))
|
||||
}
|
||||
|
||||
func (n nodeDo) Clauses(conds ...clause.Expression) *nodeDo {
|
||||
return n.withDO(n.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Returning(value interface{}, columns ...string) *nodeDo {
|
||||
return n.withDO(n.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Not(conds ...gen.Condition) *nodeDo {
|
||||
return n.withDO(n.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Or(conds ...gen.Condition) *nodeDo {
|
||||
return n.withDO(n.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Select(conds ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Where(conds ...gen.Condition) *nodeDo {
|
||||
return n.withDO(n.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Order(conds ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Distinct(cols ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Omit(cols ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Join(table schema.Tabler, on ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (n nodeDo) LeftJoin(table schema.Tabler, on ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n nodeDo) RightJoin(table schema.Tabler, on ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Group(cols ...field.Expr) *nodeDo {
|
||||
return n.withDO(n.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Having(conds ...gen.Condition) *nodeDo {
|
||||
return n.withDO(n.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Limit(limit int) *nodeDo {
|
||||
return n.withDO(n.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (n nodeDo) Offset(offset int) *nodeDo {
|
||||
return n.withDO(n.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (n nodeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *nodeDo {
|
||||
return n.withDO(n.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Unscoped() *nodeDo {
|
||||
return n.withDO(n.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (n nodeDo) Create(values ...*models.Node) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Create(values)
|
||||
}
|
||||
|
||||
func (n nodeDo) CreateInBatches(values []*models.Node, batchSize int) error {
|
||||
return n.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (n nodeDo) Save(values ...*models.Node) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return n.DO.Save(values)
|
||||
}
|
||||
|
||||
func (n nodeDo) First() (*models.Node, error) {
|
||||
if result, err := n.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Node), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n nodeDo) Take() (*models.Node, error) {
|
||||
if result, err := n.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Node), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n nodeDo) Last() (*models.Node, error) {
|
||||
if result, err := n.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Node), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n nodeDo) Find() ([]*models.Node, error) {
|
||||
result, err := n.DO.Find()
|
||||
return result.([]*models.Node), err
|
||||
}
|
||||
|
||||
func (n nodeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Node, err error) {
|
||||
buf := make([]*models.Node, 0, batchSize)
|
||||
err = n.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (n nodeDo) FindInBatches(result *[]*models.Node, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return n.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (n nodeDo) Attrs(attrs ...field.AssignExpr) *nodeDo {
|
||||
return n.withDO(n.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Assign(attrs ...field.AssignExpr) *nodeDo {
|
||||
return n.withDO(n.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (n nodeDo) Joins(fields ...field.RelationField) *nodeDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Joins(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n nodeDo) Preload(fields ...field.RelationField) *nodeDo {
|
||||
for _, _f := range fields {
|
||||
n = *n.withDO(n.DO.Preload(_f))
|
||||
}
|
||||
return &n
|
||||
}
|
||||
|
||||
func (n nodeDo) FirstOrInit() (*models.Node, error) {
|
||||
if result, err := n.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Node), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n nodeDo) FirstOrCreate() (*models.Node, error) {
|
||||
if result, err := n.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Node), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (n nodeDo) FindByPage(offset int, limit int) (result []*models.Node, count int64, err error) {
|
||||
result, err = n.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = n.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (n nodeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = n.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = n.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (n nodeDo) Scan(result interface{}) (err error) {
|
||||
return n.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (n nodeDo) Delete(models ...*models.Node) (result gen.ResultInfo, err error) {
|
||||
return n.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (n *nodeDo) withDO(do gen.Dao) *nodeDo {
|
||||
n.DO = *do.(*gen.DO)
|
||||
return n
|
||||
}
|
||||
343
web/queries/permission.gen.go
Normal file
343
web/queries/permission.gen.go
Normal file
@@ -0,0 +1,343 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newPermission(db *gorm.DB, opts ...gen.DOOption) permission {
|
||||
_permission := permission{}
|
||||
|
||||
_permission.permissionDo.UseDB(db, opts...)
|
||||
_permission.permissionDo.UseModel(&models.Permission{})
|
||||
|
||||
tableName := _permission.permissionDo.TableName()
|
||||
_permission.ALL = field.NewAsterisk(tableName)
|
||||
_permission.ID = field.NewInt32(tableName, "id")
|
||||
_permission.ParentID = field.NewInt32(tableName, "parent_id")
|
||||
_permission.Name = field.NewString(tableName, "name")
|
||||
_permission.Description = field.NewString(tableName, "description")
|
||||
_permission.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_permission.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_permission.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_permission.fillFieldMap()
|
||||
|
||||
return _permission
|
||||
}
|
||||
|
||||
type permission struct {
|
||||
permissionDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 权限ID
|
||||
ParentID field.Int32 // 父权限ID
|
||||
Name field.String // 权限名称
|
||||
Description field.String // 权限描述
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p permission) Table(newTableName string) *permission {
|
||||
p.permissionDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p permission) As(alias string) *permission {
|
||||
p.permissionDo.DO = *(p.permissionDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *permission) updateTableName(table string) *permission {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt32(table, "id")
|
||||
p.ParentID = field.NewInt32(table, "parent_id")
|
||||
p.Name = field.NewString(table, "name")
|
||||
p.Description = field.NewString(table, "description")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *permission) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := p.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (p *permission) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 7)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["parent_id"] = p.ParentID
|
||||
p.fieldMap["name"] = p.Name
|
||||
p.fieldMap["description"] = p.Description
|
||||
p.fieldMap["created_at"] = p.CreatedAt
|
||||
p.fieldMap["updated_at"] = p.UpdatedAt
|
||||
p.fieldMap["deleted_at"] = p.DeletedAt
|
||||
}
|
||||
|
||||
func (p permission) clone(db *gorm.DB) permission {
|
||||
p.permissionDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p permission) replaceDB(db *gorm.DB) permission {
|
||||
p.permissionDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type permissionDo struct{ gen.DO }
|
||||
|
||||
func (p permissionDo) Debug() *permissionDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p permissionDo) WithContext(ctx context.Context) *permissionDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p permissionDo) ReadDB() *permissionDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p permissionDo) WriteDB() *permissionDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p permissionDo) Session(config *gorm.Session) *permissionDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p permissionDo) Clauses(conds ...clause.Expression) *permissionDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Returning(value interface{}, columns ...string) *permissionDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Not(conds ...gen.Condition) *permissionDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Or(conds ...gen.Condition) *permissionDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Select(conds ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Where(conds ...gen.Condition) *permissionDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Order(conds ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Distinct(cols ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Omit(cols ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Join(table schema.Tabler, on ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p permissionDo) LeftJoin(table schema.Tabler, on ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p permissionDo) RightJoin(table schema.Tabler, on ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Group(cols ...field.Expr) *permissionDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Having(conds ...gen.Condition) *permissionDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Limit(limit int) *permissionDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p permissionDo) Offset(offset int) *permissionDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p permissionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *permissionDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Unscoped() *permissionDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p permissionDo) Create(values ...*models.Permission) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p permissionDo) CreateInBatches(values []*models.Permission, batchSize int) error {
|
||||
return p.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (p permissionDo) Save(values ...*models.Permission) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p permissionDo) First() (*models.Permission, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Permission), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p permissionDo) Take() (*models.Permission, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Permission), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p permissionDo) Last() (*models.Permission, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Permission), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p permissionDo) Find() ([]*models.Permission, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*models.Permission), err
|
||||
}
|
||||
|
||||
func (p permissionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Permission, err error) {
|
||||
buf := make([]*models.Permission, 0, batchSize)
|
||||
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (p permissionDo) FindInBatches(result *[]*models.Permission, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p permissionDo) Attrs(attrs ...field.AssignExpr) *permissionDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Assign(attrs ...field.AssignExpr) *permissionDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p permissionDo) Joins(fields ...field.RelationField) *permissionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p permissionDo) Preload(fields ...field.RelationField) *permissionDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p permissionDo) FirstOrInit() (*models.Permission, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Permission), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p permissionDo) FirstOrCreate() (*models.Permission, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Permission), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p permissionDo) FindByPage(offset int, limit int) (result []*models.Permission, count int64, err error) {
|
||||
result, err = p.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = p.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (p permissionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = p.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = p.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (p permissionDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p permissionDo) Delete(models ...*models.Permission) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *permissionDo) withDO(do gen.Dao) *permissionDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
||||
351
web/queries/product.gen.go
Normal file
351
web/queries/product.gen.go
Normal file
@@ -0,0 +1,351 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newProduct(db *gorm.DB, opts ...gen.DOOption) product {
|
||||
_product := product{}
|
||||
|
||||
_product.productDo.UseDB(db, opts...)
|
||||
_product.productDo.UseModel(&models.Product{})
|
||||
|
||||
tableName := _product.productDo.TableName()
|
||||
_product.ALL = field.NewAsterisk(tableName)
|
||||
_product.ID = field.NewInt32(tableName, "id")
|
||||
_product.Code = field.NewString(tableName, "code")
|
||||
_product.Name = field.NewString(tableName, "name")
|
||||
_product.Description = field.NewString(tableName, "description")
|
||||
_product.Sort = field.NewInt32(tableName, "sort")
|
||||
_product.Status = field.NewInt32(tableName, "status")
|
||||
_product.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_product.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_product.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_product.fillFieldMap()
|
||||
|
||||
return _product
|
||||
}
|
||||
|
||||
type product struct {
|
||||
productDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 产品ID
|
||||
Code field.String // 产品代码
|
||||
Name field.String // 产品名称
|
||||
Description field.String // 产品描述
|
||||
Sort field.Int32 // 排序
|
||||
Status field.Int32 // 产品状态:1-正常,0-禁用
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (p product) Table(newTableName string) *product {
|
||||
p.productDo.UseTable(newTableName)
|
||||
return p.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (p product) As(alias string) *product {
|
||||
p.productDo.DO = *(p.productDo.As(alias).(*gen.DO))
|
||||
return p.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (p *product) updateTableName(table string) *product {
|
||||
p.ALL = field.NewAsterisk(table)
|
||||
p.ID = field.NewInt32(table, "id")
|
||||
p.Code = field.NewString(table, "code")
|
||||
p.Name = field.NewString(table, "name")
|
||||
p.Description = field.NewString(table, "description")
|
||||
p.Sort = field.NewInt32(table, "sort")
|
||||
p.Status = field.NewInt32(table, "status")
|
||||
p.CreatedAt = field.NewTime(table, "created_at")
|
||||
p.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
p.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
p.fillFieldMap()
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *product) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := p.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (p *product) fillFieldMap() {
|
||||
p.fieldMap = make(map[string]field.Expr, 9)
|
||||
p.fieldMap["id"] = p.ID
|
||||
p.fieldMap["code"] = p.Code
|
||||
p.fieldMap["name"] = p.Name
|
||||
p.fieldMap["description"] = p.Description
|
||||
p.fieldMap["sort"] = p.Sort
|
||||
p.fieldMap["status"] = p.Status
|
||||
p.fieldMap["created_at"] = p.CreatedAt
|
||||
p.fieldMap["updated_at"] = p.UpdatedAt
|
||||
p.fieldMap["deleted_at"] = p.DeletedAt
|
||||
}
|
||||
|
||||
func (p product) clone(db *gorm.DB) product {
|
||||
p.productDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return p
|
||||
}
|
||||
|
||||
func (p product) replaceDB(db *gorm.DB) product {
|
||||
p.productDo.ReplaceDB(db)
|
||||
return p
|
||||
}
|
||||
|
||||
type productDo struct{ gen.DO }
|
||||
|
||||
func (p productDo) Debug() *productDo {
|
||||
return p.withDO(p.DO.Debug())
|
||||
}
|
||||
|
||||
func (p productDo) WithContext(ctx context.Context) *productDo {
|
||||
return p.withDO(p.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (p productDo) ReadDB() *productDo {
|
||||
return p.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (p productDo) WriteDB() *productDo {
|
||||
return p.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (p productDo) Session(config *gorm.Session) *productDo {
|
||||
return p.withDO(p.DO.Session(config))
|
||||
}
|
||||
|
||||
func (p productDo) Clauses(conds ...clause.Expression) *productDo {
|
||||
return p.withDO(p.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Returning(value interface{}, columns ...string) *productDo {
|
||||
return p.withDO(p.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (p productDo) Not(conds ...gen.Condition) *productDo {
|
||||
return p.withDO(p.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Or(conds ...gen.Condition) *productDo {
|
||||
return p.withDO(p.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Select(conds ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Where(conds ...gen.Condition) *productDo {
|
||||
return p.withDO(p.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Order(conds ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Distinct(cols ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (p productDo) Omit(cols ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (p productDo) Join(table schema.Tabler, on ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (p productDo) LeftJoin(table schema.Tabler, on ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p productDo) RightJoin(table schema.Tabler, on ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (p productDo) Group(cols ...field.Expr) *productDo {
|
||||
return p.withDO(p.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (p productDo) Having(conds ...gen.Condition) *productDo {
|
||||
return p.withDO(p.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (p productDo) Limit(limit int) *productDo {
|
||||
return p.withDO(p.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (p productDo) Offset(offset int) *productDo {
|
||||
return p.withDO(p.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (p productDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *productDo {
|
||||
return p.withDO(p.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (p productDo) Unscoped() *productDo {
|
||||
return p.withDO(p.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (p productDo) Create(values ...*models.Product) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Create(values)
|
||||
}
|
||||
|
||||
func (p productDo) CreateInBatches(values []*models.Product, batchSize int) error {
|
||||
return p.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (p productDo) Save(values ...*models.Product) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return p.DO.Save(values)
|
||||
}
|
||||
|
||||
func (p productDo) First() (*models.Product, error) {
|
||||
if result, err := p.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Product), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p productDo) Take() (*models.Product, error) {
|
||||
if result, err := p.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Product), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p productDo) Last() (*models.Product, error) {
|
||||
if result, err := p.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Product), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p productDo) Find() ([]*models.Product, error) {
|
||||
result, err := p.DO.Find()
|
||||
return result.([]*models.Product), err
|
||||
}
|
||||
|
||||
func (p productDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Product, err error) {
|
||||
buf := make([]*models.Product, 0, batchSize)
|
||||
err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (p productDo) FindInBatches(result *[]*models.Product, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return p.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (p productDo) Attrs(attrs ...field.AssignExpr) *productDo {
|
||||
return p.withDO(p.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (p productDo) Assign(attrs ...field.AssignExpr) *productDo {
|
||||
return p.withDO(p.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (p productDo) Joins(fields ...field.RelationField) *productDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Joins(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p productDo) Preload(fields ...field.RelationField) *productDo {
|
||||
for _, _f := range fields {
|
||||
p = *p.withDO(p.DO.Preload(_f))
|
||||
}
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p productDo) FirstOrInit() (*models.Product, error) {
|
||||
if result, err := p.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Product), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p productDo) FirstOrCreate() (*models.Product, error) {
|
||||
if result, err := p.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Product), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p productDo) FindByPage(offset int, limit int) (result []*models.Product, count int64, err error) {
|
||||
result, err = p.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = p.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (p productDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = p.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = p.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (p productDo) Scan(result interface{}) (err error) {
|
||||
return p.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (p productDo) Delete(models ...*models.Product) (result gen.ResultInfo, err error) {
|
||||
return p.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (p *productDo) withDO(do gen.Dao) *productDo {
|
||||
p.DO = *do.(*gen.DO)
|
||||
return p
|
||||
}
|
||||
343
web/queries/refund.gen.go
Normal file
343
web/queries/refund.gen.go
Normal file
@@ -0,0 +1,343 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newRefund(db *gorm.DB, opts ...gen.DOOption) refund {
|
||||
_refund := refund{}
|
||||
|
||||
_refund.refundDo.UseDB(db, opts...)
|
||||
_refund.refundDo.UseModel(&models.Refund{})
|
||||
|
||||
tableName := _refund.refundDo.TableName()
|
||||
_refund.ALL = field.NewAsterisk(tableName)
|
||||
_refund.ID = field.NewInt32(tableName, "id")
|
||||
_refund.OrderID = field.NewInt32(tableName, "order_id")
|
||||
_refund.ProductID = field.NewInt32(tableName, "product_id")
|
||||
_refund.Amount = field.NewFloat64(tableName, "amount")
|
||||
_refund.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_refund.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_refund.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_refund.fillFieldMap()
|
||||
|
||||
return _refund
|
||||
}
|
||||
|
||||
type refund struct {
|
||||
refundDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 退款ID
|
||||
OrderID field.Int32 // 订单ID
|
||||
ProductID field.Int32 // 产品ID
|
||||
Amount field.Float64 // 退款金额
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r refund) Table(newTableName string) *refund {
|
||||
r.refundDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r refund) As(alias string) *refund {
|
||||
r.refundDo.DO = *(r.refundDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *refund) updateTableName(table string) *refund {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.OrderID = field.NewInt32(table, "order_id")
|
||||
r.ProductID = field.NewInt32(table, "product_id")
|
||||
r.Amount = field.NewFloat64(table, "amount")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *refund) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *refund) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 7)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["order_id"] = r.OrderID
|
||||
r.fieldMap["product_id"] = r.ProductID
|
||||
r.fieldMap["amount"] = r.Amount
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
}
|
||||
|
||||
func (r refund) clone(db *gorm.DB) refund {
|
||||
r.refundDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r refund) replaceDB(db *gorm.DB) refund {
|
||||
r.refundDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type refundDo struct{ gen.DO }
|
||||
|
||||
func (r refundDo) Debug() *refundDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r refundDo) WithContext(ctx context.Context) *refundDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r refundDo) ReadDB() *refundDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r refundDo) WriteDB() *refundDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r refundDo) Session(config *gorm.Session) *refundDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r refundDo) Clauses(conds ...clause.Expression) *refundDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Returning(value interface{}, columns ...string) *refundDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r refundDo) Not(conds ...gen.Condition) *refundDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Or(conds ...gen.Condition) *refundDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Select(conds ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Where(conds ...gen.Condition) *refundDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Order(conds ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Distinct(cols ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r refundDo) Omit(cols ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r refundDo) Join(table schema.Tabler, on ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r refundDo) LeftJoin(table schema.Tabler, on ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r refundDo) RightJoin(table schema.Tabler, on ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r refundDo) Group(cols ...field.Expr) *refundDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r refundDo) Having(conds ...gen.Condition) *refundDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r refundDo) Limit(limit int) *refundDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r refundDo) Offset(offset int) *refundDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r refundDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *refundDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r refundDo) Unscoped() *refundDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r refundDo) Create(values ...*models.Refund) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r refundDo) CreateInBatches(values []*models.Refund, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r refundDo) Save(values ...*models.Refund) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r refundDo) First() (*models.Refund, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Refund), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r refundDo) Take() (*models.Refund, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Refund), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r refundDo) Last() (*models.Refund, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Refund), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r refundDo) Find() ([]*models.Refund, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.Refund), err
|
||||
}
|
||||
|
||||
func (r refundDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Refund, err error) {
|
||||
buf := make([]*models.Refund, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r refundDo) FindInBatches(result *[]*models.Refund, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r refundDo) Attrs(attrs ...field.AssignExpr) *refundDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r refundDo) Assign(attrs ...field.AssignExpr) *refundDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r refundDo) Joins(fields ...field.RelationField) *refundDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r refundDo) Preload(fields ...field.RelationField) *refundDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r refundDo) FirstOrInit() (*models.Refund, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Refund), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r refundDo) FirstOrCreate() (*models.Refund, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Refund), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r refundDo) FindByPage(offset int, limit int) (result []*models.Refund, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r refundDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r refundDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r refundDo) Delete(models ...*models.Refund) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *refundDo) withDO(do gen.Dao) *refundDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
335
web/queries/resource.gen.go
Normal file
335
web/queries/resource.gen.go
Normal file
@@ -0,0 +1,335 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newResource(db *gorm.DB, opts ...gen.DOOption) resource {
|
||||
_resource := resource{}
|
||||
|
||||
_resource.resourceDo.UseDB(db, opts...)
|
||||
_resource.resourceDo.UseModel(&models.Resource{})
|
||||
|
||||
tableName := _resource.resourceDo.TableName()
|
||||
_resource.ALL = field.NewAsterisk(tableName)
|
||||
_resource.ID = field.NewInt32(tableName, "id")
|
||||
_resource.UserID = field.NewInt32(tableName, "user_id")
|
||||
_resource.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_resource.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_resource.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_resource.fillFieldMap()
|
||||
|
||||
return _resource
|
||||
}
|
||||
|
||||
type resource struct {
|
||||
resourceDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 套餐ID
|
||||
UserID field.Int32 // 用户ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r resource) Table(newTableName string) *resource {
|
||||
r.resourceDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r resource) As(alias string) *resource {
|
||||
r.resourceDo.DO = *(r.resourceDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *resource) updateTableName(table string) *resource {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.UserID = field.NewInt32(table, "user_id")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *resource) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *resource) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 5)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["user_id"] = r.UserID
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
}
|
||||
|
||||
func (r resource) clone(db *gorm.DB) resource {
|
||||
r.resourceDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resource) replaceDB(db *gorm.DB) resource {
|
||||
r.resourceDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type resourceDo struct{ gen.DO }
|
||||
|
||||
func (r resourceDo) Debug() *resourceDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r resourceDo) WithContext(ctx context.Context) *resourceDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r resourceDo) ReadDB() *resourceDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r resourceDo) WriteDB() *resourceDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r resourceDo) Session(config *gorm.Session) *resourceDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r resourceDo) Clauses(conds ...clause.Expression) *resourceDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Returning(value interface{}, columns ...string) *resourceDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Not(conds ...gen.Condition) *resourceDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Or(conds ...gen.Condition) *resourceDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Select(conds ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Where(conds ...gen.Condition) *resourceDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Order(conds ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Distinct(cols ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Omit(cols ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Join(table schema.Tabler, on ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Group(cols ...field.Expr) *resourceDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Having(conds ...gen.Condition) *resourceDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Limit(limit int) *resourceDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r resourceDo) Offset(offset int) *resourceDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r resourceDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourceDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Unscoped() *resourceDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r resourceDo) Create(values ...*models.Resource) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r resourceDo) CreateInBatches(values []*models.Resource, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r resourceDo) Save(values ...*models.Resource) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r resourceDo) First() (*models.Resource, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Resource), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceDo) Take() (*models.Resource, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Resource), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceDo) Last() (*models.Resource, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Resource), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceDo) Find() ([]*models.Resource, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.Resource), err
|
||||
}
|
||||
|
||||
func (r resourceDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Resource, err error) {
|
||||
buf := make([]*models.Resource, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r resourceDo) FindInBatches(result *[]*models.Resource, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r resourceDo) Attrs(attrs ...field.AssignExpr) *resourceDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Assign(attrs ...field.AssignExpr) *resourceDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r resourceDo) Joins(fields ...field.RelationField) *resourceDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourceDo) Preload(fields ...field.RelationField) *resourceDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourceDo) FirstOrInit() (*models.Resource, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Resource), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceDo) FirstOrCreate() (*models.Resource, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Resource), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourceDo) FindByPage(offset int, limit int) (result []*models.Resource, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourceDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourceDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r resourceDo) Delete(models ...*models.Resource) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *resourceDo) withDO(do gen.Dao) *resourceDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
339
web/queries/resource_pps.gen.go
Normal file
339
web/queries/resource_pps.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newResourcePps(db *gorm.DB, opts ...gen.DOOption) resourcePps {
|
||||
_resourcePps := resourcePps{}
|
||||
|
||||
_resourcePps.resourcePpsDo.UseDB(db, opts...)
|
||||
_resourcePps.resourcePpsDo.UseModel(&models.ResourcePps{})
|
||||
|
||||
tableName := _resourcePps.resourcePpsDo.TableName()
|
||||
_resourcePps.ALL = field.NewAsterisk(tableName)
|
||||
_resourcePps.ID = field.NewInt32(tableName, "id")
|
||||
_resourcePps.ResourceID = field.NewInt32(tableName, "resource_id")
|
||||
_resourcePps.Active = field.NewBool(tableName, "active")
|
||||
_resourcePps.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_resourcePps.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_resourcePps.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_resourcePps.fillFieldMap()
|
||||
|
||||
return _resourcePps
|
||||
}
|
||||
|
||||
type resourcePps struct {
|
||||
resourcePpsDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // ID
|
||||
ResourceID field.Int32 // 套餐ID
|
||||
Active field.Bool // 是否启用
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r resourcePps) Table(newTableName string) *resourcePps {
|
||||
r.resourcePpsDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r resourcePps) As(alias string) *resourcePps {
|
||||
r.resourcePpsDo.DO = *(r.resourcePpsDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *resourcePps) updateTableName(table string) *resourcePps {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.ResourceID = field.NewInt32(table, "resource_id")
|
||||
r.Active = field.NewBool(table, "active")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *resourcePps) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *resourcePps) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 6)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["resource_id"] = r.ResourceID
|
||||
r.fieldMap["active"] = r.Active
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
}
|
||||
|
||||
func (r resourcePps) clone(db *gorm.DB) resourcePps {
|
||||
r.resourcePpsDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resourcePps) replaceDB(db *gorm.DB) resourcePps {
|
||||
r.resourcePpsDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type resourcePpsDo struct{ gen.DO }
|
||||
|
||||
func (r resourcePpsDo) Debug() *resourcePpsDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) WithContext(ctx context.Context) *resourcePpsDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) ReadDB() *resourcePpsDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) WriteDB() *resourcePpsDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Session(config *gorm.Session) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Clauses(conds ...clause.Expression) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Returning(value interface{}, columns ...string) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Not(conds ...gen.Condition) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Or(conds ...gen.Condition) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Select(conds ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Where(conds ...gen.Condition) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Order(conds ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Distinct(cols ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Omit(cols ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Join(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Group(cols ...field.Expr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Having(conds ...gen.Condition) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Limit(limit int) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Offset(offset int) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Unscoped() *resourcePpsDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Create(values ...*models.ResourcePps) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) CreateInBatches(values []*models.ResourcePps, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r resourcePpsDo) Save(values ...*models.ResourcePps) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) First() (*models.ResourcePps, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePps), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Take() (*models.ResourcePps, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePps), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Last() (*models.ResourcePps, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePps), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Find() ([]*models.ResourcePps, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.ResourcePps), err
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ResourcePps, err error) {
|
||||
buf := make([]*models.ResourcePps, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) FindInBatches(result *[]*models.ResourcePps, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Attrs(attrs ...field.AssignExpr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Assign(attrs ...field.AssignExpr) *resourcePpsDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Joins(fields ...field.RelationField) *resourcePpsDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Preload(fields ...field.RelationField) *resourcePpsDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) FirstOrInit() (*models.ResourcePps, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePps), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) FirstOrCreate() (*models.ResourcePps, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePps), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) FindByPage(offset int, limit int) (result []*models.ResourcePps, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r resourcePpsDo) Delete(models ...*models.ResourcePps) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *resourcePpsDo) withDO(do gen.Dao) *resourcePpsDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
355
web/queries/resource_psr.gen.go
Normal file
355
web/queries/resource_psr.gen.go
Normal file
@@ -0,0 +1,355 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newResourcePsr(db *gorm.DB, opts ...gen.DOOption) resourcePsr {
|
||||
_resourcePsr := resourcePsr{}
|
||||
|
||||
_resourcePsr.resourcePsrDo.UseDB(db, opts...)
|
||||
_resourcePsr.resourcePsrDo.UseModel(&models.ResourcePsr{})
|
||||
|
||||
tableName := _resourcePsr.resourcePsrDo.TableName()
|
||||
_resourcePsr.ALL = field.NewAsterisk(tableName)
|
||||
_resourcePsr.ID = field.NewInt32(tableName, "id")
|
||||
_resourcePsr.ResourceID = field.NewInt32(tableName, "resource_id")
|
||||
_resourcePsr.Active = field.NewBool(tableName, "active")
|
||||
_resourcePsr.Live = field.NewInt32(tableName, "live")
|
||||
_resourcePsr.Conn = field.NewInt32(tableName, "conn")
|
||||
_resourcePsr.Expire = field.NewTime(tableName, "expire")
|
||||
_resourcePsr.Used = field.NewBool(tableName, "used")
|
||||
_resourcePsr.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_resourcePsr.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_resourcePsr.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_resourcePsr.fillFieldMap()
|
||||
|
||||
return _resourcePsr
|
||||
}
|
||||
|
||||
type resourcePsr struct {
|
||||
resourcePsrDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // ID
|
||||
ResourceID field.Int32 // 套餐ID
|
||||
Active field.Bool // 是否启用
|
||||
Live field.Int32 // 轮换周期(秒)
|
||||
Conn field.Int32 // 最大连接数
|
||||
Expire field.Time // 过期时间
|
||||
Used field.Bool // 是否已使用
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r resourcePsr) Table(newTableName string) *resourcePsr {
|
||||
r.resourcePsrDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r resourcePsr) As(alias string) *resourcePsr {
|
||||
r.resourcePsrDo.DO = *(r.resourcePsrDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *resourcePsr) updateTableName(table string) *resourcePsr {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.ResourceID = field.NewInt32(table, "resource_id")
|
||||
r.Active = field.NewBool(table, "active")
|
||||
r.Live = field.NewInt32(table, "live")
|
||||
r.Conn = field.NewInt32(table, "conn")
|
||||
r.Expire = field.NewTime(table, "expire")
|
||||
r.Used = field.NewBool(table, "used")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *resourcePsr) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *resourcePsr) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 10)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["resource_id"] = r.ResourceID
|
||||
r.fieldMap["active"] = r.Active
|
||||
r.fieldMap["live"] = r.Live
|
||||
r.fieldMap["conn"] = r.Conn
|
||||
r.fieldMap["expire"] = r.Expire
|
||||
r.fieldMap["used"] = r.Used
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
}
|
||||
|
||||
func (r resourcePsr) clone(db *gorm.DB) resourcePsr {
|
||||
r.resourcePsrDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resourcePsr) replaceDB(db *gorm.DB) resourcePsr {
|
||||
r.resourcePsrDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type resourcePsrDo struct{ gen.DO }
|
||||
|
||||
func (r resourcePsrDo) Debug() *resourcePsrDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) WithContext(ctx context.Context) *resourcePsrDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) ReadDB() *resourcePsrDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) WriteDB() *resourcePsrDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Session(config *gorm.Session) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Clauses(conds ...clause.Expression) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Returning(value interface{}, columns ...string) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Not(conds ...gen.Condition) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Or(conds ...gen.Condition) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Select(conds ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Where(conds ...gen.Condition) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Order(conds ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Distinct(cols ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Omit(cols ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Join(table schema.Tabler, on ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Group(cols ...field.Expr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Having(conds ...gen.Condition) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Limit(limit int) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Offset(offset int) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Unscoped() *resourcePsrDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Create(values ...*models.ResourcePsr) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) CreateInBatches(values []*models.ResourcePsr, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r resourcePsrDo) Save(values ...*models.ResourcePsr) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) First() (*models.ResourcePsr, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePsr), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Take() (*models.ResourcePsr, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePsr), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Last() (*models.ResourcePsr, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePsr), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Find() ([]*models.ResourcePsr, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.ResourcePsr), err
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ResourcePsr, err error) {
|
||||
buf := make([]*models.ResourcePsr, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) FindInBatches(result *[]*models.ResourcePsr, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Attrs(attrs ...field.AssignExpr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Assign(attrs ...field.AssignExpr) *resourcePsrDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Joins(fields ...field.RelationField) *resourcePsrDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Preload(fields ...field.RelationField) *resourcePsrDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) FirstOrInit() (*models.ResourcePsr, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePsr), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) FirstOrCreate() (*models.ResourcePsr, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePsr), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) FindByPage(offset int, limit int) (result []*models.ResourcePsr, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r resourcePsrDo) Delete(models ...*models.ResourcePsr) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *resourcePsrDo) withDO(do gen.Dao) *resourcePsrDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
367
web/queries/resource_pss.gen.go
Normal file
367
web/queries/resource_pss.gen.go
Normal file
@@ -0,0 +1,367 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newResourcePss(db *gorm.DB, opts ...gen.DOOption) resourcePss {
|
||||
_resourcePss := resourcePss{}
|
||||
|
||||
_resourcePss.resourcePssDo.UseDB(db, opts...)
|
||||
_resourcePss.resourcePssDo.UseModel(&models.ResourcePss{})
|
||||
|
||||
tableName := _resourcePss.resourcePssDo.TableName()
|
||||
_resourcePss.ALL = field.NewAsterisk(tableName)
|
||||
_resourcePss.ID = field.NewInt32(tableName, "id")
|
||||
_resourcePss.ResourceID = field.NewInt32(tableName, "resource_id")
|
||||
_resourcePss.Active = field.NewBool(tableName, "active")
|
||||
_resourcePss.Type = field.NewInt32(tableName, "type")
|
||||
_resourcePss.Live = field.NewInt32(tableName, "live")
|
||||
_resourcePss.Quota = field.NewInt32(tableName, "quota")
|
||||
_resourcePss.Used = field.NewInt32(tableName, "used")
|
||||
_resourcePss.Expire = field.NewTime(tableName, "expire")
|
||||
_resourcePss.LimitDay = field.NewInt32(tableName, "limit_day")
|
||||
_resourcePss.LastUsed = field.NewTime(tableName, "last_used")
|
||||
_resourcePss.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_resourcePss.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_resourcePss.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_resourcePss.fillFieldMap()
|
||||
|
||||
return _resourcePss
|
||||
}
|
||||
|
||||
type resourcePss struct {
|
||||
resourcePssDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // ID
|
||||
ResourceID field.Int32 // 套餐ID
|
||||
Active field.Bool // 是否启用
|
||||
Type field.Int32 // 套餐类型:1-包时,2-包量
|
||||
Live field.Int32 // 可用时长(秒)
|
||||
Quota field.Int32 // 配额数量
|
||||
Used field.Int32 // 已用数量
|
||||
Expire field.Time // 过期时间
|
||||
LimitDay field.Int32 // 每日限额
|
||||
LastUsed field.Time // 最后提取时间
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (r resourcePss) Table(newTableName string) *resourcePss {
|
||||
r.resourcePssDo.UseTable(newTableName)
|
||||
return r.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (r resourcePss) As(alias string) *resourcePss {
|
||||
r.resourcePssDo.DO = *(r.resourcePssDo.As(alias).(*gen.DO))
|
||||
return r.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (r *resourcePss) updateTableName(table string) *resourcePss {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.ResourceID = field.NewInt32(table, "resource_id")
|
||||
r.Active = field.NewBool(table, "active")
|
||||
r.Type = field.NewInt32(table, "type")
|
||||
r.Live = field.NewInt32(table, "live")
|
||||
r.Quota = field.NewInt32(table, "quota")
|
||||
r.Used = field.NewInt32(table, "used")
|
||||
r.Expire = field.NewTime(table, "expire")
|
||||
r.LimitDay = field.NewInt32(table, "limit_day")
|
||||
r.LastUsed = field.NewTime(table, "last_used")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *resourcePss) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := r.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (r *resourcePss) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 13)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["resource_id"] = r.ResourceID
|
||||
r.fieldMap["active"] = r.Active
|
||||
r.fieldMap["type"] = r.Type
|
||||
r.fieldMap["live"] = r.Live
|
||||
r.fieldMap["quota"] = r.Quota
|
||||
r.fieldMap["used"] = r.Used
|
||||
r.fieldMap["expire"] = r.Expire
|
||||
r.fieldMap["limit_day"] = r.LimitDay
|
||||
r.fieldMap["last_used"] = r.LastUsed
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
}
|
||||
|
||||
func (r resourcePss) clone(db *gorm.DB) resourcePss {
|
||||
r.resourcePssDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func (r resourcePss) replaceDB(db *gorm.DB) resourcePss {
|
||||
r.resourcePssDo.ReplaceDB(db)
|
||||
return r
|
||||
}
|
||||
|
||||
type resourcePssDo struct{ gen.DO }
|
||||
|
||||
func (r resourcePssDo) Debug() *resourcePssDo {
|
||||
return r.withDO(r.DO.Debug())
|
||||
}
|
||||
|
||||
func (r resourcePssDo) WithContext(ctx context.Context) *resourcePssDo {
|
||||
return r.withDO(r.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) ReadDB() *resourcePssDo {
|
||||
return r.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) WriteDB() *resourcePssDo {
|
||||
return r.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Session(config *gorm.Session) *resourcePssDo {
|
||||
return r.withDO(r.DO.Session(config))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Clauses(conds ...clause.Expression) *resourcePssDo {
|
||||
return r.withDO(r.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Returning(value interface{}, columns ...string) *resourcePssDo {
|
||||
return r.withDO(r.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Not(conds ...gen.Condition) *resourcePssDo {
|
||||
return r.withDO(r.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Or(conds ...gen.Condition) *resourcePssDo {
|
||||
return r.withDO(r.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Select(conds ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Where(conds ...gen.Condition) *resourcePssDo {
|
||||
return r.withDO(r.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Order(conds ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Distinct(cols ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Omit(cols ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Join(table schema.Tabler, on ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) LeftJoin(table schema.Tabler, on ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) RightJoin(table schema.Tabler, on ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Group(cols ...field.Expr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Having(conds ...gen.Condition) *resourcePssDo {
|
||||
return r.withDO(r.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Limit(limit int) *resourcePssDo {
|
||||
return r.withDO(r.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Offset(offset int) *resourcePssDo {
|
||||
return r.withDO(r.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *resourcePssDo {
|
||||
return r.withDO(r.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Unscoped() *resourcePssDo {
|
||||
return r.withDO(r.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Create(values ...*models.ResourcePss) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Create(values)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) CreateInBatches(values []*models.ResourcePss, batchSize int) error {
|
||||
return r.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (r resourcePssDo) Save(values ...*models.ResourcePss) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DO.Save(values)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) First() (*models.ResourcePss, error) {
|
||||
if result, err := r.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePss), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Take() (*models.ResourcePss, error) {
|
||||
if result, err := r.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePss), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Last() (*models.ResourcePss, error) {
|
||||
if result, err := r.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePss), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Find() ([]*models.ResourcePss, error) {
|
||||
result, err := r.DO.Find()
|
||||
return result.([]*models.ResourcePss), err
|
||||
}
|
||||
|
||||
func (r resourcePssDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.ResourcePss, err error) {
|
||||
buf := make([]*models.ResourcePss, 0, batchSize)
|
||||
err = r.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (r resourcePssDo) FindInBatches(result *[]*models.ResourcePss, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return r.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Attrs(attrs ...field.AssignExpr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Assign(attrs ...field.AssignExpr) *resourcePssDo {
|
||||
return r.withDO(r.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Joins(fields ...field.RelationField) *resourcePssDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Joins(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Preload(fields ...field.RelationField) *resourcePssDo {
|
||||
for _, _f := range fields {
|
||||
r = *r.withDO(r.DO.Preload(_f))
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func (r resourcePssDo) FirstOrInit() (*models.ResourcePss, error) {
|
||||
if result, err := r.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePss), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePssDo) FirstOrCreate() (*models.ResourcePss, error) {
|
||||
if result, err := r.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.ResourcePss), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r resourcePssDo) FindByPage(offset int, limit int) (result []*models.ResourcePss, count int64, err error) {
|
||||
result, err = r.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = r.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePssDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = r.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = r.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Scan(result interface{}) (err error) {
|
||||
return r.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (r resourcePssDo) Delete(models ...*models.ResourcePss) (result gen.ResultInfo, err error) {
|
||||
return r.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (r *resourcePssDo) withDO(do gen.Dao) *resourcePssDo {
|
||||
r.DO = *do.(*gen.DO)
|
||||
return r
|
||||
}
|
||||
367
web/queries/trade.gen.go
Normal file
367
web/queries/trade.gen.go
Normal file
@@ -0,0 +1,367 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newTrade(db *gorm.DB, opts ...gen.DOOption) trade {
|
||||
_trade := trade{}
|
||||
|
||||
_trade.tradeDo.UseDB(db, opts...)
|
||||
_trade.tradeDo.UseModel(&models.Trade{})
|
||||
|
||||
tableName := _trade.tradeDo.TableName()
|
||||
_trade.ALL = field.NewAsterisk(tableName)
|
||||
_trade.ID = field.NewInt32(tableName, "id")
|
||||
_trade.UserID = field.NewInt32(tableName, "user_id")
|
||||
_trade.InnerNo = field.NewString(tableName, "inner_no")
|
||||
_trade.OuterNo = field.NewString(tableName, "outer_no")
|
||||
_trade.Subject = field.NewString(tableName, "subject")
|
||||
_trade.Remark = field.NewString(tableName, "remark")
|
||||
_trade.Amount = field.NewFloat64(tableName, "amount")
|
||||
_trade.Payment = field.NewFloat64(tableName, "payment")
|
||||
_trade.Method = field.NewInt32(tableName, "method")
|
||||
_trade.Status = field.NewInt32(tableName, "status")
|
||||
_trade.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_trade.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_trade.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_trade.fillFieldMap()
|
||||
|
||||
return _trade
|
||||
}
|
||||
|
||||
type trade struct {
|
||||
tradeDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 订单ID
|
||||
UserID field.Int32 // 用户ID
|
||||
InnerNo field.String // 内部订单号
|
||||
OuterNo field.String // 外部订单号
|
||||
Subject field.String // 订单主题
|
||||
Remark field.String // 订单备注
|
||||
Amount field.Float64 // 订单总金额
|
||||
Payment field.Float64 // 支付金额
|
||||
Method field.Int32 // 支付方式:1-支付宝,2-微信
|
||||
Status field.Int32 // 订单状态:0-待支付,1-已支付,2-已取消,3-已退款
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (t trade) Table(newTableName string) *trade {
|
||||
t.tradeDo.UseTable(newTableName)
|
||||
return t.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (t trade) As(alias string) *trade {
|
||||
t.tradeDo.DO = *(t.tradeDo.As(alias).(*gen.DO))
|
||||
return t.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (t *trade) updateTableName(table string) *trade {
|
||||
t.ALL = field.NewAsterisk(table)
|
||||
t.ID = field.NewInt32(table, "id")
|
||||
t.UserID = field.NewInt32(table, "user_id")
|
||||
t.InnerNo = field.NewString(table, "inner_no")
|
||||
t.OuterNo = field.NewString(table, "outer_no")
|
||||
t.Subject = field.NewString(table, "subject")
|
||||
t.Remark = field.NewString(table, "remark")
|
||||
t.Amount = field.NewFloat64(table, "amount")
|
||||
t.Payment = field.NewFloat64(table, "payment")
|
||||
t.Method = field.NewInt32(table, "method")
|
||||
t.Status = field.NewInt32(table, "status")
|
||||
t.CreatedAt = field.NewTime(table, "created_at")
|
||||
t.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
t.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
t.fillFieldMap()
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func (t *trade) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := t.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (t *trade) fillFieldMap() {
|
||||
t.fieldMap = make(map[string]field.Expr, 13)
|
||||
t.fieldMap["id"] = t.ID
|
||||
t.fieldMap["user_id"] = t.UserID
|
||||
t.fieldMap["inner_no"] = t.InnerNo
|
||||
t.fieldMap["outer_no"] = t.OuterNo
|
||||
t.fieldMap["subject"] = t.Subject
|
||||
t.fieldMap["remark"] = t.Remark
|
||||
t.fieldMap["amount"] = t.Amount
|
||||
t.fieldMap["payment"] = t.Payment
|
||||
t.fieldMap["method"] = t.Method
|
||||
t.fieldMap["status"] = t.Status
|
||||
t.fieldMap["created_at"] = t.CreatedAt
|
||||
t.fieldMap["updated_at"] = t.UpdatedAt
|
||||
t.fieldMap["deleted_at"] = t.DeletedAt
|
||||
}
|
||||
|
||||
func (t trade) clone(db *gorm.DB) trade {
|
||||
t.tradeDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return t
|
||||
}
|
||||
|
||||
func (t trade) replaceDB(db *gorm.DB) trade {
|
||||
t.tradeDo.ReplaceDB(db)
|
||||
return t
|
||||
}
|
||||
|
||||
type tradeDo struct{ gen.DO }
|
||||
|
||||
func (t tradeDo) Debug() *tradeDo {
|
||||
return t.withDO(t.DO.Debug())
|
||||
}
|
||||
|
||||
func (t tradeDo) WithContext(ctx context.Context) *tradeDo {
|
||||
return t.withDO(t.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (t tradeDo) ReadDB() *tradeDo {
|
||||
return t.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (t tradeDo) WriteDB() *tradeDo {
|
||||
return t.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (t tradeDo) Session(config *gorm.Session) *tradeDo {
|
||||
return t.withDO(t.DO.Session(config))
|
||||
}
|
||||
|
||||
func (t tradeDo) Clauses(conds ...clause.Expression) *tradeDo {
|
||||
return t.withDO(t.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Returning(value interface{}, columns ...string) *tradeDo {
|
||||
return t.withDO(t.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Not(conds ...gen.Condition) *tradeDo {
|
||||
return t.withDO(t.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Or(conds ...gen.Condition) *tradeDo {
|
||||
return t.withDO(t.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Select(conds ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Where(conds ...gen.Condition) *tradeDo {
|
||||
return t.withDO(t.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Order(conds ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Distinct(cols ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Omit(cols ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Join(table schema.Tabler, on ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (t tradeDo) LeftJoin(table schema.Tabler, on ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t tradeDo) RightJoin(table schema.Tabler, on ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Group(cols ...field.Expr) *tradeDo {
|
||||
return t.withDO(t.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Having(conds ...gen.Condition) *tradeDo {
|
||||
return t.withDO(t.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Limit(limit int) *tradeDo {
|
||||
return t.withDO(t.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (t tradeDo) Offset(offset int) *tradeDo {
|
||||
return t.withDO(t.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (t tradeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *tradeDo {
|
||||
return t.withDO(t.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Unscoped() *tradeDo {
|
||||
return t.withDO(t.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (t tradeDo) Create(values ...*models.Trade) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Create(values)
|
||||
}
|
||||
|
||||
func (t tradeDo) CreateInBatches(values []*models.Trade, batchSize int) error {
|
||||
return t.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (t tradeDo) Save(values ...*models.Trade) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return t.DO.Save(values)
|
||||
}
|
||||
|
||||
func (t tradeDo) First() (*models.Trade, error) {
|
||||
if result, err := t.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Trade), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t tradeDo) Take() (*models.Trade, error) {
|
||||
if result, err := t.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Trade), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t tradeDo) Last() (*models.Trade, error) {
|
||||
if result, err := t.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Trade), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t tradeDo) Find() ([]*models.Trade, error) {
|
||||
result, err := t.DO.Find()
|
||||
return result.([]*models.Trade), err
|
||||
}
|
||||
|
||||
func (t tradeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Trade, err error) {
|
||||
buf := make([]*models.Trade, 0, batchSize)
|
||||
err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (t tradeDo) FindInBatches(result *[]*models.Trade, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return t.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (t tradeDo) Attrs(attrs ...field.AssignExpr) *tradeDo {
|
||||
return t.withDO(t.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Assign(attrs ...field.AssignExpr) *tradeDo {
|
||||
return t.withDO(t.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (t tradeDo) Joins(fields ...field.RelationField) *tradeDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Joins(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t tradeDo) Preload(fields ...field.RelationField) *tradeDo {
|
||||
for _, _f := range fields {
|
||||
t = *t.withDO(t.DO.Preload(_f))
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
func (t tradeDo) FirstOrInit() (*models.Trade, error) {
|
||||
if result, err := t.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Trade), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t tradeDo) FirstOrCreate() (*models.Trade, error) {
|
||||
if result, err := t.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Trade), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (t tradeDo) FindByPage(offset int, limit int) (result []*models.Trade, count int64, err error) {
|
||||
result, err = t.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = t.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (t tradeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = t.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = t.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (t tradeDo) Scan(result interface{}) (err error) {
|
||||
return t.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (t tradeDo) Delete(models ...*models.Trade) (result gen.ResultInfo, err error) {
|
||||
return t.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (t *tradeDo) withDO(do gen.Dao) *tradeDo {
|
||||
t.DO = *do.(*gen.DO)
|
||||
return t
|
||||
}
|
||||
399
web/queries/user.gen.go
Normal file
399
web/queries/user.gen.go
Normal file
@@ -0,0 +1,399 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newUser(db *gorm.DB, opts ...gen.DOOption) user {
|
||||
_user := user{}
|
||||
|
||||
_user.userDo.UseDB(db, opts...)
|
||||
_user.userDo.UseModel(&models.User{})
|
||||
|
||||
tableName := _user.userDo.TableName()
|
||||
_user.ALL = field.NewAsterisk(tableName)
|
||||
_user.ID = field.NewInt32(tableName, "id")
|
||||
_user.AdminID = field.NewInt32(tableName, "admin_id")
|
||||
_user.Phone = field.NewString(tableName, "phone")
|
||||
_user.Username = field.NewString(tableName, "username")
|
||||
_user.Email = field.NewString(tableName, "email")
|
||||
_user.Password = field.NewString(tableName, "password")
|
||||
_user.Name = field.NewString(tableName, "name")
|
||||
_user.Avatar = field.NewString(tableName, "avatar")
|
||||
_user.Status = field.NewInt32(tableName, "status")
|
||||
_user.Balance = field.NewFloat64(tableName, "balance")
|
||||
_user.IDType = field.NewInt32(tableName, "id_type")
|
||||
_user.IDNo = field.NewString(tableName, "id_no")
|
||||
_user.IDToken = field.NewString(tableName, "id_token")
|
||||
_user.ContactQq = field.NewString(tableName, "contact_qq")
|
||||
_user.ContactWechat = field.NewString(tableName, "contact_wechat")
|
||||
_user.LastLogin = field.NewTime(tableName, "last_login")
|
||||
_user.LastLoginAddr = field.NewString(tableName, "last_login_addr")
|
||||
_user.LastLoginAgent = field.NewString(tableName, "last_login_agent")
|
||||
_user.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_user.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_user.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_user.fillFieldMap()
|
||||
|
||||
return _user
|
||||
}
|
||||
|
||||
type user struct {
|
||||
userDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32
|
||||
AdminID field.Int32
|
||||
Phone field.String
|
||||
Username field.String
|
||||
Email field.String
|
||||
Password field.String
|
||||
Name field.String
|
||||
Avatar field.String
|
||||
Status field.Int32
|
||||
Balance field.Float64
|
||||
IDType field.Int32
|
||||
IDNo field.String
|
||||
IDToken field.String
|
||||
ContactQq field.String
|
||||
ContactWechat field.String
|
||||
LastLogin field.Time
|
||||
LastLoginAddr field.String
|
||||
LastLoginAgent field.String
|
||||
CreatedAt field.Time
|
||||
UpdatedAt field.Time
|
||||
DeletedAt field.Field
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u user) Table(newTableName string) *user {
|
||||
u.userDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u user) As(alias string) *user {
|
||||
u.userDo.DO = *(u.userDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *user) updateTableName(table string) *user {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt32(table, "id")
|
||||
u.AdminID = field.NewInt32(table, "admin_id")
|
||||
u.Phone = field.NewString(table, "phone")
|
||||
u.Username = field.NewString(table, "username")
|
||||
u.Email = field.NewString(table, "email")
|
||||
u.Password = field.NewString(table, "password")
|
||||
u.Name = field.NewString(table, "name")
|
||||
u.Avatar = field.NewString(table, "avatar")
|
||||
u.Status = field.NewInt32(table, "status")
|
||||
u.Balance = field.NewFloat64(table, "balance")
|
||||
u.IDType = field.NewInt32(table, "id_type")
|
||||
u.IDNo = field.NewString(table, "id_no")
|
||||
u.IDToken = field.NewString(table, "id_token")
|
||||
u.ContactQq = field.NewString(table, "contact_qq")
|
||||
u.ContactWechat = field.NewString(table, "contact_wechat")
|
||||
u.LastLogin = field.NewTime(table, "last_login")
|
||||
u.LastLoginAddr = field.NewString(table, "last_login_addr")
|
||||
u.LastLoginAgent = field.NewString(table, "last_login_agent")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *user) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 21)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["admin_id"] = u.AdminID
|
||||
u.fieldMap["phone"] = u.Phone
|
||||
u.fieldMap["username"] = u.Username
|
||||
u.fieldMap["email"] = u.Email
|
||||
u.fieldMap["password"] = u.Password
|
||||
u.fieldMap["name"] = u.Name
|
||||
u.fieldMap["avatar"] = u.Avatar
|
||||
u.fieldMap["status"] = u.Status
|
||||
u.fieldMap["balance"] = u.Balance
|
||||
u.fieldMap["id_type"] = u.IDType
|
||||
u.fieldMap["id_no"] = u.IDNo
|
||||
u.fieldMap["id_token"] = u.IDToken
|
||||
u.fieldMap["contact_qq"] = u.ContactQq
|
||||
u.fieldMap["contact_wechat"] = u.ContactWechat
|
||||
u.fieldMap["last_login"] = u.LastLogin
|
||||
u.fieldMap["last_login_addr"] = u.LastLoginAddr
|
||||
u.fieldMap["last_login_agent"] = u.LastLoginAgent
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
}
|
||||
|
||||
func (u user) clone(db *gorm.DB) user {
|
||||
u.userDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u user) replaceDB(db *gorm.DB) user {
|
||||
u.userDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userDo struct{ gen.DO }
|
||||
|
||||
func (u userDo) Debug() *userDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userDo) WithContext(ctx context.Context) *userDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userDo) ReadDB() *userDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userDo) WriteDB() *userDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userDo) Session(config *gorm.Session) *userDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userDo) Clauses(conds ...clause.Expression) *userDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Returning(value interface{}, columns ...string) *userDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userDo) Not(conds ...gen.Condition) *userDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Or(conds ...gen.Condition) *userDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Select(conds ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Where(conds ...gen.Condition) *userDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Order(conds ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Distinct(cols ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Omit(cols ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Join(table schema.Tabler, on ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) RightJoin(table schema.Tabler, on ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userDo) Group(cols ...field.Expr) *userDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userDo) Having(conds ...gen.Condition) *userDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userDo) Limit(limit int) *userDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userDo) Offset(offset int) *userDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userDo) Unscoped() *userDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userDo) Create(values ...*models.User) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userDo) CreateInBatches(values []*models.User, batchSize int) error {
|
||||
return u.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (u userDo) Save(values ...*models.User) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userDo) First() (*models.User, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Take() (*models.User, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Last() (*models.User, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) Find() ([]*models.User, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.User), err
|
||||
}
|
||||
|
||||
func (u userDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.User, err error) {
|
||||
buf := make([]*models.User, 0, batchSize)
|
||||
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (u userDo) FindInBatches(result *[]*models.User, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userDo) Attrs(attrs ...field.AssignExpr) *userDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userDo) Assign(attrs ...field.AssignExpr) *userDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userDo) Joins(fields ...field.RelationField) *userDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userDo) Preload(fields ...field.RelationField) *userDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userDo) FirstOrInit() (*models.User, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) FirstOrCreate() (*models.User, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.User), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userDo) FindByPage(offset int, limit int) (result []*models.User, count int64, err error) {
|
||||
result, err = u.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userDo) Delete(models ...*models.User) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userDo) withDO(do gen.Dao) *userDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
||||
347
web/queries/user_role.gen.go
Normal file
347
web/queries/user_role.gen.go
Normal file
@@ -0,0 +1,347 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newUserRole(db *gorm.DB, opts ...gen.DOOption) userRole {
|
||||
_userRole := userRole{}
|
||||
|
||||
_userRole.userRoleDo.UseDB(db, opts...)
|
||||
_userRole.userRoleDo.UseModel(&models.UserRole{})
|
||||
|
||||
tableName := _userRole.userRoleDo.TableName()
|
||||
_userRole.ALL = field.NewAsterisk(tableName)
|
||||
_userRole.ID = field.NewInt32(tableName, "id")
|
||||
_userRole.Name = field.NewString(tableName, "name")
|
||||
_userRole.Description = field.NewString(tableName, "description")
|
||||
_userRole.Active = field.NewBool(tableName, "active")
|
||||
_userRole.Sort = field.NewInt32(tableName, "sort")
|
||||
_userRole.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userRole.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userRole.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_userRole.fillFieldMap()
|
||||
|
||||
return _userRole
|
||||
}
|
||||
|
||||
type userRole struct {
|
||||
userRoleDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 角色ID
|
||||
Name field.String // 角色名称
|
||||
Description field.String // 角色描述
|
||||
Active field.Bool // 是否激活
|
||||
Sort field.Int32 // 排序
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userRole) Table(newTableName string) *userRole {
|
||||
u.userRoleDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userRole) As(alias string) *userRole {
|
||||
u.userRoleDo.DO = *(u.userRoleDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userRole) updateTableName(table string) *userRole {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt32(table, "id")
|
||||
u.Name = field.NewString(table, "name")
|
||||
u.Description = field.NewString(table, "description")
|
||||
u.Active = field.NewBool(table, "active")
|
||||
u.Sort = field.NewInt32(table, "sort")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *userRole) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 8)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["name"] = u.Name
|
||||
u.fieldMap["description"] = u.Description
|
||||
u.fieldMap["active"] = u.Active
|
||||
u.fieldMap["sort"] = u.Sort
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
}
|
||||
|
||||
func (u userRole) clone(db *gorm.DB) userRole {
|
||||
u.userRoleDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userRole) replaceDB(db *gorm.DB) userRole {
|
||||
u.userRoleDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userRoleDo struct{ gen.DO }
|
||||
|
||||
func (u userRoleDo) Debug() *userRoleDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userRoleDo) WithContext(ctx context.Context) *userRoleDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userRoleDo) ReadDB() *userRoleDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userRoleDo) WriteDB() *userRoleDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userRoleDo) Session(config *gorm.Session) *userRoleDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Clauses(conds ...clause.Expression) *userRoleDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Returning(value interface{}, columns ...string) *userRoleDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Not(conds ...gen.Condition) *userRoleDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Or(conds ...gen.Condition) *userRoleDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Select(conds ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Where(conds ...gen.Condition) *userRoleDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Order(conds ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Distinct(cols ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Omit(cols ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Join(table schema.Tabler, on ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Group(cols ...field.Expr) *userRoleDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Having(conds ...gen.Condition) *userRoleDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Limit(limit int) *userRoleDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Offset(offset int) *userRoleDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userRoleDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Unscoped() *userRoleDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userRoleDo) Create(values ...*models.UserRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userRoleDo) CreateInBatches(values []*models.UserRole, batchSize int) error {
|
||||
return u.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (u userRoleDo) Save(values ...*models.UserRole) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userRoleDo) First() (*models.UserRole, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleDo) Take() (*models.UserRole, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleDo) Last() (*models.UserRole, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleDo) Find() ([]*models.UserRole, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserRole), err
|
||||
}
|
||||
|
||||
func (u userRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRole, err error) {
|
||||
buf := make([]*models.UserRole, 0, batchSize)
|
||||
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (u userRoleDo) FindInBatches(result *[]*models.UserRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userRoleDo) Attrs(attrs ...field.AssignExpr) *userRoleDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Assign(attrs ...field.AssignExpr) *userRoleDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userRoleDo) Joins(fields ...field.RelationField) *userRoleDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRoleDo) Preload(fields ...field.RelationField) *userRoleDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRoleDo) FirstOrInit() (*models.UserRole, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleDo) FirstOrCreate() (*models.UserRole, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRole), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleDo) FindByPage(offset int, limit int) (result []*models.UserRole, count int64, err error) {
|
||||
result, err = u.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRoleDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userRoleDo) Delete(models ...*models.UserRole) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userRoleDo) withDO(do gen.Dao) *userRoleDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
||||
339
web/queries/user_role_link.gen.go
Normal file
339
web/queries/user_role_link.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newUserRoleLink(db *gorm.DB, opts ...gen.DOOption) userRoleLink {
|
||||
_userRoleLink := userRoleLink{}
|
||||
|
||||
_userRoleLink.userRoleLinkDo.UseDB(db, opts...)
|
||||
_userRoleLink.userRoleLinkDo.UseModel(&models.UserRoleLink{})
|
||||
|
||||
tableName := _userRoleLink.userRoleLinkDo.TableName()
|
||||
_userRoleLink.ALL = field.NewAsterisk(tableName)
|
||||
_userRoleLink.ID = field.NewInt32(tableName, "id")
|
||||
_userRoleLink.UserID = field.NewInt32(tableName, "user_id")
|
||||
_userRoleLink.RoleID = field.NewInt32(tableName, "role_id")
|
||||
_userRoleLink.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userRoleLink.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userRoleLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_userRoleLink.fillFieldMap()
|
||||
|
||||
return _userRoleLink
|
||||
}
|
||||
|
||||
type userRoleLink struct {
|
||||
userRoleLinkDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 关联ID
|
||||
UserID field.Int32 // 用户ID
|
||||
RoleID field.Int32 // 角色ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userRoleLink) Table(newTableName string) *userRoleLink {
|
||||
u.userRoleLinkDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userRoleLink) As(alias string) *userRoleLink {
|
||||
u.userRoleLinkDo.DO = *(u.userRoleLinkDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userRoleLink) updateTableName(table string) *userRoleLink {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt32(table, "id")
|
||||
u.UserID = field.NewInt32(table, "user_id")
|
||||
u.RoleID = field.NewInt32(table, "role_id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userRoleLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *userRoleLink) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 6)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["user_id"] = u.UserID
|
||||
u.fieldMap["role_id"] = u.RoleID
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
}
|
||||
|
||||
func (u userRoleLink) clone(db *gorm.DB) userRoleLink {
|
||||
u.userRoleLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userRoleLink) replaceDB(db *gorm.DB) userRoleLink {
|
||||
u.userRoleLinkDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userRoleLinkDo struct{ gen.DO }
|
||||
|
||||
func (u userRoleLinkDo) Debug() *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) WithContext(ctx context.Context) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) ReadDB() *userRoleLinkDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) WriteDB() *userRoleLinkDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Session(config *gorm.Session) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Clauses(conds ...clause.Expression) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Returning(value interface{}, columns ...string) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Not(conds ...gen.Condition) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Or(conds ...gen.Condition) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Select(conds ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Where(conds ...gen.Condition) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Order(conds ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Distinct(cols ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Omit(cols ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Join(table schema.Tabler, on ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Group(cols ...field.Expr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Having(conds ...gen.Condition) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Limit(limit int) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Offset(offset int) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Unscoped() *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Create(values ...*models.UserRoleLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) CreateInBatches(values []*models.UserRoleLink, batchSize int) error {
|
||||
return u.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (u userRoleLinkDo) Save(values ...*models.UserRoleLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) First() (*models.UserRoleLink, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Take() (*models.UserRoleLink, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Last() (*models.UserRoleLink, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Find() ([]*models.UserRoleLink, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserRoleLink), err
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRoleLink, err error) {
|
||||
buf := make([]*models.UserRoleLink, 0, batchSize)
|
||||
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) FindInBatches(result *[]*models.UserRoleLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Attrs(attrs ...field.AssignExpr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Assign(attrs ...field.AssignExpr) *userRoleLinkDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Joins(fields ...field.RelationField) *userRoleLinkDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Preload(fields ...field.RelationField) *userRoleLinkDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) FirstOrInit() (*models.UserRoleLink, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) FirstOrCreate() (*models.UserRoleLink, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRoleLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) FindByPage(offset int, limit int) (result []*models.UserRoleLink, count int64, err error) {
|
||||
result, err = u.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userRoleLinkDo) Delete(models ...*models.UserRoleLink) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userRoleLinkDo) withDO(do gen.Dao) *userRoleLinkDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
||||
339
web/queries/user_role_permission_link.gen.go
Normal file
339
web/queries/user_role_permission_link.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newUserRolePermissionLink(db *gorm.DB, opts ...gen.DOOption) userRolePermissionLink {
|
||||
_userRolePermissionLink := userRolePermissionLink{}
|
||||
|
||||
_userRolePermissionLink.userRolePermissionLinkDo.UseDB(db, opts...)
|
||||
_userRolePermissionLink.userRolePermissionLinkDo.UseModel(&models.UserRolePermissionLink{})
|
||||
|
||||
tableName := _userRolePermissionLink.userRolePermissionLinkDo.TableName()
|
||||
_userRolePermissionLink.ALL = field.NewAsterisk(tableName)
|
||||
_userRolePermissionLink.ID = field.NewInt32(tableName, "id")
|
||||
_userRolePermissionLink.RoleID = field.NewInt32(tableName, "role_id")
|
||||
_userRolePermissionLink.PermissionID = field.NewInt32(tableName, "permission_id")
|
||||
_userRolePermissionLink.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_userRolePermissionLink.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_userRolePermissionLink.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_userRolePermissionLink.fillFieldMap()
|
||||
|
||||
return _userRolePermissionLink
|
||||
}
|
||||
|
||||
type userRolePermissionLink struct {
|
||||
userRolePermissionLinkDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 关联ID
|
||||
RoleID field.Int32 // 角色ID
|
||||
PermissionID field.Int32 // 权限ID
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (u userRolePermissionLink) Table(newTableName string) *userRolePermissionLink {
|
||||
u.userRolePermissionLinkDo.UseTable(newTableName)
|
||||
return u.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLink) As(alias string) *userRolePermissionLink {
|
||||
u.userRolePermissionLinkDo.DO = *(u.userRolePermissionLinkDo.As(alias).(*gen.DO))
|
||||
return u.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (u *userRolePermissionLink) updateTableName(table string) *userRolePermissionLink {
|
||||
u.ALL = field.NewAsterisk(table)
|
||||
u.ID = field.NewInt32(table, "id")
|
||||
u.RoleID = field.NewInt32(table, "role_id")
|
||||
u.PermissionID = field.NewInt32(table, "permission_id")
|
||||
u.CreatedAt = field.NewTime(table, "created_at")
|
||||
u.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
u.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
u.fillFieldMap()
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *userRolePermissionLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := u.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (u *userRolePermissionLink) fillFieldMap() {
|
||||
u.fieldMap = make(map[string]field.Expr, 6)
|
||||
u.fieldMap["id"] = u.ID
|
||||
u.fieldMap["role_id"] = u.RoleID
|
||||
u.fieldMap["permission_id"] = u.PermissionID
|
||||
u.fieldMap["created_at"] = u.CreatedAt
|
||||
u.fieldMap["updated_at"] = u.UpdatedAt
|
||||
u.fieldMap["deleted_at"] = u.DeletedAt
|
||||
}
|
||||
|
||||
func (u userRolePermissionLink) clone(db *gorm.DB) userRolePermissionLink {
|
||||
u.userRolePermissionLinkDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return u
|
||||
}
|
||||
|
||||
func (u userRolePermissionLink) replaceDB(db *gorm.DB) userRolePermissionLink {
|
||||
u.userRolePermissionLinkDo.ReplaceDB(db)
|
||||
return u
|
||||
}
|
||||
|
||||
type userRolePermissionLinkDo struct{ gen.DO }
|
||||
|
||||
func (u userRolePermissionLinkDo) Debug() *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Debug())
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) WithContext(ctx context.Context) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) ReadDB() *userRolePermissionLinkDo {
|
||||
return u.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) WriteDB() *userRolePermissionLinkDo {
|
||||
return u.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Session(config *gorm.Session) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Session(config))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Clauses(conds ...clause.Expression) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Returning(value interface{}, columns ...string) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Not(conds ...gen.Condition) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Or(conds ...gen.Condition) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Select(conds ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Where(conds ...gen.Condition) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Order(conds ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Distinct(cols ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Omit(cols ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Join(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Group(cols ...field.Expr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Having(conds ...gen.Condition) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Limit(limit int) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Offset(offset int) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Unscoped() *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Create(values ...*models.UserRolePermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Create(values)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) CreateInBatches(values []*models.UserRolePermissionLink, batchSize int) error {
|
||||
return u.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (u userRolePermissionLinkDo) Save(values ...*models.UserRolePermissionLink) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return u.DO.Save(values)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) First() (*models.UserRolePermissionLink, error) {
|
||||
if result, err := u.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Take() (*models.UserRolePermissionLink, error) {
|
||||
if result, err := u.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Last() (*models.UserRolePermissionLink, error) {
|
||||
if result, err := u.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Find() ([]*models.UserRolePermissionLink, error) {
|
||||
result, err := u.DO.Find()
|
||||
return result.([]*models.UserRolePermissionLink), err
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.UserRolePermissionLink, err error) {
|
||||
buf := make([]*models.UserRolePermissionLink, 0, batchSize)
|
||||
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) FindInBatches(result *[]*models.UserRolePermissionLink, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return u.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Attrs(attrs ...field.AssignExpr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Assign(attrs ...field.AssignExpr) *userRolePermissionLinkDo {
|
||||
return u.withDO(u.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Joins(fields ...field.RelationField) *userRolePermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Joins(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Preload(fields ...field.RelationField) *userRolePermissionLinkDo {
|
||||
for _, _f := range fields {
|
||||
u = *u.withDO(u.DO.Preload(_f))
|
||||
}
|
||||
return &u
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) FirstOrInit() (*models.UserRolePermissionLink, error) {
|
||||
if result, err := u.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) FirstOrCreate() (*models.UserRolePermissionLink, error) {
|
||||
if result, err := u.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.UserRolePermissionLink), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) FindByPage(offset int, limit int) (result []*models.UserRolePermissionLink, count int64, err error) {
|
||||
result, err = u.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = u.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = u.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = u.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Scan(result interface{}) (err error) {
|
||||
return u.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (u userRolePermissionLinkDo) Delete(models ...*models.UserRolePermissionLink) (result gen.ResultInfo, err error) {
|
||||
return u.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (u *userRolePermissionLinkDo) withDO(do gen.Dao) *userRolePermissionLinkDo {
|
||||
u.DO = *do.(*gen.DO)
|
||||
return u
|
||||
}
|
||||
339
web/queries/whitelist.gen.go
Normal file
339
web/queries/whitelist.gen.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package queries
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"platform/web/models"
|
||||
)
|
||||
|
||||
func newWhitelist(db *gorm.DB, opts ...gen.DOOption) whitelist {
|
||||
_whitelist := whitelist{}
|
||||
|
||||
_whitelist.whitelistDo.UseDB(db, opts...)
|
||||
_whitelist.whitelistDo.UseModel(&models.Whitelist{})
|
||||
|
||||
tableName := _whitelist.whitelistDo.TableName()
|
||||
_whitelist.ALL = field.NewAsterisk(tableName)
|
||||
_whitelist.ID = field.NewInt32(tableName, "id")
|
||||
_whitelist.UserID = field.NewInt32(tableName, "user_id")
|
||||
_whitelist.Address = field.NewString(tableName, "address")
|
||||
_whitelist.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_whitelist.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_whitelist.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_whitelist.fillFieldMap()
|
||||
|
||||
return _whitelist
|
||||
}
|
||||
|
||||
type whitelist struct {
|
||||
whitelistDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 白名单ID
|
||||
UserID field.Int32 // 用户ID
|
||||
Address field.String // IP地址
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (w whitelist) Table(newTableName string) *whitelist {
|
||||
w.whitelistDo.UseTable(newTableName)
|
||||
return w.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (w whitelist) As(alias string) *whitelist {
|
||||
w.whitelistDo.DO = *(w.whitelistDo.As(alias).(*gen.DO))
|
||||
return w.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (w *whitelist) updateTableName(table string) *whitelist {
|
||||
w.ALL = field.NewAsterisk(table)
|
||||
w.ID = field.NewInt32(table, "id")
|
||||
w.UserID = field.NewInt32(table, "user_id")
|
||||
w.Address = field.NewString(table, "address")
|
||||
w.CreatedAt = field.NewTime(table, "created_at")
|
||||
w.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
w.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
w.fillFieldMap()
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *whitelist) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := w.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (w *whitelist) fillFieldMap() {
|
||||
w.fieldMap = make(map[string]field.Expr, 6)
|
||||
w.fieldMap["id"] = w.ID
|
||||
w.fieldMap["user_id"] = w.UserID
|
||||
w.fieldMap["address"] = w.Address
|
||||
w.fieldMap["created_at"] = w.CreatedAt
|
||||
w.fieldMap["updated_at"] = w.UpdatedAt
|
||||
w.fieldMap["deleted_at"] = w.DeletedAt
|
||||
}
|
||||
|
||||
func (w whitelist) clone(db *gorm.DB) whitelist {
|
||||
w.whitelistDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return w
|
||||
}
|
||||
|
||||
func (w whitelist) replaceDB(db *gorm.DB) whitelist {
|
||||
w.whitelistDo.ReplaceDB(db)
|
||||
return w
|
||||
}
|
||||
|
||||
type whitelistDo struct{ gen.DO }
|
||||
|
||||
func (w whitelistDo) Debug() *whitelistDo {
|
||||
return w.withDO(w.DO.Debug())
|
||||
}
|
||||
|
||||
func (w whitelistDo) WithContext(ctx context.Context) *whitelistDo {
|
||||
return w.withDO(w.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (w whitelistDo) ReadDB() *whitelistDo {
|
||||
return w.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (w whitelistDo) WriteDB() *whitelistDo {
|
||||
return w.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (w whitelistDo) Session(config *gorm.Session) *whitelistDo {
|
||||
return w.withDO(w.DO.Session(config))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Clauses(conds ...clause.Expression) *whitelistDo {
|
||||
return w.withDO(w.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Returning(value interface{}, columns ...string) *whitelistDo {
|
||||
return w.withDO(w.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Not(conds ...gen.Condition) *whitelistDo {
|
||||
return w.withDO(w.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Or(conds ...gen.Condition) *whitelistDo {
|
||||
return w.withDO(w.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Select(conds ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Where(conds ...gen.Condition) *whitelistDo {
|
||||
return w.withDO(w.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Order(conds ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Distinct(cols ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Omit(cols ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Join(table schema.Tabler, on ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) LeftJoin(table schema.Tabler, on ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) RightJoin(table schema.Tabler, on ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Group(cols ...field.Expr) *whitelistDo {
|
||||
return w.withDO(w.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Having(conds ...gen.Condition) *whitelistDo {
|
||||
return w.withDO(w.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Limit(limit int) *whitelistDo {
|
||||
return w.withDO(w.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Offset(offset int) *whitelistDo {
|
||||
return w.withDO(w.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *whitelistDo {
|
||||
return w.withDO(w.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Unscoped() *whitelistDo {
|
||||
return w.withDO(w.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (w whitelistDo) Create(values ...*models.Whitelist) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return w.DO.Create(values)
|
||||
}
|
||||
|
||||
func (w whitelistDo) CreateInBatches(values []*models.Whitelist, batchSize int) error {
|
||||
return w.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (w whitelistDo) Save(values ...*models.Whitelist) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return w.DO.Save(values)
|
||||
}
|
||||
|
||||
func (w whitelistDo) First() (*models.Whitelist, error) {
|
||||
if result, err := w.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Whitelist), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w whitelistDo) Take() (*models.Whitelist, error) {
|
||||
if result, err := w.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Whitelist), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w whitelistDo) Last() (*models.Whitelist, error) {
|
||||
if result, err := w.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Whitelist), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w whitelistDo) Find() ([]*models.Whitelist, error) {
|
||||
result, err := w.DO.Find()
|
||||
return result.([]*models.Whitelist), err
|
||||
}
|
||||
|
||||
func (w whitelistDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*models.Whitelist, err error) {
|
||||
buf := make([]*models.Whitelist, 0, batchSize)
|
||||
err = w.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (w whitelistDo) FindInBatches(result *[]*models.Whitelist, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return w.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (w whitelistDo) Attrs(attrs ...field.AssignExpr) *whitelistDo {
|
||||
return w.withDO(w.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Assign(attrs ...field.AssignExpr) *whitelistDo {
|
||||
return w.withDO(w.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (w whitelistDo) Joins(fields ...field.RelationField) *whitelistDo {
|
||||
for _, _f := range fields {
|
||||
w = *w.withDO(w.DO.Joins(_f))
|
||||
}
|
||||
return &w
|
||||
}
|
||||
|
||||
func (w whitelistDo) Preload(fields ...field.RelationField) *whitelistDo {
|
||||
for _, _f := range fields {
|
||||
w = *w.withDO(w.DO.Preload(_f))
|
||||
}
|
||||
return &w
|
||||
}
|
||||
|
||||
func (w whitelistDo) FirstOrInit() (*models.Whitelist, error) {
|
||||
if result, err := w.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Whitelist), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w whitelistDo) FirstOrCreate() (*models.Whitelist, error) {
|
||||
if result, err := w.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*models.Whitelist), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (w whitelistDo) FindByPage(offset int, limit int) (result []*models.Whitelist, count int64, err error) {
|
||||
result, err = w.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = w.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (w whitelistDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = w.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = w.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (w whitelistDo) Scan(result interface{}) (err error) {
|
||||
return w.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (w whitelistDo) Delete(models ...*models.Whitelist) (result gen.ResultInfo, err error) {
|
||||
return w.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (w *whitelistDo) withDO(do gen.Dao) *whitelistDo {
|
||||
w.DO = *do.(*gen.DO)
|
||||
return w
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package web
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func UseRoute(app *fiber.App) {
|
||||
|
||||
|
||||
5
web/utils/resp.go
Normal file
5
web/utils/resp.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package utils
|
||||
|
||||
type ErrResp struct {
|
||||
Cause string `json:"cause"`
|
||||
}
|
||||
Reference in New Issue
Block a user