First merge from develop to main (WIP) #7

Merged
sugar merged 199 commits from develop into main 2026-01-27 17:47:07 +00:00
Showing only changes of commit 0a861fa674 - Show all commits

View File

@@ -165,18 +165,25 @@ func (self *User) FastListUsers(limit, offset int64) (*[]UserSearchDoc, error) {
} }
func (self *User) GenCheckinCode(eventId uuid.UUID) (*string, error) { func (self *User) GenCheckinCode(eventId uuid.UUID) (*string, error) {
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
randomNumber := rng.Intn(900000) + 100000
randNumString := fmt.Sprintf("%06d", randomNumber)
ctx := context.Background() ctx := context.Background()
ttl := viper.GetDuration("ttl.checkin_code_ttl") ttl := viper.GetDuration("ttl.checkin_code_ttl")
Redis.Set( rng := rand.New(rand.NewSource(time.Now().UnixNano()))
ctx,
"checkin_code:"+randNumString, for {
self.UserId.String()+":"+eventId.String(), code := fmt.Sprintf("%06d", rng.Intn(900000)+100000)
ttl, ok, err := Redis.SetNX(
) ctx,
return &randNumString, nil "checkin_code:"+code,
"user_id:"+self.UserId.String()+":event_id:"+eventId.String(),
ttl,
).Result()
if err != nil {
return nil, err
}
if ok {
return &code, nil
}
}
} }
func (self *User) VerifyCheckinCode(checkinCode string) (*uuid.UUID, error) { func (self *User) VerifyCheckinCode(checkinCode string) (*uuid.UUID, error) {