|
|
@@ -119,6 +119,87 @@ func IsCanPublish(c *gin.Context) { |
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
} |
|
|
|
|
|
|
|
func FriendCircleLikeList(c *gin.Context) { |
|
|
|
var req friend_circles.FriendCircleLikeListReq |
|
|
|
if err1 := c.ShouldBindJSON(&req); err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
//查找朋友圈记录 |
|
|
|
//doc, err := es.FirstDoc(md.EggFriendCircleEsIndex, req.CircleIndexId) |
|
|
|
//if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
//} |
|
|
|
//if !doc.Found { // 表示没找到数据 |
|
|
|
// e.OutErr(c, e.ERR_NOT_FAN, "朋友圈文档记录不存在") |
|
|
|
// return |
|
|
|
//} |
|
|
|
|
|
|
|
from := (req.Page - 1) * req.PageSize |
|
|
|
|
|
|
|
// 查找点赞列表 |
|
|
|
query := elastic.NewBoolQuery() |
|
|
|
query.Must(elastic.NewTermQuery("circle_id", req.CircleIndexId)) |
|
|
|
|
|
|
|
searchResult, err := es.EsClient.Search(). |
|
|
|
Index(md.EggFriendCircleLikeEsAlias). // 替换为你的索引名称 |
|
|
|
Query(query). |
|
|
|
From(from). |
|
|
|
Size(req.PageSize). |
|
|
|
Sort("created_at", false). // 按时间倒排 |
|
|
|
Pretty(true). |
|
|
|
Do(context.Background()) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var docs []*md.EggFriendCircleLikeEs |
|
|
|
var docUserIds []int64 |
|
|
|
var total int64 |
|
|
|
// 检查是否有结果 |
|
|
|
if searchResult.Hits.TotalHits.Value != 0 { |
|
|
|
// 解析结果 |
|
|
|
total = searchResult.Hits.TotalHits.Value |
|
|
|
for _, hit := range searchResult.Hits.Hits { |
|
|
|
var like md.EggFriendCircleLikeEs |
|
|
|
err = json.Unmarshal(hit.Source, &like) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
docUserIds = append(docUserIds, like.ImUid) |
|
|
|
docs = append(docs, &like) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
nicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(docUserIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
var list []*friend_circles.FriendCircleLikeEsStruct |
|
|
|
for _, like := range docs { |
|
|
|
temp := friend_circles.FriendCircleLikeEsStruct{ |
|
|
|
Uid: like.Uid, |
|
|
|
ImUid: like.ImUid, |
|
|
|
CircleId: like.CircleId, |
|
|
|
} |
|
|
|
val, ok := nicknameAndAvatarMap[like.ImUid] |
|
|
|
if ok { |
|
|
|
temp.ImNickname = val.NickName |
|
|
|
temp.ImAvatar = val.Avatar |
|
|
|
} |
|
|
|
list = append(list, &temp) |
|
|
|
} |
|
|
|
resp := friend_circles.FriendCircleLikeListResp{ |
|
|
|
List: list, |
|
|
|
Page: req.Page, |
|
|
|
PageSize: req.PageSize, |
|
|
|
Total: total, |
|
|
|
} |
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
} |
|
|
|
|
|
|
|
// Publish |
|
|
|
// @Summary 朋友圈-发布朋友圈 |
|
|
|
// @Tags 朋友圈 |
|
|
@@ -153,6 +234,10 @@ func Publish(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
var imageStr string |
|
|
|
if len(req.ImageList) > 0 { |
|
|
|
imageStr = utils.SerializeStr(req.ImageList) |
|
|
|
} |
|
|
|
|
|
|
|
//插入es记录 |
|
|
|
now := time.Now() |
|
|
@@ -161,7 +246,7 @@ func Publish(c *gin.Context) { |
|
|
|
ImUid: imUser.Id, |
|
|
|
Kind: 1, |
|
|
|
Content: req.Content, |
|
|
|
Image: utils.SerializeStr(req.ImageList), |
|
|
|
Image: imageStr, |
|
|
|
Video: req.Video, |
|
|
|
LikesNums: 0, |
|
|
|
ShareNums: 0, |
|
|
|