package controller import ( "service/api/consts" "service/api/errcode" streamerproto "service/api/proto/streamer/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "service/library/mediafiller" "github.com/gin-gonic/gin" ) func ApiUpdateStreamer(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiUpdateReq) ec := service.DefaultService.ApiUpdateStreamer(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpUpdateStreamer fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ApiGetStreamerListByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListByMidReq) streamer, ec := service.DefaultService.ApiGetStreamerListByMid(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 mediaFillableList := make([]mediafiller.MediaFillable, 3) mediaFillableList[0] = streamer.Cover mediaFillableList[1] = streamer.Shorts mediaFillableList[2] = streamer.Album mediafiller.FillList(ctx, mediaFillableList) data := &streamerproto.ApiListByMidData{ Streamer: streamer, } ReplyOk(ctx, data) } func ApiGetStreamerExtListByMid(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListExtByMidReq) data, ec := service.DefaultService.ApiGetStreamerExtListByMid(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerExtListByMid fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 mediaFillableList := make([]mediafiller.MediaFillable, 4) mediaFillableList[0] = data.StreamerExt.Avatar mediaFillableList[1] = data.StreamerExt.Cover mediaFillableList[2] = data.StreamerExt.Shorts mediaFillableList[3] = data.StreamerExt.Album mediafiller.FillList(ctx, mediaFillableList) ReplyOk(ctx, data) } func ApiGetStreamerExtListByMids(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListExtByMidsReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.ApiGetStreamerExtListByMids(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerExtListByMids fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 objectMediaNum := 4 // 单个主播服务总共4个媒体类 mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) for i, vo := range list { mediaFillableList[objectMediaNum*i+0] = vo.Avatar mediaFillableList[objectMediaNum*i+1] = vo.Cover mediaFillableList[objectMediaNum*i+2] = vo.Shorts mediaFillableList[objectMediaNum*i+3] = vo.Album } mediafiller.FillList(ctx, mediaFillableList) data := &streamerproto.ApiListExtByMidsData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func ApiGetStreamerExtListByUserId(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListExtByUserIdReq) data, ec := service.DefaultService.ApiGetStreamerExtListByUserId(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerExtListByUserId fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 mediaFillableList := make([]mediafiller.MediaFillable, 4) mediaFillableList[0] = data.StreamerExt.Avatar mediaFillableList[1] = data.StreamerExt.Cover mediaFillableList[2] = data.StreamerExt.Shorts mediaFillableList[3] = data.StreamerExt.Album mediafiller.FillList(ctx, mediaFillableList) ReplyOk(ctx, data) } func ApiGetStreamerExtListFuzzilyByUserId(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListExtFuzzilyByUserIdReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.ApiGetStreamerExtListFuzzilyByUserId(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerExtListFuzzilyByUserId fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 objectMediaNum := 4 // 单个主播服务总共4个媒体类 mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) for i, vo := range list { mediaFillableList[objectMediaNum*i+0] = vo.Avatar mediaFillableList[objectMediaNum*i+1] = vo.Cover mediaFillableList[objectMediaNum*i+2] = vo.Shorts mediaFillableList[objectMediaNum*i+3] = vo.Album } mediafiller.FillList(ctx, mediaFillableList) data := &streamerproto.ApiListExtFuzzilyByUserIdData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func ApiGetStreamerExtListFuzzilyByName(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListExtFuzzilyByNameReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.ApiGetStreamerExtListFuzzilyByName(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerExtListFuzzilyByName fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 objectMediaNum := 4 // 单个主播服务总共4个媒体类 mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) for i, vo := range list { mediaFillableList[objectMediaNum*i+0] = vo.Avatar mediaFillableList[objectMediaNum*i+1] = vo.Cover mediaFillableList[objectMediaNum*i+2] = vo.Shorts mediaFillableList[objectMediaNum*i+3] = vo.Album } mediafiller.FillList(ctx, mediaFillableList) data := &streamerproto.ApiListExtFuzzilyByUserIdData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func ApiGetStreamerWxId(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiListStreamerWxIdReq) wxIdVO, ec := service.DefaultService.ApiGetStreamerWxId(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerWxId fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &streamerproto.ApiListStreamerWxIdData{ WxIdVO: wxIdVO, } ReplyOk(ctx, data) } func ApiGetStreamerRecommList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*streamerproto.ApiRecommListReq) list, ec := service.DefaultService.ApiGetStreamerRecommList(ctx, req) if ec != errcode.ErrCodeStreamerSrvOk { logger.Error("OpGetStreamerRecommList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } objectMediaNum := 4 // 单个主播服务总共4个媒体类 mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum) for i, vo := range list { mediaFillableList[objectMediaNum*i+0] = vo.Avatar mediaFillableList[objectMediaNum*i+1] = vo.Cover mediaFillableList[objectMediaNum*i+2] = vo.Shorts mediaFillableList[objectMediaNum*i+3] = vo.Album } mediafiller.FillList(ctx, mediaFillableList) data := &streamerproto.ApiRecommListData{ RecommList: list, } ReplyOk(ctx, data) }