42 lines
771 B
Go
42 lines
771 B
Go
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})
|
|
}
|