|
|
@ -1,8 +1,9 @@
|
|
|
|
package db
|
|
|
|
package mongo
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
|
|
|
|
"Open_IM/pkg/common/db"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
"Open_IM/pkg/common/log"
|
|
|
|
pbMsg "Open_IM/pkg/proto/msg"
|
|
|
|
pbMsg "Open_IM/pkg/proto/msg"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
|
@ -59,7 +60,7 @@ type GroupMember_x struct {
|
|
|
|
|
|
|
|
|
|
|
|
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
|
|
|
var ErrMsgListNotExist = errors.New("user not have msg in mongoDB")
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
|
|
|
func (d *db.DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
|
|
|
return 1, nil
|
|
|
|
return 1, nil
|
|
|
|
//var i, NB uint32
|
|
|
|
//var i, NB uint32
|
|
|
|
//var seqUid string
|
|
|
|
//var seqUid string
|
|
|
@ -89,12 +90,12 @@ func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq uint32, err error) {
|
|
|
|
//return MinSeq, nil
|
|
|
|
//return MinSeq, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
|
|
|
func (d *db.DataBases) GetMinSeqFromMongo2(uid string) (MinSeq uint32, err error) {
|
|
|
|
return 1, nil
|
|
|
|
return 1, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deleteMsgByLogic
|
|
|
|
// deleteMsgByLogic
|
|
|
|
func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnexistSeqList []uint32, err error) {
|
|
|
|
func (d *db.DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID string) (totalUnexistSeqList []uint32, err error) {
|
|
|
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
|
|
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", userID, seqList)
|
|
|
|
sortkeys.Uint32s(seqList)
|
|
|
|
sortkeys.Uint32s(seqList)
|
|
|
|
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
|
|
|
|
suffixUserID2SubSeqList := func(uid string, seqList []uint32) map[string][]uint32 {
|
|
|
@ -130,7 +131,7 @@ func (d *DataBases) DelMsgBySeqList(userID string, seqList []uint32, operationID
|
|
|
|
return totalUnexistSeqList, err
|
|
|
|
return totalUnexistSeqList, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint32, operationID string) ([]uint32, error) {
|
|
|
|
func (d *db.DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint32, operationID string) ([]uint32, error) {
|
|
|
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", suffixUserID, seqList)
|
|
|
|
log.Debug(operationID, utils.GetSelfFuncName(), "args ", suffixUserID, seqList)
|
|
|
|
seqMsgList, indexList, unexistSeqList, err := d.GetMsgAndIndexBySeqListInOneMongo2(suffixUserID, seqList, operationID)
|
|
|
|
seqMsgList, indexList, unexistSeqList, err := d.GetMsgAndIndexBySeqListInOneMongo2(suffixUserID, seqList, operationID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -145,7 +146,7 @@ func (d *DataBases) DelMsgBySeqListInOneDoc(suffixUserID string, seqList []uint3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deleteMsgByLogic
|
|
|
|
// deleteMsgByLogic
|
|
|
|
func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string) error {
|
|
|
|
func (d *db.DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string) error {
|
|
|
|
sortkeys.Uint32s(seqList)
|
|
|
|
sortkeys.Uint32s(seqList)
|
|
|
|
seqMsgs, err := d.GetMsgBySeqListMongo2(uid, seqList, operationID)
|
|
|
|
seqMsgs, err := d.GetMsgBySeqListMongo2(uid, seqList, operationID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -161,7 +162,7 @@ func (d *DataBases) DelMsgLogic(uid string, seqList []uint32, operationID string
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) ReplaceMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgData, operationID string, seqIndex int) error {
|
|
|
|
func (d *db.DataBases) ReplaceMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgData, operationID string, seqIndex int) error {
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), suffixUserID, *msg)
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), suffixUserID, *msg)
|
|
|
|
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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
@ -182,7 +183,7 @@ func (d *DataBases) ReplaceMsgByIndex(suffixUserID string, msg *open_im_sdk.MsgD
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error {
|
|
|
|
func (d *db.DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operationID string) error {
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, *msg)
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, *msg)
|
|
|
|
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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
@ -207,14 +208,14 @@ func (d *DataBases) ReplaceMsgBySeq(uid string, msg *open_im_sdk.MsgData, operat
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) UpdateOneMsgList(msg *UserChat) error {
|
|
|
|
func (d *db.DataBases) UpdateOneMsgList(msg *UserChat) 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
_, err := c.UpdateOne(ctx, bson.M{"uid": msg.UID}, bson.M{"$set": bson.M{"msg": msg.Msg}})
|
|
|
|
_, err := c.UpdateOne(ctx, bson.M{"uid": msg.UID}, bson.M{"$set": bson.M{"msg": msg.Msg}})
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
func (d *db.DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList)
|
|
|
|
log.NewInfo(operationID, utils.GetSelfFuncName(), uid, seqList)
|
|
|
|
var hasSeqList []uint32
|
|
|
|
var hasSeqList []uint32
|
|
|
|
singleCount := 0
|
|
|
|
singleCount := 0
|
|
|
@ -270,7 +271,7 @@ func (d *DataBases) GetMsgBySeqList(uid string, seqList []uint32, operationID st
|
|
|
|
return seqMsg, nil
|
|
|
|
return seqMsg, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, error) {
|
|
|
|
func (d *db.DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
@ -292,14 +293,14 @@ func (d *DataBases) GetUserMsgListByIndex(ID string, index int64) (*UserChat, er
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DelMongoMsgs(IDList []string) error {
|
|
|
|
func (d *db.DataBases) DelMongoMsgs(IDList []string) 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
_, err := c.DeleteMany(ctx, bson.M{"uid": bson.M{"$in": IDList}})
|
|
|
|
_, err := c.DeleteMany(ctx, bson.M{"uid": bson.M{"$in": IDList}})
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) ReplaceMsgToBlankByIndex(suffixID string, index int) (replaceMaxSeq uint32, err error) {
|
|
|
|
func (d *db.DataBases) ReplaceMsgToBlankByIndex(suffixID string, index int) (replaceMaxSeq uint32, err 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
userChat := &UserChat{}
|
|
|
|
userChat := &UserChat{}
|
|
|
@ -327,7 +328,7 @@ func (d *DataBases) ReplaceMsgToBlankByIndex(suffixID string, index int) (replac
|
|
|
|
return replaceMaxSeq, err
|
|
|
|
return replaceMaxSeq, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
|
|
|
func (d *db.DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
@ -355,7 +356,7 @@ func (d *DataBases) GetNewestMsg(ID string) (msg *open_im_sdk.MsgData, err error
|
|
|
|
return nil, nil
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetOldestMsg(ID string) (msg *open_im_sdk.MsgData, err error) {
|
|
|
|
func (d *db.DataBases) GetOldestMsg(ID string) (msg *open_im_sdk.MsgData, err 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
|
regex := fmt.Sprintf("^%s", ID)
|
|
|
@ -390,7 +391,7 @@ func (d *DataBases) GetOldestMsg(ID string) (msg *open_im_sdk.MsgData, err error
|
|
|
|
return nil, nil
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
func (d *db.DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
var hasSeqList []uint32
|
|
|
|
var hasSeqList []uint32
|
|
|
|
singleCount := 0
|
|
|
|
singleCount := 0
|
|
|
|
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)
|
|
|
@ -441,7 +442,7 @@ func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operatio
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return seqMsg, nil
|
|
|
|
return seqMsg, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
func (d *db.DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, err error) {
|
|
|
|
var hasSeqList []uint32
|
|
|
|
var hasSeqList []uint32
|
|
|
|
singleCount := 0
|
|
|
|
singleCount := 0
|
|
|
|
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)
|
|
|
@ -493,7 +494,7 @@ func (d *DataBases) GetSuperGroupMsgBySeqListMongo(groupID string, seqList []uin
|
|
|
|
return seqMsg, nil
|
|
|
|
return seqMsg, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetMsgAndIndexBySeqListInOneMongo2(suffixUserID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexList []int, unexistSeqList []uint32, err error) {
|
|
|
|
func (d *db.DataBases) GetMsgAndIndexBySeqListInOneMongo2(suffixUserID string, seqList []uint32, operationID string) (seqMsg []*open_im_sdk.MsgData, indexList []int, unexistSeqList []uint32, err 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
sChat := UserChat{}
|
|
|
|
sChat := UserChat{}
|
|
|
@ -548,7 +549,7 @@ func genExceptionSuperGroupMessageBySeqList(seqList []uint32, groupID string) (e
|
|
|
|
return exceptionMsg
|
|
|
|
return exceptionMsg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) SaveUserChatMongo2(uid string, sendTime int64, m *pbMsg.MsgDataToDB) error {
|
|
|
|
func (d *db.DataBases) SaveUserChatMongo2(uid string, sendTime int64, m *pbMsg.MsgDataToDB) 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
newTime := getCurrentTimestampByMill()
|
|
|
|
newTime := getCurrentTimestampByMill()
|
|
|
@ -620,7 +621,7 @@ func (d *DataBases) SaveUserChatMongo2(uid string, sendTime int64, m *pbMsg.MsgD
|
|
|
|
// return nil
|
|
|
|
// return nil
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgDataToDB) error {
|
|
|
|
func (d *db.DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgDataToDB) error {
|
|
|
|
var seqUid string
|
|
|
|
var seqUid string
|
|
|
|
newTime := getCurrentTimestampByMill()
|
|
|
|
newTime := getCurrentTimestampByMill()
|
|
|
|
session := d.mgoSession.Clone()
|
|
|
|
session := d.mgoSession.Clone()
|
|
|
@ -659,7 +660,7 @@ func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgDataToD
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DelUserChat(uid string) error {
|
|
|
|
func (d *db.DataBases) DelUserChat(uid string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//if session == nil {
|
|
|
|
//if session == nil {
|
|
|
@ -677,7 +678,7 @@ func (d *DataBases) DelUserChat(uid string) error {
|
|
|
|
//return nil
|
|
|
|
//return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DelUserChatMongo2(uid string) error {
|
|
|
|
func (d *db.DataBases) DelUserChatMongo2(uid string) 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(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
filter := bson.M{"uid": uid}
|
|
|
|
filter := bson.M{"uid": uid}
|
|
|
@ -689,7 +690,7 @@ func (d *DataBases) DelUserChatMongo2(uid string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) MgoUserCount() (int, error) {
|
|
|
|
func (d *db.DataBases) MgoUserCount() (int, error) {
|
|
|
|
return 0, nil
|
|
|
|
return 0, nil
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//if session == nil {
|
|
|
|
//if session == nil {
|
|
|
@ -702,7 +703,7 @@ func (d *DataBases) MgoUserCount() (int, error) {
|
|
|
|
//return c.Find(nil).Count()
|
|
|
|
//return c.Find(nil).Count()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) MgoSkipUID(count int) (string, error) {
|
|
|
|
func (d *db.DataBases) MgoSkipUID(count int) (string, error) {
|
|
|
|
return "", nil
|
|
|
|
return "", nil
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//if session == nil {
|
|
|
|
//if session == nil {
|
|
|
@ -717,7 +718,7 @@ func (d *DataBases) MgoSkipUID(count int) (string, error) {
|
|
|
|
//return sChat.UID, nil
|
|
|
|
//return sChat.UID, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetGroupMember(groupID string) []string {
|
|
|
|
func (d *db.DataBases) GetGroupMember(groupID string) []string {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
//groupInfo := GroupMember_x{}
|
|
|
|
//groupInfo := GroupMember_x{}
|
|
|
|
//groupInfo.GroupID = groupID
|
|
|
|
//groupInfo.GroupID = groupID
|
|
|
@ -738,7 +739,7 @@ func (d *DataBases) GetGroupMember(groupID string) []string {
|
|
|
|
//return groupInfo.UIDList
|
|
|
|
//return groupInfo.UIDList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) AddGroupMember(groupID, uid string) error {
|
|
|
|
func (d *db.DataBases) AddGroupMember(groupID, uid string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//if session == nil {
|
|
|
|
//if session == nil {
|
|
|
@ -771,7 +772,7 @@ func (d *DataBases) AddGroupMember(groupID, uid string) error {
|
|
|
|
//return nil
|
|
|
|
//return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DelGroupMember(groupID, uid string) error {
|
|
|
|
func (d *db.DataBases) DelGroupMember(groupID, uid string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//session := d.mgoSession.Clone()
|
|
|
|
//if session == nil {
|
|
|
|
//if session == nil {
|
|
|
@ -795,7 +796,7 @@ type Tag struct {
|
|
|
|
UserList []string `bson:"user_list"`
|
|
|
|
UserList []string `bson:"user_list"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserTags(userID string) ([]Tag, error) {
|
|
|
|
func (d *db.DataBases) GetUserTags(userID string) ([]Tag, 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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
|
var tags []Tag
|
|
|
|
var tags []Tag
|
|
|
@ -809,7 +810,7 @@ func (d *DataBases) GetUserTags(userID string) ([]Tag, error) {
|
|
|
|
return tags, nil
|
|
|
|
return tags, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) CreateTag(userID, tagName string, userList []string) error {
|
|
|
|
func (d *db.DataBases) CreateTag(userID, tagName string, userList []string) 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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
|
tagID := generateTagID(tagName, userID)
|
|
|
|
tagID := generateTagID(tagName, userID)
|
|
|
@ -823,7 +824,7 @@ func (d *DataBases) CreateTag(userID, tagName string, userList []string) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetTagByID(userID, tagID string) (Tag, error) {
|
|
|
|
func (d *db.DataBases) GetTagByID(userID, tagID string) (Tag, 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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
|
var tag Tag
|
|
|
|
var tag Tag
|
|
|
@ -831,14 +832,14 @@ func (d *DataBases) GetTagByID(userID, tagID string) (Tag, error) {
|
|
|
|
return tag, err
|
|
|
|
return tag, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DeleteTag(userID, tagID string) error {
|
|
|
|
func (d *db.DataBases) DeleteTag(userID, tagID string) 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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
|
_, err := c.DeleteOne(ctx, bson.M{"user_id": userID, "tag_id": tagID})
|
|
|
|
_, err := c.DeleteOne(ctx, bson.M{"user_id": userID, "tag_id": tagID})
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []string, reduceUserIDList []string) error {
|
|
|
|
func (d *db.DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []string, reduceUserIDList []string) 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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
|
var tag Tag
|
|
|
|
var tag Tag
|
|
|
@ -873,7 +874,7 @@ func (d *DataBases) SetTag(userID, tagID, newName string, increaseUserIDList []s
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserIDListByTagID(userID, tagID string) ([]string, error) {
|
|
|
|
func (d *db.DataBases) GetUserIDListByTagID(userID, tagID string) ([]string, error) {
|
|
|
|
var tag Tag
|
|
|
|
var tag Tag
|
|
|
|
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(cTag)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cTag)
|
|
|
@ -894,14 +895,14 @@ type TagSendLog struct {
|
|
|
|
SendTime int64 `bson:"send_time"`
|
|
|
|
SendTime int64 `bson:"send_time"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) SaveTagSendLog(tagSendLog *TagSendLog) error {
|
|
|
|
func (d *db.DataBases) SaveTagSendLog(tagSendLog *TagSendLog) 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(cSendLog)
|
|
|
|
_, err := c.InsertOne(ctx, tagSendLog)
|
|
|
|
_, err := c.InsertOne(ctx, tagSendLog)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32) ([]TagSendLog, error) {
|
|
|
|
func (d *db.DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32) ([]TagSendLog, error) {
|
|
|
|
var tagSendLogs []TagSendLog
|
|
|
|
var tagSendLogs []TagSendLog
|
|
|
|
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)
|
|
|
@ -947,7 +948,7 @@ type Comment struct {
|
|
|
|
CreateTime int32 `bson:"create_time" json:"create_time"`
|
|
|
|
CreateTime int32 `bson:"create_time" json:"create_time"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) CreateOneWorkMoment(workMoment *WorkMoment) error {
|
|
|
|
func (d *db.DataBases) CreateOneWorkMoment(workMoment *WorkMoment) 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
workMomentID := generateWorkMomentID(workMoment.UserID)
|
|
|
|
workMomentID := generateWorkMomentID(workMoment.UserID)
|
|
|
@ -957,14 +958,14 @@ func (d *DataBases) CreateOneWorkMoment(workMoment *WorkMoment) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DeleteOneWorkMoment(workMomentID string) error {
|
|
|
|
func (d *db.DataBases) DeleteOneWorkMoment(workMomentID string) 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
_, err := c.DeleteOne(ctx, bson.M{"work_moment_id": workMomentID})
|
|
|
|
_, err := c.DeleteOne(ctx, bson.M{"work_moment_id": workMomentID})
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DeleteComment(workMomentID, contentID, opUserID string) error {
|
|
|
|
func (d *db.DataBases) DeleteComment(workMomentID, contentID, opUserID string) 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
_, err := c.UpdateOne(ctx, bson.D{{"work_moment_id", workMomentID},
|
|
|
|
_, err := c.UpdateOne(ctx, bson.D{{"work_moment_id", workMomentID},
|
|
|
@ -976,7 +977,7 @@ func (d *DataBases) DeleteComment(workMomentID, contentID, opUserID string) erro
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetWorkMomentByID(workMomentID string) (*WorkMoment, error) {
|
|
|
|
func (d *db.DataBases) GetWorkMomentByID(workMomentID string) (*WorkMoment, 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
workMoment := &WorkMoment{}
|
|
|
|
workMoment := &WorkMoment{}
|
|
|
@ -984,7 +985,7 @@ func (d *DataBases) GetWorkMomentByID(workMomentID string) (*WorkMoment, error)
|
|
|
|
return workMoment, err
|
|
|
|
return workMoment, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) LikeOneWorkMoment(likeUserID, userName, workMomentID string) (*WorkMoment, bool, error) {
|
|
|
|
func (d *db.DataBases) LikeOneWorkMoment(likeUserID, userName, workMomentID string) (*WorkMoment, bool, error) {
|
|
|
|
workMoment, err := d.GetWorkMomentByID(workMomentID)
|
|
|
|
workMoment, err := d.GetWorkMomentByID(workMomentID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, false, err
|
|
|
|
return nil, false, err
|
|
|
@ -1006,11 +1007,11 @@ func (d *DataBases) LikeOneWorkMoment(likeUserID, userName, workMomentID string)
|
|
|
|
return workMoment, !isAlreadyLike, err
|
|
|
|
return workMoment, !isAlreadyLike, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) SetUserWorkMomentsLevel(userID string, level int32) error {
|
|
|
|
func (d *db.DataBases) SetUserWorkMomentsLevel(userID string, level int32) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) CommentOneWorkMoment(comment *Comment, workMomentID string) (WorkMoment, error) {
|
|
|
|
func (d *db.DataBases) CommentOneWorkMoment(comment *Comment, workMomentID string) (WorkMoment, error) {
|
|
|
|
comment.ContentID = generateWorkMomentCommentID(workMomentID)
|
|
|
|
comment.ContentID = generateWorkMomentCommentID(workMomentID)
|
|
|
|
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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
@ -1019,7 +1020,7 @@ func (d *DataBases) CommentOneWorkMoment(comment *Comment, workMomentID string)
|
|
|
|
return workMoment, err
|
|
|
|
return workMoment, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserSelfWorkMoments(userID string, showNumber, pageNumber int32) ([]WorkMoment, error) {
|
|
|
|
func (d *db.DataBases) GetUserSelfWorkMoments(userID string, showNumber, pageNumber int32) ([]WorkMoment, 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
var workMomentList []WorkMoment
|
|
|
|
var workMomentList []WorkMoment
|
|
|
@ -1032,7 +1033,7 @@ func (d *DataBases) GetUserSelfWorkMoments(userID string, showNumber, pageNumber
|
|
|
|
return workMomentList, err
|
|
|
|
return workMomentList, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserWorkMoments(opUserID, userID string, showNumber, pageNumber int32, friendIDList []string) ([]WorkMoment, error) {
|
|
|
|
func (d *db.DataBases) GetUserWorkMoments(opUserID, userID string, showNumber, pageNumber int32, friendIDList []string) ([]WorkMoment, 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
var workMomentList []WorkMoment
|
|
|
|
var workMomentList []WorkMoment
|
|
|
@ -1052,7 +1053,7 @@ func (d *DataBases) GetUserWorkMoments(opUserID, userID string, showNumber, page
|
|
|
|
return workMomentList, err
|
|
|
|
return workMomentList, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetUserFriendWorkMoments(showNumber, pageNumber int32, userID string, friendIDList []string) ([]WorkMoment, error) {
|
|
|
|
func (d *db.DataBases) GetUserFriendWorkMoments(showNumber, pageNumber int32, userID string, friendIDList []string) ([]WorkMoment, 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(cWorkMoment)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cWorkMoment)
|
|
|
|
var workMomentList []WorkMoment
|
|
|
|
var workMomentList []WorkMoment
|
|
|
@ -1100,7 +1101,7 @@ type UserToSuperGroup struct {
|
|
|
|
GroupIDList []string `bson:"group_id_list" json:"groupIDList"`
|
|
|
|
GroupIDList []string `bson:"group_id_list" json:"groupIDList"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string, memberNumCount int) error {
|
|
|
|
func (d *db.DataBases) CreateSuperGroup(groupID string, initMemberIDList []string, memberNumCount int) 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(cSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
@ -1145,7 +1146,7 @@ func (d *DataBases) CreateSuperGroup(groupID string, initMemberIDList []string,
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetSuperGroup(groupID string) (SuperGroup, error) {
|
|
|
|
func (d *db.DataBases) GetSuperGroup(groupID string) (SuperGroup, 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(cSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
|
|
superGroup := SuperGroup{}
|
|
|
|
superGroup := SuperGroup{}
|
|
|
@ -1153,7 +1154,7 @@ func (d *DataBases) GetSuperGroup(groupID string) (SuperGroup, error) {
|
|
|
|
return superGroup, err
|
|
|
|
return superGroup, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) error {
|
|
|
|
func (d *db.DataBases) AddUserToSuperGroup(groupID string, userIDList []string) 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(cSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
@ -1192,7 +1193,7 @@ func (d *DataBases) AddUserToSuperGroup(groupID string, userIDList []string) err
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []string) error {
|
|
|
|
func (d *db.DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []string) 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(cSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
@ -1215,7 +1216,7 @@ func (d *DataBases) RemoverUserFromSuperGroup(groupID string, userIDList []strin
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) GetSuperGroupByUserID(userID string) (UserToSuperGroup, error) {
|
|
|
|
func (d *db.DataBases) GetSuperGroupByUserID(userID string) (UserToSuperGroup, 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(cUserToSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cUserToSuperGroup)
|
|
|
|
var user UserToSuperGroup
|
|
|
|
var user UserToSuperGroup
|
|
|
@ -1223,7 +1224,7 @@ func (d *DataBases) GetSuperGroupByUserID(userID string) (UserToSuperGroup, erro
|
|
|
|
return user, nil
|
|
|
|
return user, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) DeleteSuperGroup(groupID string) error {
|
|
|
|
func (d *db.DataBases) DeleteSuperGroup(groupID string) 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(cSuperGroup)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cSuperGroup)
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
|
session, err := d.mongoClient.StartSession()
|
|
|
@ -1247,7 +1248,7 @@ func (d *DataBases) DeleteSuperGroup(groupID string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) RemoveGroupFromUser(ctx, sCtx context.Context, groupID string, userIDList []string) error {
|
|
|
|
func (d *db.DataBases) RemoveGroupFromUser(ctx, sCtx context.Context, groupID string, userIDList []string) error {
|
|
|
|
var users []UserToSuperGroup
|
|
|
|
var users []UserToSuperGroup
|
|
|
|
for _, v := range userIDList {
|
|
|
|
for _, v := range userIDList {
|
|
|
|
users = append(users, UserToSuperGroup{
|
|
|
|
users = append(users, UserToSuperGroup{
|
|
|
@ -1342,7 +1343,7 @@ func superGroupIndexGen(groupID string, seqSuffix uint32) string {
|
|
|
|
return "super_group_" + groupID + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
|
|
|
return "super_group_" + groupID + ":" + strconv.FormatInt(int64(seqSuffix), 10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *DataBases) CleanUpUserMsgFromMongo(userID string, operationID string) error {
|
|
|
|
func (d *db.DataBases) CleanUpUserMsgFromMongo(userID string, operationID string) error {
|
|
|
|
ctx := context.Background()
|
|
|
|
ctx := context.Background()
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cChat)
|
|
|
|
maxSeq, err := d.GetUserMaxSeq(userID)
|
|
|
|
maxSeq, err := d.GetUserMaxSeq(userID)
|