| 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_project", "配置用户项目关联表").
- ID("id", 128).NotNull().Comment("主键").End().
- String("project_id", 128).NotNull().Comment("项目ID").End().
- String("user_id", 128).NotNull().Comment("用户ID").End().
- String("creator", 32).NotNull().Comment("创建人").End().
- DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End()
-
- tb.AddIndex("idx_project_id", "project_id")
- tb.AddIndex("idx_user_id", "user_id")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type UserProject struct {
- ProjectID string `gorm:"column:project_id;type:varchar(128);not null;primaryKey;comment:项目ID"`
- UserID string `gorm:"column:user_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 UserProjectDB struct {
- ID string `db:"id"`
- ProjectID string `db:"project_id"`
- UserID string `db:"user_id"`
- Creator string `db:"creator"`
- CreatedAt time.Time `db:"created_at"`
- }
-
- func (UserProject) TableName() string {
- return "config_user_project"
- }
|