处理 GORM 0 的bug
This commit is contained in:
+21
-1
@@ -9,6 +9,10 @@ import (
|
||||
type ProductDto struct {
|
||||
ProductId string `json:"product_id"` // 主键id
|
||||
ProductPlatformId string `json:"product_platform_id"` // 处方平台商品id
|
||||
PharmacyId string `json:"pharmacy_id"` // 所属药房ID
|
||||
PharmacyCode string `json:"pharmacy_code"` // 所属药房编码
|
||||
PharmacyName string `json:"pharmacy_name"` // 所属药房名称
|
||||
Pharmacy *PharmacyDto `json:"pharmacy"` // 所属药房详情
|
||||
ProductStatus int `json:"product_status"` // 商品状态(1:正常 2:下架)
|
||||
IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是)
|
||||
PrescriptionNum int `json:"prescription_num"` // 处方可开具的数量
|
||||
@@ -36,9 +40,11 @@ type ProductDto struct {
|
||||
|
||||
// GetProductDto 商品详情
|
||||
func GetProductDto(m *model.Product) *ProductDto {
|
||||
return &ProductDto{
|
||||
dto := &ProductDto{
|
||||
ProductId: fmt.Sprintf("%d", m.ProductId),
|
||||
ProductPlatformId: fmt.Sprintf("%d", m.ProductPlatformId),
|
||||
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
||||
PharmacyCode: m.PharmacyCode,
|
||||
ProductStatus: m.ProductStatus,
|
||||
IsDelete: m.IsDelete,
|
||||
PrescriptionNum: m.PrescriptionNum,
|
||||
@@ -62,6 +68,13 @@ func GetProductDto(m *model.Product) *ProductDto {
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
|
||||
if m.Pharmacy != nil {
|
||||
dto.Pharmacy = GetPharmacyDto(m.Pharmacy)
|
||||
dto.PharmacyName = m.Pharmacy.PharmacyName
|
||||
}
|
||||
|
||||
return dto
|
||||
}
|
||||
|
||||
// GetProductListDto 商品列表
|
||||
@@ -74,6 +87,8 @@ func GetProductListDto(m []*model.Product) []*ProductDto {
|
||||
response := &ProductDto{
|
||||
ProductId: fmt.Sprintf("%d", v.ProductId),
|
||||
ProductPlatformId: fmt.Sprintf("%d", v.ProductPlatformId),
|
||||
PharmacyId: fmt.Sprintf("%d", v.PharmacyId),
|
||||
PharmacyCode: v.PharmacyCode,
|
||||
ProductStatus: v.ProductStatus,
|
||||
IsDelete: v.IsDelete,
|
||||
PrescriptionNum: v.PrescriptionNum,
|
||||
@@ -98,6 +113,11 @@ func GetProductListDto(m []*model.Product) []*ProductDto {
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
if v.Pharmacy != nil {
|
||||
response.Pharmacy = GetPharmacyDto(v.Pharmacy)
|
||||
response.PharmacyName = v.Pharmacy.PharmacyName
|
||||
}
|
||||
|
||||
// 加载商品库存
|
||||
if v.ProductPlatformAmount != nil {
|
||||
response = response.LoadProductAmount(v.ProductPlatformAmount)
|
||||
|
||||
Reference in New Issue
Block a user