新增科普分类管理
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/utils"
|
||||
)
|
||||
|
||||
// ArticleScienceSourceDto 文章-科普-来源
|
||||
type ArticleScienceSourceDto struct {
|
||||
SourceId string `json:"source_id"` // 主键id
|
||||
SourceName string `json:"source_name"` // 来源名称
|
||||
SourceImage string `json:"source_image"` // 来源图片
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetArticleScienceSourceDto 详情
|
||||
func GetArticleScienceSourceDto(m *model.ArticleScienceSource) *ArticleScienceSourceDto {
|
||||
return &ArticleScienceSourceDto{
|
||||
SourceId: fmt.Sprintf("%d", m.SourceId),
|
||||
SourceName: m.SourceName,
|
||||
SourceImage: utils.AddOssDomain(m.SourceImage),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetArticleScienceSourceListDto 列表
|
||||
func GetArticleScienceSourceListDto(m []*model.ArticleScienceSource) []*ArticleScienceSourceDto {
|
||||
// 处理返回值
|
||||
responses := make([]*ArticleScienceSourceDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &ArticleScienceSourceDto{
|
||||
SourceId: fmt.Sprintf("%d", v.SourceId),
|
||||
SourceName: v.SourceName,
|
||||
SourceImage: utils.AddOssDomain(v.SourceImage),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
Reference in New Issue
Block a user