key_generator.go 820 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package redis
  2. import "fmt"
  3. const (
  4. SmsKeyPrefix = "sms_code:"
  5. PaymentKeyPrefix = "payment:"
  6. LoginTokenPrefix = "login:token:"
  7. CAPAccessTokenKey = "cap:access_token"
  8. )
  9. const (
  10. ValidAreaCode = "areaCode:valid:list"
  11. MerchantKey = "merchant:id"
  12. )
  13. func GenerateSmsKey(mobile string) string {
  14. return fmt.Sprint(SmsKeyPrefix, mobile)
  15. }
  16. func GenerateTokenKey(openId string) string {
  17. return fmt.Sprint(LoginTokenPrefix, openId)
  18. }
  19. func GenerateCAPAccessTokenKey() string {
  20. return fmt.Sprint(CAPAccessTokenKey)
  21. }
  22. func GenerateReportRefreshKey(source string, id int, modifyTime int64) string {
  23. return fmt.Sprintf("%s:%d:%d", source, id, modifyTime)
  24. }
  25. func GeneratePaymentKey(orderNo string) string {
  26. return fmt.Sprint(PaymentKeyPrefix, orderNo)
  27. }
  28. func GenerateMerchantKey() string {
  29. return MerchantKey
  30. }