@@ -27,7 +27,7 @@ import ( | |||
// @Produce json | |||
// @param Authorization header string true "验证参数Bearer和token空格拼接" | |||
// @Param req body md.GetDynamicReq false "筛选条件" | |||
// @Success 200 {object} md.GetDynamicResp "生成的黑名单id" | |||
// @Success 200 {object} md.GetDynamicResp "具体数据" | |||
// @Failure 400 {object} md.Response "具体错误" | |||
// @Router /api/friendCircleSettings/dynamic/index [POST] | |||
func GetDynamic(c *gin.Context) { | |||
@@ -65,11 +65,15 @@ func GetDynamic(c *gin.Context) { | |||
if req.Limit == 0 { | |||
req.Limit = 10 | |||
} | |||
userIdInterface := make([]interface{}, len(userIds)) | |||
for index, value := range userIds { | |||
userIdInterface[index] = value | |||
} | |||
aliasName := md2.EggFriendCircleEsAlias | |||
boolQuery := elastic.NewBoolQuery() | |||
if userIds != nil { | |||
boolQuery.Filter(elastic.NewTermsQuery("uid", userIds)) | |||
boolQuery.Filter(elastic.NewTermsQuery("uid", userIdInterface...)) | |||
} | |||
if req.BeginAt != "" && req.EndAt != "" { | |||
boolQuery.Filter(elastic.NewRangeQuery("created_at").Gte(req.BeginAt).Lte(req.EndAt).Format("yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")) | |||
@@ -81,12 +85,8 @@ func GetDynamic(c *gin.Context) { | |||
Sort("created_at", true). | |||
Pretty(true). | |||
Do(context.Background()) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
var docs []md.EggFriendCircleNode | |||
var docs []*md.EggFriendCircleNode | |||
var docUserIds []int64 | |||
var total int64 | |||
// 检查是否有结果 | |||
@@ -101,7 +101,7 @@ func GetDynamic(c *gin.Context) { | |||
} | |||
docUserIds = append(docUserIds, doc.Uid) | |||
doc.IndexId = hit.Id | |||
docs = append(docs, doc) | |||
docs = append(docs, &doc) | |||
} | |||
} | |||
@@ -133,7 +133,7 @@ func GetDynamic(c *gin.Context) { | |||
userMap[user.Id] = user.Nickname | |||
} | |||
scheme, domain := svc.ImageBucket(db.Db) | |||
list := make([]md.DynamicRespNode, len(docs)) | |||
list := make([]md.DynamicRespNode, 0, len(docs)) | |||
for _, doc := range docs { | |||
switch doc.Kind { | |||
case 1: | |||
@@ -142,9 +142,9 @@ func GetDynamic(c *gin.Context) { | |||
doc.Username = adminMap[doc.Uid] | |||
} | |||
imageStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Image) | |||
videoStr := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) | |||
images := strings.Split(imageStr, ";") | |||
videos := strings.Split(videoStr, ";") | |||
videos := svc.ImageFormatWithBucketForDataInfo(scheme, domain, doc.Video) | |||
var images []string | |||
utils.Unserialize([]byte(imageStr), &images) | |||
temp := md.DynamicRespNode{ | |||
IndexId: doc.IndexId, | |||
Uid: doc.Uid, | |||
@@ -290,22 +290,17 @@ func ReleaseDynamic(c *gin.Context) { | |||
scheme, domain := svc.ImageBucket(db.Db) | |||
var imageStr string | |||
if len(req.Image) > 0 { | |||
imageStr = strings.Join(req.Image, ";") | |||
imageStr = utils.SerializeStr(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: imageStr, | |||
Video: videoStr, | |||
Video: req.Video, | |||
LikesNums: 0, | |||
ShareNums: 0, | |||
CommentNums: 0, | |||
@@ -34,7 +34,7 @@ type DynamicRespNode struct { | |||
Kind int32 `json:"kind" label:"类型(1:普通 2:官方)"` // 类型(1:普通 2:官方) | |||
Content string `json:"content" label:"文本内容"` // 文本内容 | |||
Image []string `json:"image" label:"图片"` // 图片 | |||
Video []string `json:"video" 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:否) | |||
@@ -62,7 +62,7 @@ type ReleaseDynamicReq struct { | |||
Kind int32 `json:"kind"` // 类型(1:普通 2:官方) | |||
Content string `json:"content"` // 文本内容 | |||
Image []string `json:"image"` // 图片 | |||
Video []string `json:"video"` // 视频 | |||
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:否) | |||
@@ -4,7 +4,6 @@ import ( | |||
"applet/app/db" | |||
"applet/app/db/im/model" | |||
md "applet/app/md/im" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"errors" | |||
"time" | |||
) | |||
@@ -12,14 +11,14 @@ import ( | |||
func PageCustomerService(req md.PageCustomerServiceReq) (err error, resp md.PageCustomerServiceResp) { | |||
var userId int64 | |||
if req.Phone != "" { | |||
userDb := implement.NewUserDb(db.Db) | |||
user, err := userDb.UserGetOneByParams(map[string]interface{}{ | |||
"phone": req.Phone, | |||
}) | |||
var user model.User | |||
get, err := db.DbIm.Where("phone_number = ?", req.Phone).Get(&user) | |||
if err != nil { | |||
return err, md.PageCustomerServiceResp{} | |||
return err, resp | |||
} | |||
if get { | |||
userId = user.Id | |||
} | |||
userId = user.Id | |||
} | |||
sess := db.DbIm.Where("1=1") | |||
@@ -2,8 +2,10 @@ package svc | |||
import ( | |||
"applet/app/db" | |||
model2 "applet/app/db/im/model" | |||
md "applet/app/md/im" | |||
"applet/app/utils" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
"errors" | |||
"fmt" | |||
@@ -16,9 +18,46 @@ type PageSendRedPackageOrdJoinUser struct { | |||
} | |||
func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md.PageSendRedPackageOrdResp) { | |||
userDb := implement.NewUserDb(db.Db) | |||
var phones []string | |||
if req.InviteCode != "" { | |||
user1, err := userDb.UserGetOneByParams(map[string]interface{}{ | |||
"key": "system_invite_code", | |||
"value": req.InviteCode, | |||
}) | |||
if err != nil { | |||
return err, md.PageSendRedPackageOrdResp{} | |||
} | |||
if user1 != nil { | |||
phones = append(phones, user1.Phone) | |||
} | |||
user2, err := userDb.UserGetOneByParams(map[string]interface{}{ | |||
"key": "custom_invite_code", | |||
"value": req.InviteCode, | |||
}) | |||
if err != nil { | |||
return err, md.PageSendRedPackageOrdResp{} | |||
} | |||
if user2 != nil { | |||
phones = append(phones, user2.Phone) | |||
} | |||
} | |||
var imUsers []model2.User | |||
err = db.DbIm.In("phone_number", phones).Find(&imUsers) | |||
if err != nil { | |||
return err, md.PageSendRedPackageOrdResp{} | |||
} | |||
var imUserIds []int64 | |||
for _, imUser := range imUsers { | |||
imUserIds = append(imUserIds, imUser.Id) | |||
} | |||
if req.Uid != 0 { | |||
imUserIds = append(imUserIds, int64(req.Uid)) | |||
} | |||
sess := db.DbIm.Table("im_send_red_package_ord").Where("1=1") | |||
if req.Phone != "" { | |||
sess.And("user.phone LIKE ?", "%"+req.Phone+"%") | |||
sess.And("user.phone_number LIKE ?", "%"+req.Phone+"%") | |||
} | |||
if req.Nickname != "" { | |||
sess.And("user.nickname LIKE ?", "%"+req.Nickname+"%") | |||
@@ -29,8 +68,8 @@ func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md. | |||
if req.State != 0 { | |||
sess.And("im_send_red_package_ord.state = ?", req.State) | |||
} | |||
if req.Uid != 0 { | |||
sess.And("im_send_red_package_ord.uid = ?", req.Uid) | |||
if len(imUserIds) != 0 { | |||
sess.In("im_send_red_package_ord.uid", imUserIds) | |||
} | |||
if req.RedPacketType != 0 { | |||
sess.And("im_send_red_package_ord.red_packet_type = ?", req.RedPacketType) | |||
@@ -41,9 +80,7 @@ func PageSendRedPackageOrd(req md.PageSendRedPackageOrdReq) (err error, resp md. | |||
if req.StartTimeEnd != "" { | |||
sess.And("im_send_red_package_ord.create_time <= ?", req.StartTimeEnd) | |||
} | |||
if req.InviteCode != "" { | |||
sess.And("user.invite_code = ?", req.InviteCode) | |||
} | |||
sess.Join("LEFT", "user", "im_send_red_package_ord.uid = user.id") | |||
var mm []*PageSendRedPackageOrdJoinUser | |||
@@ -89,7 +89,7 @@ mq: | |||
pwd: 'guest' | |||
es: | |||
url: 'http://120.55.48.175:9200' | |||
url: 'http://123.57.140.192:9200' | |||
user: 'elastic' | |||
pwd: 'fnuo123' | |||