first commit
This commit is contained in:
21
controllers/base_utils.go
Normal file
21
controllers/base_utils.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func getCode(ctx *gin.Context) (string, error) {
|
||||
userIDInterface, exists := ctx.Get("code")
|
||||
if !exists {
|
||||
return "", errors.New("用户ID不存在")
|
||||
}
|
||||
|
||||
code, ok := userIDInterface.(string)
|
||||
if !ok {
|
||||
return "", errors.New("用户ID类型错误")
|
||||
}
|
||||
|
||||
return code, nil
|
||||
}
|
||||
Reference in New Issue
Block a user