feat: driver manage api
This commit is contained in:
26
server/controllers/driver.go
Normal file
26
server/controllers/driver.go
Normal file
@ -0,0 +1,26 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/internal/operations"
|
||||
"github.com/alist-org/alist/v3/server/common"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ListDriverItems(c *gin.Context) {
|
||||
common.SuccessResp(c, operations.GetDriverItemsMap())
|
||||
}
|
||||
|
||||
func ListDriverNames(c *gin.Context) {
|
||||
common.SuccessResp(c, operations.GetDriverNames())
|
||||
}
|
||||
|
||||
func GetDriverItems(c *gin.Context) {
|
||||
driverName := c.Query("driver")
|
||||
itemsMap := operations.GetDriverItemsMap()
|
||||
items, ok := itemsMap[driverName]
|
||||
if !ok {
|
||||
common.ErrorStrResp(c, "driver not found", 404)
|
||||
return
|
||||
}
|
||||
common.SuccessResp(nil, items)
|
||||
}
|
@ -36,6 +36,11 @@ func Init(r *gin.Engine) {
|
||||
account.POST("/create", controllers.CreateAccount)
|
||||
account.POST("/update", controllers.UpdateAccount)
|
||||
account.POST("/delete", controllers.DeleteAccount)
|
||||
|
||||
driver := admin.Group("/driver")
|
||||
driver.GET("/list", controllers.ListDriverItems)
|
||||
driver.GET("/names", controllers.ListDriverNames)
|
||||
driver.GET("/items", controllers.GetDriverItems)
|
||||
}
|
||||
|
||||
func Cors(r *gin.Engine) {
|
||||
|
Reference in New Issue
Block a user