Documentation ¶
Index ¶
- Constants
- Variables
- func AreStringEquals(str1, str2 *string) bool
- func AssertNotEmptyString(str *string)
- func Base64(input string) string
- func GenToken() string
- func GenUid() int64
- func GenVerifyCode() string
- func GetCharCount(input string) (count int)
- func GetTimeMillis() int64
- func IsEmptyString(str *string) bool
- func IsLegalFreeStringWithLength(input string, length int) bool
- func IsLegalRestrictedStringWithLength(input string, length int) bool
- func IsValidPhone(phone string) bool
- func Secret2Password(username, secret string) string
- func Sha1(input string) string
- func UrlEncode(input string) string
- type ApiError
- type AuthUserInfo
Constants ¶
View Source
const ( GENDER_UNKNOWN = 0 GENDER_MALE = 1 << iota GENDER_FEMALE )
View Source
const ( SNS_PLATFORM_WEIXIN = iota SNS_PLATFORM_WEIBO SNS_PLATFORM_QQ )
View Source
const ( // system level ERROR_CODE_SYSTEM_ERROR = 10001 ERROR_CODE_PARAM_ERROR = 10002 // users ERROR_CODE_USERS_USER_NOT_EXISTS = 20101 ERROR_CODE_USERS_PHONE_REGISTERED = 20102 ERROR_CODE_USERS_INVALID_NICKNAME = 20103 ERROR_CODE_USERS_INVALID_GENDER_VALUE = 20104 ERROR_CODE_USERS_INVALID_AVATAR = 20105 // verify code ERROR_CODE_VERIFY_CODE_MISMATCH = 20201 // tokens ERROR_CODE_TOKENS_PASSWORD_MISMATCH = 20301 ERROR_CODE_TOKENS_INVALID_TOKEN = 20302 // auth ERROR_CODE_AUTH_WEIXIN_AUTH_FAIL = 20401 ERROR_CODE_AUTH_WEIBO_AUTH_FAIL = 20402 ERROR_CODE_AUTH_QQ_AUTH_FAIL = 20403 // basic auth ERROR_CODE_BASIC_AUTH_FAIL = 20801 )
error code definition, three part, [level][function][number] [level], 1: system level, 2: service level [function] 01: tokens; 02: verify code; ... [number] detailed error number
View Source
const USER_AVATAR_MEX_LEN int = 255
View Source
const USER_MIN_UID int64 = 1000000000
View Source
const USER_NICKNAME_MEX_LEN int = 20
View Source
const VERIFY_CODE_EXPIRE_IN_SECONDS int64 = 10 * 60
View Source
const VERIFY_CODE_LEN int = 6
Variables ¶
View Source
var ( ERROR_MESSAGES = map[int]string{ ERROR_CODE_SYSTEM_ERROR: "Oops, System error", ERROR_CODE_PARAM_ERROR: "Param error, see doc for more info", ERROR_CODE_USERS_USER_NOT_EXISTS: "Queried user not exists", ERROR_CODE_USERS_PHONE_REGISTERED: "Phone has registered", ERROR_CODE_USERS_INVALID_NICKNAME: "Nickname invalid", ERROR_CODE_USERS_INVALID_GENDER_VALUE: "Invalid gender value, should only be 1 or 2", ERROR_CODE_USERS_INVALID_AVATAR: "Avatar url invalid", ERROR_CODE_VERIFY_CODE_MISMATCH: "Verify code mismatch", ERROR_CODE_TOKENS_PASSWORD_MISMATCH: "Password mismatch", ERROR_CODE_TOKENS_INVALID_TOKEN: "Invalid token", ERROR_CODE_AUTH_WEIXIN_AUTH_FAIL: "Weixin auth fail", ERROR_CODE_AUTH_WEIBO_AUTH_FAIL: "Weibo auth fail", ERROR_CODE_AUTH_QQ_AUTH_FAIL: "QQ auth fail", ERROR_CODE_BASIC_AUTH_FAIL: "Basic auth fail", } )
Functions ¶
func AreStringEquals ¶
func AssertNotEmptyString ¶
func AssertNotEmptyString(str *string)
func GenVerifyCode ¶
func GenVerifyCode() string
func GetCharCount ¶
func GetTimeMillis ¶
func GetTimeMillis() int64
func IsEmptyString ¶
func IsValidPhone ¶
func Secret2Password ¶
Types ¶
type ApiError ¶
type AuthUserInfo ¶
func AuthWithQQ ¶
func AuthWithQQ(qq_openid, qq_token, qq_oauth_consumer_key string) (*AuthUserInfo, int)
func AuthWithWeiBo ¶
func AuthWithWeiBo(wb_token string) (*AuthUserInfo, int)
func AuthWithWeiXin ¶
func AuthWithWeiXin(wx_openid, wx_token string) (*AuthUserInfo, int)
Click to show internal directories.
Click to hide internal directories.