45 lines
1002 B
Go
45 lines
1002 B
Go
package dbstruct
|
|
|
|
type MediaComponent struct {
|
|
ImageIds *[]int64 `json:"image_ids" bson:"image_ids"` // 图片ids
|
|
VideoIds *[]int64 `json:"video_ids" bson:"video_ids"` // 视频ids
|
|
Images []*ToCImage `json:"images"`
|
|
Videos []*ToCVideo `json:"videos"`
|
|
}
|
|
|
|
func (p *MediaComponent) GetImageIds() []int64 {
|
|
if p != nil && p.ImageIds != nil {
|
|
return *p.ImageIds
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *MediaComponent) GetVideoIds() []int64 {
|
|
if p != nil && p.VideoIds != nil {
|
|
return *p.VideoIds
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *MediaComponent) SetImages(images []*ToCImage) {
|
|
if p != nil {
|
|
p.Images = make([]*ToCImage, 0)
|
|
p.Images = append(p.Images, images...)
|
|
}
|
|
}
|
|
|
|
func (p *MediaComponent) SetVideos(videos []*ToCVideo) {
|
|
if p != nil {
|
|
p.Videos = make([]*ToCVideo, 0)
|
|
p.Videos = append(p.Videos, videos...)
|
|
}
|
|
}
|
|
|
|
// ImageIds和VideoIds不可同时为空
|
|
func (p *MediaComponent) IsEmpty() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
return len(p.GetImageIds()) == 0 && len(p.GetVideoIds()) == 0
|
|
}
|