Açıklama Yok
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_role.go 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_role", "配置角色表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("role_id", 128).NotNull().Comment("角色ID").End().
  11. String("name", 128).NotNull().Default("''").Comment("角色名称").End().
  12. String("description", 256).NotNull().Default("''").Comment("角色描述").End().
  13. String("creator", 32).NotNull().Comment("创建人").End().
  14. DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
  15. tb.AddIndex("idx_role_id", "role_id")
  16. tb.AddIndex("idx_name", "name")
  17. r.RegisterTable(tb.Build())
  18. })
  19. }
  20. type Role struct {
  21. RoleID string `gorm:"column:role_id;type:varchar(128);not null;primaryKey;comment:角色ID"`
  22. Name string `gorm:"column:name;type:varchar(128);not null;default:'';comment:角色名称"`
  23. Description string `gorm:"column:description;type:varchar(256);not null;default:'';comment:角色描述"`
  24. Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"`
  25. CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"`
  26. }
  27. type RoleDB struct {
  28. ID string `db:"id" json:"id"`
  29. RoleID string `db:"role_id" json:"roleID"`
  30. Name string `db:"name" json:"name"`
  31. Description string `db:"description" json:"description"`
  32. Creator string `db:"creator" json:"creator"`
  33. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  34. }
  35. func (Role) TableName() string {
  36. return "config_role"
  37. }