瀏覽代碼

Merge remote-tracking branch 'origin/master'

master
huangjiajun 1 天之前
父節點
當前提交
5de9caf3ac
共有 8 個文件被更改,包括 411 次插入12 次删除
  1. +3
    -8
      app/hdl/friend_circle/hdl_friend_circle._test.go
  2. +97
    -1
      app/hdl/friend_circle/hdl_friend_circle.go
  3. +23
    -2
      app/md/friend_circles/md_friend_circle.go
  4. +1
    -0
      app/router/router.go
  5. +107
    -0
      docs/docs.go
  6. +107
    -0
      docs/swagger.json
  7. +72
    -0
      docs/swagger.yaml
  8. +1
    -1
      go.mod

+ 3
- 8
app/hdl/friend_circle/hdl_friend_circle._test.go 查看文件

@@ -103,14 +103,14 @@ func TestDeleteEggScoreIndex(t *testing.T) {

// 创建临时蛋蛋分记录
func TestCreateTempEggScoreIndex(t *testing.T) {
es.Init("http://120.55.48.175:9200", "elastic", "fnuo123")
index := fmt.Sprintf("%s_%d_1", md.EggEnergyUserEggScoreEsAlias, 202451)
es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123")
index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451)
err := es.CreateIndexIfNotExists(index, md.EggEnergyUserEggScoreEsMapping)
if err != nil {
fmt.Println(err)
}

for i := 1; i < 650; i++ {
for i := 1; i < 41; i++ {
egg_energy.ExistOrDefaultUserEggScore(int64(i))
}

@@ -125,11 +125,6 @@ func TestCreateEggScoreIndex(t *testing.T) {
if err != nil {
fmt.Println(err)
}
index2 := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202452)
err = es.CreateIndexIfNotExists(index2, md.EggEnergyUserEggScoreEsMapping)
if err != nil {
fmt.Println(err)
}

fmt.Println("success")
}

+ 97
- 1
app/hdl/friend_circle/hdl_friend_circle.go 查看文件

@@ -119,6 +119,98 @@ func IsCanPublish(c *gin.Context) {
e.OutSuc(c, resp, nil)
}

// FriendCircleLikeList
// @Summary 朋友圈-朋友圈点赞列表
// @Tags 朋友圈
// @Description 朋友圈点赞列表
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body friend_circles.FriendCircleLikeListReq true "签名上传url"
// @Success 200 {object} friend_circles.FriendCircleLikeListResp "返回数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/circleFriends/likeList [POST]
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 +245,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 +257,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,


+ 23
- 2
app/md/friend_circles/md_friend_circle.go 查看文件

@@ -12,6 +12,27 @@ type RecommendListResp struct {
List []*EggFriendCircleEsStruct `json:"list"`
}

type FriendCircleLikeListReq struct {
CircleIndexId string `json:"circle_index_id"` //朋友圈文档记录
Page int `json:"page"` // 页码
PageSize int `json:"page_size"` // 每页数量
}

type FriendCircleLikeListResp struct {
List []*FriendCircleLikeEsStruct `json:"list"`
Page int `json:"page"` // 页码
PageSize int `json:"page_size"` // 每页数量
Total int64 `json:"total"` // 总量
}

type FriendCircleLikeEsStruct struct {
Uid int64 `json:"uid" label:"uid"`
ImUid int64 `json:"im_uid" label:"im_uid"`
CircleId string `json:"circle_id" label:"朋友圈id"`
ImNickname string `json:"im_nickname" label:"im 昵称"`
ImAvatar string `json:"im_avatar" label:"im 头像"`
}

type CommentListReq struct {
CircleIndexId string `json:"circle_index_id"` //朋友圈文档记录
Page int `json:"page"` // 页码
@@ -55,8 +76,8 @@ type EggFriendCircleEsStruct struct {
CircleIndexId string `json:"circle_index_id"` //朋友圈文档记录
Uid int64 `json:"uid" label:"uid"`
ImUid int64 `json:"im_uid" label:"im_uid"`
ImNickname string `json:"im_nickname" label:"im_nickname"`
ImAvatar string `json:"im_avatar" label:"im_avatar"`
ImNickname string `json:"im_nickname" label:"im 昵称"`
ImAvatar string `json:"im_avatar" label:"im 头像"`
Kind int32 `json:"kind" label:"类型(1:普通 2:官方)"` //类型(1:普通 2:官方)
Content string `json:"content" label:"文本内容"` //文本内容
Image string `json:"image" label:"图片"` //图片


+ 1
- 0
app/router/router.go 查看文件

@@ -217,6 +217,7 @@ func rCircleFriends(r *gin.RouterGroup) {
r.POST("/commentDetail", friend_circle.CommentDetail) // 评论详情
r.POST("/publish", friend_circle.Publish) // 发送朋友圈
r.GET("/isCanPublish", friend_circle.IsCanPublish) // 是否可以发朋友圈
r.POST("/likeList", friend_circle.FriendCircleLikeList) // 点赞列表

r.DELETE("/delete", friend_circle.Delete) // 删除朋友圈
r.POST("/like", friend_circle.Like) // 点赞


+ 107
- 0
docs/docs.go 查看文件

@@ -983,6 +983,53 @@ const docTemplate = `{
}
}
},
"/api/v1/circleFriends/likeList": {
"post": {
"description": "朋友圈点赞列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"朋友圈"
],
"summary": "朋友圈-朋友圈点赞列表",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeListReq"
}
}
],
"responses": {
"200": {
"description": "返回数据",
"schema": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeListResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/circleFriends/mySelfList": {
"post": {
"description": "我的朋友圈列表",
@@ -4429,6 +4476,66 @@ const docTemplate = `{
}
}
},
"friend_circles.FriendCircleLikeEsStruct": {
"type": "object",
"properties": {
"circle_id": {
"type": "string"
},
"im_avatar": {
"type": "string"
},
"im_nickname": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"uid": {
"type": "integer"
}
}
},
"friend_circles.FriendCircleLikeListReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "朋友圈文档记录",
"type": "string"
},
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页数量",
"type": "integer"
}
}
},
"friend_circles.FriendCircleLikeListResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeEsStruct"
}
},
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页数量",
"type": "integer"
},
"total": {
"description": "总量",
"type": "integer"
}
}
},
"friend_circles.MySelfListReq": {
"type": "object",
"properties": {


+ 107
- 0
docs/swagger.json 查看文件

@@ -977,6 +977,53 @@
}
}
},
"/api/v1/circleFriends/likeList": {
"post": {
"description": "朋友圈点赞列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"朋友圈"
],
"summary": "朋友圈-朋友圈点赞列表",
"parameters": [
{
"type": "string",
"description": "验证参数Bearer和token空格拼接",
"name": "Authorization",
"in": "header",
"required": true
},
{
"description": "签名上传url",
"name": "req",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeListReq"
}
}
],
"responses": {
"200": {
"description": "返回数据",
"schema": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeListResp"
}
},
"400": {
"description": "具体错误",
"schema": {
"$ref": "#/definitions/md.Response"
}
}
}
}
},
"/api/v1/circleFriends/mySelfList": {
"post": {
"description": "我的朋友圈列表",
@@ -4423,6 +4470,66 @@
}
}
},
"friend_circles.FriendCircleLikeEsStruct": {
"type": "object",
"properties": {
"circle_id": {
"type": "string"
},
"im_avatar": {
"type": "string"
},
"im_nickname": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"uid": {
"type": "integer"
}
}
},
"friend_circles.FriendCircleLikeListReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "朋友圈文档记录",
"type": "string"
},
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页数量",
"type": "integer"
}
}
},
"friend_circles.FriendCircleLikeListResp": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/friend_circles.FriendCircleLikeEsStruct"
}
},
"page": {
"description": "页码",
"type": "integer"
},
"page_size": {
"description": "每页数量",
"type": "integer"
},
"total": {
"description": "总量",
"type": "integer"
}
}
},
"friend_circles.MySelfListReq": {
"type": "object",
"properties": {


+ 72
- 0
docs/swagger.yaml 查看文件

@@ -112,6 +112,47 @@ definitions:
description: 文章索引
type: string
type: object
friend_circles.FriendCircleLikeEsStruct:
properties:
circle_id:
type: string
im_avatar:
type: string
im_nickname:
type: string
im_uid:
type: integer
uid:
type: integer
type: object
friend_circles.FriendCircleLikeListReq:
properties:
circle_index_id:
description: 朋友圈文档记录
type: string
page:
description: 页码
type: integer
page_size:
description: 每页数量
type: integer
type: object
friend_circles.FriendCircleLikeListResp:
properties:
list:
items:
$ref: '#/definitions/friend_circles.FriendCircleLikeEsStruct'
type: array
page:
description: 页码
type: integer
page_size:
description: 每页数量
type: integer
total:
description: 总量
type: integer
type: object
friend_circles.MySelfListReq:
properties:
page:
@@ -2424,6 +2465,37 @@ paths:
summary: 朋友圈-点赞朋友圈
tags:
- 朋友圈
/api/v1/circleFriends/likeList:
post:
consumes:
- application/json
description: 朋友圈点赞列表
parameters:
- description: 验证参数Bearer和token空格拼接
in: header
name: Authorization
required: true
type: string
- description: 签名上传url
in: body
name: req
required: true
schema:
$ref: '#/definitions/friend_circles.FriendCircleLikeListReq'
produces:
- application/json
responses:
"200":
description: 返回数据
schema:
$ref: '#/definitions/friend_circles.FriendCircleLikeListResp'
"400":
description: 具体错误
schema:
$ref: '#/definitions/md.Response'
summary: 朋友圈-朋友圈点赞列表
tags:
- 朋友圈
/api/v1/circleFriends/mySelfList:
post:
consumes:


+ 1
- 1
go.mod 查看文件

@@ -34,7 +34,7 @@ require (

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241219070554-7d4bf7b5cbb2
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241218155438-73db9904c556
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241220073933-42987f91e880
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…
取消
儲存