56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package dto
|
||
|
||
import (
|
||
"case-admin-api/api/model"
|
||
"fmt"
|
||
)
|
||
|
||
// PlatformDto 平台表
|
||
type PlatformDto struct {
|
||
PlatformId string `json:"platform_id"` // 主键id
|
||
PlatformName string `json:"platform_name"` // 平台名称
|
||
PlatformStatus int `json:"platform_status"` // 平台状态(1:正常 2:禁用)
|
||
PlatformKey string `json:"platform_key"` // 平台标识(用于鉴权)
|
||
PlatformSecret string `json:"platform_secret"` // 平台密钥(用于鉴权)
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||
}
|
||
|
||
// GetPlatformListDto 列表
|
||
func GetPlatformListDto(m []*model.Platform) []*PlatformDto {
|
||
// 处理返回值
|
||
responses := make([]*PlatformDto, len(m))
|
||
|
||
if len(m) > 0 {
|
||
for i, v := range m {
|
||
response := &PlatformDto{
|
||
PlatformId: fmt.Sprintf("%d", v.PlatformId),
|
||
PlatformStatus: v.PlatformStatus,
|
||
PlatformName: v.PlatformName,
|
||
PlatformKey: v.PlatformKey,
|
||
PlatformSecret: v.PlatformSecret,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
responses[i] = response
|
||
}
|
||
}
|
||
|
||
return responses
|
||
}
|
||
|
||
// GetPlatformDto 详情
|
||
func GetPlatformDto(m *model.Platform) *PlatformDto {
|
||
return &PlatformDto{
|
||
PlatformId: fmt.Sprintf("%d", m.PlatformId),
|
||
PlatformStatus: m.PlatformStatus,
|
||
PlatformName: m.PlatformName,
|
||
PlatformKey: m.PlatformKey,
|
||
PlatformSecret: m.PlatformSecret,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
}
|