修改createBy和updateBy为uint类型
This commit is contained in:
1 parent
0ae41f247c
commit
41b06c806a
7 files changed
+25
-9
No files matched your search
@@ -0,0 +1,6 @@
|
||||
package model
|
||||
|
||||
type ByModel struct {
|
||||
CreateBy uint `gorm:"index;"` // 创建者
|
||||
UpdateBy uint `gorm:"index;"` // 更新者
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ import "gorm.io/gorm/schema"
|
||||
|
||||
type ActiveRecord interface {
|
||||
schema.Tabler
|
||||
SetCreateBy(createBy string)
|
||||
SetUpdateBy(updateBy string)
|
||||
SetCreateBy(createBy uint)
|
||||
SetUpdateBy(updateBy uint)
|
||||
Generate() ActiveRecord
|
||||
GetId() interface{}
|
||||
}
|
||||
@@ -17,6 +17,15 @@ func ExtractClaims(c *gin.Context) jwt.MapClaims {
|
||||
return claims.(jwt.MapClaims)
|
||||
}
|
||||
|
||||
func GetUserIdUint(c *gin.Context) uint {
|
||||
data := ExtractClaims(c)
|
||||
if data["identity"] != nil {
|
||||
return uint((data["identity"]).(float64))
|
||||
}
|
||||
fmt.Println(GetCurrentTimeStr() + " [WARING] " + c.Request.Method + " " + c.Request.URL.Path + " GetUserId 缺少identity")
|
||||
return 0
|
||||
}
|
||||
|
||||
func GetUserId(c *gin.Context) int {
|
||||
data := ExtractClaims(c)
|
||||
if data["identity"] != nil {
|
||||
|
||||
Reference in new issue
Block a user