package mediafiller import ( "errors" "service/api/base" "service/api/errcode" "service/app/mix/service" "service/dbstruct" "service/library/configcenter" "service/library/logger" "service/library/mediafiller" mediaproto "service/api/proto/media/proto" "github.com/gin-gonic/gin" ) func Init(cfg *configcenter.ServerInfoConfig) { getImageByIdsFunc := func(ctx *gin.Context, ids []int64) ([]*dbstruct.Image, error) { list, ec := service.DefaultService.GetImageByIds(ctx, &mediaproto.ImageListReq{ BaseRequest: base.BaseRequest{}, Ids: ids, }) if ec != errcode.ErrCodeMediaSrvOk { logger.Error("GetImageByIds fail, ec: %v", ec) return nil, errors.New(errcode.ErrCodeMsgMap[ec]) } return list, nil } getVideoByIdsFunc := func(ctx *gin.Context, ids []int64) ([]*dbstruct.Video, error) { list, ec := service.DefaultService.GetVideoByIds(ctx, &mediaproto.VideoListReq{ BaseRequest: base.BaseRequest{}, Ids: ids, }) if ec != errcode.ErrCodeMediaSrvOk { logger.Error("GetVideoByIds fail, ec: %v", ec) return nil, errors.New(errcode.ErrCodeMsgMap[ec]) } return list, nil } mediafiller.InitDefaultMediaFiller() mediafiller.SetGetImageByIdsFunc(getImageByIdsFunc) mediafiller.SetGetVideoByIdsFunc(getVideoByIdsFunc) mediafiller.SetFileServerDomainName(cfg.FileServerDomainName) }