|
@@ -0,0 +1,45 @@
|
|
|
+package shanghu
|
|
|
+
|
|
|
+import (
|
|
|
+ orm "duoduo/database"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type MerchantJoin struct {
|
|
|
+ ID int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"` // 主键
|
|
|
+ Type int `gorm:"column:type;type:int(11)" json:"type"` // 1-商家 2-销售 3-创业人员
|
|
|
+ Message string `gorm:"column:message;type:varchar(255)" json:"message"` //
|
|
|
+ Wx string `gorm:"column:wx;type:varchar(255)" json:"wx"` // 联系方式
|
|
|
+ OpenID string `gorm:"column:open_id;type:varchar(255)" json:"open_id"` //
|
|
|
+ CreateBy int64 `gorm:"column:create_by;type:bigint(20)" json:"create_by"` // 创建者
|
|
|
+ UpdateBy int64 `gorm:"column:update_by;type:bigint(20)" json:"update_by"` // 更新者
|
|
|
+ CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"` // 创建时间
|
|
|
+ UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"` // 最后更新时间
|
|
|
+ DeletedAt time.Time `gorm:"column:deleted_at;type:datetime(3);default:null" json:"deleted_at"` // 删除时间
|
|
|
+}
|
|
|
+
|
|
|
+func (m *MerchantJoin) TableName() string {
|
|
|
+ return "merchant_join"
|
|
|
+}
|
|
|
+
|
|
|
+func (m *MerchantJoin) Create() (MerchantJoin, error) {
|
|
|
+ var doc MerchantJoin
|
|
|
+ var err error
|
|
|
+
|
|
|
+ doc = *m
|
|
|
+ err = orm.ShMysql.Table(m.TableName()).Create(&doc).Error
|
|
|
+ if err != nil {
|
|
|
+ return doc, err
|
|
|
+ }
|
|
|
+
|
|
|
+ return doc, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (m *MerchantJoin) GetNum() int {
|
|
|
+ var count int
|
|
|
+
|
|
|
+ tableCount := orm.ShMysql.Table(m.TableName()).Where("open_id = ? ", m.OpenID)
|
|
|
+ tableCount.Count(&count)
|
|
|
+ return count
|
|
|
+
|
|
|
+}
|