From dd408fdfb77a3acf47f7f74b9ea76aaa9685b897 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 9 Dec 2024 18:39:54 +0800 Subject: [PATCH] update --- app/hdl/friend_circle/hdl_friend_circle.go | 30 +++++- app/md/friend_circles/md_friend_circle.go | 12 +++ app/router/router.go | 2 +- app/svc/friend_circle/svc_firend_circle.go | 41 ++++++++ docs/docs.go | 103 +++++++++++++++++++-- docs/swagger.json | 103 +++++++++++++++++++-- docs/swagger.yaml | 76 +++++++++++++-- 7 files changed, 335 insertions(+), 32 deletions(-) diff --git a/app/hdl/friend_circle/hdl_friend_circle.go b/app/hdl/friend_circle/hdl_friend_circle.go index 1426d18..5f8ef75 100644 --- a/app/hdl/friend_circle/hdl_friend_circle.go +++ b/app/hdl/friend_circle/hdl_friend_circle.go @@ -76,7 +76,7 @@ func IsCanPublish(c *gin.Context) { // @Param req body friend_circles.PublishReq true "请求参数" // @Success 200 {string} "success" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/v1/circleFriends/public [POST] +// @Router /api/v1/circleFriends/publish [POST] func Publish(c *gin.Context) { var req friend_circles.PublishReq if err1 := c.ShouldBindJSON(&req); err1 != nil { @@ -132,6 +132,34 @@ func Publish(c *gin.Context) { e.OutSuc(c, "success", nil) } +// RecommendList +// @Summary 朋友圈-推荐列表 +// @Tags 朋友圈 +// @Description 我的朋友圈列表 +// @Accept json +// @Produce json +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Param req body friend_circles.RecommendListReq true "签名上传url" +// @Success 200 {object} friend_circles.RecommendListResp "返回数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/circleFriends/recommendList [POST] +func RecommendList(c *gin.Context) { + var req friend_circles.RecommendListReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = svc.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + resp, err := svc2.GetRecommendList(c, req) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, resp, nil) +} + // CommentList // @Summary 朋友圈-评论列表 // @Tags 朋友圈 diff --git a/app/md/friend_circles/md_friend_circle.go b/app/md/friend_circles/md_friend_circle.go index 5014364..7af0320 100644 --- a/app/md/friend_circles/md_friend_circle.go +++ b/app/md/friend_circles/md_friend_circle.go @@ -1,5 +1,17 @@ package friend_circles +type RecommendListReq struct { + Page int `json:"page"` // 页码 + PageSize int `json:"page_size"` // 每页数量 +} + +type RecommendListResp struct { + Page int `json:"page"` // 页码 + PageSize int `json:"page_size"` // 每页数量 + Total int64 `json:"total"` // 总量 + List []EggFriendCircleEsStruct `json:"list"` +} + type CommentListReq struct { CircleIndexId string `json:"circle_index_id"` //朋友圈文档记录 Page int `json:"page"` // 页码 diff --git a/app/router/router.go b/app/router/router.go index c8e2d39..5196b3b 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -199,7 +199,7 @@ func route(r *gin.RouterGroup) { func rCircleFriends(r *gin.RouterGroup) { r.POST("/mySelfList", friend_circle.MySelfList) // 我的朋友圈列表 - r.POST("/recommendList", friend_circle.Publish) // 推荐列表 + r.GET("/recommendList", friend_circle.RecommendList) // 推荐列表 r.POST("/commentList", friend_circle.CommentList) // 评论列表 r.POST("/commentDetail", friend_circle.CommentDetail) // 评论详情 r.POST("/publish", friend_circle.Publish) // 发送朋友圈 diff --git a/app/svc/friend_circle/svc_firend_circle.go b/app/svc/friend_circle/svc_firend_circle.go index 1dd19cc..6357c5c 100644 --- a/app/svc/friend_circle/svc_firend_circle.go +++ b/app/svc/friend_circle/svc_firend_circle.go @@ -121,6 +121,47 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c return } +func GetRecommendList(c *gin.Context, req friend_circles.RecommendListReq) (resp friend_circles.RecommendListResp, err error) { + // 分页参数 + from := (req.Page - 1) * req.PageSize + + // 构建查询 + query := elastic.NewBoolQuery() + query.Must(elastic.NewTermQuery("state", "1")) + query.Should(elastic.NewTermQuery("is_top_up", "1")) + searchResult, err := es.EsClient.Search(). + Index(md.EggFriendCircleEsIndex). // 替换为你的索引名称 + Query(query). + Sort("create_at", false). // 按时间倒排 + From(from). + Size(req.PageSize). + Pretty(true). + Do(context.Background()) + if err != nil { + logx.Fatalf("Error searching for documents: %v", err) + return + } + + // 检查是否有结果 + if searchResult.Hits.TotalHits.Value == 0 { + return + } + + // 解析结果 + for _, hit := range searchResult.Hits.Hits { + var doc friend_circles.EggFriendCircleEsStruct + err = json.Unmarshal(hit.Source, &doc) + if err != nil { + return + } + doc.CircleIndexId = hit.Id + resp.List = append(resp.List, doc) + } + + resp.Total = searchResult.TotalHits() + return +} + func CommentList(req friend_circles.CommentListReq) (resp friend_circles.CommentListResp, err error) { // 分页参数 from := (req.Page - 1) * req.PageSize diff --git a/docs/docs.go b/docs/docs.go index c4ea3da..95b03b8 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -985,7 +985,7 @@ const docTemplate = `{ } } }, - "/api/v1/circleFriends/public": { + "/api/v1/circleFriends/publish": { "post": { "description": "发布朋友圈", "consumes": [ @@ -1032,6 +1032,53 @@ const docTemplate = `{ } } }, + "/api/v1/circleFriends/recommendList": { + "post": { + "description": "我的朋友圈列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "朋友圈" + ], + "summary": "朋友圈-推荐列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "签名上传url", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend_circles.RecommendListReq" + } + } + ], + "responses": { + "200": { + "description": "返回数据", + "schema": { + "$ref": "#/definitions/friend_circles.RecommendListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/circleFriends/share": { "post": { "description": "分享后朋友圈分享数(增加)", @@ -2406,7 +2453,7 @@ const docTemplate = `{ }, "/api/v1/playlet/base": { "get": { - "description": "短视频-基本信息", + "description": "短剧-基本信息", "consumes": [ "application/json" ], @@ -2416,7 +2463,7 @@ const docTemplate = `{ "tags": [ "短视频" ], - "summary": "短视频-基本信息", + "summary": "短剧-基本信息", "parameters": [ { "type": "string", @@ -2444,7 +2491,7 @@ const docTemplate = `{ }, "/api/v1/playlet/reward": { "post": { - "description": "实名认证-保存", + "description": "短剧-保存", "consumes": [ "application/json" ], @@ -2452,9 +2499,9 @@ const docTemplate = `{ "application/json" ], "tags": [ - "实名认证" + "短视频" ], - "summary": "实名认证-保存", + "summary": "短剧-保存", "parameters": [ { "type": "string", @@ -3405,7 +3452,7 @@ const docTemplate = `{ }, "/api/v1/video/reward": { "post": { - "description": "实名认证-保存", + "description": "短视频-领取", "consumes": [ "application/json" ], @@ -3413,9 +3460,9 @@ const docTemplate = `{ "application/json" ], "tags": [ - "实名认证" + "短视频" ], - "summary": "实名认证-保存", + "summary": "短视频-领取", "parameters": [ { "type": "string", @@ -4023,6 +4070,42 @@ const docTemplate = `{ } } }, + "friend_circles.RecommendListReq": { + "type": "object", + "properties": { + "page": { + "description": "页码", + "type": "integer" + }, + "page_size": { + "description": "每页数量", + "type": "integer" + } + } + }, + "friend_circles.RecommendListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + } + }, + "page": { + "description": "页码", + "type": "integer" + }, + "page_size": { + "description": "每页数量", + "type": "integer" + }, + "total": { + "description": "总量", + "type": "integer" + } + } + }, "md.AdvertisingBasic": { "type": "object", "properties": { @@ -5161,7 +5244,7 @@ const docTemplate = `{ "type": "string" }, "ratio": { - "description": "兑换比例(x:y)", + "description": "能量值兑换比例(x:y)", "type": "string" } } diff --git a/docs/swagger.json b/docs/swagger.json index f70555b..01b7f57 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -979,7 +979,7 @@ } } }, - "/api/v1/circleFriends/public": { + "/api/v1/circleFriends/publish": { "post": { "description": "发布朋友圈", "consumes": [ @@ -1026,6 +1026,53 @@ } } }, + "/api/v1/circleFriends/recommendList": { + "post": { + "description": "我的朋友圈列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "朋友圈" + ], + "summary": "朋友圈-推荐列表", + "parameters": [ + { + "type": "string", + "description": "验证参数Bearer和token空格拼接", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "签名上传url", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/friend_circles.RecommendListReq" + } + } + ], + "responses": { + "200": { + "description": "返回数据", + "schema": { + "$ref": "#/definitions/friend_circles.RecommendListResp" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/circleFriends/share": { "post": { "description": "分享后朋友圈分享数(增加)", @@ -2400,7 +2447,7 @@ }, "/api/v1/playlet/base": { "get": { - "description": "短视频-基本信息", + "description": "短剧-基本信息", "consumes": [ "application/json" ], @@ -2410,7 +2457,7 @@ "tags": [ "短视频" ], - "summary": "短视频-基本信息", + "summary": "短剧-基本信息", "parameters": [ { "type": "string", @@ -2438,7 +2485,7 @@ }, "/api/v1/playlet/reward": { "post": { - "description": "实名认证-保存", + "description": "短剧-保存", "consumes": [ "application/json" ], @@ -2446,9 +2493,9 @@ "application/json" ], "tags": [ - "实名认证" + "短视频" ], - "summary": "实名认证-保存", + "summary": "短剧-保存", "parameters": [ { "type": "string", @@ -3399,7 +3446,7 @@ }, "/api/v1/video/reward": { "post": { - "description": "实名认证-保存", + "description": "短视频-领取", "consumes": [ "application/json" ], @@ -3407,9 +3454,9 @@ "application/json" ], "tags": [ - "实名认证" + "短视频" ], - "summary": "实名认证-保存", + "summary": "短视频-领取", "parameters": [ { "type": "string", @@ -4017,6 +4064,42 @@ } } }, + "friend_circles.RecommendListReq": { + "type": "object", + "properties": { + "page": { + "description": "页码", + "type": "integer" + }, + "page_size": { + "description": "每页数量", + "type": "integer" + } + } + }, + "friend_circles.RecommendListResp": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct" + } + }, + "page": { + "description": "页码", + "type": "integer" + }, + "page_size": { + "description": "每页数量", + "type": "integer" + }, + "total": { + "description": "总量", + "type": "integer" + } + } + }, "md.AdvertisingBasic": { "type": "object", "properties": { @@ -5155,7 +5238,7 @@ "type": "string" }, "ratio": { - "description": "兑换比例(x:y)", + "description": "能量值兑换比例(x:y)", "type": "string" } } diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2e1616b..bef0bf8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -147,6 +147,31 @@ definitions: description: 视屏 type: string type: object + friend_circles.RecommendListReq: + properties: + page: + description: 页码 + type: integer + page_size: + description: 每页数量 + type: integer + type: object + friend_circles.RecommendListResp: + properties: + list: + items: + $ref: '#/definitions/friend_circles.EggFriendCircleEsStruct' + type: array + page: + description: 页码 + type: integer + page_size: + description: 每页数量 + type: integer + total: + description: 总量 + type: integer + type: object md.AdvertisingBasic: properties: android_ad_is_open: @@ -938,7 +963,7 @@ definitions: phone: type: string ratio: - description: 兑换比例(x:y) + description: 能量值兑换比例(x:y) type: string type: object md.MyFansResp: @@ -2264,7 +2289,7 @@ paths: summary: 朋友圈-我的朋友圈列表 tags: - 朋友圈 - /api/v1/circleFriends/public: + /api/v1/circleFriends/publish: post: consumes: - application/json @@ -2295,6 +2320,37 @@ paths: summary: 朋友圈-发布朋友圈 tags: - 朋友圈 + /api/v1/circleFriends/recommendList: + post: + consumes: + - application/json + description: 我的朋友圈列表 + parameters: + - description: 验证参数Bearer和token空格拼接 + in: header + name: Authorization + required: true + type: string + - description: 签名上传url + in: body + name: req + required: true + schema: + $ref: '#/definitions/friend_circles.RecommendListReq' + produces: + - application/json + responses: + "200": + description: 返回数据 + schema: + $ref: '#/definitions/friend_circles.RecommendListResp' + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 朋友圈-推荐列表 + tags: + - 朋友圈 /api/v1/circleFriends/share: post: consumes: @@ -3202,7 +3258,7 @@ paths: get: consumes: - application/json - description: 短视频-基本信息 + description: 短剧-基本信息 parameters: - description: 验证参数Bearer和token空格拼接 in: header @@ -3220,14 +3276,14 @@ paths: description: 具体错误 schema: $ref: '#/definitions/md.Response' - summary: 短视频-基本信息 + summary: 短剧-基本信息 tags: - 短视频 /api/v1/playlet/reward: post: consumes: - application/json - description: 实名认证-保存 + description: 短剧-保存 parameters: - description: 验证参数Bearer和token空格拼接 in: header @@ -3251,9 +3307,9 @@ paths: description: 具体错误 schema: $ref: '#/definitions/md.Response' - summary: 实名认证-保存 + summary: 短剧-保存 tags: - - 实名认证 + - 短视频 /api/v1/pointsCenter/basic: get: consumes: @@ -3862,7 +3918,7 @@ paths: post: consumes: - application/json - description: 实名认证-保存 + description: 短视频-领取 parameters: - description: 验证参数Bearer和token空格拼接 in: header @@ -3886,9 +3942,9 @@ paths: description: 具体错误 schema: $ref: '#/definitions/md.Response' - summary: 实名认证-保存 + summary: 短视频-领取 tags: - - 实名认证 + - 短视频 /api/v1/wallet/amountFlow: get: consumes: