GetVCode 获取短信验证码
(ctx context.Context, smsID, number string)
| 48 | |
| 49 | // GetVCode 获取短信验证码 |
| 50 | func (s *smsCache) GetVCode(ctx context.Context, smsID, number string) (string, error) { |
| 51 | key := getVCodeKey(smsID, number) |
| 52 | vCode, err := s.client.Get(ctx, key).Result() |
| 53 | if err != nil { |
| 54 | if errors.Is(err, redis.Nil) { |
| 55 | return "", nil //键不存在或者过期了 |
| 56 | } |
| 57 | return "", err |
| 58 | } |
| 59 | return vCode, nil |
| 60 | } |
| 61 | |
| 62 | // StoreVCode 存储短信验证码 |
| 63 | func (s *smsCache) StoreVCode(ctx context.Context, smsID string, number string, vCode string) error { |
nothing calls this directly
no test coverage detected