新增专长

This commit is contained in:
2023-07-11 13:11:28 +08:00
parent b7528ce40f
commit fade9ea4a7
7 changed files with 140 additions and 24 deletions
@@ -0,0 +1,49 @@
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
}