Няма описание
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_project.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_project", "配置用户项目关联表").
  9. ID("id", 128).NotNull().Comment("主键").End().
  10. String("project_id", 128).NotNull().Comment("项目ID").End().
  11. String("user_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_project_id", "project_id")
  15. tb.AddIndex("idx_user_id", "user_id")
  16. r.RegisterTable(tb.Build())
  17. })
  18. }
  19. type UserProject struct {
  20. ProjectID string `gorm:"column:project_id;type:varchar(128);not null;primaryKey;comment:项目ID"`
  21. UserID string `gorm:"column:user_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 UserProjectDB struct {
  26. ID string `db:"id" json:"id"`
  27. ProjectID string `db:"project_id" json:"projectID"`
  28. UserID string `db:"user_id" json:"userID"`
  29. Creator string `db:"creator" json:"creator"`
  30. CreatedAt time.Time `db:"created_at" json:"createdAt"`
  31. }
  32. func (UserProject) TableName() string {
  33. return "config_user_project"
  34. }