2024-03-20 10:06:26 +08:00
|
|
|
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"
|
2024-04-05 19:23:36 +08:00
|
|
|
"service/library/mediafiller"
|
2024-03-20 10:06:26 +08:00
|
|
|
|
|
|
|
"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)
|
|
|
|
ReplyErrorMsg(ctx, "server error")
|
|
|
|
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)
|
|
|
|
}
|
2024-04-04 20:48:42 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2024-04-05 19:23:36 +08:00
|
|
|
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)
|
2024-04-04 20:48:42 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2024-04-05 19:23:36 +08:00
|
|
|
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)
|
2024-04-04 20:48:42 +08:00
|
|
|
|
|
|
|
data := &zoneproto.ApiListByMidData{
|
|
|
|
List: list,
|
|
|
|
Offset: req.Offset + len(list),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|
2024-04-12 06:40:30 +08:00
|
|
|
|
|
|
|
func ApiGetZoneListByUserIdFromOutside(ctx *gin.Context) {
|
|
|
|
req := ctx.MustGet("client_req").(*zoneproto.ApiListByUserIdFromOutsideReq)
|
|
|
|
|
|
|
|
//设置默认页长
|
|
|
|
if req.Limit == 0 {
|
|
|
|
req.Limit = consts.DefaultPageSize
|
|
|
|
}
|
|
|
|
|
|
|
|
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),
|
|
|
|
}
|
|
|
|
if len(list) >= req.Limit {
|
|
|
|
data.More = 1
|
|
|
|
}
|
|
|
|
ReplyOk(ctx, data)
|
|
|
|
}
|