Browse Source

update friend circle image struct

master
shenjiachi 1 day ago
parent
commit
2c4f615ae3
6 changed files with 155 additions and 59 deletions
  1. +4
    -1
      app/hdl/friend_circle/hdl_friend_circle.go
  2. +53
    -12
      app/md/friend_circles/md_friend_circle.go
  3. +40
    -4
      app/svc/friend_circle/svc_firend_circle.go
  4. +21
    -15
      docs/docs.go
  5. +21
    -15
      docs/swagger.json
  6. +16
    -12
      docs/swagger.yaml

+ 4
- 1
app/hdl/friend_circle/hdl_friend_circle.go View File

@@ -19,6 +19,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/olivere/elastic/v7" "github.com/olivere/elastic/v7"
"strconv" "strconv"
"strings"
"time" "time"
) )


@@ -245,9 +246,11 @@ func Publish(c *gin.Context) {
e.OutErr(c, e.ERR_DB_ORM, err.Error()) e.OutErr(c, e.ERR_DB_ORM, err.Error())
return return
} }
scheme, domain := svc.ImageBucket(db.Db)
var imageStr string var imageStr string
if len(req.ImageList) > 0 { if len(req.ImageList) > 0 {
imageStr = utils.SerializeStr(req.ImageList) imageStr = utils.SerializeStr(req.ImageList)
imageStr = strings.ReplaceAll(imageStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}")
} }


//插入es记录 //插入es记录
@@ -311,7 +314,7 @@ func Publish(c *gin.Context) {
// RecommendList // RecommendList
// @Summary 朋友圈-推荐列表 // @Summary 朋友圈-推荐列表
// @Tags 朋友圈 // @Tags 朋友圈
// @Description 我的朋友圈列表
// @Description 推荐列表
// @Accept json // @Accept json
// @Produce json // @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接" // @param Authorization header string true "验证参数Bearer和token空格拼接"


+ 53
- 12
app/md/friend_circles/md_friend_circle.go View File

@@ -6,10 +6,10 @@ type RecommendListReq struct {
} }


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


type FriendCircleLikeListReq struct { type FriendCircleLikeListReq struct {
@@ -55,10 +55,10 @@ type PersonalSendingListReq struct {
} }


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


type MySelfListReq struct { type MySelfListReq struct {
@@ -66,10 +66,10 @@ type MySelfListReq struct {
PageSize int `json:"page_size"` // 每页数量 PageSize int `json:"page_size"` // 每页数量
} }
type MySelfListResp struct { type MySelfListResp struct {
Page int `json:"page"` // 页码
PageSize int `json:"page_size"` // 每页数量
Total int64 `json:"total"` // 总量
List []*EggFriendCircleEsStruct `json:"list"`
Page int `json:"page"` // 页码
PageSize int `json:"page_size"` // 每页数量
Total int64 `json:"total"` // 总量
List []*EggFriendCircleRespStruct `json:"list"`
} }


type EggFriendCircleEsStruct struct { type EggFriendCircleEsStruct struct {
@@ -148,3 +148,44 @@ type ImUserNicknameAndAvatar struct {
NickName string `json:"nickname"` NickName string `json:"nickname"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
} }

type EggFriendCircleRespStruct 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 昵称"`
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:"图片"` //图片
Video string `json:"video" label:"视频"` //视频
LikesNums int `json:"likes_nums" label:"点赞数"` //点赞数
ShareNums int `json:"share_nums" label:"分享数"` //分享数
CommentNums int `json:"comment_nums" label:"评论数"` //评论数
IsLike bool `json:"is_like" label:"是否点赞"` //是否点赞
//State int32 `json:"state" label:"状态(1:正常 2:隐藏)"`
//IsTopUp int32 `json:"is_top_up" label:"是否置顶(1:是 2:否)"`
//IsPraise int32 `json:"is_praise" label:"是否被表扬(1:是 2:否)"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}

func EggFriendCircleEsStructToRespStruct(src EggFriendCircleEsStruct) EggFriendCircleRespStruct {
return EggFriendCircleRespStruct{
CircleIndexId: src.CircleIndexId,
Uid: src.Uid,
ImUid: src.ImUid,
ImNickname: src.ImNickname,
ImAvatar: src.ImAvatar,
Kind: src.Kind,
Content: src.Content,
Image: nil,
Video: src.Video,
LikesNums: src.LikesNums,
ShareNums: src.ShareNums,
CommentNums: src.CommentNums,
IsLike: src.IsLike,
CreatedAt: src.CreatedAt,
UpdatedAt: src.UpdatedAt,
}
}

+ 40
- 4
app/svc/friend_circle/svc_firend_circle.go View File

@@ -6,6 +6,7 @@ import (
"applet/app/e" "applet/app/e"
"applet/app/md/friend_circles" "applet/app/md/friend_circles"
"applet/app/svc" "applet/app/svc"
"applet/app/utils"
"applet/app/utils/logx" "applet/app/utils/logx"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/md" "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
@@ -95,8 +96,8 @@ func GetPersonalSendingList(c *gin.Context, req friend_circles.PersonalSendingLi
if searchResult.Hits.TotalHits.Value == 0 { if searchResult.Hits.TotalHits.Value == 0 {
return return
} }

// 解析结果 // 解析结果
scheme, domain := svc.ImageBucket(db.Db)
for _, hit := range searchResult.Hits.Hits { for _, hit := range searchResult.Hits.Hits {
var doc friend_circles.EggFriendCircleEsStruct var doc friend_circles.EggFriendCircleEsStruct
err = json.Unmarshal(hit.Source, &doc) err = json.Unmarshal(hit.Source, &doc)
@@ -110,7 +111,18 @@ func GetPersonalSendingList(c *gin.Context, req friend_circles.PersonalSendingLi
if likeDoc != nil && likeDoc.Found { // 表示已点赞 if likeDoc != nil && likeDoc.Found { // 表示已点赞
doc.IsLike = true doc.IsLike = true
} }
resp.List = append(resp.List, &doc)
temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc)
if doc.Image != "" {
imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image)
var images []string
utils.Unserialize([]byte(imageStr), &images)
temp.Image = images
}
if doc.Video != "" {
video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video)
temp.Video = video
}
resp.List = append(resp.List, &temp)
} }


resp.Total = searchResult.TotalHits() resp.Total = searchResult.TotalHits()
@@ -164,6 +176,7 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c
} }


// 解析结果 // 解析结果
scheme, domain := svc.ImageBucket(db.Db)
for _, hit := range searchResult.Hits.Hits { for _, hit := range searchResult.Hits.Hits {
var doc friend_circles.EggFriendCircleEsStruct var doc friend_circles.EggFriendCircleEsStruct
err = json.Unmarshal(hit.Source, &doc) err = json.Unmarshal(hit.Source, &doc)
@@ -177,7 +190,18 @@ func MySelfList(c *gin.Context, req friend_circles.MySelfListReq) (resp friend_c
if likeDoc != nil && likeDoc.Found { // 表示已点赞 if likeDoc != nil && likeDoc.Found { // 表示已点赞
doc.IsLike = true doc.IsLike = true
} }
resp.List = append(resp.List, &doc)
temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc)
if doc.Image != "" {
imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image)
var images []string
utils.Unserialize([]byte(imageStr), &images)
temp.Image = images
}
if doc.Video != "" {
video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video)
temp.Video = video
}
resp.List = append(resp.List, &temp)
} }


