merchant.join.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package shanghu
  2. import (
  3. orm "duoduo/database"
  4. "time"
  5. )
  6. type MerchantJoin struct {
  7. ID int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
  8. Type int `gorm:"column:type;type:int(11)" json:"type"` // 1-商家 2-销售 3-创业人员
  9. Message string `gorm:"column:message;type:varchar(255)" json:"message"` //
  10. Wx string `gorm:"column:wx;type:varchar(255)" json:"wx"` // 联系方式
  11. OpenID string `gorm:"column:open_id;type:varchar(255)" json:"open_id"` //
  12. CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
  13. UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
  14. CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
  15. UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
  16. DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
  17. }
  18. func (m *MerchantJoin) TableName() string {
  19. return "merchant_join"
  20. }
  21. func (m *MerchantJoin) Create() (MerchantJoin, error) {
  22. var doc MerchantJoin
  23. var err error
  24. doc = *m
  25. err = orm.ShMysql.Table(m.TableName()).Create(&doc).Error
  26. if err != nil {
  27. return doc, err
  28. }
  29. return doc, nil
  30. }
  31. func (m *MerchantJoin) GetNum() int {
  32. var count int
  33. tableCount := orm.ShMysql.Table(m.TableName()).Where("open_id = ? ", m.OpenID)
  34. tableCount.Count(&count)
  35. return count
  36. }