45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package dto
|
|
|
|
import (
|
|
"vote-video-api/api/model"
|
|
)
|
|
|
|
type VideoAuthorDto struct {
|
|
AuthorName string `json:"author_name"` // 作者姓名
|
|
AuthorAvatar string `json:"author_avatar"` // 作者头像
|
|
HospitalName string `json:"hospital_name"` // 作者所属医院
|
|
}
|
|
|
|
// GetVideoAuthorListDto 列表-分页
|
|
func GetVideoAuthorListDto(m []*model.VideoAuthor) []*VideoAuthorDto {
|
|
// 处理返回值
|
|
responses := make([]*VideoAuthorDto, len(m))
|
|
|
|
if len(m) > 0 {
|
|
for i, v := range m {
|
|
response := &VideoAuthorDto{
|
|
AuthorName: v.AuthorName,
|
|
AuthorAvatar: v.AuthorAvatar,
|
|
}
|
|
|
|
// 加载数据-医院属性
|
|
if v.BaseHospital != nil {
|
|
response = response.LoadBaseHospitalAttr(v.BaseHospital)
|
|
}
|
|
|
|
// 将转换后的结构体添加到新切片中
|
|
responses[i] = response
|
|
}
|
|
}
|
|
|
|
return responses
|
|
}
|
|
|
|
// LoadBaseHospitalAttr 加载数据-医院属性
|
|
func (r *VideoAuthorDto) LoadBaseHospitalAttr(m *model.BaseHospital) *VideoAuthorDto {
|
|
if m != nil {
|
|
r.HospitalName = m.HospitalName
|
|
}
|
|
return r
|
|
}
|