package user import ( "database/sql" "recook/internal/libs/phonedata" "github.com/golangkit/formatime" ) type Information struct { ID uint `gorm:"column:id;primary_key" json:"id"` AncestorID uint `gorm:"column:ancestor_id" json:"-"` Nickname string `gorm:"column:nickname" json:"nickname"` HeadImgUrl string `gorm:"column:head_img_url" json:"headImgUrl"` WxUnionId string `gorm:"column:wx_union_id" json:"wxUnionId"` WxAppOpenId string `gorm:"column:wx_app_open_id" json:"-"` WxMiniOpenId string `gorm:"wx_mini_open_id" json:"-"` WxGzhOpenId string `gorm:"wx_gzh_open_id" json:"-"` Mobile string `gorm:"column:mobile" json:"mobile"` Gender uint `gorm:"column:gender;default:0" json:"gender"` Birthday formatime.Second `gorm:"column:birthday" json:"birthday"` InvitationNo string `gorm:"column:invitation_no" json:"invitationNo"` //Role uint `gorm:"column:role" json:"role"` Type uint `gorm:"column:type" json:"type"` CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"` UpdatedAt formatime.Second `gorm:"column:updated_at" json:"-"` Address string `gorm:"column:address;size:300" json:"addr"` Phone string `gorm:"column:phone;size:20" json:"phone"` WechatNo string `gorm:"column:wechat_no;size:30" json:"wechatNo"` RemarkName string `gorm:"column:remark_name;size:32" json:"remarkName"` IntroCode string `gorm:"column:intro_code" json:"introCode" ` UpgradeCode string `gorm:"column:upgrade_code" json:"upgradeCode" ` Audit int8 `gorm:"column:audit" json:"audit"` // 用户审核状态, 1 待审核, 2 通过, 3 拒绝了 RealName string `gorm:"column:real_name" json:"realName"` IDCard string `gorm:"column:id_card" json:"idCard"` RealInfoStatus int64 `gorm:"column:realinfo_status" json:"realInfoStatus"` SeqNo string `gorm:"column:seq_no" json:"seqNo"` AssessBegin formatime.Second `gorm:"column:assess_begin" json:"assessBegin"` AssessEnd formatime.Date `gorm:"column:assess_end" json:"assessEnd"` Identifier string `gorm:"column:identifier" json:"identifier"` //用户编号 LevelId uint `json:"levelId"` Secret uint `json:"secret"` Province string `json:"province"` City string `json:"city"` Level int `json:"level"` ParentID uint `json:"parent_id"` UpgradeTime1 formatime.Second `json:"upgrade_time1"` UpgradeTime2 formatime.Second `json:"upgrade_time2"` RootID uint `json:"root_id"` LoginApp bool `json:"login_app"` IsOffline bool `json:"is_offline"` VipUpgradeStart sql.NullTime `json:"vip_upgrade_start"` VipUpgradeEnd sql.NullTime `json:"vip_upgrade_end"` OldParentID int `json:"old_parent_id"` OldRootID int `json:"old_root_id"` OldLevel int `json:"old_level"` } const ( AuditWait = 1 AuditPass = 2 AuditDecline = 3 // 结果1:验证一致,计费;2:验证不一致,计费;3:异常情况,不计费 RealInfoErr = 1 RealInfoPass = 2 ) // TableName sets the insert table name for this struct type func (i *Information) TableName() string { return "recook_user_info" } func (i *Information) BeforeCreate() (err error) { if len(i.Mobile) == 11 { pr, e := phonedata.Find(i.Mobile) if e != nil { return } i.Province = pr.Province i.City = pr.City } return }