79 lines
1.4 KiB
Go
79 lines
1.4 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 CreateBundle(c *gin.Context) {
|
||
|
var req bundle.BundleProfile
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.CreateBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|
||
|
|
||
|
func UpdateBundle(c *gin.Context) {
|
||
|
var req bundle.BundleProfile
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.UpdateBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
|
||
|
}
|
||
|
|
||
|
func DeleteBundle(c *gin.Context) {
|
||
|
var req bundle.DelBundleRequest
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.DeleteBundle(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|
||
|
|
||
|
func BundleList(c *gin.Context) {
|
||
|
var req bundle.BundleListRequest
|
||
|
|
||
|
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
res, err := service.BundleProvider.BundleList(context.Background(), &req)
|
||
|
if err != nil {
|
||
|
service.Error(c, err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
service.Success(c, res)
|
||
|
}
|