Documentation
¶
Index ¶
- func IsZero(value any) bool
- type Backup
- type DeleteParam
- type FirstParam
- type ListData
- type ListParamBase
- type Model
- func (m *Model) Code(n int, field string) (string, error)
- func (m *Model) Copy(param any) *Model
- func (m *Model) Delete(id any) *Model
- func (m *Model) FindChildren(pid any, idName, pidName, childrenName, order string) *Model
- func (m *Model) FindChildrenID(ids *[]int32, pidName string) *Model
- func (m *Model) List(data *ListData) *Model
- func (m *Model) NotSame(sames *[]Same) *Model
- func (m *Model) Save() *Model
- func (m *Model) SetModel(db *gorm.DB) *Model
- func (m *Model) SetPk(pk int32) *Model
- func (m *Model) SetPkName(pkName string) *Model
- func (m *Model) Update(field string, value any, containsas []string) *Model
- func (m *Model) Where(data []Where) *Model
- type ModelChildren
- type ModelCreatedAt
- type ModelDeleteAt
- type ModelHasChildren
- type ModelID
- type ModelSort
- type ModelState
- type ModelUpdatedAt
- type Same
- type ShardingMeta
- type ShardingService
- type Time
- type UpdateParam
- type Where
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeleteParam ¶
type DeleteParam struct {
IDS []int32 `json:"id" validate:"required:主键值必须"`
}
type FirstParam ¶
type FirstParam struct {
ID int32 `form:"id" validate:"required:主键值必须"`
}
type ListParamBase ¶
type ModelChildren ¶ added in v1.0.4
type ModelCreatedAt ¶ added in v1.0.4
type ModelCreatedAt struct {
CreatedAt Time `gorm:"column:created_at;type:datetime(3);autoCreateTime:milli;comment:创建时间" json:"created_at"`
}
type ModelDeleteAt ¶ added in v1.0.4
type ModelDeleteAt struct {
DeleteAt Time `gorm:"column:delete_at;type:datetime(3);comment:删除时间" json:"delete_at"`
}
type ModelHasChildren ¶ added in v1.0.4
type ModelHasChildren struct {
HasChildren bool `gorm:"-:all;default:false" json:"hasChildren"`
}
type ModelID ¶ added in v1.0.4
type ModelID struct {
ID int32 `gorm:"column:id;primaryKey;autoIncrement;comment:ID" json:"id"`
}
type ModelSort ¶ added in v1.0.4
type ModelSort struct {
Sort int32 `gorm:"column:sort;type:bigint(11);default:100;comment:排序" json:"sort"`
}
type ModelState ¶ added in v1.0.4
type ModelState struct {
State int32 `gorm:"column:state;type:tinyint(1);default:1;comment:状态:1-开启,2-关闭" json:"state"`
}
type ModelUpdatedAt ¶ added in v1.0.4
type ModelUpdatedAt struct {
UpdatedAt Time `gorm:"column:updated_at;type:datetime(3);autoUpdateTime:milli;comment:更新时间" json:"updated_at"`
}
type ShardingMeta ¶
type ShardingMeta struct {
ID int32 `gorm:"primaryKey;autoIncrement"` // 自增主键
BaseTable string `gorm:"type:varchar(50);not null;index"` // 基础表名(如 access_log)
ActualTable string `gorm:"type:varchar(50);not null;unique"` // 实际分表名(如 access_log_1)
Num int64 `gorm:"not null"` // 分表序号(1、2、3...)
CreatedAt time.Time `gorm:"type:datetime;"` // 分表创建时间
}
ShardingMeta 分表元数据模型:记录基础表对应的所有分表
func (*ShardingMeta) TableName ¶
func (m *ShardingMeta) TableName() string
type ShardingService ¶
type ShardingService struct {
MaxNum int64
Table string
Num int64
Error error
// contains filtered or unexported fields
}
func NewShardingService ¶
func NewShardingService(gormDB *gorm.DB, baseName string, maxNum int64) *ShardingService
func (*ShardingService) GetTable ¶
func (s *ShardingService) GetTable(model any) *ShardingService
func (*ShardingService) SetTable ¶
func (s *ShardingService) SetTable(model any) *ShardingService
type UpdateParam ¶
type UpdateParam struct {
ID int32 `json:"id" validate:"required:主键值必须"`
Field string `json:"field" validate:"required:字段名必须"`
Value any `json:"value"`
}
更新参数
Click to show internal directories.
Click to hide internal directories.