53 lines
2.2 KiB
Go
53 lines
2.2 KiB
Go
package hosDepCustomResponse
|
||
|
||
import (
|
||
"hospital-admin-api/api/model"
|
||
"strconv"
|
||
)
|
||
|
||
type HosDepCustom struct {
|
||
DepartmentCustomId string `json:"department_custom_id"` // 主键
|
||
DepartmentId string `json:"department_id"` // 医院科室-标准id
|
||
DepartmentCustomName string `json:"department_custom_name"` // 科室名称-自定义
|
||
DepartmentName string `json:"department_name"` // 科室名称-标准
|
||
DepartmentCode string `json:"department_code"` // 科室编码-标准
|
||
DepartmentStatus int `json:"department_status"` // 状态(1:正常 2:删除)
|
||
}
|
||
|
||
// HospitalDepartmentCustomResponse 自定义详情
|
||
func HospitalDepartmentCustomResponse(hospitalDepartmentCustom *model.HospitalDepartmentCustom) *HosDepCustom {
|
||
return &HosDepCustom{
|
||
DepartmentCustomId: strconv.FormatInt(hospitalDepartmentCustom.DepartmentCustomId, 10),
|
||
DepartmentId: strconv.FormatInt(hospitalDepartmentCustom.DepartmentId, 10),
|
||
DepartmentCustomName: hospitalDepartmentCustom.DepartmentCustomName,
|
||
DepartmentName: hospitalDepartmentCustom.DepartmentName,
|
||
DepartmentCode: hospitalDepartmentCustom.DepartmentCode,
|
||
DepartmentStatus: hospitalDepartmentCustom.DepartmentStatus,
|
||
}
|
||
}
|
||
|
||
// GetHospitalDepartmentCustomListResponse 自定义列表
|
||
func GetHospitalDepartmentCustomListResponse(hospitalDepartmentCustom []*model.HospitalDepartmentCustom) []HosDepCustom {
|
||
// 处理返回值
|
||
getHospitalDepartmentCustomListResponses := make([]HosDepCustom, len(hospitalDepartmentCustom))
|
||
|
||
if len(hospitalDepartmentCustom) > 0 {
|
||
for i, v := range hospitalDepartmentCustom {
|
||
// 将原始结构体转换为新结构体
|
||
getHospitalDepartmentCustomListResponse := HosDepCustom{
|
||
DepartmentCustomId: strconv.FormatInt(v.DepartmentCustomId, 10),
|
||
DepartmentId: strconv.FormatInt(v.DepartmentId, 10),
|
||
DepartmentCustomName: v.DepartmentCustomName,
|
||
DepartmentName: v.DepartmentName,
|
||
DepartmentCode: v.DepartmentCode,
|
||
DepartmentStatus: v.DepartmentStatus,
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
getHospitalDepartmentCustomListResponses[i] = getHospitalDepartmentCustomListResponse
|
||
}
|
||
}
|
||
|
||
return getHospitalDepartmentCustomListResponses
|
||
}
|