@@ -1 +1,41 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"nixcn-cms/data"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Full(c *gin.Context) {
|
||||||
|
userIdOrig, ok := c.Get("user_id")
|
||||||
|
if !ok {
|
||||||
|
c.JSON(403, gin.H{"status": "userid error"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
userId, err := uuid.Parse(userIdOrig.(string))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(500, gin.H{"status": "failed to parse uuid"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
userData := new(data.User)
|
||||||
|
user, err := userData.GetByUserId(userId)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(404, gin.H{"status": "user not found"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.PermissionLevel < 50 {
|
||||||
|
c.JSON(403, gin.H{"status": "permission denied"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := userData.GetFullTable()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(500, gin.H{"status": "database error"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(200, gin.H{"user_table": data})
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ func Handler(r *gin.RouterGroup) {
|
|||||||
r.PATCH("/update", Update)
|
r.PATCH("/update", Update)
|
||||||
r.GET("/list", List)
|
r.GET("/list", List)
|
||||||
r.GET("/query", Query)
|
r.GET("/query", Query)
|
||||||
|
r.POST("/full", Full)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user