54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
package dto
|
||
|
||
import (
|
||
"case-open-api/api/model"
|
||
"fmt"
|
||
)
|
||
|
||
// ProjectPlatformDoctorDto 关联平台-白名单-医生
|
||
type ProjectPlatformDoctorDto struct {
|
||
WhiteDoctorId string `json:"white_doctor_id"` // 主键id
|
||
PlatformId string `json:"platform_id"` // 关联平台id
|
||
UserId string `json:"user_id"` // 关联用户id
|
||
Status int `json:"status"` // 状态(1:正常 2:禁用)
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||
User []*UserDto `json:"user"` //
|
||
}
|
||
|
||
// GetProjectPlatformDoctorListDto 列表
|
||
func GetProjectPlatformDoctorListDto(m []*model.ProjectPlatformDoctor) []*ProjectPlatformDoctorDto {
|
||
// 处理返回值
|
||
responses := make([]*ProjectPlatformDoctorDto, len(m))
|
||
|
||
if len(m) > 0 {
|
||
for i, v := range m {
|
||
response := &ProjectPlatformDoctorDto{
|
||
WhiteDoctorId: fmt.Sprintf("%d", v.WhiteDoctorId),
|
||
PlatformId: fmt.Sprintf("%d", v.PlatformId),
|
||
UserId: fmt.Sprintf("%d", v.UserId),
|
||
Status: v.Status,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 加载数据-医院列表
|
||
response = response.LoadUser(v.User)
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
responses[i] = response
|
||
}
|
||
}
|
||
|
||
return responses
|
||
}
|
||
|
||
// LoadUser 加载数据-用户列表
|
||
func (r *ProjectPlatformDoctorDto) LoadUser(m []*model.User) *ProjectPlatformDoctorDto {
|
||
if len(m) > 0 {
|
||
r.User = GetUserListDto(m)
|
||
}
|
||
|
||
return r
|
||
}
|