| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("config_role", "配置角色表").
- ID("id", 128).NotNull().Comment("主键").End().
- String("role_id", 128).NotNull().Comment("角色ID").End().
- String("name", 128).NotNull().Default("''").Comment("角色名称").End().
- String("description", 256).NotNull().Default("''").Comment("角色描述").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
-
- tb.AddIndex("idx_role_id", "role_id")
- tb.AddIndex("idx_name", "name")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type Role struct {
- RoleID string `gorm:"column:role_id;type:varchar(128);not null;primaryKey;comment:角色ID"`
- Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:角色名称"`
- Description string `gorm:"column:description;type:varchar(256);not null;default:'';comment:角色描述"`
- Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
- CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
- }
-
- type RoleDB struct {
- ID string `db:"id" json:"id"`
- RoleID string `db:"role_id" json:"roleID"`
- Name string `db:"name" json:"name"`
- Description string `db:"description" json:"description"`
- Creator string `db:"creator" json:"creator"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- }
-
- func (Role) TableName() string {
- return "config_role"
- }
|