|
@@ -129,7 +129,7 @@ func GetMediaPageByIds(mediaType string, pageInfo page.PageInfo, mediaIds []int)
|
|
|
medias, err := mediaDao.GetMediaPageByIds(pageInfo.LatestId, pageInfo.PageSize, offset, mediaType, mediaIds)
|
|
|
if err == nil && medias != nil {
|
|
|
for _, media := range medias {
|
|
|
- dto := convertMediaDTO(media)
|
|
|
+ dto := convertMediaDTO(media, false)
|
|
|
list = append(list, dto)
|
|
|
}
|
|
|
}
|
|
@@ -141,26 +141,43 @@ func GetMediaPageByAnalystId(mediaType string, pageInfo page.PageInfo, analystId
|
|
|
medias, err := mediaDao.GetMediaPageByAnalystId(pageInfo.LatestId, pageInfo.PageSize, offset, mediaType, analystId)
|
|
|
if err == nil && medias != nil {
|
|
|
for _, media := range medias {
|
|
|
- dto := convertMediaDTO(media)
|
|
|
+ dto := convertMediaDTO(media, false)
|
|
|
list = append(list, dto)
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func convertMediaDTO(media mediaDao.Media) MediaDTO {
|
|
|
- return MediaDTO{
|
|
|
- MediaId: media.Id,
|
|
|
- AuthorId: media.AuthorID,
|
|
|
- AuthorName: media.AuthorName,
|
|
|
- MediaType: string(media.MediaType),
|
|
|
- Src: media.Src,
|
|
|
- MediaName: media.MediaName,
|
|
|
- SourceType: media.SourceType,
|
|
|
- CoverSrc: media.CoverSrc,
|
|
|
- MediaPlaySeconds: media.MediaPlayMilliseconds,
|
|
|
- MediaPlayMillisSeconds: media.MediaPlayMilliseconds,
|
|
|
- PermissionIDs: media.PermissionIDs,
|
|
|
- PublishedTime: media.PublishedTime.Format(time.DateOnly),
|
|
|
+func convertMediaDTO(media mediaDao.Media, fullTime bool) MediaDTO {
|
|
|
+ if fullTime {
|
|
|
+ return MediaDTO{
|
|
|
+ MediaId: media.Id,
|
|
|
+ AuthorId: media.AuthorID,
|
|
|
+ AuthorName: media.AuthorName,
|
|
|
+ MediaType: string(media.MediaType),
|
|
|
+ Src: media.Src,
|
|
|
+ MediaName: media.MediaName,
|
|
|
+ SourceType: media.SourceType,
|
|
|
+ CoverSrc: media.CoverSrc,
|
|
|
+ MediaPlaySeconds: media.MediaPlayMilliseconds,
|
|
|
+ MediaPlayMillisSeconds: media.MediaPlayMilliseconds,
|
|
|
+ PermissionIDs: media.PermissionIDs,
|
|
|
+ PublishedTime: media.PublishedTime.Format(time.DateTime),
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return MediaDTO{
|
|
|
+ MediaId: media.Id,
|
|
|
+ AuthorId: media.AuthorID,
|
|
|
+ AuthorName: media.AuthorName,
|
|
|
+ MediaType: string(media.MediaType),
|
|
|
+ Src: media.Src,
|
|
|
+ MediaName: media.MediaName,
|
|
|
+ SourceType: media.SourceType,
|
|
|
+ CoverSrc: media.CoverSrc,
|
|
|
+ MediaPlaySeconds: media.MediaPlayMilliseconds,
|
|
|
+ MediaPlayMillisSeconds: media.MediaPlayMilliseconds,
|
|
|
+ PermissionIDs: media.PermissionIDs,
|
|
|
+ PublishedTime: media.PublishedTime.Format(time.DateOnly),
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
func GetMediaById(mediaType string, mediaId int) (mediaDTO MediaDTO, err error) {
|
|
@@ -169,7 +186,7 @@ func GetMediaById(mediaType string, mediaId int) (mediaDTO MediaDTO, err error)
|
|
|
logger.Error("查询媒体信息失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- mediaDTO = convertMediaDTO(media)
|
|
|
+ mediaDTO = convertMediaDTO(media, true)
|
|
|
return
|
|
|
}
|
|
|
func GetPermissionsByIds(ids []int) (permissionDTOs []reportService.PermissionDTO, err error) {
|