修正返回目录
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
type OrderProductItemDto struct {
|
||||
ProductItemId string `json:"product_item_id"` // 主键id
|
||||
OrderProductId string `json:"order_product_id"` // 订单-商品订单id
|
||||
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id
|
||||
OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id
|
||||
ProductId string `json:"product_id"` // 商品id
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductPrice float64 `json:"product_price"` // 商品价格
|
||||
ProductPlatformCode string `json:"product_platform_code"` // 商品处方平台编码
|
||||
Amount int `json:"amount"` // 数量
|
||||
Manufacturer string `json:"manufacturer"` // 生产厂家
|
||||
ProductCoverImg string `json:"product_cover_img"` // 商品封面图
|
||||
ProductSpec string `json:"product_spec"` // 商品规格
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
|
||||
func GetOrderProductItemDto(m *model.OrderProductItem) *OrderProductItemDto {
|
||||
return &OrderProductItemDto{
|
||||
ProductItemId: fmt.Sprintf("%d", m.ProductItemId),
|
||||
OrderProductId: fmt.Sprintf("%d", m.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId),
|
||||
ProductId: fmt.Sprintf("%d", m.ProductId),
|
||||
ProductName: m.ProductName,
|
||||
ProductPrice: m.ProductPrice,
|
||||
ProductPlatformCode: m.ProductPlatformCode,
|
||||
Amount: m.Amount,
|
||||
Manufacturer: m.Manufacturer,
|
||||
ProductCoverImg: utils.AddOssDomain(m.ProductCoverImg),
|
||||
ProductSpec: m.ProductSpec,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func GetOrderProductItemListDto(m []*model.OrderProductItem) []*OrderProductItemDto {
|
||||
// 处理返回值
|
||||
responses := make([]*OrderProductItemDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &OrderProductItemDto{
|
||||
ProductItemId: fmt.Sprintf("%d", v.ProductItemId),
|
||||
OrderProductId: fmt.Sprintf("%d", v.OrderProductId),
|
||||
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||||
ProductId: fmt.Sprintf("%d", 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,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user