From 01b3c2f1a1a8ee2d23b4e94e3eb485994f06bcde Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 15:47:24 +0800 Subject: [PATCH] update --- app/hdl/friend_circle/hdl_friend_circle.go | 2 +- app/svc/friend_circle/svc_firend_circle.go | 6 ++--- .../friend_circle/svc_firend_circle_test.go | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 app/svc/friend_circle/svc_firend_circle_test.go diff --git a/app/hdl/friend_circle/hdl_friend_circle.go b/app/hdl/friend_circle/hdl_friend_circle.go index fce2a06..9649c3e 100644 --- a/app/hdl/friend_circle/hdl_friend_circle.go +++ b/app/hdl/friend_circle/hdl_friend_circle.go @@ -154,7 +154,7 @@ func RecommendList(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - resp, err := svc2.GetRecommendList(c, req) + resp, err := svc2.GetRecommendList(req) if err != nil { e.OutErr(c, e.ERR, err.Error()) return diff --git a/app/svc/friend_circle/svc_firend_circle.go b/app/svc/friend_circle/svc_firend_circle.go index 26f9b9a..e99f110 100644 --- a/app/svc/friend_circle/svc_firend_circle.go +++ b/app/svc/friend_circle/svc_firend_circle.go @@ -91,7 +91,7 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c searchResult, err := es.EsClient.Search(). Index(md.EggFriendCircleEsIndex). // 替换为你的索引名称 Query(query). - Sort("create_at", false). // 按时间倒排 + Sort("created_at", false). // 按时间倒排 From(from). Size(req.PageSize). Pretty(true). @@ -121,7 +121,7 @@ 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) { +func GetRecommendList(req friend_circles.RecommendListReq) (resp friend_circles.RecommendListResp, err error) { // 分页参数 from := (req.Page - 1) * req.PageSize @@ -132,7 +132,7 @@ func GetRecommendList(c *gin.Context, req friend_circles.RecommendListReq) (resp searchResult, err := es.EsClient.Search(). Index(md.EggFriendCircleEsAlias). // 替换为你的索引名称 Query(query). - //Sort("create_at", false). // 按时间倒排 + Sort("created_at", false). // 按时间倒排 From(from). Size(req.PageSize). Pretty(true). diff --git a/app/svc/friend_circle/svc_firend_circle_test.go b/app/svc/friend_circle/svc_firend_circle_test.go new file mode 100644 index 0000000..5e34ab0 --- /dev/null +++ b/app/svc/friend_circle/svc_firend_circle_test.go @@ -0,0 +1,26 @@ +package svc + +import ( + "applet/app/md/friend_circles" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "fmt" + "testing" +) + +func TestGetRecommendList(test *testing.T) { + req := friend_circles.RecommendListReq{ + Page: 1, + PageSize: 10, + } + es.Init("http://120.55.48.175:9200", "elastic", "fnuo123") + fmt.Println("start") + list, err := GetRecommendList(req) + if err != nil { + fmt.Println(err) + return + } + fmt.Println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") + if &list != nil { + fmt.Println(list) + } +}