fonchain-fiee/pkg/service/bundle/valueAddBundle.go

70 lines
1.4 KiB
Go
Raw Normal View History

2025-03-25 08:30:58 +00:00
package bundle
import (
"context"
2025-03-28 01:25:54 +00:00
"fmt"
2025-03-25 08:30:58 +00:00
"fonchain-fiee/api/bundle"
2025-03-28 08:48:23 +00:00
"fonchain-fiee/pkg/model/login"
2025-03-25 08:30:58 +00:00
"fonchain-fiee/pkg/service"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
func CreateValueAddBundle(c *gin.Context) {
2025-03-28 01:25:54 +00:00
var req bundle.CreateValueAddBundleRequest
2025-03-25 08:30:58 +00:00
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
2025-03-28 01:25:54 +00:00
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
res, err := service.BundleProvider.CreateValueAddBundle(context.Background(), &req)
if err != nil {
2025-03-28 01:25:54 +00:00
fmt.Println(err)
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
2025-03-28 01:25:54 +00:00
service.Success1(c, res.Msg, res)
2025-03-25 08:30:58 +00:00
}
2025-03-28 01:25:54 +00:00
func ValueAddBundleList(c *gin.Context) {
var req bundle.ValueAddBundleListRequest
2025-03-25 08:30:58 +00:00
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
2025-03-28 01:25:54 +00:00
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
2025-03-28 08:48:23 +00:00
// 获取 用户信息
userInfo := login.GetUserInfoFromC(c)
req.UserId = int32(userInfo.ID)
//req.UserId = 39
2025-03-28 01:25:54 +00:00
res, err := service.BundleProvider.ValueAddBundleList(context.Background(), &req)
2025-03-25 08:30:58 +00:00
if err != nil {
2025-03-28 01:25:54 +00:00
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
2025-03-28 01:25:54 +00:00
service.Success1(c, res.Msg, res)
2025-03-25 08:30:58 +00:00
}
2025-03-28 01:25:54 +00:00
func ValueAddBundleDetail(c *gin.Context) {
var req bundle.ValueAddBundleDetailRequest
2025-03-25 08:30:58 +00:00
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
2025-03-28 01:25:54 +00:00
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
2025-03-28 01:25:54 +00:00
res, err := service.BundleProvider.ValueAddBundleDetail(context.Background(), &req)
2025-03-25 08:30:58 +00:00
if err != nil {
2025-03-28 01:25:54 +00:00
service.Error1(c, err)
2025-03-25 08:30:58 +00:00
return
}
2025-03-28 01:25:54 +00:00
service.Success1(c, res.Msg, res)
2025-03-25 08:30:58 +00:00
}