rts-sim-testing-service/dto/trainManage.go

54 lines
1.7 KiB
Go
Raw Normal View History

package dto
import (
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/dto/data_proto"
)
type PageTrainInfoReqDto struct {
PageQueryDto
Name string `json:"name" form:"name"`
}
type TrainInfoReqDto struct {
Name string `json:"name" form:"name"`
2023-11-22 17:05:38 +08:00
Pid int32 `json:"pid" form:"pid"`
}
type TrainInfoDto struct {
2024-01-17 17:02:17 +08:00
Id int32 `json:"id" form:"id"`
Name string `json:"name" form:"name"`
TrainModel int32 `json:"train_model" form:"train_model"`
CarriageLength int32 `json:"carriage_length" form:"carriage_length"`
TotalLength int32 `json:"total_length" form:"total_length"`
MinDiameter int32 `json:"min_diameter" form:"min_diameter"`
MaxDiameter int32 `json:"max_diameter" form:"max_diameter"`
TrainSets string `json:"train_sets" form:"train_sets"`
Description string `json:"description" form:"description"`
TrainConfigData ConfigTrainData `json:"TrainConfigData" form:"TrainConfigData"`
}
2023-11-22 17:05:38 +08:00
func ConvertToTrainDto(trailInfos []*PublishedDto) []*TrainInfoDto {
var result []*TrainInfoDto
for _, t := range trailInfos {
2023-11-22 17:05:38 +08:00
result = append(result, ConvertDtoFromTrain(t))
}
return result
}
2023-11-22 17:05:38 +08:00
func ConvertDtoFromTrain(t *PublishedDto) *TrainInfoDto {
message := &data_proto.Train{}
proto.Unmarshal(t.Proto, message)
return &TrainInfoDto{
Id: t.ID,
Name: t.Name,
2023-11-22 17:05:38 +08:00
Description: t.Note,
TrainModel: int32(message.TrainModel),
CarriageLength: message.CarriageLength,
TotalLength: message.TotalLength,
MinDiameter: message.MinDiameter,
MaxDiameter: message.MaxDiameter,
TrainSets: message.TrainSets,
}
}