mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-07 19:50:07 +08:00
tag
This commit is contained in:
parent
13c29d2c1e
commit
574c7600e0
@ -227,7 +227,7 @@ func GetTagSendLogs(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
resp.Data.Logs = respPb.TagSendLogs
|
resp.Data.Logs = respPb.TagSendLogs
|
||||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
|
@ -164,6 +164,11 @@ func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSen
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp = &pbOffice.GetTagSendLogsResp{
|
resp = &pbOffice.GetTagSendLogsResp{
|
||||||
CommonResp: &pbOffice.CommonResp{},
|
CommonResp: &pbOffice.CommonResp{},
|
||||||
|
Pagination: &pbCommon.ResponsePagination{
|
||||||
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
|
},
|
||||||
|
TagSendLogs: []*pbOffice.TagSendLog{},
|
||||||
}
|
}
|
||||||
tagSendLogs, err := db.DB.GetTagSendLogs(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
tagSendLogs, err := db.DB.GetTagSendLogs(req.UserID, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -175,10 +180,6 @@ func (s *officeServer) GetTagSendLogs(_ context.Context, req *pbOffice.GetTagSen
|
|||||||
if err := utils.CopyStructFields(resp.TagSendLogs, tagSendLogs); err != nil {
|
if err := utils.CopyStructFields(resp.TagSendLogs, tagSendLogs); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
resp.Pagination = &pbCommon.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ type DeleteTagResp struct {
|
|||||||
|
|
||||||
type SetTagReq struct {
|
type SetTagReq struct {
|
||||||
TagID string `json:"tagID" binding:"required"`
|
TagID string `json:"tagID" binding:"required"`
|
||||||
NewName string `json:"newName" binding:"required"`
|
NewName string `json:"newName"`
|
||||||
IncreaseUserIDList []string `json:"increaseUserIDList" binding:"required"`
|
IncreaseUserIDList []string `json:"increaseUserIDList"`
|
||||||
ReduceUserIDList []string `json:"reduceUserIDList" binding:"required"`
|
ReduceUserIDList []string `json:"reduceUserIDList"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ func (d *DataBases) GetUserTags(userID string) ([]Tag, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return tags, err
|
return tags, err
|
||||||
}
|
}
|
||||||
if err = cursor.Decode(tags); err != nil {
|
if err = cursor.Decode(&tags); err != nil {
|
||||||
return tags, err
|
return tags, err
|
||||||
}
|
}
|
||||||
return tags, nil
|
return tags, nil
|
||||||
@ -483,7 +483,7 @@ func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []s
|
|||||||
var tag Tag
|
var tag Tag
|
||||||
err := c.FindOne(ctx, bson.M{"tagID": tagID, "userID": userID}).Decode(&tag)
|
err := c.FindOne(ctx, bson.M{"tagID": tagID, "userID": userID}).Decode(&tag)
|
||||||
if newName != "" {
|
if newName != "" {
|
||||||
_, err = c.UpdateOne(ctx, bson.M{"userID": userID, "tagID": tagID}, bson.D{
|
_, err = c.UpdateOne(ctx, bson.D{{"userID", userID}, {"tagID", tagID}}, bson.D{
|
||||||
{"$set", bson.D{
|
{"$set", bson.D{
|
||||||
{"tagName", newName},
|
{"tagName", newName},
|
||||||
}},
|
}},
|
||||||
@ -501,7 +501,7 @@ func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = c.UpdateOne(ctx, bson.M{"userID": userID, "tagID": tagID}, bson.D{
|
_, err = c.UpdateOne(ctx, bson.D{{"userID", userID}, {"tagID", tagID}}, bson.D{
|
||||||
{"$set", bson.D{
|
{"$set", bson.D{
|
||||||
{"userList", tag.UserList},
|
{"userList", tag.UserList},
|
||||||
}},
|
}},
|
||||||
@ -533,9 +533,10 @@ type TagSendLog struct {
|
|||||||
|
|
||||||
func (d *DataBases) SaveTagSendLog(sendReq *officePb.SendMsg2TagReq) error {
|
func (d *DataBases) SaveTagSendLog(sendReq *officePb.SendMsg2TagReq) error {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
||||||
var tag Tag
|
var tag Tag
|
||||||
_ = c.FindOne(ctx, bson.M{"userID": sendReq.SendID, "tagID": sendReq.TagID}).Decode(&tag)
|
_ = c.FindOne(ctx, bson.M{"userID": sendReq.SendID, "tagID": sendReq.TagID}).Decode(&tag)
|
||||||
|
c = d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
||||||
tagSendLog := TagSendLog{
|
tagSendLog := TagSendLog{
|
||||||
TagID: sendReq.TagID,
|
TagID: sendReq.TagID,
|
||||||
TagName: tag.TagName,
|
TagName: tag.TagName,
|
||||||
@ -544,6 +545,7 @@ func (d *DataBases) SaveTagSendLog(sendReq *officePb.SendMsg2TagReq) error {
|
|||||||
Content: sendReq.Content,
|
Content: sendReq.Content,
|
||||||
ContentType: sendReq.ContentType,
|
ContentType: sendReq.ContentType,
|
||||||
SendTime: time.Now().Unix(),
|
SendTime: time.Now().Unix(),
|
||||||
|
UserList: tag.UserList,
|
||||||
}
|
}
|
||||||
_, err := c.InsertOne(ctx, tagSendLog)
|
_, err := c.InsertOne(ctx, tagSendLog)
|
||||||
return err
|
return err
|
||||||
@ -554,7 +556,7 @@ func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32)
|
|||||||
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
|
||||||
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSendLog)
|
||||||
findOpts := options.Find().SetSort(-1).SetLimit(int64(showNumber)).SetSkip(int64(showNumber) * (int64(pageNumber) - 1))
|
findOpts := options.Find().SetSort(-1).SetLimit(int64(showNumber)).SetSkip(int64(showNumber) * (int64(pageNumber) - 1))
|
||||||
cursor, err := c.Find(ctx, bson.M{"sendID": userID}, findOpts)
|
cursor, err := c.Find(ctx, bson.D{{"sendID", userID}}, findOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tagSendLogs, err
|
return tagSendLogs, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user