rts-sim-testing-service/dto/projectLink.go
2023-08-25 10:41:13 +08:00

42 lines
1.3 KiB
Go

package dto
import "joylink.club/bj-rtsts-server/db/model"
type ProjectLinkRspDto struct {
Pid int32 `json:"pid" form:"pid"`
Name string `json:"name" form:"name"`
Code string `json:"code" form:"code"`
TrainSizeLinks []*TrainSizeDto `json:"trainSizeLinks" form:"trainSizeLinks"`
PublishedGiLinks []*PublishedGiLinkDto `json:"mapInfoLinks" form:"mapInfoLinks"`
}
type ProjectLinkReqDto struct {
Pid int32 `json:"pid" form:"pid"`
Sids []*int32 `json:"sids" form:"sids"`
Mids []*int32 `json:"mids" form:"mids"`
}
type PublishedGiLinkDto struct {
Id int32 `json:"id" form:"id"`
Name string `json:"name" form:"name"`
Category string `json:"category" form:"category"`
}
func ConvertProjectLink(gi *model.Project) *ProjectLinkRspDto {
return &ProjectLinkRspDto{
Pid: gi.ID,
Name: gi.Name,
Code: gi.Code,
TrainSizeLinks: []*TrainSizeDto{},
PublishedGiLinks: []*PublishedGiLinkDto{},
}
}
func ConvertFromPublishedGiLink(giSlice []*model.PublishedGi) []*PublishedGiLinkDto {
var result []*PublishedGiLinkDto
for _, gi := range giSlice {
result = append(result, &PublishedGiLinkDto{Id: gi.ID, Name: gi.Name, Category: gi.Category})
}
return result
}