feat: add disable option for storage (close #1476)

This commit is contained in:
Noah Hsu
2022-08-11 21:08:50 +08:00
parent af884010d1
commit 74f1154e5e
4 changed files with 101 additions and 0 deletions

View File

@ -70,6 +70,34 @@ func DeleteStorage(c *gin.Context) {
common.SuccessResp(c)
}
func DisableStorage(c *gin.Context) {
idStr := c.Query("id")
id, err := strconv.Atoi(idStr)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
if err := operations.DisableStorage(c, uint(id)); err != nil {
common.ErrorResp(c, err, 500, true)
return
}
common.SuccessResp(c)
}
func EnableStorage(c *gin.Context) {
idStr := c.Query("id")
id, err := strconv.Atoi(idStr)
if err != nil {
common.ErrorResp(c, err, 400)
return
}
if err := operations.EnableStorage(c, uint(id)); err != nil {
common.ErrorResp(c, err, 500, true)
return
}
common.SuccessResp(c)
}
func GetStorage(c *gin.Context) {
idStr := c.Query("id")
id, err := strconv.Atoi(idStr)

View File

@ -61,6 +61,8 @@ func admin(g *gin.RouterGroup) {
storage.POST("/create", handles.CreateStorage)
storage.POST("/update", handles.UpdateStorage)
storage.POST("/delete", handles.DeleteStorage)
storage.POST("/enable", handles.EnableStorage)
storage.POST("/disable", handles.DisableStorage)
driver := g.Group("/driver")
driver.GET("/list", handles.ListDriverItems)