hospital-admin-api/api/dto/UserShipAddress.go
2023-09-28 08:40:43 +08:00

69 lines
3.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dto
import (
"fmt"
"hospital-admin-api/api/model"
)
type UserShipAddressDto struct {
AddressId string `json:"address_id"` // 主键id
UserId string `json:"user_id"` // 用户id;NOT NULL
ProvinceId string `json:"province_id"` // 省份id
Province string `json:"province"` // 省份
CityId string `json:"city_id"` // 城市id
City string `json:"city"` // 城市
CountyId string `json:"county_id"` // 区县id
County string `json:"county"` // 区县
ConsigneeTownId string `json:"consignee_town_id"` // 镇id
ConsigneeTown string `json:"consignee_town"` // 镇
Address string `json:"address"` // 详细地址
AddressMask string `json:"address_mask"` // 详细地址(掩码)
ConsigneeName string `json:"consignee_name"` // 收货人姓名;NOT NULL
ConsigneeNameMask string `json:"consignee_name_mask"` // 收货人姓名(掩码)
ConsigneeTel string `json:"consignee_tel"` // 收货人电话;NOT NULL
ConsigneeTelMask string `json:"consignee_tel_mask"` // 收货人电话(掩码)
ConsigneeZipCode string `json:"consignee_zip_code"` // 收货邮编
IsDefault *int `json:"is_default"` // 默认地址0:否 1:是)
Tag *int `json:"tag"` // 地址标签1:家 2:公司 3:学校 4:其他)
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
func GetUserShipAddressListDto(m []*model.UserShipAddress) []*UserShipAddressDto {
// 处理返回值
responses := make([]*UserShipAddressDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &UserShipAddressDto{
AddressId: fmt.Sprintf("%d", v.AddressId),
UserId: fmt.Sprintf("%d", v.UserId),
ProvinceId: fmt.Sprintf("%d", v.ProvinceId),
Province: v.Province,
CityId: fmt.Sprintf("%d", v.CityId),
City: v.City,
CountyId: fmt.Sprintf("%d", v.CountyId),
County: v.County,
ConsigneeTownId: fmt.Sprintf("%d", v.ConsigneeTownId),
ConsigneeTown: v.ConsigneeTown,
Address: v.Address,
AddressMask: v.AddressMask,
ConsigneeName: v.ConsigneeName,
ConsigneeNameMask: v.ConsigneeNameMask,
ConsigneeTel: v.ConsigneeTel,
ConsigneeTelMask: v.ConsigneeTelMask,
ConsigneeZipCode: v.ConsigneeZipCode,
IsDefault: &v.IsDefault,
Tag: &v.Tag,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}