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