63 lines
2.7 KiB
Go
63 lines
2.7 KiB
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/model"
|
|
)
|
|
|
|
type PharmacyDto struct {
|
|
PharmacyId string `json:"pharmacy_id"` // 主键id
|
|
PharmacyName string `json:"pharmacy_name"` // 药房名称
|
|
PharmacyCode string `json:"pharmacy_code"` // 药房代码
|
|
Postage float64 `json:"postage"` // 基础邮费
|
|
FreeShippingThreshold float64 `json:"free_shipping_threshold"` // 满XX包邮门槛金额
|
|
IsPickup int `json:"is_pickup"` // 是否支持自提(0:否 1:是)
|
|
Telephone string `json:"telephone"` // 电话
|
|
ProvinceId int `json:"province_id"` // 省份id
|
|
Province string `json:"province"` // 省份
|
|
CityId int `json:"city_id"` // 城市id
|
|
City string `json:"city"` // 城市
|
|
CountyId int `json:"county_id"` // 区县id
|
|
County string `json:"county"` // 区县
|
|
Address string `json:"address"` // 详细地址
|
|
FullAddress string `json:"full_address"` // 完整地址(省市区+详细地址)
|
|
Status int `json:"status"` // 状态(0:禁用 1:正常 2:删除)
|
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
|
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
|
}
|
|
|
|
func GetPharmacyDto(m *model.Pharmacy) *PharmacyDto {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
fullAddress := fmt.Sprintf("%s%s%s%s", m.Province, m.City, m.County, m.Address)
|
|
return &PharmacyDto{
|
|
PharmacyId: fmt.Sprintf("%d", m.PharmacyId),
|
|
PharmacyName: m.PharmacyName,
|
|
PharmacyCode: m.PharmacyCode,
|
|
Postage: m.Postage,
|
|
FreeShippingThreshold: m.FreeShippingThreshold,
|
|
IsPickup: m.IsPickup,
|
|
Telephone: m.Telephone,
|
|
ProvinceId: m.ProvinceId,
|
|
Province: m.Province,
|
|
CityId: m.CityId,
|
|
City: m.City,
|
|
CountyId: m.CountyId,
|
|
County: m.County,
|
|
Address: m.Address,
|
|
FullAddress: fullAddress,
|
|
Status: m.Status,
|
|
CreatedAt: m.CreatedAt,
|
|
UpdatedAt: m.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func GetPharmacyListDto(m []*model.Pharmacy) []PharmacyDto {
|
|
responses := make([]PharmacyDto, len(m))
|
|
for i, v := range m {
|
|
responses[i] = *GetPharmacyDto(v)
|
|
}
|
|
return responses
|
|
}
|