This commit is contained in:
蒋海成 2025-02-22 18:50:56 +08:00
parent 58131f934f
commit 702846f687
2 changed files with 9 additions and 9 deletions

View File

@ -9,9 +9,9 @@ import (
"micro-bundle/pkg/msg"
)
func CreateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err error) {
func CreateBundle(bundle *model.BundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Create(&req).Error
err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Create(&bundle).Error
if err != nil {
res.Msg = msg.ErrorCreateBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorCreateBundleInfo, "创建套餐信息失败: ")
@ -20,9 +20,9 @@ func CreateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err err
return
}
func UpdateBundle(req *model.BundleProfile) (res *bundle.CommonResponse, err error) {
func UpdateBundle(bundle *model.BundleProfile) (res *bundle.CommonResponse, err error) {
res = new(bundle.CommonResponse)
err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ?", req.UUID).Updates(req).Error
err = app.ModuleClients.BundleDB.Model(&model.BundleProfile{}).Where("uuid = ?", bundle.UUID).Updates(bundle).Error
if err != nil {
res.Msg = msg.ErrorUpdateBundleInfo
return res, commonErr.ReturnError(err, msg.ErrorUpdateBundleInfo, "更新套餐信息失败: ")
@ -59,11 +59,11 @@ func BundleList(req *bundle.BundleListRequest) (res *bundle.BundleListResponse,
count := *query
if err = query.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize)).Find(&bundles).Error; err != nil {
if err = query.Find(&bundles).Error; err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetBundleList, "获取套餐列表失败: ")
}
_ = copier.CopyWithOption(&res.Bundles, &bundles, copier.Option{DeepCopy: true})
_ = copier.CopyWithOption(&res.Bundles, bundles, copier.Option{DeepCopy: true})
var total int64
@ -82,6 +82,6 @@ func BundleDetail(uuid string) (res *bundle.BundleProfile, err error) {
if err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetBundleInfo, "获取套餐信息失败: ")
}
_ = copier.CopyWithOption(&res, &bundle, copier.Option{DeepCopy: true})
_ = copier.CopyWithOption(&res, bundle, copier.Option{DeepCopy: true})
return
}

View File

@ -102,7 +102,7 @@ func OrderRecordsList(req *bundle.OrderRecordsRequest) (res *bundle.OrderRecords
return res, commonErr.ReturnError(err, msg.ErrorGetOrderList, "获取订单信息失败: ")
}
_ = copier.CopyWithOption(&res.OrderRecords, &records, copier.Option{DeepCopy: true})
_ = copier.CopyWithOption(&res.OrderRecords, records, copier.Option{DeepCopy: true})
var total int64
@ -131,6 +131,6 @@ func OrderRecordDetail(req *bundle.OrderRecordsDetailRequest) (res *bundle.Order
if err != nil {
return res, commonErr.ReturnError(err, msg.ErrorGetOrderInfo, "获取订单信息失败: ")
}
_ = copier.CopyWithOption(&res, &orderRecord, copier.Option{DeepCopy: true})
_ = copier.CopyWithOption(&res, orderRecord, copier.Option{DeepCopy: true})
return
}