mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-24 06:14:04 +08:00
feat: user and meta get api
This commit is contained in:
parent
b399c924b7
commit
53fd09814a
@ -95,3 +95,18 @@ func DeleteMeta(c *gin.Context) {
|
||||
}
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
func GetMeta(c *gin.Context) {
|
||||
idStr := c.Query("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
meta, err := db.GetMetaById(uint(id))
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
return
|
||||
}
|
||||
common.SuccessResp(c, meta)
|
||||
}
|
||||
|
@ -81,3 +81,18 @@ func DeleteUser(c *gin.Context) {
|
||||
}
|
||||
common.SuccessResp(c)
|
||||
}
|
||||
|
||||
func GetUser(c *gin.Context) {
|
||||
idStr := c.Query("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 400)
|
||||
return
|
||||
}
|
||||
user, err := db.GetUserById(uint(id))
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500, true)
|
||||
return
|
||||
}
|
||||
common.SuccessResp(c, user)
|
||||
}
|
||||
|
@ -36,12 +36,14 @@ func Init(r *gin.Engine) {
|
||||
func admin(g *gin.RouterGroup) {
|
||||
meta := g.Group("/meta")
|
||||
meta.GET("/list", handles.ListMetas)
|
||||
meta.GET("/get", handles.GetMeta)
|
||||
meta.POST("/create", handles.CreateMeta)
|
||||
meta.POST("/update", handles.UpdateMeta)
|
||||
meta.POST("/delete", handles.DeleteMeta)
|
||||
|
||||
user := g.Group("/user")
|
||||
user.GET("/list", handles.ListUsers)
|
||||
user.GET("/get", handles.GetUser)
|
||||
user.POST("/create", handles.CreateUser)
|
||||
user.POST("/update", handles.UpdateUser)
|
||||
user.POST("/delete", handles.DeleteUser)
|
||||
|
Loading…
x
Reference in New Issue
Block a user