resp.Total = searchResult.TotalHits() resp.Total = searchResult.TotalHits()
@@ -210,6 +234,7 @@ func GetRecommendList(req friend_circles.RecommendListReq) (resp friend_circles.
} }


// 解析结果 // 解析结果
scheme, domain := svc.ImageBucket(db.Db)
for _, hit := range searchResult.Hits.Hits { for _, hit := range searchResult.Hits.Hits {
var doc friend_circles.EggFriendCircleEsStruct var doc friend_circles.EggFriendCircleEsStruct
err = json.Unmarshal(hit.Source, &doc) err = json.Unmarshal(hit.Source, &doc)
@@ -217,7 +242,18 @@ func GetRecommendList(req friend_circles.RecommendListReq) (resp friend_circles.
return return
} }
doc.CircleIndexId = hit.Id doc.CircleIndexId = hit.Id
resp.List = append(resp.List, &doc)
temp := friend_circles.EggFriendCircleEsStructToRespStruct(doc)
if doc.Image != "" {
imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image)
var images []string
utils.Unserialize([]byte(imageStr), &images)
temp.Image = images
}
if doc.Video != "" {
video := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video)
temp.Video = video
}
resp.List = append(resp.List, &temp)
} }


resp.Total = searchResult.TotalHits() resp.Total = searchResult.TotalHits()


+ 21
- 15
docs/docs.go View File

