|
|
@@ -17,6 +17,7 @@ import ( |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"github.com/olivere/elastic/v7" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
@@ -135,20 +136,37 @@ func GetDynamic(c *gin.Context) { |
|
|
|
} |
|
|
|
redisConn := cache.GetPool().Get() |
|
|
|
scheme, domain := svc2.ImageBucket(db.Db, redisConn) |
|
|
|
list := make([]md.DynamicRespNode, len(docs)) |
|
|
|
for _, doc := range docs { |
|
|
|
switch doc.Kind { |
|
|
|
case 1: |
|
|
|
doc.Username = userMap[doc.Uid] |
|
|
|
case 2: |
|
|
|
doc.Username = adminMap[doc.Uid] |
|
|
|
|
|
|
|
} |
|
|
|
doc.Image = svc2.ImageFormatWithBucket(scheme, domain, doc.Image) |
|
|
|
doc.Video = svc2.ImageFormatWithBucket(scheme, domain, doc.Video) |
|
|
|
imageStr := svc2.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) |
|
|
|
videoStr := svc2.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) |
|
|
|
images := strings.Split(imageStr, ";") |
|
|
|
videos := strings.Split(videoStr, ";") |
|
|
|
temp := md.DynamicRespNode{ |
|
|
|
IndexId: doc.IndexId, |
|
|
|
Uid: doc.Uid, |
|
|
|
Username: doc.Username, |
|
|
|
Kind: doc.Kind, |
|
|
|
Content: doc.Content, |
|
|
|
Image: images, |
|
|
|
Video: videos, |
|
|
|
State: doc.State, |
|
|
|
IsTopUp: doc.IsTopUp, |
|
|
|
IsPraise: doc.IsPraise, |
|
|
|
CreatedAt: doc.CreatedAt, |
|
|
|
UpdatedAt: doc.UpdatedAt, |
|
|
|
} |
|
|
|
list = append(list, temp) |
|
|
|
} |
|
|
|
|
|
|
|
resp := md.GetDynamicResp{ |
|
|
|
List: docs, |
|
|
|
List: list, |
|
|
|
Paginate: md.Paginate{ |
|
|
|
Limit: req.Limit, |
|
|
|
Page: req.Page, |
|
|
@@ -271,14 +289,26 @@ func ReleaseDynamic(c *gin.Context) { |
|
|
|
if req.IsTopUp == 0 { |
|
|
|
req.IsTopUp = 2 |
|
|
|
} |
|
|
|
redisConn := cache.GetPool().Get() |
|
|
|
scheme, domain := svc2.ImageBucket(db.Db, redisConn) |
|
|
|
var imageStr string |
|
|
|
if len(req.Image) > 0 { |
|
|
|
imageStr = strings.Join(req.Image, ";") |
|
|
|
imageStr = strings.ReplaceAll(imageStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}") |
|
|
|
} |
|
|
|
|
|
|
|
var videoStr string |
|
|
|
if len(req.Video) > 0 { |
|
|
|
videoStr = strings.Join(req.Video, ";") |
|
|
|
videoStr = strings.ReplaceAll(videoStr, fmt.Sprintf("%s://%s/", scheme, domain), "{{tempHost}}") |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|
m := md2.EggFriendCircleEs{ |
|
|
|
Uid: int64(user.AdmId), |
|
|
|
Kind: req.Kind, |
|
|
|
Content: req.Content, |
|
|
|
Image: utils.SerializeStr(req.Image), |
|
|
|
Video: req.Video, |
|
|
|
Image: imageStr, |
|
|
|
Video: videoStr, |
|
|
|
LikesNums: 0, |
|
|
|
ShareNums: 0, |
|
|
|
CommentNums: 0, |
|
|
|