mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 20:15:59 +08:00
getui
This commit is contained in:
@@ -49,10 +49,11 @@ func init() {
|
||||
if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" {
|
||||
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s/?maxPoolSize=%d", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress[0],
|
||||
config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize)
|
||||
} else {
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
}
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
}
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
@@ -64,7 +65,7 @@ func init() {
|
||||
panic(err1.Error())
|
||||
}
|
||||
}
|
||||
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success")
|
||||
fmt.Println("0", utils.GetSelfFuncName(), "mongo driver client init success: ", uri)
|
||||
|
||||
DB.mongoClient = mongoClient
|
||||
|
||||
|
||||
@@ -564,16 +564,87 @@ func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32)
|
||||
}
|
||||
|
||||
type WorkMoment struct {
|
||||
WorkMomentID string `bson:"work_moment_id"`
|
||||
UserID string `bson:"user_id"`
|
||||
Content string `bson:"content"`
|
||||
LikeUsers []*LikeUser `bson:"like_users"`
|
||||
Comments []*Comment `bson:"comments"`
|
||||
WhoCanSeeUserIDList []string `bson:"who_can_see_user_id_list"`
|
||||
WhoCantSeeUserIDList []string `bson:"who_cant_see_user_id_list"`
|
||||
IsPrivate bool
|
||||
IsPublic bool
|
||||
CreateTime int32
|
||||
}
|
||||
|
||||
type LikeUser struct {
|
||||
UserID string
|
||||
UserName string
|
||||
}
|
||||
|
||||
type Comment struct {
|
||||
UserID string
|
||||
UserName string
|
||||
ReplyUserID string
|
||||
ReplyUserName string
|
||||
ContentID string
|
||||
Content string
|
||||
CreateTime int32
|
||||
}
|
||||
|
||||
func (d *DataBases) CreateOneWorkMoment(workMoment *WorkMoment) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) DeleteOneWorkMoment(workMomentID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetWorkMomentByID(workMomentID string) (*WorkMoment, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) LikeOneWorkMoment(likeUserID, workMomentID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) SetUserWorkMomentsLevel(userID string, level int32) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) ClearUserWorkMomentsCommentsMsg(userID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type CommentMsg struct {
|
||||
WorkMomentID string `bson:"workMoment"`
|
||||
CommentContent string `bson:"content"`
|
||||
Comment
|
||||
}
|
||||
|
||||
func (d *DataBases) GetUserWorkMomentsCommentsMsg(userID string, showNumber, pageNumber int32) ([]CommentMsg, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) CommentOneWorkMoment(comment Comment, workMomentID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetUserWorkMoments(userID string, showNumber, pageNumber int32) ([]WorkMoment, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetUserFriendWorkMoments(friendIDList []string, showNumber, pageNumber int32) ([]WorkMoment, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func generateTagID(tagName, userID string) string {
|
||||
return utils.Md5(tagName + userID + strconv.Itoa(rand.Int()) + time.Now().String())
|
||||
}
|
||||
|
||||
func generateWorkMomentID(userID string) string {
|
||||
return utils.Md5(userID + strconv.Itoa(rand.Int()) + time.Now().String())
|
||||
}
|
||||
|
||||
func getCurrentTimestampByMill() int64 {
|
||||
return time.Now().UnixNano() / 1e6
|
||||
}
|
||||
|
||||
@@ -49,6 +49,19 @@ func GetFriendListByUserID(OwnerUserID string) ([]db.Friend, error) {
|
||||
return friends, nil
|
||||
}
|
||||
|
||||
func GetFriendIDListByUserID(OwnerUserID string) ([]string, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var friendIDList []string
|
||||
err = dbConn.Table("friends").Select("friend_user_id").Where("owner_user_id=?", OwnerUserID).Find(&friendIDList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return friendIDList, nil
|
||||
}
|
||||
|
||||
func UpdateFriendComment(OwnerUserID, FriendUserID, Remark string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user