package models import ( "context" "time" "github.com/go-pg/pg/v10" ) // 公司信息 type Company struct { tableName struct{} `pg:"company"` // 唯一标识 Id int64 `pg:",pk"` // 名称 Name string //简称 Abbreviation string // 手机号码 Phone string // 公司logo Logo string // 备注 Remarks string // 总后台的公司id AdminCompanyId int // 状态 1正常 2禁用 //Status int8 //是否开启机会模块,是否有效【1:有效】【2:无效】 Enable int8 // 创建时间 CreateAt time.Time // 更新时间 UpdateAt time.Time // 删除时间 DeleteAt time.Time } var _ pg.BeforeUpdateHook = (*Company)(nil) func (c *Company) BeforeUpdate(ctx context.Context) (context.Context, error) { c.UpdateAt = time.Now() return ctx, nil } var _ pg.BeforeInsertHook = (*Company)(nil) func (c *Company) BeforeInsert(ctx context.Context) (context.Context, error) { c.CreateAt = time.Now() c.UpdateAt = time.Now() return ctx, nil }