single_sign.go 679 B

123456789101112131415161718192021222324252627
  1. package utils
  2. import (
  3. "fmt"
  4. "git.getensh.com/common/gopkgs/cache"
  5. "property-system-gateway/errors"
  6. )
  7. const SingleSignKeyPrefix = "single_sign_"
  8. func GetSingleFlag(byCompany bool, cid, gardenId, uid int64) string {
  9. return fmt.Sprintf("%v-%v-%v-%v\n", byCompany, cid, gardenId, uid)
  10. }
  11. func SetSingleSignTime(flag string, timestamp int64) error {
  12. key := SingleSignKeyPrefix + fmt.Sprintf("%s", flag)
  13. _, err := cache.Redis().Set(key, fmt.Sprintf("%d", timestamp))
  14. if err != nil {
  15. return errors.RedisError
  16. }
  17. return nil
  18. }
  19. func GetSingleSignTime(flag string) string {
  20. key := SingleSignKeyPrefix + fmt.Sprintf("%s", flag)
  21. str, _ := cache.Redis().Get(key)
  22. return str
  23. }