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
+46
View File
@@ -0,0 +1,46 @@
package volume
import (
"encoding/json"
"floares/lib/http/volume"
"floares/lib/model"
"github.com/gin-gonic/gin"
)
func Create(c *gin.Context) {
var req model.CreateVolume
if err := json.NewDecoder(c.Request.Body).Decode(&req); err != nil {
c.JSON(200, gin.H{
"code": 400,
"err": err.Error(),
})
return
}
err := volume.Create(req)
if err != nil {
c.JSON(200, gin.H{
"code": 400,
"err": err.Error(),
})
return
}
c.JSON(200, gin.H{
"code": 200,
"err": "",
})
}
func Delete(c *gin.Context) {
err := volume.Delete(c.Param("id"))
if err != nil {
c.JSON(200, gin.H{
"code": 400,
"err": err.Error(),
})
return
}
c.JSON(200, gin.H{
"code": 200,
"err": "",
})
}
+3
View File
@@ -4,4 +4,7 @@ import "github.com/gin-gonic/gin"
func RegisterRouter(c *gin.RouterGroup) {
c.GET("/", List)
c.POST("/", Create)
c.DELETE("/:id", Delete)
}