diff --git a/app/hdl/friend_circle/hdl_friend_circle.go b/app/hdl/friend_circle/hdl_friend_circle.go index bce892c..05c6125 100644 --- a/app/hdl/friend_circle/hdl_friend_circle.go +++ b/app/hdl/friend_circle/hdl_friend_circle.go @@ -19,6 +19,7 @@ import ( "github.com/gin-gonic/gin" "github.com/olivere/elastic/v7" "strconv" + "strings" "time" ) @@ -245,9 +246,11 @@ func Publish(c *gin.Context) { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } + scheme, domain := svc.ImageBucket(db.Db) var imageStr string if len(req.ImageList) > 0 { imageStr = utils.SerializeStr(req.ImageList) + imageStr = strings.ReplaceAll(imageStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}") } //插入es记录 @@ -311,7 +314,7 @@ func Publish(c *gin.Context) { // RecommendList // @Summary 朋友圈-推荐列表 // @Tags 朋友圈 -// @Description 我的朋友圈列表 +// @Description 推荐列表 // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" diff --git a/app/md/friend_circles/md_friend_circle.go b/app/md/friend_circles/md_friend_circle.go index a4d0a20..f5dbc11 100644 --- a/app/md/friend_circles/md_friend_circle.go +++ b/app/md/friend_circles/md_friend_circle.go @@ -6,10 +6,10 @@ type RecommendListReq struct { } type RecommendListResp struct { - Page int `json:"page"` // 页码 - PageSize int `json:"page_size"` // 每页数量 - Total int64 `json:"total"` // 总量 - List []*EggFriendCircleEsStruct `json:"list"` + Page int `json:"page"` // 页码 + PageSize int `json:"page_size"` // 每页数量 + Total int64 `json:"total"` // 总量 + List []*EggFriendCircleRespStruct `json:"list"` } type FriendCircleLikeListReq struct { @@ -55,10 +55,10 @@ type PersonalSendingListReq struct { } type PersonalSendingListResp struct { - Page int `json:"page"` // 页码 - PageSize int `json:"page_size"` // 每页数量 - Total int64 `json:"total"` // 总量 - List []*EggFriendCircleEsStruct `json:"list"` + Page int `json:"page"` // 页码 + PageSize int `json:"page_size"` // 每页数量 + Total int64 `json:"total"` // 总量 + List []*EggFriendCircleRespStruct `json:"list"` } type MySelfListReq struct { @@ -66,10 +66,10 @@ type MySelfListReq struct { PageSize int `json:"page_size"` // 每页数量 } type MySelfListResp struct { - Page int `json:"page"` // 页码 - PageSize int `json:"page_size"` // 每页数量 - Total int64 `json:"total"` // 总量 - List []*EggFriendCircleEsStruct `json:"list"` + Page int `json:"page"` // 页码 + PageSize int `json:"page_size"` // 每页数量 + Total int64 `json:"total"` // 总量 + List []*EggFriendCircleRespStruct `json:"list"` } type EggFriendCircleEsStruct struct { @@ -148,3 +148,44 @@ type ImUserNicknameAndAvatar struct { NickName string `json:"nickname"` Avatar string `json:"avatar"` } + +type EggFriendCircleRespStruct struct { + CircleIndexId string `json:"circle_index_id"` //朋友圈文档记录 + Uid int64 `json:"uid" label:"uid"` + ImUid int64 `json:"im_uid" label:"im_uid"` + ImNickname string `json:"im_nickname" label:"im 昵称"` + ImAvatar string `json:"im_avatar" label:"im 头像"` + Kind int32 `json:"kind" label:"类型(1:普通 2:官方)"` //类型(1:普通 2:官方) + Content string `json:"content" label:"文本内容"` //文本内容 + Image []string `json:"image" label:"图片"` //图片 + Video string `json:"video" label:"视频"` //视频 + LikesNums int `json:"likes_nums" label:"点赞数"` //点赞数 + ShareNums int `json:"share_nums" label:"分享数"` //分享数 + CommentNums int `json:"comment_nums" label:"评论数"` //评论数 + IsLike bool `json:"is_like" label:"是否点赞"` //是否点赞 + //State int32 `json:"state" label:"状态(1:正常 2:隐藏)"` + //IsTopUp int32 `json:"is_top_up" label:"是否置顶(1:是 2:否)"` + //IsPraise int32 `json:"is_praise" label:"是否被表扬(1:是 2:否)"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +func EggFriendCircleEsStructToRespStruct(src EggFriendCircleEsStruct) EggFriendCircleRespStruct { + return EggFriendCircleRespStruct{ + CircleIndexId: src.CircleIndexId, + Uid: src.Uid, + ImUid: src.ImUid, + ImNickname: src.ImNickname, + ImAvatar: src.ImAvatar, + Kind: src.Kind, + Content: src.Content, + Image: nil, + Video: src.Video, + LikesNums: src.LikesNums, + ShareNums: src.ShareNums, + CommentNums: src.CommentNums, + IsLike: src.IsLike, + CreatedAt: src.CreatedAt, + UpdatedAt: src.UpdatedAt, + } +} diff --git a/app/svc/friend_circle/svc_firend_circle.go b/app/svc/friend_circle/svc_firend_circle.go index 3c3b0d7..1990849 100644 --- a/app/svc/friend_circle/svc_firend_circle.go +++ b/app/svc/friend_circle/svc_firend_circle.go @@ -6,6 +6,7 @@ import ( "applet/app/e" "applet/app/md/friend_circles" "applet/app/svc" + "applet/app/utils" "applet/app/utils/logx" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" @@ -95,8 +96,8 @@ func GetPersonalSendingList(c *gin.Context, req friend_circles.PersonalSendingLi if searchResult.Hits.TotalHits.Value == 0 { return } - // 解析结果 + scheme, domain := svc.ImageBucket(db.Db) for _, hit := range searchResult.Hits.Hits { var doc friend_circles.EggFriendCircleEsStruct err = json.Unmarshal(hit.Source, &doc) @@ -110,7 +111,18 @@ func GetPersonalSendingList(c *gin.Context, req friend_circles.PersonalSendingLi if likeDoc != nil && likeDoc.Found { // 表示已点赞 doc.IsLike = true } - resp.List = append(resp.List, &doc) + temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc) + if doc.Image != "" { + imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) + var images []string + utils.Unserialize([]byte(imageStr), &images) + temp.Image = images + } + if doc.Video != "" { + video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) + temp.Video = video + } + resp.List = append(resp.List, &temp) } resp.Total = searchResult.TotalHits() @@ -164,6 +176,7 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c } // 解析结果 + scheme, domain := svc.ImageBucket(db.Db) for _, hit := range searchResult.Hits.Hits { var doc friend_circles.EggFriendCircleEsStruct err = json.Unmarshal(hit.Source, &doc) @@ -177,7 +190,18 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c if likeDoc != nil && likeDoc.Found { // 表示已点赞 doc.IsLike = true } - resp.List = append(resp.List, &doc) + temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc) + if doc.Image != "" { + imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) + var images []string + utils.Unserialize([]byte(imageStr), &images) + temp.Image = images + } + if doc.Video != "" { + video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) + temp.Video = video + } + resp.List = append(resp.List, &temp) } resp.Total = searchResult.TotalHits() @@ -210,6 +234,7 @@ func GetRecommendList(req friend_circles.RecommendListReq) (resp friend_circles. } // 解析结果 + scheme, domain := svc.ImageBucket(db.Db) for _, hit := range searchResult.Hits.Hits { var doc friend_circles.EggFriendCircleEsStruct err = json.Unmarshal(hit.Source, &doc) @@ -217,7 +242,18 @@ func GetRecommendList(req friend_circles.RecommendListReq) (resp friend_circles. return } doc.CircleIndexId = hit.Id - resp.List = append(resp.List, &doc) + temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc) + if doc.Image != "" { + imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) + var images []string + utils.Unserialize([]byte(imageStr), &images) + temp.Image = images + } + if doc.Video != "" { + video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) + temp.Video = video + } + resp.List = append(resp.List, &temp) } resp.Total = searchResult.TotalHits() diff --git a/docs/docs.go b/docs/docs.go index 5819b90..3bfeb8c 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1173,7 +1173,7 @@ const docTemplate = `{ }, "/api/v1/circleFriends/recommendList": { "post": { - "description": "我的朋友圈列表", + "description": "推荐列表", "consumes": [ "application/json" ], @@ -4398,7 +4398,16 @@ const docTemplate = `{ } } }, - "friend_circles.EggFriendCircleEsStruct": { + "friend_circles.EggFriendCircleLikeReq": { + "type": "object", + "properties": { + "circle_index_id": { + "description": "文章索引", + "type": "string" + } + } + }, + "friend_circles.EggFriendCircleRespStruct": { "type": "object", "properties": { "circle_index_id": { @@ -4428,7 +4437,10 @@ const docTemplate = `{ }, "image": { "description": "图片", - "type": "string" + "type": "array", + "items": { + "type": "string" + } }, "is_like": { "description": "是否点赞", @@ -4458,15 +4470,6 @@ const docTemplate = `{ } } }, - "friend_circles.EggFriendCircleLikeReq": { - "type": "object", - "properties": { - "circle_index_id": { - "description": "文章索引", - "type": "string" - } - } - }, "friend_circles.EggFriendCircleShareReq": { "type": "object", "properties": { @@ -4555,7 +4558,7 @@ const docTemplate = `{ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4591,7 +4594,7 @@ const docTemplate = `{ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4647,7 +4650,7 @@ const docTemplate = `{ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4971,6 +4974,9 @@ const docTemplate = `{ "down_url": { "type": "string" }, + "down_view_url": { + "type": "string" + }, "guide": { "type": "array", "items": { diff --git a/docs/swagger.json b/docs/swagger.json index 7836d7e..d719bb6 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1167,7 +1167,7 @@ }, "/api/v1/circleFriends/recommendList": { "post": { - "description": "我的朋友圈列表", + "description": "推荐列表", "consumes": [ "application/json" ], @@ -4392,7 +4392,16 @@ } } }, - "friend_circles.EggFriendCircleEsStruct": { + "friend_circles.EggFriendCircleLikeReq": { + "type": "object", + "properties": { + "circle_index_id": { + "description": "文章索引", + "type": "string" + } + } + }, + "friend_circles.EggFriendCircleRespStruct": { "type": "object", "properties": { "circle_index_id": { @@ -4422,7 +4431,10 @@ }, "image": { "description": "图片", - "type": "string" + "type": "array", + "items": { + "type": "string" + } }, "is_like": { "description": "是否点赞", @@ -4452,15 +4464,6 @@ } } }, - "friend_circles.EggFriendCircleLikeReq": { - "type": "object", - "properties": { - "circle_index_id": { - "description": "文章索引", - "type": "string" - } - } - }, "friend_circles.EggFriendCircleShareReq": { "type": "object", "properties": { @@ -4549,7 +4552,7 @@ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4585,7 +4588,7 @@ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4641,7 +4644,7 @@ "list": { "type": "array", "items": { - "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + "$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct" } }, "page": { @@ -4965,6 +4968,9 @@ "down_url": { "type": "string" }, + "down_view_url": { + "type": "string" + }, "guide": { "type": "array", "items": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 68825c7..9721281 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -54,7 +54,13 @@ definitions: description: 文章索引 type: string type: object - friend_circles.EggFriendCircleEsStruct: + friend_circles.EggFriendCircleLikeReq: + properties: + circle_index_id: + description: 文章索引 + type: string + type: object + friend_circles.EggFriendCircleRespStruct: properties: circle_index_id: description: 朋友圈文档记录 @@ -79,7 +85,9 @@ definitions: type: integer image: description: 图片 - type: string + items: + type: string + type: array is_like: description: 是否点赞 type: boolean @@ -100,12 +108,6 @@ definitions: description: 视频 type: string type: object - friend_circles.EggFriendCircleLikeReq: - properties: - circle_index_id: - description: 文章索引 - type: string - type: object friend_circles.EggFriendCircleShareReq: properties: circle_index_id: @@ -166,7 +168,7 @@ definitions: properties: list: items: - $ref: '#/definitions/friend_circles.EggFriendCircleEsStruct' + $ref: '#/definitions/friend_circles.EggFriendCircleRespStruct' type: array page: description: 页码 @@ -191,7 +193,7 @@ definitions: properties: list: items: - $ref: '#/definitions/friend_circles.EggFriendCircleEsStruct' + $ref: '#/definitions/friend_circles.EggFriendCircleRespStruct' type: array page: description: 页码 @@ -230,7 +232,7 @@ definitions: properties: list: items: - $ref: '#/definitions/friend_circles.EggFriendCircleEsStruct' + $ref: '#/definitions/friend_circles.EggFriendCircleRespStruct' type: array page: description: 页码 @@ -454,6 +456,8 @@ definitions: type: string down_url: type: string + down_view_url: + type: string guide: items: $ref: '#/definitions/md.Guide' @@ -2593,7 +2597,7 @@ paths: post: consumes: - application/json - description: 我的朋友圈列表 + description: 推荐列表 parameters: - description: 验证参数Bearer和token空格拼接 in: header