diff --git a/app/hdl/friend_circle/hdl_friend_circle.go b/app/hdl/friend_circle/hdl_friend_circle.go index 1a35746..63d4b00 100644 --- a/app/hdl/friend_circle/hdl_friend_circle.go +++ b/app/hdl/friend_circle/hdl_friend_circle.go @@ -9,9 +9,10 @@ import ( svc2 "applet/app/svc/friend_circle" "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" svc3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/svc" - es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es" "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "context" "encoding/json" "errors" @@ -274,43 +275,15 @@ func Publish(c *gin.Context) { }) fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet) - // 更新发朋友圈次数 - year, week := time.Now().ISOWeek() - yearStr := utils.IntToStr(year) - weekStr := utils.IntToStr(week) - index := es2.GetAppointIndexFromAlias(yearStr, weekStr) - id := fmt.Sprintf("%d%d_%d", year, week, user.Id) - _, err = es.FirstDoc(index, id) - if err != nil { - if err.Error() != "elastic: Error 404 (Not Found)" { - e.OutErr(c, e.ERR, err.Error()) - return - } else { - m := md.EggEnergyUserEggScoreEs{ - Uid: user.Id, - SendCircleOfFriendNums: 1, - CreatedAt: nowStr, - UpdatedAt: nowStr, - } - newCreateDoc, err1 := es.CreateDoc(index, id, &m) - if err1 != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - fmt.Printf("newCreateDoc ==> %+v \n\n", newCreateDoc) - } - } else { - script := elastic.NewScript("ctx._source.send_circle_of_friend_nums += params.inc").Param("inc", 1) - _, err = es.EsClient.Update(). - Index(index). - Id(id). - Script(script). - Do(context.Background()) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } + // 推到 es 更新发朋友圈次数 + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return } + defer ch.Release() + + ch.Publish(md2.EggAppExchange, md2.EggSendFriendCircleData{Uid: user.Id}, md2.EggRoutKeyForSendFriendCircle) + e.OutSuc(c, "success", nil) } diff --git a/go.mod b/go.mod index c7abd12..34fc3a9 100644 --- a/go.mod +++ b/go.mod @@ -34,7 +34,7 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241225092233-b22661930965 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241226054303-d275a23f4323 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241226083724-d7b4eb9ea3b5 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible