80 lines
1.5 KiB
Go
80 lines
1.5 KiB
Go
|
package bundle
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fonchain-fiee/api/bundle"
|
||
|
"fonchain-fiee/pkg/service"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/gin-gonic/gin/binding"
|
||
|
)
|
||
|
|
||
|
func CreateValueAddBundle(c *gin.Context) {
|
||
|
var req bundle.ValueAddBundleProfile
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.CreateValueAddBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|
||
|
|
||
|
func UpdateValueAddBundle(c *gin.Context) {
|
||
|
var req bundle.ValueAddBundleProfile
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.UpdateValueAddBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
|
||
|
}
|
||
|
|
||
|
func DeleteValueAddBundle(c *gin.Context) {
|
||
|
var req bundle.DelValueAddBundleRequest
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.DeleteValueAddBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|
||
|
|
||
|
func ValueAddBundleList(c *gin.Context) {
|
||
|
var req bundle.ValueAddBundleListRequest
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.ValueAddBundleList(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|