feat: get storage by id api

refactor/fs
Noah Hsu 2022-07-18 23:02:14 +08:00
parent e08810a12f
commit 184b9d1e6c
3 changed files with 16 additions and 0 deletions

View File

@ -69,3 +69,18 @@ func DeleteStorage(c *gin.Context) {
}
common.SuccessResp(c)
}
func GetStorage(c *gin.Context) {
idStr := c.Query("id")
id, err := strconv.Atoi(idStr)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
storage, err := db.GetStorageById(uint(id))
if err != nil {
common.ErrorResp(c, err, 500, true)
return
}
common.SuccessResp(c, storage)
}

View File

@ -39,6 +39,7 @@ func Init(r *gin.Engine) {
storage := admin.Group("/storage")
storage.GET("/list", handles.ListStorages)
storage.GET("/get", handles.GetStorage)
storage.POST("/create", handles.CreateStorage)
storage.POST("/update", handles.UpdateStorage)
storage.POST("/delete", handles.DeleteStorage)