You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
393 B
24 lines
393 B
5 years ago
|
package common
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"encoding/hex"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
// @Title md5签名
|
||
|
// @Param src string true "签名元数据"
|
||
|
func Md5(src string) string {
|
||
|
toolMd5 := md5.New()
|
||
|
toolMd5.Write([]byte(src))
|
||
|
return hex.EncodeToString(toolMd5.Sum(nil))
|
||
|
}
|
||
|
|
||
|
func GetUserId(c *gin.Context) uint {
|
||
|
uid, flag := c.Get("userId")
|
||
|
if !flag {
|
||
|
return 0
|
||
|
}
|
||
|
return uid.(uint)
|
||
|
}
|