173 lines
3.6 KiB
Go
173 lines
3.6 KiB
Go
package request
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"gitea.ddegame.cn/open/servicebase/pkg/htools"
|
|
)
|
|
|
|
// PresentGiftFromChatRoomRequest 聊天室打赏的请求
|
|
type PresentGiftFromChatRoomRequest struct {
|
|
BaseRequest
|
|
ChatroomId string
|
|
ReceiveUserId string
|
|
ReceiveUserIds string // 打赏全麦的用户ID
|
|
GiftCount string // 礼物数量
|
|
GiftId string
|
|
GiftDiamond string
|
|
HostUserId string // 主持人ID
|
|
IsBatch string // 0=打赏个人 1= 打赏全麦
|
|
BoxId string // 背包ID
|
|
IsFromGiftBox string // 是否从礼物盒打赏
|
|
}
|
|
|
|
// 注册用户信息签名验证
|
|
func (request *PresentGiftFromChatRoomRequest) CheckParameter() (err error) {
|
|
|
|
if len(request.AccessToken) == 0 {
|
|
err = errors.New("AccessToken不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.ChatroomId) == 0 {
|
|
err = errors.New("ChatroomRoomId不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.GiftId) == 0 {
|
|
err = errors.New("GiftId不能为空")
|
|
return
|
|
}
|
|
if len(request.GiftDiamond) == 0 {
|
|
err = errors.New("GiftDiamond不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.GiftCount) == 0 {
|
|
err = errors.New("GiftCount不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.IsBatch) == 0 {
|
|
err = errors.New("IsBatch不能为空")
|
|
return
|
|
}
|
|
|
|
if request.IsBatch != "0" && request.IsBatch != "1" {
|
|
err = errors.New("IsBatch只能是0或1")
|
|
return
|
|
}
|
|
/*
|
|
if request.IsBatch == "0"{
|
|
if len(request.ReceiveUserId) == 0 {
|
|
err = errors.New("ReceiveUserId不能为空")
|
|
return
|
|
}
|
|
}else if request.IsBatch == "1"{
|
|
if len(request.ReceiveUserIds) == 0 {
|
|
err = errors.New("ReceiveUserIds不能为空")
|
|
return
|
|
}
|
|
}*/
|
|
|
|
if htools.StringToInt(request.GiftDiamond) < 0 {
|
|
err = errors.New("GiftDiamond不合法")
|
|
return
|
|
}
|
|
|
|
if htools.StringToInt(request.GiftCount) <= 0 {
|
|
err = errors.New("GiftCount不合法")
|
|
return
|
|
}
|
|
|
|
if request.IsFromGiftBox == "1" {
|
|
if len(request.BoxId) == 0 {
|
|
err = errors.New("背包礼物打赏缺少BoxId")
|
|
return
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 动态/消息 打赏
|
|
type PresentGiftRequest struct {
|
|
BaseRequest
|
|
FromType string // IM TIMELINE
|
|
TimelineId string
|
|
TargetUserId string
|
|
GiftCount string // 礼物数量
|
|
GiftId string
|
|
BoxId string // 背包ID
|
|
IsFromGiftBox string // 是否从礼物盒打赏
|
|
}
|
|
|
|
// 注册用户信息签名验证
|
|
func (request *PresentGiftRequest) CheckParameter() (err error) {
|
|
|
|
if len(request.AccessToken) == 0 {
|
|
err = errors.New("AccessToken不能为空")
|
|
return
|
|
}
|
|
if len(request.FromType) == 0 {
|
|
err = errors.New("打赏方式不能为空")
|
|
return
|
|
}
|
|
if len(request.GiftId) == 0 {
|
|
err = errors.New("GiftId不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.GiftCount) == 0 {
|
|
err = errors.New("GiftCount不能为空")
|
|
return
|
|
}
|
|
|
|
if htools.StringToInt(request.GiftCount) <= 0 {
|
|
err = errors.New("GiftCount不合法")
|
|
return
|
|
}
|
|
|
|
if request.IsFromGiftBox == "1" {
|
|
if len(request.BoxId) == 0 {
|
|
err = errors.New("背包礼物打赏缺少BoxId")
|
|
return
|
|
}
|
|
}
|
|
|
|
if request.FromType == "IM" && len(request.TargetUserId) == 0 {
|
|
err = errors.New("消息打赏缺少目标用户")
|
|
return
|
|
}
|
|
|
|
if request.FromType == "TIMELINE" && len(request.TimelineId) == 0 {
|
|
err = errors.New("动态打赏缺少动态ID")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// 获取动态打赏列表
|
|
type GetTimelinePresentListRequest struct {
|
|
BaseRequest
|
|
TimelineId string
|
|
AnchorId string
|
|
}
|
|
|
|
// 获取动态打赏列表
|
|
func (request *GetTimelinePresentListRequest) GetTimelinePresentListRequest() (err error) {
|
|
|
|
if len(request.AccessToken) == 0 {
|
|
err = errors.New("AccessToken不能为空")
|
|
return
|
|
}
|
|
|
|
if len(request.TimelineId) == 0 {
|
|
err = errors.New("缺少动态ID")
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|