case-admin-api/api/dto/ProjectPlatformDynamic.go
2025-03-07 17:23:50 +08:00

51 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dto
import (
"case-admin-api/api/model"
"fmt"
)
// ProjectPlatformDynamicDto 关联平台-白名单-动态
type ProjectPlatformDynamicDto struct {
WhiteDynamicId string `gorm:"column:white_dynamic_id;type:bigint(19);primary_key;comment:主键id" json:"white_dynamic_id"`
ProjectPlatformId string `json:"project_platform_id"` // 关联id
DynamicType string `gorm:"column:dynamic_type;type:varchar(50);comment:动态类型area:省份 level:医院等级 title:职称 department:科室 url:地址栏 类型间以-链接)" json:"dynamic_type"`
Status int `gorm:"column:status;type:tinyint(1);comment:状态1:正常 2:禁用)" json:"status"`
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
ProjectPlatformDynamicItemDto []*ProjectPlatformDynamicItemDto `json:"project_platform_dynamic_item"`
}
// GetProjectPlatformDynamicListDto 列表
func GetProjectPlatformDynamicListDto(m []*model.ProjectPlatformDynamic) []*ProjectPlatformDynamicDto {
// 处理返回值
responses := make([]*ProjectPlatformDynamicDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &ProjectPlatformDynamicDto{
WhiteDynamicId: fmt.Sprintf("%d", v.WhiteDynamicId),
ProjectPlatformId: fmt.Sprintf("%d", v.ProjectPlatformId),
DynamicType: v.DynamicType,
Status: v.Status,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
// LoadItem 加载数据-明细
func (r *ProjectPlatformDynamicDto) LoadItem(m []*model.ProjectPlatformDynamicItem) *ProjectPlatformDynamicDto {
if len(m) > 0 {
r.ProjectPlatformDynamicItemDto = GetProjectPlatformDynamicItemListDto(m)
}
return r
}