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

63 lines
1.7 KiB
Go
Raw Normal View History

package publishedGi
import (
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto"
)
type PublishedGiReqDto struct {
dto.PageQueryDto
Name string `json:"name" form:"name"`
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
}
type PublishedGiListReqDto struct {
Name string `json:"name" form:"name"`
Type int32 `json:"type" form:"type"`
Category string `json:"category" form:"category"`
Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"`
}
type PublishReqDto struct {
//发布后的名称
Name string `json:"name" form:"name"`
//草稿数据的id
2023-08-07 15:05:37 +08:00
DraftId int32 `json:"draftId" form:"draftId"`
Note string `json:"note" form:"note"`
//Time dto.JsonTime `json:"time" form:"time"`
////是否覆盖同名数据
//Overwrite bool `json:"overwrite" form:"overwrite"`
}
type PublishedGiDto struct {
ID int32 `json:"id"`
Name string `json:"name"`
Proto []byte `json:"proto"`
UserID int32 `json:"userID"`
2023-08-07 15:05:37 +08:00
Note string `json:"note"`
2023-09-05 09:38:12 +08:00
Category string `json:"category" form:"category"`
PublishAt dto.JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"`
}
func ConvertFrom(gi *model.PublishedGi) *PublishedGiDto {
return &PublishedGiDto{
ID: gi.ID,
Name: gi.Name,
Proto: gi.Proto,
2023-08-07 15:05:37 +08:00
Note: gi.Note,
UserID: gi.UserID,
2023-09-05 09:38:12 +08:00
Category: gi.Category,
PublishAt: dto.JsonTime(gi.PublishAt),
}
}
func ConvertFromSlice(giSlice []*model.PublishedGi) []*PublishedGiDto {
var result []*PublishedGiDto
for _, gi := range giSlice {
result = append(result, ConvertFrom(gi))
}
return result
}