70 lines
1.3 KiB
Go
70 lines
1.3 KiB
Go
package request
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// 动态的图片对象
|
|
type TimelineImgDTO struct {
|
|
ImgPhotoKey string
|
|
Width string
|
|
Height string
|
|
}
|
|
|
|
// 动态的视频对象
|
|
type TimelineVideoDTO struct {
|
|
VideoKey string
|
|
Width string
|
|
Height string
|
|
Duration string
|
|
}
|
|
|
|
type CreateTimelineRequest struct {
|
|
AccessToken string
|
|
ContentType string //1=图片 2=视频
|
|
TextContent string
|
|
ImgUrls string
|
|
ImgSizes string
|
|
ImgList string //json字符串
|
|
VideoDTO string //json字符串
|
|
CityName string // 城市名
|
|
AddressName string
|
|
Latitude string
|
|
Longitude string
|
|
UserSkillId string
|
|
}
|
|
|
|
// 参数合法性检验
|
|
func (request *CreateTimelineRequest) CheckParameter() (err error) {
|
|
|
|
if len(request.AccessToken) == 0 {
|
|
err = errors.New("AccessToken不能为空")
|
|
return
|
|
}
|
|
|
|
// if utf8.RuneCountInString(request.TextContent) > 140 {
|
|
// err = errors.New("内容最多140个字")
|
|
// return
|
|
// }
|
|
|
|
if len([]rune(request.TextContent)) > 1000 {
|
|
return errors.New("不能超过1000字")
|
|
}
|
|
|
|
// 视频
|
|
if request.ContentType == "2" {
|
|
|
|
if len(request.VideoDTO) == 0 {
|
|
err = errors.New("VideoDTO不能为空")
|
|
return
|
|
}
|
|
} else {
|
|
|
|
if len(request.ImgUrls) == 0 && len(request.ImgList) == 0 {
|
|
err = errors.New("ImgUrls不能为空")
|
|
return
|
|
}
|
|
}
|
|
return
|
|
}
|