@@ -1173,7 +1173,7 @@ const docTemplate = `{
}, },
"/api/v1/circleFriends/recommendList": { "/api/v1/circleFriends/recommendList": {
"post": { "post": {
"description": "我的朋友圈列表",
"description": "推荐列表",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -4398,7 +4398,16 @@ const docTemplate = `{
} }
} }
}, },
"friend_circles.EggFriendCircleEsStruct": {
"friend_circles.EggFriendCircleLikeReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "文章索引",
"type": "string"
}
}
},
"friend_circles.EggFriendCircleRespStruct": {
"type": "object", "type": "object",
"properties": { "properties": {
"circle_index_id": { "circle_index_id": {
@@ -4428,7 +4437,10 @@ const docTemplate = `{
}, },
"image": { "image": {
"description": "图片", "description": "图片",
"type": "string"
"type": "array",
"items": {
"type": "string"
}
}, },
"is_like": { "is_like": {
"description": "是否点赞", "description": "是否点赞",
@@ -4458,15 +4470,6 @@ const docTemplate = `{
} }
} }
}, },
"friend_circles.EggFriendCircleLikeReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "文章索引",
"type": "string"
}
}
},
"friend_circles.EggFriendCircleShareReq": { "friend_circles.EggFriendCircleShareReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -4555,7 +4558,7 @@ const docTemplate = `{
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4591,7 +4594,7 @@ const docTemplate = `{
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4647,7 +4650,7 @@ const docTemplate = `{
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4971,6 +4974,9 @@ const docTemplate = `{
"down_url": { "down_url": {
"type": "string" "type": "string"
}, },
"down_view_url": {
"type": "string"
},
"guide": { "guide": {
"type": "array", "type": "array",
"items": { "items": {


+ 21
- 15
docs/swagger.json View File

@@ -1167,7 +1167,7 @@
}, },
"/api/v1/circleFriends/recommendList": { "/api/v1/circleFriends/recommendList": {
"post": { "post": {
"description": "我的朋友圈列表",
"description": "推荐列表",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
@@ -4392,7 +4392,16 @@
} }
} }
}, },
"friend_circles.EggFriendCircleEsStruct": {
"friend_circles.EggFriendCircleLikeReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "文章索引",
"type": "string"
}
}
},
"friend_circles.EggFriendCircleRespStruct": {
"type": "object", "type": "object",
"properties": { "properties": {
"circle_index_id": { "circle_index_id": {
@@ -4422,7 +4431,10 @@
}, },
"image": { "image": {
"description": "图片", "description": "图片",
"type": "string"
"type": "array",
"items": {
"type": "string"
}
}, },
"is_like": { "is_like": {
"description": "是否点赞", "description": "是否点赞",
@@ -4452,15 +4464,6 @@
} }
} }
}, },
"friend_circles.EggFriendCircleLikeReq": {
"type": "object",
"properties": {
"circle_index_id": {
"description": "文章索引",
"type": "string"
}
}
},
"friend_circles.EggFriendCircleShareReq": { "friend_circles.EggFriendCircleShareReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -4549,7 +4552,7 @@
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4585,7 +4588,7 @@
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4641,7 +4644,7 @@
"list": { "list": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/definitions/friend_circles.EggFriendCircleEsStruct"
"$ref": "#/definitions/friend_circles.EggFriendCircleRespStruct"
} }
}, },
"page": { "page": {
@@ -4965,6 +4968,9 @@
"down_url": { "down_url": {
"type": "string" "type": "string"
}, },
"down_view_url": {
"type": "string"
},
"guide": { "guide": {
"type": "array", "type": "array",
"items": { "items": {


+ 16
- 12
docs/swagger.yaml View File

@@ -54,7 +54,13 @@ definitions:
description: 文章索引 description: 文章索引
type: string type: string
type: object type: object
friend_circles.EggFriendCircleEsStruct:
friend_circles.EggFriendCircleLikeReq:
properties:
circle_index_id:
description: 文章索引
type: string
type: object
friend_circles.EggFriendCircleRespStruct:
properties: properties:
circle_index_id: circle_index_id:
description: 朋友圈文档记录 description: 朋友圈文档记录
@@ -79,7 +85,9 @@ definitions:
type: integer type: integer
image: image:
description: 图片 description: 图片
type: string
items:
type: string
type: array
is_like: is_like:
description: 是否点赞 description: 是否点赞
type: boolean type: boolean
@@ -100,12 +108,6 @@ definitions:
description: 视频 description: 视频
type: string type: string
type: object type: object
friend_circles.EggFriendCircleLikeReq:
properties:
circle_index_id:
description: 文章索引
type: string
type: object
friend_circles.EggFriendCircleShareReq: friend_circles.EggFriendCircleShareReq:
properties: properties:
circle_index_id: circle_index_id:
@@ -166,7 +168,7 @@ definitions:
properties: properties:
list: list:
items: items:
$ref: '#/definitions/friend_circles.EggFriendCircleEsStruct'
$ref: '#/definitions/friend_circles.EggFriendCircleRespStruct'
type: array type: array
page: page:
description: 页码 description: 页码
@@ -191,7 +193,7 @@ definitions:
properties: properties:
list: list:
items: items:
$ref: '#/definitions/friend_circles.EggFriendCircleEsStruct'
$ref: '#/definitions/friend_circles.EggFriendCircleRespStruct'
type: array type: array
page: page:
description: 页码 description: 页码
@@ -230,7 +232,7 @@ definitions:
properties: properties:
list: list:
items: items:
$ref: '#/definitions/friend_circles.EggFriendCircleEsStruct'
$ref: '#/definitions/friend_circles.EggFriendCircleRespStruct'
type: array type: array
page: page:
description: 页码 description: 页码
@@ -454,6 +456,8 @@ definitions:
type: string type: string
down_url: down_url:
type: string type: string
down_view_url:
type: string
guide: guide:
items: items:
$ref: '#/definitions/md.Guide' $ref: '#/definitions/md.Guide'
@@ -2593,7 +2597,7 @@ paths:
post: post:
consumes: consumes:
- application/json - application/json
description: 我的朋友圈列表
description: 推荐列表
parameters: parameters:
- description: 验证参数Bearer和token空格拼接 - description: 验证参数Bearer和token空格拼接
in: header in: header


Loading…
Cancel
Save