feat: added modules

This commit is contained in:
Marvin Zhang
2024-06-14 15:42:50 +08:00
parent f1833fed21
commit 0b67fd9ece
626 changed files with 60104 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package controllers
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/gin-gonic/gin"
)
func GetUserFromContext(c *gin.Context) (u interfaces.User) {
value, ok := c.Get(constants.UserContextKey)
if !ok {
return nil
}
u, ok = value.(interfaces.User)
if !ok {
return nil
}
return u
}
func GetUserFromContextV2(c *gin.Context) (u *models.UserV2) {
value, ok := c.Get(constants.UserContextKey)
if !ok {
return nil
}
u, ok = value.(*models.UserV2)
if !ok {
return nil
}
return u
}