184 lines
5.3 KiB
Go
184 lines
5.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/api/errcode"
|
|
zoneproto "service/api/proto/zone/proto"
|
|
"service/app/mix/service"
|
|
"service/bizcommon/util"
|
|
"service/library/logger"
|
|
"service/library/mediafiller"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ApiCreateZone(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiCreateReq)
|
|
ec := service.DefaultService.ApiCreateZone(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiCreateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiUpdateZone(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiUpdateReq)
|
|
ec := service.DefaultService.ApiUpdateZone(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiUpdateZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiDeleteZone(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiDeleteReq)
|
|
ec := service.DefaultService.ApiDeleteZone(ctx, req.Id)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiDeleteZone fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
ReplyOk(ctx, nil)
|
|
}
|
|
|
|
func ApiGetZoneList(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiListReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.ApiGetZoneList(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiGetZoneList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
|
|
data := &zoneproto.ApiListData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiGetZoneListByVisitorMid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiListByVisitorMidReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
list, ec := service.DefaultService.ApiGetZoneListByVisitorMid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiGetZoneList fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
objectMediaNum := 5 // 单个空间服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.Previews
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
data := &zoneproto.ApiListByVisitorMidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiGetZoneListByMid(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiListByMidReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
refundEnable, refundStatus, list, ec := service.DefaultService.ApiGetZoneListByMid(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiGetZoneListByMid fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
objectMediaNum := 5 // 单个空间服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.Previews
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
data := &zoneproto.ApiListByMidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
RefundEnable: refundEnable,
|
|
RefundStatus: refundStatus,
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|
|
|
|
func ApiGetZoneListByUserIdFromOutside(ctx *gin.Context) {
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiListByUserIdFromOutsideReq)
|
|
|
|
//设置默认页长
|
|
if req.Limit == 0 {
|
|
req.Limit = consts.DefaultPageSize
|
|
}
|
|
|
|
refundEnable, refundStatus, list, ec := service.DefaultService.ApiGetZoneListByUserIdFromOutside(ctx, req)
|
|
if ec != errcode.ErrCodeZoneSrvOk {
|
|
logger.Error("ApiGetZoneListByUserIdFromOutside fail, req: %v, ec: %v", util.ToJson(req), ec)
|
|
ReplyErrCodeMsg(ctx, ec)
|
|
return
|
|
}
|
|
objectMediaNum := 5 // 单个空间服务总共5个媒体类
|
|
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
|
|
for i, vo := range list {
|
|
mediaFillableList[objectMediaNum*i+0] = vo.Previews
|
|
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
|
|
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
|
|
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
|
|
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
|
|
}
|
|
mediafiller.FillList(ctx, mediaFillableList)
|
|
|
|
data := &zoneproto.ApiListByMidData{
|
|
List: list,
|
|
Offset: req.Offset + len(list),
|
|
RefundEnable: refundEnable,
|
|
RefundStatus: refundStatus,
|
|
}
|
|
if len(list) >= req.Limit {
|
|
data.More = 1
|
|
}
|
|
ReplyOk(ctx, data)
|
|
}
|