Browse Source

feat: publish egg score send frien circle count to mq

master
shenjiachi 2 days ago
parent
commit
730f9bb4fc
2 changed files with 11 additions and 38 deletions
  1. +10
    -37
      app/hdl/friend_circle/hdl_friend_circle.go
  2. +1
    -1
      go.mod

+ 10
- 37
app/hdl/friend_circle/hdl_friend_circle.go View File

@@ -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)
}



+ 1
- 1
go.mod View File

@@ -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


Loading…
Cancel
Save