| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("config_user_role", "配置用户角色关联表").
- ID("id", 128).NotNull().Comment("主键").End().
- String("user_id", 128).NotNull().Comment("用户ID").End().
- String("role_id", 128).NotNull().Comment("角色ID").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
-
- tb.AddIndex("idx_user_id", "user_id")
- tb.AddIndex("idx_role_id", "role_id")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type UserRole struct {
- UserID string `gorm:"column:user_id;type:varchar(128);not null;primaryKey;comment:用户ID"`
- RoleID string `gorm:"column:role_id;type:varchar(128);not null;primaryKey;comment:角色ID"`
- 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 UserRoleDB struct {
- ID string `db:"id" json:"id"`
- UserID string `db:"user_id" json:"userID"`
- RoleID string `db:"role_id" json:"roleID"`
- Creator string `db:"creator" json:"creator"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- }
-
- func (UserRole) TableName() string {
- return "config_user_role"
- }
|