mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-15 22:39:03 +08:00
Merge remote-tracking branch 'origin/tuoyun' into tuoyun
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package base_info
|
||||
|
||||
import "Open_IM/pkg/proto/office"
|
||||
|
||||
type CreateOneWorkMomentReq struct {
|
||||
office.CreateOneWorkMomentReq
|
||||
}
|
||||
|
||||
type CreateOneWorkMomentResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type DeleteOneWorkMomentReq struct {
|
||||
office.DeleteOneWorkMomentReq
|
||||
}
|
||||
|
||||
type DeleteOneWorkMomentResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type LikeOneWorkMomentReq struct {
|
||||
office.LikeOneWorkMomentReq
|
||||
}
|
||||
|
||||
type LikeOneWorkMomentResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type CommentOneWorkMomentReq struct {
|
||||
office.CommentOneWorkMomentReq
|
||||
}
|
||||
|
||||
type CommentOneWorkMomentResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type WorkMomentsUserCommonReq struct {
|
||||
PageNumber int32 `json:"pageNumber" binding:"required"`
|
||||
ShowNumber int32 `json:"showNumber" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UserID string `json:"UserID" binding:"required"`
|
||||
}
|
||||
|
||||
type GetUserWorkMomentsReq struct {
|
||||
WorkMomentsUserCommonReq
|
||||
}
|
||||
|
||||
type GetUserWorkMomentsResp struct {
|
||||
CommResp
|
||||
Data struct {
|
||||
WorkMoments []*office.WorkMoment `json:"workMoments"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
ShowNumber int32 `json:"showNumber"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type GetUserFriendWorkMomentsReq struct {
|
||||
WorkMomentsUserCommonReq
|
||||
}
|
||||
|
||||
type GetUserFriendWorkMomentsResp struct {
|
||||
CommResp
|
||||
Data struct {
|
||||
WorkMoments []*office.WorkMoment `json:"workMoments"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
ShowNumber int32 `json:"showNumber"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type GetUserWorkMomentsCommentsMsgReq struct {
|
||||
WorkMomentsUserCommonReq
|
||||
}
|
||||
|
||||
type GetUserWorkMomentsCommentsMsgResp struct {
|
||||
CommResp
|
||||
Data struct {
|
||||
CommentMsgs []*office.CommentsMsg `json:"comments"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
ShowNumber int32 `json:"showNumber"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type SetUserWorkMomentsLevelReq struct {
|
||||
office.SetUserWorkMomentsLevelReq
|
||||
}
|
||||
|
||||
type SetUserWorkMomentsLevelResp struct {
|
||||
CommResp
|
||||
}
|
||||
|
||||
type ClearUserWorkMomentsCommentsMsgReq struct {
|
||||
office.ClearUserWorkMomentsCommentsMsgReq
|
||||
}
|
||||
|
||||
type ClearUserWorkMomentsCommentsMsgResp struct {
|
||||
CommResp
|
||||
}
|
||||
@@ -46,11 +46,15 @@ func init() {
|
||||
// example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
|
||||
uri = config.Config.Mongo.DBUri
|
||||
} else {
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
config.Config.Mongo.DBAddress[0], config.Config.Mongo.DBDatabase,
|
||||
config.Config.Mongo.DBMaxPoolSize)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)
|
||||
@@ -61,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
|
||||
|
||||
|
||||
@@ -563,10 +563,88 @@ func (d *DataBases) GetTagSendLogs(userID string, showNumber, pageNumber int32)
|
||||
return tagSendLogs, nil
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -93,7 +93,7 @@ func GetClaimFromToken(tokensString string) (*Claims, error) {
|
||||
}
|
||||
} else {
|
||||
if claims, ok := token.Claims.(*Claims); ok && token.Valid {
|
||||
log.NewDebug("", claims.UID, claims.Platform)
|
||||
//log.NewDebug("", claims.UID, claims.Platform)
|
||||
return claims, nil
|
||||
}
|
||||
return nil, &constant.ErrTokenNotValidYet
|
||||
|
||||
+1618
-72
File diff suppressed because it is too large
Load Diff
@@ -106,6 +106,139 @@ message GetUserTagByIDResp {
|
||||
Tag tag = 2;
|
||||
}
|
||||
|
||||
/// WorkMoment
|
||||
|
||||
message LikeUser {
|
||||
string userID = 1;
|
||||
string userName = 2;
|
||||
}
|
||||
|
||||
message Comment {
|
||||
string userID = 1;
|
||||
string userName = 2;
|
||||
string replyUserID = 3;
|
||||
string replyUserName = 4;
|
||||
string contentID = 5;
|
||||
string content = 6;
|
||||
int32 createTime = 7;
|
||||
}
|
||||
|
||||
message WorkMoment {
|
||||
string workMomentID = 1;
|
||||
string userID = 2;
|
||||
string content = 3;
|
||||
repeated LikeUser likeUsers = 4;
|
||||
repeated Comment comments = 5;
|
||||
repeated string whoCanSeeUserIDList = 6;
|
||||
repeated string whoCantSeeUserIDList = 7;
|
||||
bool isPrivate = 8;
|
||||
bool isPublic = 9;
|
||||
int32 CreateTime = 10;
|
||||
}
|
||||
|
||||
message CreateOneWorkMomentReq {
|
||||
WorkMoment workMoment = 1;
|
||||
string userID = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message CreateOneWorkMomentResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message DeleteOneWorkMomentReq {
|
||||
string workMomentID = 1;
|
||||
string userID = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message DeleteOneWorkMomentResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message LikeOneWorkMomentReq {
|
||||
string userID = 1;
|
||||
string WorkMomentID = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message LikeOneWorkMomentResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message CommentOneWorkMomentReq {
|
||||
string userID = 1;
|
||||
string workMomentID = 2;
|
||||
string replyUserID = 3;
|
||||
string content = 4;
|
||||
string operationID = 5;
|
||||
}
|
||||
|
||||
message CommentOneWorkMomentResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message GetUserWorkMomentsReq {
|
||||
string userID = 1;
|
||||
server_api_params.RequestPagination Pagination = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message GetUserWorkMomentsResp {
|
||||
CommonResp commonResp = 1;
|
||||
repeated WorkMoment workMoments = 2;
|
||||
server_api_params.ResponsePagination Pagination = 3;
|
||||
}
|
||||
|
||||
message GetUserFriendWorkMomentsReq {
|
||||
string userID = 1;
|
||||
server_api_params.RequestPagination Pagination = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message GetUserFriendWorkMomentsResp {
|
||||
CommonResp commonResp = 1;
|
||||
repeated WorkMoment workMoments = 2;
|
||||
server_api_params.ResponsePagination Pagination = 3;
|
||||
}
|
||||
|
||||
message CommentsMsg {
|
||||
Comment comment = 1;
|
||||
string workMomentID = 2;
|
||||
string content = 3;
|
||||
}
|
||||
|
||||
message GetUserWorkMomentsCommentsMsgReq {
|
||||
string userID = 1;
|
||||
string operationID = 2;
|
||||
server_api_params.RequestPagination Pagination = 3;
|
||||
}
|
||||
|
||||
message GetUserWorkMomentsCommentsMsgResp {
|
||||
CommonResp commonResp = 1;
|
||||
repeated CommentsMsg commentsMsgs = 2;
|
||||
server_api_params.ResponsePagination Pagination = 3;
|
||||
}
|
||||
|
||||
message ClearUserWorkMomentsCommentsMsgReq {
|
||||
string userID = 1;
|
||||
string operationID = 2;
|
||||
}
|
||||
|
||||
message ClearUserWorkMomentsCommentsMsgResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
message SetUserWorkMomentsLevelReq {
|
||||
string userID = 1;
|
||||
int32 level = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message SetUserWorkMomentsLevelResp {
|
||||
CommonResp commonResp = 1;
|
||||
}
|
||||
|
||||
service OfficeService {
|
||||
rpc GetUserTags(GetUserTagsReq) returns(GetUserTagsResp);
|
||||
rpc CreateTag(CreateTagReq) returns(CreateTagResp);
|
||||
@@ -114,5 +247,17 @@ service OfficeService {
|
||||
rpc SendMsg2Tag(SendMsg2TagReq) returns(SendMsg2TagResp);
|
||||
rpc GetTagSendLogs(GetTagSendLogsReq) returns(GetTagSendLogsResp);
|
||||
rpc GetUserTagByID(GetUserTagByIDReq) returns(GetUserTagByIDResp);
|
||||
|
||||
rpc CreateOneWorkMoment(CreateOneWorkMomentReq) returns(CreateOneWorkMomentResp);
|
||||
rpc DeleteOneWorkMoment(DeleteOneWorkMomentReq) returns(DeleteOneWorkMomentResp);
|
||||
rpc LikeOneWorkMoment(LikeOneWorkMomentReq) returns(LikeOneWorkMomentResp);
|
||||
rpc CommentOneWorkMoment(CommentOneWorkMomentReq) returns(CommentOneWorkMomentResp);
|
||||
/// user self
|
||||
rpc GetUserWorkMoments(GetUserWorkMomentsReq) returns(GetUserWorkMomentsResp);
|
||||
/// users friend
|
||||
rpc GetUserFriendWorkMoments(GetUserFriendWorkMomentsReq) returns(GetUserFriendWorkMomentsResp);
|
||||
rpc GetUserWorkMomentsCommentsMsg(GetUserWorkMomentsCommentsMsgReq) returns(GetUserWorkMomentsCommentsMsgResp);
|
||||
rpc ClearUserWorkMomentsCommentsMsg(ClearUserWorkMomentsCommentsMsgReq) returns(ClearUserWorkMomentsCommentsMsgResp);
|
||||
rpc SetUserWorkMomentsLevel(SetUserWorkMomentsLevelReq) returns(SetUserWorkMomentsLevelResp);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,14 @@ func IsContain(target string, List []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func IsContainInt32(target int32, List []int32) bool {
|
||||
for _, element := range List {
|
||||
if target == element {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func InterfaceArrayToStringArray(data []interface{}) (i []string) {
|
||||
for _, param := range data {
|
||||
|
||||
Reference in New Issue
Block a user