finish work
This commit is contained in:
@@ -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": "",
|
||||
})
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user