shenjiachi преди 2 седмици
родител
ревизия
e8447a9806
променени са 2 файла, в които са добавени 59 реда и са изтрити 15 реда
  1. +36
    -6
      app/hdl/friend_circle/hdl_dynamic.go
  2. +23
    -9
      app/md/friend_circle/md_dynamic.go

+ 36
- 6
app/hdl/friend_circle/hdl_dynamic.go Целия файл

@@ -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,


+ 23
- 9
app/md/friend_circle/md_dynamic.go Целия файл

@@ -27,10 +27,24 @@ type EggFriendCircleNode struct {
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
type DynamicRespNode struct {
IndexId string `json:"index_id"` // 动态id
Uid int64 `json:"uid" label:"uid"` // 用户id
Username string `json:"username"` // 用户名称
Kind int32 `json:"kind" label:"类型(1:普通 2:官方)"` // 类型(1:普通 2:官方)
Content string `json:"content" label:"文本内容"` // 文本内容
Image []string `json:"image" label:"图片"` // 图片
Video []string `json:"video" label:"视频"` // 视频
State int32 `json:"state" label:"状态(1:正常 2:隐藏)"` // 状态(1:正常 2:隐藏)
IsTopUp int32 `json:"is_top_up" label:"是否置顶(1:是 2:否)"` // 是否置顶(1:是 2:否)
IsPraise int32 `json:"is_praise" label:"是否被表扬(1:是 2:否)"` // 是否被表扬(1:是 2:否)
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}

type GetDynamicResp struct {
List []EggFriendCircleNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
List []DynamicRespNode `json:"list"`
Paginate Paginate `json:"paginate"` // 分页信息
}

type UpdateDynamicReq struct {
@@ -45,11 +59,11 @@ type DeleteDynamicReq struct {
}

type ReleaseDynamicReq struct {
Kind int32 `json:"kind"` // 类型(1:普通 2:官方)
Content string `json:"content"` // 文本内容
Image string `json:"[]image"` // 图片
Video string `json:"video"` // 视频 uri
State int32 `json:"state"` // 状态(1:正常 2:隐藏)
IsTopUp int32 `json:"is_top_up"` // 是否置顶(1:是 2:否)
IsPraise int32 `json:"is_praise"` // 是否被表扬(1:是 2:否)
Kind int32 `json:"kind"` // 类型(1:普通 2:官方)
Content string `json:"content"` // 文本内容
Image []string `json:"image"` // 图片
Video []string `json:"video"` // 视频
State int32 `json:"state"` // 状态(1:正常 2:隐藏)
IsTopUp int32 `json:"is_top_up"` // 是否置顶(1:是 2:否)
IsPraise int32 `json:"is_praise"` // 是否被表扬(1:是 2:否)
}

||||||
x
 
000:0
Зареждане…
Отказ
Запис