修正返回目录,新增处方详情。删除原response目录

This commit is contained in:
2023-10-07 09:55:06 +08:00
parent 605f0ba40b
commit 7642449eda
33 changed files with 293 additions and 1622 deletions
-50
View File
@@ -1,54 +1,4 @@
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
}