新增药品订单详情

This commit is contained in:
2023-09-11 14:34:50 +08:00
parent e82932ab53
commit 0a51e0fcbc
19 changed files with 869 additions and 116 deletions
+54
View File
@@ -0,0 +1,54 @@
package service
import (
"errors"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/responses/orderProductItemResponse"
"hospital-admin-api/utils"
"strconv"
)
type OrderProductItemService struct {
}
// GetOrderProductItemByOrderProductId 获取商品列表-问诊订单id
func (r *OrderProductItemService) GetOrderProductItemByOrderProductId(orderProductId int64) (u []*orderProductItemResponse.OrderProductItem, err error) {
orderProductItemDao := dao.OrderProductItemDao{}
orderProductItems, err := orderProductItemDao.GetOrderProductItemByOrderProductId(orderProductId)
if err != nil {
return nil, errors.New("数据错误,无药品数据")
}
if len(orderProductItems) == 0 {
return nil, errors.New("数据错误,无药品数据")
}
// 处理返回值
items := make([]*orderProductItemResponse.OrderProductItem, len(orderProductItems))
if len(orderProductItems) > 0 {
for i, v := range orderProductItems {
// 将原始结构体转换为新结构体
item := &orderProductItemResponse.OrderProductItem{
ProductItemId: strconv.Itoa(int(v.ProductItemId)),
OrderProductId: strconv.Itoa(int(v.OrderProductId)),
OrderInquiryId: strconv.Itoa(int(v.OrderInquiryId)),
OrderPrescriptionId: strconv.Itoa(int(v.OrderPrescriptionId)),
ProductId: strconv.Itoa(int(v.ProductId)),
ProductName: v.ProductName,
ProductPrice: v.ProductPrice,
ProductPlatformCode: v.ProductPlatformCode,
Amount: v.Amount,
Manufacturer: v.Manufacturer,
ProductCoverImg: utils.AddOssDomain(v.ProductCoverImg),
ProductSpec: v.ProductSpec,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
items[i] = item
}
}
return items, nil
}