新增平台商品
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
)
|
||||
|
||||
type ProductPlatformDto struct {
|
||||
ProductPlatformId string `json:"product_platform_id"` // 主键id
|
||||
ProductName string `json:"product_name"` // 商品名称
|
||||
ProductPrice float64 `json:"product_price"` // 商品价格
|
||||
ProductType int `json:"product_type"` // 药品类型(0:未知 1:中成药 2:西药)
|
||||
ProductPlatformCode string `json:"product_platform_code"` // 处方平台商品编码
|
||||
ProductPharmacyCode string `json:"product_pharmacy_code"` // 第三方药店商品编码
|
||||
ProductSpec string `json:"product_spec"` // 商品规格
|
||||
LicenseNumber string `json:"license_number"` // 批准文号
|
||||
Manufacturer string `json:"manufacturer"` // 生产厂家
|
||||
SingleUnit string `json:"single_unit"` // 单次剂量单位
|
||||
PackagingUnit string `json:"packaging_unit"` // 基本包装单位
|
||||
PackagingCount string `json:"packaging_count"` // 基本包装数量
|
||||
RetailUnit string `json:"retail_unit"` // 零售单位
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetProductPlatformDto 平台商品详情
|
||||
func GetProductPlatformDto(m *model.ProductPlatform) *ProductPlatformDto {
|
||||
return &ProductPlatformDto{
|
||||
ProductPlatformId: fmt.Sprintf("%d", m.ProductPlatformId),
|
||||
ProductName: m.ProductName,
|
||||
ProductPrice: m.ProductPrice,
|
||||
ProductType: m.ProductType,
|
||||
ProductPlatformCode: m.ProductPlatformCode,
|
||||
ProductPharmacyCode: m.ProductPharmacyCode,
|
||||
ProductSpec: m.ProductSpec,
|
||||
LicenseNumber: m.LicenseNumber,
|
||||
Manufacturer: m.Manufacturer,
|
||||
SingleUnit: m.SingleUnit,
|
||||
PackagingUnit: m.PackagingUnit,
|
||||
PackagingCount: m.PackagingCount,
|
||||
RetailUnit: m.RetailUnit,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetProductPlatformListDto 平台商品列表
|
||||
func GetProductPlatformListDto(m []*model.ProductPlatform) []*ProductPlatformDto {
|
||||
// 处理返回值
|
||||
responses := make([]*ProductPlatformDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &ProductPlatformDto{
|
||||
ProductPlatformId: fmt.Sprintf("%d", v.ProductPlatformId),
|
||||
ProductName: v.ProductName,
|
||||
ProductPrice: v.ProductPrice,
|
||||
ProductType: v.ProductType,
|
||||
ProductPlatformCode: v.ProductPlatformCode,
|
||||
ProductPharmacyCode: v.ProductPharmacyCode,
|
||||
ProductSpec: v.ProductSpec,
|
||||
LicenseNumber: v.LicenseNumber,
|
||||
Manufacturer: v.Manufacturer,
|
||||
SingleUnit: v.SingleUnit,
|
||||
PackagingUnit: v.PackagingUnit,
|
||||
PackagingCount: v.PackagingCount,
|
||||
RetailUnit: v.RetailUnit,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user