2023-07-11 13:11:28 +08:00

50 lines
1.8 KiB
Go

package diseaseClassExpertiseResponse
import (
"hospital-admin-api/api/model"
"strconv"
)
type DiseaseClassExpertise struct {
ExpertiseId string `json:"expertise_id"` // 主键
ExpertiseName string `json:"expertise_name"` // 专长名称
ExpertiseSort int `json:"expertise_sort"` // 排序(越大排序越靠前)
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
// DiseaseClassExpertiseResponse 专长详情
func DiseaseClassExpertiseResponse(diseaseClassExpertise *model.DiseaseClassExpertise) *DiseaseClassExpertise {
return &DiseaseClassExpertise{
ExpertiseId: strconv.FormatInt(diseaseClassExpertise.ExpertiseId, 10),
ExpertiseName: diseaseClassExpertise.ExpertiseName,
ExpertiseSort: diseaseClassExpertise.ExpertiseSort,
CreatedAt: diseaseClassExpertise.CreatedAt,
UpdatedAt: diseaseClassExpertise.UpdatedAt,
}
}
// GetDiseaseClassExpertiseListResponse 自定义列表
func GetDiseaseClassExpertiseListResponse(diseaseClassExpertises []*model.DiseaseClassExpertise) []DiseaseClassExpertise {
// 处理返回值
getDiseaseClassExpertiseListResponses := make([]DiseaseClassExpertise, len(diseaseClassExpertises))
if len(diseaseClassExpertises) > 0 {
for i, v := range diseaseClassExpertises {
// 将原始结构体转换为新结构体
getDiseaseClassExpertiseListResponse := DiseaseClassExpertise{
ExpertiseId: strconv.FormatInt(v.ExpertiseId, 10),
ExpertiseName: v.ExpertiseName,
ExpertiseSort: v.ExpertiseSort,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
getDiseaseClassExpertiseListResponses[i] = getDiseaseClassExpertiseListResponse
}
}
return getDiseaseClassExpertiseListResponses
}