214 lines
12 KiB
Go
214 lines
12 KiB
Go
package service
|
||
|
||
import (
|
||
"encoding/json"
|
||
"net/http"
|
||
)
|
||
|
||
type GetAliveListRequest struct {
|
||
AlivePlayState *int `json:"alive_play_state,omitempty"` // 直播状态:-1全部,0未开始,1直播中,2已结束;默认0
|
||
SearchAliveType *int `json:"search_alive_type,omitempty"` // 直播模式:-1全部,10横屏,11竖屏,12语音,13录播;默认(文档未明确,建议传-1或0)
|
||
SearchContent *string `json:"search_content,omitempty"` // 直播名称关键字
|
||
CreateMode *int `json:"create_mode,omitempty"` // 创建类型 -1全部 0店铺课程 1转播;默认0
|
||
State *int `json:"state,omitempty"` // 上架状态: -1全部,0已上架,1已下架,2待上架;默认0
|
||
ZbStartAtMin *string `json:"zb_start_at_min,omitempty"` // 直播开始时间-最小值
|
||
ZbStartAtMax *string `json:"zb_start_at_max,omitempty"` // 直播开始时间-最大值
|
||
TagIds []int `json:"tag_ids,omitempty"` // 商品分组ID数组
|
||
Page *int `json:"page,omitempty"` // 页码,默认1
|
||
PageSize *int `json:"page_size,omitempty"` // 每页条数,最大50,默认10
|
||
IsGetThumbs *int `json:"is_get_thumbs,omitempty"` // 是否需要获取点赞数 0:否 1:是
|
||
}
|
||
|
||
type Alive struct {
|
||
AppId string `json:"app_id"` // 店铺ID
|
||
Id string `json:"id"` // 直播ID
|
||
RoomId string `json:"room_id"` // 房间ID
|
||
Title string `json:"title"` // 直播标题
|
||
ImgUrl string `json:"img_url"` // 直播封面图
|
||
PageUrl string `json:"page_url"` // 页面url
|
||
ImgUrlCompressed string `json:"img_url_compressed"` // 封面压缩后的路径
|
||
CommentCount int `json:"comment_count"` // 评论数量
|
||
IsTakegoods int `json:"is_takegoods"` // 带货开关:1开,0关
|
||
Takegoods string `json:"takegoods"` // 带货商品分组ID
|
||
PaymentType int `json:"payment_type"` // 付费类型:1-免费、2-单笔、3-付费产品包
|
||
IsPublic int `json:"is_public"` // 是否公开售卖,1公开,0不公开
|
||
IsStopSell int `json:"is_stop_sell"` // 是否停售,0-否、1-是
|
||
IsTranscode int `json:"is_transcode"` // 视频是否转码,0未转码,1已转码,2转码失败
|
||
PiecePrice int `json:"piece_price"` // 单笔价格或专栏价格(分)
|
||
LinePrice int `json:"line_price"` // 划线价(分)
|
||
HavePassword int `json:"have_password"` // 该资源是否需要密码
|
||
AliveType int `json:"alive_type"` // 直播类型:0-语音,1-视频,2-推流,3-ppt
|
||
PurchaseCount int `json:"purchase_count"` // 订阅量
|
||
RewardSum int `json:"reward_sum"` // 打赏金额
|
||
IsBan int `json:"is_ban"` // 强制封禁:0-否 1-是
|
||
OnShelf int `json:"on_shelf"` // 强制下架:0-否 1-是
|
||
RecycleBinState int `json:"recycle_bin_state"` // 上下架状态:0-上架,1-下架
|
||
PushState int `json:"push_state"` // 推流状态:0断流,1推流中,2推流未开始
|
||
State int `json:"state"` // 直播状态:0-可见,1-关闭,2-删除
|
||
StartAt string `json:"start_at"` // 上架时间
|
||
ZbStartAt string `json:"zb_start_at"` // 直播开始时间
|
||
ManualStopAt string `json:"manual_stop_at"` // 手动结束直播时间
|
||
SourceShopName string `json:"source_shop_name"` // 转播店铺名称
|
||
MaterialState int `json:"material_state"` // 素材状态
|
||
VideoLength int `json:"video_length"` // 视频时长(秒)
|
||
AliveState int `json:"alive_state"` // 直播状态
|
||
AliveMode int `json:"alive_mode"` // 直播模式:0传统横屏,1竖屏直播(沉浸全屏)
|
||
CreateMode int `json:"create_mode"` // 创建类型:0-自创建,1-转播创建
|
||
IsRoundTableOn int `json:"is_round_table_on"` // 圆桌会议功能是否开启
|
||
QueryPackageList string `json:"query_package_list"` // 关联商品(可能为JSON字符串)
|
||
CourseExpire CourseExpire `json:"course_expire"` // 售卖有效期
|
||
LikeNum int `json:"like_num"` // 直播点赞数
|
||
}
|
||
|
||
// CourseExpire 售卖有效期
|
||
type CourseExpire struct {
|
||
PeriodType int `json:"period_type"` // 有效期类型:0永久,1固定,2自定义
|
||
PeriodValue string `json:"period_value"` // 自定义有效时长
|
||
IsAllowRepeatPurchase int `json:"is_allow_repeat_purchase"` // 是否允许重复购买:1是,0否
|
||
}
|
||
|
||
type GetAliveListResponseData struct {
|
||
TotalCount int `json:"total_count"`
|
||
LiveList []Alive `json:"live_list"`
|
||
}
|
||
|
||
type GetAliveListResponse struct {
|
||
BaseResponse
|
||
|
||
Data GetAliveListResponseData `json:"data"`
|
||
}
|
||
|
||
type GetAliveDetailRequest struct {
|
||
Id string `json:"id"`
|
||
}
|
||
|
||
// ResourceInfo 资源信息
|
||
type ResourceInfo struct {
|
||
AppId string `json:"app_id"` // 店铺id
|
||
Id string `json:"id"` // 直播ID
|
||
Title string `json:"title"` // 直播标题
|
||
Summary string `json:"summary"` // 直播简介
|
||
Descrb string `json:"descrb"` // 直播详情(纯文本)
|
||
AliveType int `json:"alive_type"` // 直播类型:0-语音,1-录播直播,2-推流直播
|
||
AliveState int `json:"alive_state"` // 直播状态:0-未开始,1-直播中,2-已结束
|
||
State int `json:"state"` // 删除状态:0-可见,1-关闭,2-删除
|
||
PushState int `json:"push_state"` // 推流状态:0-断流,1-推流中,2-推流未开始
|
||
IsTranscode int `json:"is_transcode"` // 转码状态:0-转码中,1-转码完成,2-转码失败
|
||
ManualStopAt string `json:"manual_stop_at"` // 手动结束时间
|
||
ZbStartAt string `json:"zb_start_at"` // 预设直播开始时间
|
||
ZbStopAt int `json:"zb_stop_at"` // 预设直播时长(秒)
|
||
ImgMaterialId string `json:"img_material_id"` // 详情封面图素材ID
|
||
AliveImgMaterialId string `json:"alive_img_material_id"` // 宣传封面图素材ID
|
||
AliveroomImgMaterialId string `json:"aliveroom_img_material_id"` // 暖场封面图素材ID
|
||
WarmUpVideoCoverMaterialId string `json:"warm_up_video_cover_material_id"` // 暖场视频封面图素材ID
|
||
WarmUpVideoMaterialId string `json:"warm_up_video_material_id"` // 暖场视频素材ID
|
||
AliveVideoMaterialId string `json:"alive_video_material_id"` // 录播视频素材ID
|
||
IosAppletDesc IosAppletDesc `json:"ios_applet_desc"` // 苹果端小程序信息调整
|
||
}
|
||
|
||
// IosAppletDesc 苹果端小程序信息
|
||
type IosAppletDesc struct {
|
||
Title string `json:"title"` // 直播标题
|
||
Summary string `json:"summary"` // 直播简介
|
||
Descrb string `json:"descrb"` // 直播详情
|
||
State int `json:"state"` // 显示设置:0-显示,1-不显示
|
||
ImgMaterialId string `json:"img_material_id"` // 直播封面链接素材ID
|
||
AliveImgMaterialId string `json:"alive_img_material_id"` // 宣传封面图素材ID
|
||
}
|
||
|
||
// ModuleInfo 配置信息
|
||
type ModuleInfo struct {
|
||
IsLookback int `json:"is_lookback"` // 是否开启回放:0-开启,1-关闭
|
||
PlayFastStateSwitch int `json:"play_fast_state_switch"` // 回放是否允许倍速/快进:0-允许,1-禁止
|
||
AliveMode int `json:"alive_mode"` // 直播模式:0-横屏,1-竖屏
|
||
ExpireType int `json:"expire_type"` // 回放有效期设置:1-永久,2-限时
|
||
Expire string `json:"expire"` // 回放过期时间
|
||
WarmUp int `json:"warm_up"` // 暖场设置:1-暖场图,2-暖场视频
|
||
IsOpenCompleteTime int `json:"is_open_complete_time"` // 是否开启完成条件:0-关闭,1-开启
|
||
CompleteTime int `json:"complete_time"` // 最短学习时间(分钟)
|
||
IsContactOn int `json:"is_contact_on"` // 是否开启联系学员:0-关闭,1-开启
|
||
}
|
||
|
||
// GoodsInfo 商品信息
|
||
type GoodsInfo struct {
|
||
SaleType int `json:"sale_type"` // 售卖类型:1-单独售卖,2-关联售卖
|
||
PaymentType int `json:"payment_type"` // 支付类型:1-免费,2-收费,3-加密,4-指定学员,5-仅关联上级
|
||
PiecePrice int `json:"piece_price"` // 价格(分)
|
||
LinePrice int `json:"line_price"` // 划线价(分)
|
||
ResourcePassword string `json:"resource_password"` // 密码
|
||
RecycleBinState int `json:"recycle_bin_state"` // 上下架:1-下架,0-上架
|
||
StartAt string `json:"start_at"` // 定时上架时间
|
||
IsStopSell int `json:"is_stop_sell"` // 是否停售:0-否,1-是
|
||
GoodsSn string `json:"goods_sn"` // 商品编码
|
||
State int `json:"state"` // 商品状态:0-可见,1-隐藏,2-删除
|
||
}
|
||
|
||
// RelationInfo 关联信息
|
||
type RelationInfo struct {
|
||
Package []string `json:"package"` // 资源id数组
|
||
AttachGoods []string `json:"attach_goods"` // 预留字段
|
||
Tags []string `json:"tags"` // 预留字段
|
||
}
|
||
|
||
// RoleInfoItem 讲师信息
|
||
type RoleInfoItem struct {
|
||
RoleName string `json:"role_name"` // 自定义身份标签
|
||
UserId string `json:"user_id"` // 用户id
|
||
Nickname string `json:"nickname"` // 用户昵称
|
||
Avator string `json:"avator"` // 用户头像
|
||
IsCanExceptional int `json:"is_can_exceptional"` // 是否接受打赏:1-接受,0-不接受
|
||
}
|
||
type GetAliveDetailResponseData struct {
|
||
ResourceInfo ResourceInfo `json:"resource_info"` // 资源信息
|
||
ModuleInfo ModuleInfo `json:"module_info"` // 配置信息
|
||
GoodsInfo GoodsInfo `json:"goods_info"` // 商品信息
|
||
RelationInfo RelationInfo `json:"relation_info"` // 关联信息
|
||
RoleInfo []RoleInfoItem `json:"role_info"` // 讲师信息列表
|
||
}
|
||
type GetAliveDetailResponse struct {
|
||
BaseResponse
|
||
|
||
Data GetAliveDetailResponseData `json:"data"`
|
||
}
|
||
|
||
// MARK 获取直播列表
|
||
func (client *Client) GetAliveList(req *GetAliveListRequest) (*GetAliveListResponse, error) {
|
||
paramsMap, err := ToMap(req)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
respByte, err := client.CurlDo(http.MethodPost, GetAliveListUrl, paramsMap)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
resp := GetAliveListResponse{}
|
||
err = json.Unmarshal(respByte, &resp)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return &resp, nil
|
||
}
|
||
|
||
// MARK 获取直播详情
|
||
func (client *Client) GetAliveDetail(req *GetAliveDetailRequest) (*GetAliveDetailResponse, error) {
|
||
paramsMap, err := ToMap(req)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
respByte, err := client.CurlDo(http.MethodPost, GetAliveDetailUrl, paramsMap)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
resp := GetAliveDetailResponse{}
|
||
err = json.Unmarshal(respByte, &resp)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
return &resp, nil
|
||
}
|