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