50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package areaResponse
|
|
|
|
import (
|
|
"hospital-admin-api/api/model"
|
|
"strconv"
|
|
)
|
|
|
|
type Area struct {
|
|
AreaId string `json:"area_id"` // 地区编号
|
|
AreaName string `json:"area_name"` // 名称
|
|
ParentId string `json:"parent_id"` // 上级编号
|
|
Zip string `json:"zip"` // 邮编
|
|
AreaType int `json:"area_type"` // 类型(1:国家,2:省,3:市,4:区县)
|
|
}
|
|
|
|
// AreaResponse 地区详情
|
|
func AreaResponse(area *model.Area) *Area {
|
|
return &Area{
|
|
AreaId: strconv.FormatInt(area.AreaId, 10),
|
|
AreaName: area.AreaName,
|
|
ParentId: strconv.FormatInt(area.ParentId, 10),
|
|
Zip: area.Zip,
|
|
AreaType: area.AreaType,
|
|
}
|
|
}
|
|
|
|
// GetAreaListResponse 获取银行列表
|
|
func GetAreaListResponse(area []*model.Area) []Area {
|
|
// 处理返回值
|
|
r := make([]Area, len(area))
|
|
|
|
if len(area) > 0 {
|
|
for i, v := range area {
|
|
// 将原始结构体转换为新结构体
|
|
l := Area{
|
|
AreaId: strconv.FormatInt(v.AreaId, 10),
|
|
AreaName: v.AreaName,
|
|
ParentId: strconv.FormatInt(v.ParentId, 10),
|
|
Zip: v.Zip,
|
|
AreaType: v.AreaType,
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
r[i] = l
|
|
}
|
|
}
|
|
|
|
return r
|
|
}
|