util

package
v0.0.0-...-411a92d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2019 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToDecimal

func AnyToDecimal(num string, n int) int64

任意进制转10进制

func Crc32IEEE

func Crc32IEEE(str string) uint32

func DecimalToAny

func DecimalToAny(num int64, n int) string

10进制转任意进制

func EncodeMD5

func EncodeMD5(value string) string

func FileExists

func FileExists(path string) bool

判断文件是否存在

func FirstDayOfISOWeek

func FirstDayOfISOWeek(year int, week int, timezone *time.Location) time.Time

得到每周第一天的日期

func GenerateToken

func GenerateToken(username, password string) (string, error)

func GetMobileOfToken

func GetMobileOfToken(token string) string

func GetPage

func GetPage(c *gin.Context) int

func GetUniversalCode

func GetUniversalCode() string

得到万能验证码

func HttpGet

func HttpGet(getUrl string) (string, error)

func HttpPost

func HttpPost(postUrl string, postData map[string]string) (string, error)

func HttpPost2

func HttpPost2(my_url string, postData string) (string, error)

HTTP 包中POST 方法

func RandKey

func RandKey() int

6位随机数

func RandMobileCode

func RandMobileCode() int

随机验证码

func RandPassword

func RandPassword() int

8位随机密码

func Round

func Round(f float64, n int) float64

func ToPostDate

func ToPostDate(model interface{}) (map[string]string, error)

结构体所有字段必须为string类型,model不能是指针类型

Types

type AesEncrypt

type AesEncrypt struct {
}

func (*AesEncrypt) AesDecrypt

func (this *AesEncrypt) AesDecrypt(str string) string

解密字符串

func (*AesEncrypt) AesEncrypt

func (this *AesEncrypt) AesEncrypt(strMesg string) string

加密字符串

type ApiCode

type ApiCode struct {
	Code int `json:"code"`
}

获取api返回码

type ApiStudent

type ApiStudent struct {
	Code int            `json:"code"`
	Data ApiStudentData `json:"data"`
}

token换取用户信息josn

func CreateStudentFromUserCenter

func CreateStudentFromUserCenter(registerStudent RegisterStudent) (ApiStudent, error)

func GetApiStudentByUnionId

func GetApiStudentByUnionId(unionId string) (ApiStudent, error)

func GetStudentFromUserCenter

func GetStudentFromUserCenter(token string) (ApiStudent, error)

type ApiStudentData

type ApiStudentData struct {
	StudentId int64  `json:"studentId"`
	UserId    int64  `json:"userId"`
	Mobile    string `json:"mobile"`
	UserName  string `json:"username"`
	Token     string `json:"token"`
}

type ApiStudentSlice

type ApiStudentSlice struct {
	Code int              `json:"code"`
	Data []ApiStudentData `json:"data"`
}

type ApiToken

type ApiToken struct {
	Code int       `json:"code"`
	Data TokenData `json:"data"`
}

获取token返回信息

func GetApiTokenByStudentId

func GetApiTokenByStudentId(studentId int64) (ApiToken, error)

通过studentId 获取用户中心token

type Claims

type Claims struct {
	Username string `json:"username"`
	Password string `json:"password"`
	jwt.StandardClaims
}

func ParseToken

func ParseToken(token string) (*Claims, error)

type ConfigData

type ConfigData struct {
	User []string `json:"user"`
	Sms  []string `json:"sms"`
}

type ConfigInfo

type ConfigInfo struct {
	Code int        `json:"code"`
	Data ConfigData `json:"data"`
}

获取配置json

func GetUserCenterConfig

func GetUserCenterConfig(forceUpdate bool) ConfigInfo

获取配置中心的配置

type RegisterStudent

type RegisterStudent struct {
	UnionId      string `json:"unionid"`
	Nickname     string `json:"nickname"`
	HeadPhoto    string `json:"headPhoto"`
	Sex          string `json:"sex"`
	Province     string `json:"province"`
	City         string `json:"city"`
	Country      string `json:"country"`
	ClientSource string `json:"clientSource"`
	Version      string `json:"version"`
	Channel      string `json:"channel"`
}

用户中心注册实体

type TokenData

type TokenData struct {
	Token string `json:"token"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL