Nessuna descrizione
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config_user_role.go 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package tables
  2. import (
  3. "time"
  4. "git.x2erp.com/qdy/go-db/sqldef"
  5. )
  6. func init() {
  7. sqldef.AddRegistration(func(r *sqldef.Registry) {
  8. tb := sqldef.NewTable("config_user_role", "配置用户角色关联表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("user_id", 128).NotNull().Comment("用户ID").End().
  11. String("role_id", 128).NotNull().Comment("角色ID").End().
  12. String("creator", 32).NotNull().Comment("创建人").End().
  13. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  14. tb.AddIndex("idx_user_id", "user_id")
  15. tb.AddIndex("idx_role_id", "role_id")
  16. r.RegisterTable(tb.Build())
  17. })
  18. }
  19. type UserRole struct {
  20. UserID string `gorm:"column:user_id;type:varchar(128);not null;primaryKey;comment:用户ID"`
  21. RoleID string `gorm:"column:role_id;type:varchar(128);not null;primaryKey;comment:角色ID"`
  22. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  23. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  24. }
  25. type UserRoleDB struct {
  26. ID string `db:"id" json:"id"`
  27. UserID string `db:"user_id" json:"userID"`
  28. RoleID string `db:"role_id" json:"roleID"`
  29. Creator string `db:"creator" json:"creator"`
  30. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  31. }
  32. func (UserRole) TableName() string {
  33. return "config_user_role"
  34. }