Files
hospital-admin-api/api/dto/OrderPrescriptionProduct.go
T

80 lines
3.6 KiB
Go

package dto
import (
"fmt"
"hospital-admin-api/api/model"
)
type OrderPrescriptionProductDto struct {
PrescriptionProductId string `json:"prescription_product_id"` // 主键id
OrderPrescriptionId string `json:"order_prescription_id"` // 订单-处方id;NOT NULL
ProductId string `json:"product_id"` // 商品id;NOT NULL
UseStatus int `json:"use_status"` // 使用状态(1:已使用 0:未使用)
PrescriptionProductNum int `json:"prescription_product_num"` // 商品数量
ProductName string `json:"product_name"` // 商品名称
ProductSpec string `json:"product_spec"` // 商品规格
LicenseNumber string `json:"license_number"` // 批准文号
Manufacturer string `json:"manufacturer"` // 生产厂家
SingleUnit string `json:"single_unit"` // 单次剂量(例:1次1包)
SingleUse string `json:"single_use"` // 单次用法(例:口服)
PackagingUnit string `json:"packaging_unit"` // 基本包装单位(例:盒/瓶)
FrequencyUse string `json:"frequency_use"` // 使用频率(例:1天3次)
AvailableDays int `json:"available_days"` // 可用天数(3)
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
func GetOrderPrescriptionProductDto(m *model.OrderPrescriptionProduct) *OrderPrescriptionProductDto {
return &OrderPrescriptionProductDto{
PrescriptionProductId: fmt.Sprintf("%d", m.OrderPrescriptionId),
OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId),
ProductId: fmt.Sprintf("%d", m.ProductId),
UseStatus: m.UseStatus,
PrescriptionProductNum: m.PrescriptionProductNum,
ProductName: m.ProductName,
ProductSpec: m.ProductSpec,
LicenseNumber: m.LicenseNumber,
Manufacturer: m.Manufacturer,
SingleUnit: m.SingleUnit,
SingleUse: m.SingleUse,
PackagingUnit: m.PackagingUnit,
FrequencyUse: m.FrequencyUse,
AvailableDays: m.AvailableDays,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
func GetOrderPrescriptionProductListDto(m []*model.OrderPrescriptionProduct) []*OrderPrescriptionProductDto {
// 处理返回值
responses := make([]*OrderPrescriptionProductDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &OrderPrescriptionProductDto{
PrescriptionProductId: fmt.Sprintf("%d", v.OrderPrescriptionId),
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
ProductId: fmt.Sprintf("%d", v.ProductId),
UseStatus: v.UseStatus,
PrescriptionProductNum: v.PrescriptionProductNum,
ProductName: v.ProductName,
ProductSpec: v.ProductSpec,
LicenseNumber: v.LicenseNumber,
Manufacturer: v.Manufacturer,
SingleUnit: v.SingleUnit,
SingleUse: v.SingleUse,
PackagingUnit: v.PackagingUnit,
FrequencyUse: v.FrequencyUse,
AvailableDays: v.AvailableDays,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}