finish work

This commit is contained in:
2025-04-18 17:40:44 +08:00
parent cc8e04a41f
commit 16e779a450
25 changed files with 483 additions and 651 deletions
+43
View File
@@ -0,0 +1,43 @@
package network
import (
"encoding/json"
"floares/lib/http/network"
"floares/lib/model"
"github.com/gin-gonic/gin"
"net/http"
)
func Create(c *gin.Context) {
var req model.CreateNetworkRequest
json.NewDecoder(c.Request.Body).Decode(&req)
err := network.Create(req)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": http.StatusBadRequest,
"error": err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"error": "",
})
}
func Delete(c *gin.Context) {
var req model.CreateNetworkRequest
json.NewDecoder(c.Request.Body).Decode(&req)
err := network.Delete(req.Name)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": http.StatusBadRequest,
"err": err.Error(),
})
return
}
c.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"err": "",
})
}