From 5a3ebbbb7cc28ccb73e7f3c437837ceb7b0c7d8a Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Fri, 13 Dec 2024 17:42:12 +0800
Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E7=9C=8B?=
 =?UTF-8?q?=E5=8E=9F=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/consts/consts.go                     |  5 ++++
 dbstruct/account.go                      |  7 ++++++
 library/mediafiller/mediafiller.go       | 29 +++++++++++++++++++++---
 library/mediafiller/mediafillerhelper.go |  8 ++++++-
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/api/consts/consts.go b/api/consts/consts.go
index 959919ec..e6425512 100644
--- a/api/consts/consts.go
+++ b/api/consts/consts.go
@@ -79,6 +79,11 @@ const (
 	Deleted = 1 //已删除
 )
 
+const (
+	PermanentMember   = 1 // 会员
+	NoPermanentMember = 0 // 非会员
+)
+
 // 默认login初始化配置
 const (
 	OriginalLoginMid            = -1
diff --git a/dbstruct/account.go b/dbstruct/account.go
index 198c621c..ea5ebc9d 100644
--- a/dbstruct/account.go
+++ b/dbstruct/account.go
@@ -88,6 +88,13 @@ func (p *Account) GetRole() int64 {
 	return *p.Role
 }
 
+func (p *Account) GetIsAMember() int64 {
+	if p == nil || p.IsAMember == nil {
+		return 0
+	}
+	return *p.IsAMember
+}
+
 // StreamerAcct 用户结构
 type StreamerAcct struct {
 	Mid          *int64  `json:"mid" bson:"_id"`                       // 用户表Id
diff --git a/library/mediafiller/mediafiller.go b/library/mediafiller/mediafiller.go
index c1d1bd29..9fd3656a 100644
--- a/library/mediafiller/mediafiller.go
+++ b/library/mediafiller/mediafiller.go
@@ -3,7 +3,9 @@ package mediafiller
 import (
 	"encoding/json"
 	"math/rand"
+	accountproto "service/api/proto/account/proto"
 	"service/api/proto/gateway/proto"
+	"service/app/mix/service/logic"
 	"service/dbstruct"
 	"service/library/logger"
 	"time"
@@ -20,7 +22,10 @@ func init() {
 	rand.Seed(time.Now().Unix())
 }
 
-var defaultMediaFiller *MediaFiller
+var (
+	defaultMediaFiller *MediaFiller
+	_DefaultAccount    *logic.Account
+)
 
 type GetImageByIdsFunc func(ctx *gin.Context, ids []int64) ([]*dbstruct.Image, error)
 type GetVideoByIdsFunc func(ctx *gin.Context, ids []int64) ([]*dbstruct.Video, error)
@@ -91,12 +96,21 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error {
 		return err
 	}
 
+	// 获取用户付费状态
+	account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
+		Mid: &baseReq.Mid,
+	})
+	if err != nil {
+		logger.Error("FillEntity mediafiller component opListByMid failed : %v", err)
+		return err
+	}
+
 	images := make([]*dbstruct.ToCImage, 0)
 	videos := make([]*dbstruct.ToCVideo, 0)
 
 	for _, imageId := range imageIds {
 		if image, ok := imageMap[imageId]; ok {
-			images = append(images, transToCImage(image))
+			images = append(images, transToCImage(image, account.GetIsAMember()))
 		}
 	}
 	for _, videoId := range videoIds {
@@ -151,13 +165,22 @@ func FillList(ctx *gin.Context, list []MediaFillable) error {
 		return err
 	}
 
+	// 获取用户付费状态
+	account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
+		Mid: &baseReq.Mid,
+	})
+	if err != nil {
+		logger.Error("FillEntity mediafiller component opListByMid failed : %v", err)
+		return err
+	}
+
 	for _, v := range list {
 
 		images := make([]*dbstruct.ToCImage, 0)
 		videos := make([]*dbstruct.ToCVideo, 0)
 		for _, imageId := range v.GetImageIds() {
 			if image, ok := imageMap[imageId]; ok {
-				images = append(images, transToCImage(image))
+				images = append(images, transToCImage(image, account.GetIsAMember()))
 			}
 		}
 		for _, videoId := range v.GetVideoIds() {
diff --git a/library/mediafiller/mediafillerhelper.go b/library/mediafiller/mediafillerhelper.go
index 667fec11..fda3839c 100644
--- a/library/mediafiller/mediafillerhelper.go
+++ b/library/mediafiller/mediafillerhelper.go
@@ -1,6 +1,7 @@
 package mediafiller
 
 import (
+	"service/api/consts"
 	"service/dbstruct"
 	"service/library/logger"
 
@@ -42,7 +43,7 @@ func getVideoMapByIds(ctx *gin.Context, ids []int64) (map[int64]*dbstruct.Video,
 }
 
 // todo
-func transToCImage(image *dbstruct.Image) *dbstruct.ToCImage {
+func transToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.ToCImage {
 	if image == nil {
 		return nil
 	}
@@ -50,6 +51,11 @@ func transToCImage(image *dbstruct.Image) *dbstruct.ToCImage {
 	// 选择内存最小的图片
 	imgSrcId := image.SelectMinSizeOssId()
 
+	// 会员可以查看原图
+	if isAMember == consts.PermanentMember {
+		imgSrcId = ""
+	}
+
 	return &dbstruct.ToCImage{
 		Id:   image.Id,
 		W:    image.W,

From bd77e505fbfcc725b24ff57198073f81b3fd39ef Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Wed, 18 Dec 2024 13:34:14 +0800
Subject: [PATCH 2/9] =?UTF-8?q?feat:=E4=BC=9A=E5=91=98=E4=BB=98=E8=B4=B9?=
 =?UTF-8?q?=E7=9C=8B=E5=8E=9F=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/errcode/errcode.go                   |  5 +++
 api/proto/previews/proto/image_api.go    | 20 +++++++++++
 app/mix/controller/image.go              | 25 +++++++++++++
 app/mix/controller/init.go               |  4 +++
 app/mix/service/apiservice.go            | 39 ++++++++++++++++++++
 app/mix/service/logic/image.go           | 45 ++++++++++++++++++++++++
 app/mix/service/service.go               |  1 +
 library/mediafiller/mediafiller.go       | 25 ++-----------
 library/mediafiller/mediafillerhelper.go |  8 +----
 9 files changed, 142 insertions(+), 30 deletions(-)
 create mode 100644 api/proto/previews/proto/image_api.go
 create mode 100644 app/mix/service/logic/image.go

diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go
index 4daf4307..14f55c0d 100644
--- a/api/errcode/errcode.go
+++ b/api/errcode/errcode.go
@@ -151,6 +151,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
 	ErrCodeImageAuditTaskSrvFail:          "图像审核任务服务错误",
 	ErrCodeImageAuditTaskNotExist:         "图像审核任务不存在",
 	ErrCodeImageAuditTaskManuallyPassFail: "图像审核人工通过失败",
+	ErrCodeImageOriginalVipView:           "会员可查看原图",
 
 	ErrCodeTextAuditSrvFail:  "文字审核服务错误",
 	ErrCodeTextAuditNotExist: "文字审核不存在",
@@ -456,6 +457,7 @@ const (
 	ErrCodeImageAuditTaskSrvFail          ErrCode = -21001 // 图像审核任务服务错误
 	ErrCodeImageAuditTaskNotExist         ErrCode = -21002 // 图像审核任务不存在
 	ErrCodeImageAuditTaskManuallyPassFail ErrCode = -21003 // 图像审核人工通过失败
+	ErrCodeImageOriginalVipView           ErrCode = -21004 // 会员可查看原图
 
 	// TextAudit: 22xxx
 	ErrCodeTextAuditSrvOk    ErrCode = ErrCodeOk
@@ -633,4 +635,7 @@ const (
 	ErrCodeRavenIQTestVisitSrvOk    ErrCode = ErrCodeOk
 	ErrCodeRavenIQTestVisitSrvFail  ErrCode = -102001 // 瑞文智商测试访问表服务错误
 	ErrCodeRavenIQTestVisitNotExist ErrCode = -102002 // 瑞文智商测试访问表不存在
+
+	//
+	ErrCodeVip ErrCode = -102003
 )
diff --git a/api/proto/previews/proto/image_api.go b/api/proto/previews/proto/image_api.go
new file mode 100644
index 00000000..1b6fac6a
--- /dev/null
+++ b/api/proto/previews/proto/image_api.go
@@ -0,0 +1,20 @@
+package proto
+
+import (
+	"service/api/base"
+	"service/dbstruct"
+)
+
+type ApiOriginalImageReq struct {
+	base.BaseRequest
+	ImageId int64 `json:"image_id"`
+}
+
+type ApiOriginalImageData struct {
+	Images []*dbstruct.ToCImage `json:"images"`
+}
+
+type ApiOriginalImageResp struct {
+	base.BaseResponse
+	*ApiOriginalImageData `json:"data"`
+}
diff --git a/app/mix/controller/image.go b/app/mix/controller/image.go
index b0b429f8..39426369 100644
--- a/app/mix/controller/image.go
+++ b/app/mix/controller/image.go
@@ -1 +1,26 @@
 package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"service/api/errcode"
+	previewsproto "service/api/proto/previews/proto"
+	"service/app/mix/service"
+	"service/bizcommon/util"
+	"service/library/logger"
+)
+
+func ApiGetOriginalImage(ctx *gin.Context) {
+	req := ctx.MustGet("client_req").(*previewsproto.ApiOriginalImageReq)
+	if req.ImageId <= 0 {
+		logger.Error(" ApiGetOriginalImage, invalid param, req: %v", util.ToJson(req))
+		ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
+	}
+
+	data, err, ec := service.DefaultService.ApiGetOriginalImage(ctx, req)
+	if err != nil {
+		logger.Error("image ApiGetOriginalImage ApiGetOriginalImage err, req: %v", util.ToJson(req))
+		ReplyErrCodeMsg(ctx, ec)
+	}
+
+	ReplyOk(ctx, data)
+}
diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go
index 9261dd43..f1ff910b 100644
--- a/app/mix/controller/init.go
+++ b/app/mix/controller/init.go
@@ -38,6 +38,7 @@ import (
 	loginproto "service/api/proto/login/proto"
 	momentproto "service/api/proto/moment/proto"
 	moment_audit_taskproto "service/api/proto/moment_audit_task/proto"
+	imageproto "service/api/proto/previews/proto"
 	productproto "service/api/proto/product/proto"
 	realname_authenticationproto "service/api/proto/realname_authentication/proto"
 	streamerproto "service/api/proto/streamer/proto"
@@ -318,6 +319,9 @@ func Init(r *gin.Engine) {
 	apiConfigGroup := r.Group("/api/config", PrepareToC())
 	apiConfigGroup.POST("cold_config", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), ColdConfigHandler)
 
+	apiPreviewsGroup := r.Group("/api/previews", PrepareToC())
+	apiPreviewsGroup.POST("original_image", middleware.JSONParamValidator(imageproto.ApiOriginalImageReq{}), middleware.JwtAuthenticator(), ApiGetOriginalImage)
+
 	// =============================== 以下是服务,只允许内网调用 ===============================
 
 	// op相关,直接调用服务,不调用gateway
diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go
index e89937b9..577c4c0c 100644
--- a/app/mix/service/apiservice.go
+++ b/app/mix/service/apiservice.go
@@ -59,6 +59,7 @@ import (
 	"time"
 
 	Raven_IQ_testproto "service/api/proto/Raven_IQ_test/proto"
+	previewsproto "service/api/proto/previews/proto"
 
 	"go.mongodb.org/mongo-driver/mongo"
 	goproto "google.golang.org/protobuf/proto"
@@ -4462,3 +4463,41 @@ func (s *Service) ApiGetRavenIQTestVisitCount(ctx *gin.Context, req *Raven_IQ_te
 	}
 	return
 }
+
+func (s *Service) ApiGetOriginalImage(ctx *gin.Context, req *previewsproto.ApiOriginalImageReq) (*previewsproto.ApiOriginalImageData, error, errcode.ErrCode) {
+	ec := errcode.ErrCodeMediaSrvOk
+	// 获取用户付费状态
+	account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
+		Mid: &req.Mid,
+	})
+	if err != nil {
+		logger.Error("ApiGetOriginalImage failed : %v", err)
+	}
+
+	// 会员可以查看原图
+	if account.GetIsAMember() != consts.PermanentMember {
+		ec = errcode.ErrCodeImageOriginalVipView
+		return nil, nil, ec
+	}
+
+	ids := make([]int64, 0)
+	ids = append(ids, req.ImageId)
+	// 获取图片
+	list, err := _DefaultMedia.GetImageByIds(ctx, ids)
+	if err != nil {
+		logger.Error("ApiGetOriginalImage GetImageByIds fail, req: %v, err: %v", util.ToJson(req), err)
+		ec = errcode.ErrCodeMediaSrvFail
+		return nil, err, ec
+	}
+
+	images := make([]*dbstruct.ToCImage, 0)
+	for _, image := range list {
+		images = append(images, _DefaultImage.TransToCImage(image, account.GetIsAMember()))
+	}
+
+	data := &previewsproto.ApiOriginalImageData{
+		Images: images,
+	}
+
+	return data, err, ec
+}
diff --git a/app/mix/service/logic/image.go b/app/mix/service/logic/image.go
new file mode 100644
index 00000000..9b0c21ea
--- /dev/null
+++ b/app/mix/service/logic/image.go
@@ -0,0 +1,45 @@
+package logic
+
+import (
+	"math/rand"
+	"service/api/consts"
+	"service/app/mix/dao"
+	"service/dbstruct"
+	_ "service/library/logger"
+)
+
+type Image struct {
+	store *dao.Store
+}
+
+func (v *Image) TransToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.ToCImage {
+	if image == nil {
+		return nil
+	}
+
+	// 选择内存最小的图片
+	imgSrcId := image.SelectMinSizeOssId()
+
+	// 会员可以查看原图
+	if isAMember == consts.PermanentMember {
+		imgSrcId = ""
+	}
+
+	return &dbstruct.ToCImage{
+		Id:   image.Id,
+		W:    image.W,
+		H:    image.H,
+		Fmt:  image.Fmt,
+		Urls: []string{v.getFileServerDomain() + imgSrcId},
+	}
+}
+
+func (v *Image) getFileServerDomain() string {
+	return "https://filecdntx01.tiefen.fun/"
+	if rand.Intn(100) < 50 {
+		return "https://filecdntx01.tiefen.fun/"
+	}
+	return "https://filecdn01.tiefen.fun/"
+
+	//return defaultMediaFiller.fileServerDomainName
+}
diff --git a/app/mix/service/service.go b/app/mix/service/service.go
index e624d029..0700ba81 100644
--- a/app/mix/service/service.go
+++ b/app/mix/service/service.go
@@ -155,6 +155,7 @@ var (
 	_DefaultRavenIQTest                    *logic.RavenIQTest
 	_DefaultRavenIQTestVisit               *logic.RavenIQTestVisit
 	_DefaultVeriCodeWrongTimes             *logic.VeriCodeWrongTimes
+	_DefaultImage                          *logic.Image
 
 	_DefaultStreamerDecrtByEs *logic.StreamerDecrtByEs
 	_DefaultZoneDecrtByEs     *logic.ZoneDecrtByEs
diff --git a/library/mediafiller/mediafiller.go b/library/mediafiller/mediafiller.go
index 9fd3656a..a33cb4ff 100644
--- a/library/mediafiller/mediafiller.go
+++ b/library/mediafiller/mediafiller.go
@@ -3,9 +3,7 @@ package mediafiller
 import (
 	"encoding/json"
 	"math/rand"
-	accountproto "service/api/proto/account/proto"
 	"service/api/proto/gateway/proto"
-	"service/app/mix/service/logic"
 	"service/dbstruct"
 	"service/library/logger"
 	"time"
@@ -24,7 +22,6 @@ func init() {
 
 var (
 	defaultMediaFiller *MediaFiller
-	_DefaultAccount    *logic.Account
 )
 
 type GetImageByIdsFunc func(ctx *gin.Context, ids []int64) ([]*dbstruct.Image, error)
@@ -96,21 +93,12 @@ func FillEntity(ctx *gin.Context, entity MediaFillable) error {
 		return err
 	}
 
-	// 获取用户付费状态
-	account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
-		Mid: &baseReq.Mid,
-	})
-	if err != nil {
-		logger.Error("FillEntity mediafiller component opListByMid failed : %v", err)
-		return err
-	}
-
 	images := make([]*dbstruct.ToCImage, 0)
 	videos := make([]*dbstruct.ToCVideo, 0)
 
 	for _, imageId := range imageIds {
 		if image, ok := imageMap[imageId]; ok {
-			images = append(images, transToCImage(image, account.GetIsAMember()))
+			images = append(images, transToCImage(image))
 		}
 	}
 	for _, videoId := range videoIds {
@@ -165,22 +153,13 @@ func FillList(ctx *gin.Context, list []MediaFillable) error {
 		return err
 	}
 
-	// 获取用户付费状态
-	account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
-		Mid: &baseReq.Mid,
-	})
-	if err != nil {
-		logger.Error("FillEntity mediafiller component opListByMid failed : %v", err)
-		return err
-	}
-
 	for _, v := range list {
 
 		images := make([]*dbstruct.ToCImage, 0)
 		videos := make([]*dbstruct.ToCVideo, 0)
 		for _, imageId := range v.GetImageIds() {
 			if image, ok := imageMap[imageId]; ok {
-				images = append(images, transToCImage(image, account.GetIsAMember()))
+				images = append(images, transToCImage(image))
 			}
 		}
 		for _, videoId := range v.GetVideoIds() {
diff --git a/library/mediafiller/mediafillerhelper.go b/library/mediafiller/mediafillerhelper.go
index fda3839c..667fec11 100644
--- a/library/mediafiller/mediafillerhelper.go
+++ b/library/mediafiller/mediafillerhelper.go
@@ -1,7 +1,6 @@
 package mediafiller
 
 import (
-	"service/api/consts"
 	"service/dbstruct"
 	"service/library/logger"
 
@@ -43,7 +42,7 @@ func getVideoMapByIds(ctx *gin.Context, ids []int64) (map[int64]*dbstruct.Video,
 }
 
 // todo
-func transToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.ToCImage {
+func transToCImage(image *dbstruct.Image) *dbstruct.ToCImage {
 	if image == nil {
 		return nil
 	}
@@ -51,11 +50,6 @@ func transToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.ToCImage {
 	// 选择内存最小的图片
 	imgSrcId := image.SelectMinSizeOssId()
 
-	// 会员可以查看原图
-	if isAMember == consts.PermanentMember {
-		imgSrcId = ""
-	}
-
 	return &dbstruct.ToCImage{
 		Id:   image.Id,
 		W:    image.W,

From 1f4e2c1109f3be318929fc02a41886bf20b2cbed Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Wed, 18 Dec 2024 14:24:03 +0800
Subject: [PATCH 3/9] =?UTF-8?q?fix:=20=E5=90=88=E4=BB=A3=E7=A0=81=E9=97=AE?=
 =?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/mix/service/logic/image.go | 1 -
 1 file changed, 1 deletion(-)

diff --git a/app/mix/service/logic/image.go b/app/mix/service/logic/image.go
index 9b0c21ea..deece129 100644
--- a/app/mix/service/logic/image.go
+++ b/app/mix/service/logic/image.go
@@ -40,6 +40,5 @@ func (v *Image) getFileServerDomain() string {
 		return "https://filecdntx01.tiefen.fun/"
 	}
 	return "https://filecdn01.tiefen.fun/"
-
 	//return defaultMediaFiller.fileServerDomainName
 }

From 9d565991291c091fbb705d11ed8a5f95ecf1ccc3 Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Wed, 18 Dec 2024 14:37:08 +0800
Subject: [PATCH 4/9] =?UTF-8?q?fix:=20=E5=90=88=E4=BB=A3=E7=A0=81=E9=97=AE?=
 =?UTF-8?q?=E9=A2=982?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/mix/service/apiservice.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go
index 577c4c0c..8ef603d2 100644
--- a/app/mix/service/apiservice.go
+++ b/app/mix/service/apiservice.go
@@ -4482,6 +4482,7 @@ func (s *Service) ApiGetOriginalImage(ctx *gin.Context, req *previewsproto.ApiOr
 
 	ids := make([]int64, 0)
 	ids = append(ids, req.ImageId)
+
 	// 获取图片
 	list, err := _DefaultMedia.GetImageByIds(ctx, ids)
 	if err != nil {

From edcb966903924f3e1f1451afae008db80b8a411c Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Wed, 18 Dec 2024 14:59:55 +0800
Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=E5=8E=9F=E5=9B=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/mix/service/logic/image.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/mix/service/logic/image.go b/app/mix/service/logic/image.go
index deece129..3797270b 100644
--- a/app/mix/service/logic/image.go
+++ b/app/mix/service/logic/image.go
@@ -22,7 +22,7 @@ func (v *Image) TransToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.
 
 	// 会员可以查看原图
 	if isAMember == consts.PermanentMember {
-		imgSrcId = ""
+		imgSrcId = image.SrcId
 	}
 
 	return &dbstruct.ToCImage{

From ea97628dedaeaa4e7b14009e5d82a2b155f0e476 Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Fri, 20 Dec 2024 17:11:39 +0800
Subject: [PATCH 6/9] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E7=9C=8B=E5=8E=9F?=
 =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=84=E4=BF=AE?=
 =?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/proto/previews/proto/image_api.go | 4 ++--
 app/mix/controller/image.go           | 8 ++++++++
 app/mix/service/apiservice.go         | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/api/proto/previews/proto/image_api.go b/api/proto/previews/proto/image_api.go
index 1b6fac6a..11218582 100644
--- a/api/proto/previews/proto/image_api.go
+++ b/api/proto/previews/proto/image_api.go
@@ -11,10 +11,10 @@ type ApiOriginalImageReq struct {
 }
 
 type ApiOriginalImageData struct {
-	Images []*dbstruct.ToCImage `json:"images"`
+	*dbstruct.ToCImage
 }
 
 type ApiOriginalImageResp struct {
 	base.BaseResponse
-	*ApiOriginalImageData `json:"data"`
+	Data *ApiOriginalImageData `json:"data"`
 }
diff --git a/app/mix/controller/image.go b/app/mix/controller/image.go
index 39426369..db6b50ad 100644
--- a/app/mix/controller/image.go
+++ b/app/mix/controller/image.go
@@ -14,12 +14,20 @@ func ApiGetOriginalImage(ctx *gin.Context) {
 	if req.ImageId <= 0 {
 		logger.Error(" ApiGetOriginalImage, invalid param, req: %v", util.ToJson(req))
 		ReplyErrCodeMsg(ctx, errcode.ErrCodeBadParam)
+		return
 	}
 
 	data, err, ec := service.DefaultService.ApiGetOriginalImage(ctx, req)
 	if err != nil {
 		logger.Error("image ApiGetOriginalImage ApiGetOriginalImage err, req: %v", util.ToJson(req))
 		ReplyErrCodeMsg(ctx, ec)
+		return
+	}
+
+	if ec == errcode.ErrCodeImageOriginalVipView {
+		logger.Info("ApiGetOriginalImage user is not vip, req: %v", util.ToJson(req))
+		ReplyErrCodeMsg(ctx, errcode.ErrCodeImageOriginalVipView)
+		return
 	}
 
 	ReplyOk(ctx, data)
diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go
index 8ef603d2..c94d2145 100644
--- a/app/mix/service/apiservice.go
+++ b/app/mix/service/apiservice.go
@@ -4497,7 +4497,7 @@ func (s *Service) ApiGetOriginalImage(ctx *gin.Context, req *previewsproto.ApiOr
 	}
 
 	data := &previewsproto.ApiOriginalImageData{
-		Images: images,
+		ToCImage: images[0],
 	}
 
 	return data, err, ec

From b89fd9638b9b0e5cdf47bb3e1adab58097e80803 Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Mon, 23 Dec 2024 17:18:21 +0800
Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=E5=9B=BE=E7=89=87=E9=93=BE=E6=8E=A5?=
 =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/errcode/errcode.go         | 2 --
 app/mix/service/logic/image.go | 8 +-------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go
index 14f55c0d..cf872162 100644
--- a/api/errcode/errcode.go
+++ b/api/errcode/errcode.go
@@ -636,6 +636,4 @@ const (
 	ErrCodeRavenIQTestVisitSrvFail  ErrCode = -102001 // 瑞文智商测试访问表服务错误
 	ErrCodeRavenIQTestVisitNotExist ErrCode = -102002 // 瑞文智商测试访问表不存在
 
-	//
-	ErrCodeVip ErrCode = -102003
 )
diff --git a/app/mix/service/logic/image.go b/app/mix/service/logic/image.go
index 3797270b..c6f15f36 100644
--- a/app/mix/service/logic/image.go
+++ b/app/mix/service/logic/image.go
@@ -1,7 +1,6 @@
 package logic
 
 import (
-	"math/rand"
 	"service/api/consts"
 	"service/app/mix/dao"
 	"service/dbstruct"
@@ -35,10 +34,5 @@ func (v *Image) TransToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.
 }
 
 func (v *Image) getFileServerDomain() string {
-	return "https://filecdntx01.tiefen.fun/"
-	if rand.Intn(100) < 50 {
-		return "https://filecdntx01.tiefen.fun/"
-	}
-	return "https://filecdn01.tiefen.fun/"
-	//return defaultMediaFiller.fileServerDomainName
+	return "https://levianderwinv01.tiefen.space/"
 }

From ec7b7adf61fb99ad1918de319c6445d8c9728e91 Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Tue, 24 Dec 2024 11:44:24 +0800
Subject: [PATCH 8/9] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E7=9C=8B=E5=8E=9F?=
 =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E5=9B=BE=E7=89=87=E6=A0=BC=E5=BC=8F=E5=88=A4?=
 =?UTF-8?q?=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/consts/consts.go           | 10 ++++++++++
 app/mix/service/logic/image.go |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/api/consts/consts.go b/api/consts/consts.go
index e6425512..f16e3953 100644
--- a/api/consts/consts.go
+++ b/api/consts/consts.go
@@ -104,6 +104,16 @@ const (
 	RedisMomentPrefix   = "moment:"   //moment服务前缀
 )
 
+const (
+	ImageTiff = "image_tiff"
+	ImageWebp = "image/webp"
+	ImageHeic = "image/heic"
+	ImageJpeg = "image/jpeg"
+	ImageGif  = "image/gif"
+	ImagePng  = "image/png"
+	VideoMp4  = "video/mp4"
+)
+
 //const PackageRootPath = "C:/Users/PC/Desktop/service"
 
 const PackageRootPath = "/app/wishpal-ironfan"
diff --git a/app/mix/service/logic/image.go b/app/mix/service/logic/image.go
index c6f15f36..7daff27e 100644
--- a/app/mix/service/logic/image.go
+++ b/app/mix/service/logic/image.go
@@ -20,7 +20,7 @@ func (v *Image) TransToCImage(image *dbstruct.Image, isAMember int64) *dbstruct.
 	imgSrcId := image.SelectMinSizeOssId()
 
 	// 会员可以查看原图
-	if isAMember == consts.PermanentMember {
+	if isAMember == consts.PermanentMember && (image.Fmt == consts.ImageWebp || image.Fmt == consts.ImageJpeg || image.Fmt == consts.ImagePng) {
 		imgSrcId = image.SrcId
 	}
 

From 324401de4a3a99d7bcf8d5b4df0bbfde292942db Mon Sep 17 00:00:00 2001
From: wangxinyu <wangxinyu4585@163.com>
Date: Tue, 24 Dec 2024 12:06:44 +0800
Subject: [PATCH 9/9] =?UTF-8?q?fix:=20=E4=BC=9A=E5=91=98=E7=9C=8B=E5=8E=9F?=
 =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E5=88=A4=E7=A9=BA=E5=92=8C=E8=BF=94=E5=9B=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 api/errcode/errcode.go        | 9 +++++++--
 app/mix/service/apiservice.go | 7 +++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/api/errcode/errcode.go b/api/errcode/errcode.go
index cf872162..ce1e981d 100644
--- a/api/errcode/errcode.go
+++ b/api/errcode/errcode.go
@@ -151,7 +151,6 @@ var ErrCodeMsgMap = map[ErrCode]string{
 	ErrCodeImageAuditTaskSrvFail:          "图像审核任务服务错误",
 	ErrCodeImageAuditTaskNotExist:         "图像审核任务不存在",
 	ErrCodeImageAuditTaskManuallyPassFail: "图像审核人工通过失败",
-	ErrCodeImageOriginalVipView:           "会员可查看原图",
 
 	ErrCodeTextAuditSrvFail:  "文字审核服务错误",
 	ErrCodeTextAuditNotExist: "文字审核不存在",
@@ -262,6 +261,9 @@ var ErrCodeMsgMap = map[ErrCode]string{
 
 	ErrCodeRavenIQTestVisitSrvFail:  "瑞文智商测试访问表服务错误",
 	ErrCodeRavenIQTestVisitNotExist: "瑞文智商测试访问表不存在",
+
+	ErrCodeImageOriginalVipView: "会员可查看原图",
+	ErrCodeImageAlreadyOriginal: "当前已经是原图",
 }
 
 const (
@@ -457,7 +459,6 @@ const (
 	ErrCodeImageAuditTaskSrvFail          ErrCode = -21001 // 图像审核任务服务错误
 	ErrCodeImageAuditTaskNotExist         ErrCode = -21002 // 图像审核任务不存在
 	ErrCodeImageAuditTaskManuallyPassFail ErrCode = -21003 // 图像审核人工通过失败
-	ErrCodeImageOriginalVipView           ErrCode = -21004 // 会员可查看原图
 
 	// TextAudit: 22xxx
 	ErrCodeTextAuditSrvOk    ErrCode = ErrCodeOk
@@ -636,4 +637,8 @@ const (
 	ErrCodeRavenIQTestVisitSrvFail  ErrCode = -102001 // 瑞文智商测试访问表服务错误
 	ErrCodeRavenIQTestVisitNotExist ErrCode = -102002 // 瑞文智商测试访问表不存在
 
+	// Image
+	ErrCodeImageOriginalVipView ErrCode = -103001 // 会员可查看原图
+	ErrCodeImageAlreadyOriginal ErrCode = -103002 // 已经是原图
+
 )
diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go
index c94d2145..ea8e6738 100644
--- a/app/mix/service/apiservice.go
+++ b/app/mix/service/apiservice.go
@@ -4471,7 +4471,9 @@ func (s *Service) ApiGetOriginalImage(ctx *gin.Context, req *previewsproto.ApiOr
 		Mid: &req.Mid,
 	})
 	if err != nil {
+		ec = errcode.ErrCodeImageAlreadyOriginal
 		logger.Error("ApiGetOriginalImage failed : %v", err)
+		return nil, err, ec
 	}
 
 	// 会员可以查看原图
@@ -4490,6 +4492,11 @@ func (s *Service) ApiGetOriginalImage(ctx *gin.Context, req *previewsproto.ApiOr
 		ec = errcode.ErrCodeMediaSrvFail
 		return nil, err, ec
 	}
+	if len(list) == 0 {
+		ec = errcode.ErrCodeImageAlreadyOriginal
+		logger.Error("ApiGetOriginalImage list len is 0, req: %v", util.ToJson(req))
+		return nil, nil, ec
+	}
 
 	images := make([]*dbstruct.ToCImage, 0)
 	for _, image := range list {