//保存一个邀请 func saveRegisterInvite(userId int64, toEmail string, db *goku.MysqlDB) (string, error) { if userId <= int64(0) || toEmail == "" { return "", errors.New("用户id不合法") } invite := new(RegisterInvite) invite.Guid = utils.GeneticKey() invite.UserId = userId invite.ToEmail = toEmail invite.IsRegister = false invite.ExpiredDate = time.Now().AddDate(0, 0, golink.Register_Invite_Expired_Day) invite.IsSend = false invite.FailCount = 0 _, err := db.InsertStruct(invite) return invite.Guid, err }
//获取一个邀请码(非邮件邀请方式,可能是通过qq和微薄发送) func CreateRegisterInviteWithoutEmail(userId int64) (string, error) { if userId <= int64(0) { return "", errors.New("用户id不合法") } var db *goku.MysqlDB = GetDB() defer db.Close() invite := new(RegisterInvite) invite.Guid = utils.GeneticKey() invite.UserId = userId invite.ToEmail = "" invite.IsRegister = false invite.ExpiredDate = time.Now().AddDate(0, 0, golink.Register_Invite_Expired_Day) invite.IsSend = true invite.FailCount = 0 _, err := db.InsertStruct(invite) return invite.Guid, err }