Create group extension field

This commit is contained in:
away 2021-09-06 17:48:14 +08:00
parent 13038514df
commit 8b156dc962
5 changed files with 581 additions and 649 deletions

View File

@ -18,6 +18,7 @@ type paramsCreateGroupStruct struct {
Notification string `json:"notification"` Notification string `json:"notification"`
FaceUrl string `json:"faceUrl"` FaceUrl string `json:"faceUrl"`
OperationID string `json:"operationID" binding:"required"` OperationID string `json:"operationID" binding:"required"`
Ex string `json:"ex"`
} }
func CreateGroup(c *gin.Context) { func CreateGroup(c *gin.Context) {
@ -39,6 +40,7 @@ func CreateGroup(c *gin.Context) {
Notification: params.Notification, Notification: params.Notification,
FaceUrl: params.FaceUrl, FaceUrl: params.FaceUrl,
OperationID: params.OperationID, OperationID: params.OperationID,
Ex: params.Ex,
Token: c.Request.Header.Get("token"), Token: c.Request.Header.Get("token"),
} }
log.Info(req.Token, req.OperationID, "api create group is server,params=%s", req.String()) log.Info(req.Token, req.OperationID, "api create group is server,params=%s", req.String())

View File

@ -8,7 +8,7 @@ import (
"time" "time"
) )
func InsertIntoGroup(groupId, name, introduction, notification, faceUrl string) error { func InsertIntoGroup(groupId, name, introduction, notification, faceUrl, ex string) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB() dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil { if err != nil {
return err return err
@ -17,7 +17,7 @@ func InsertIntoGroup(groupId, name, introduction, notification, faceUrl string)
if name == "" { if name == "" {
name = "groupChat" name = "groupChat"
} }
toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now()} toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now(), Ex: ex}
err = dbConn.Table("group").Create(toInsertInfo).Error err = dbConn.Table("group").Create(toInsertInfo).Error
if err != nil { if err != nil {
return err return err
@ -194,6 +194,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID) ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID)
if err != nil { if err != nil {
log.ErrorByKv("FindGroupMemberInfoByGroupIdAndUserId failed", pb.OperationID, "groupId", pb.GroupID, "ownerID", pb.OwnerID)
return nil, err return nil, err
} }
if ownerUser.AdministratorLevel <= 0 { if ownerUser.AdministratorLevel <= 0 {
@ -208,6 +209,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and from_user_id = ? and to_user_id = ?", err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and from_user_id = ? and to_user_id = ?",
"", pb.GroupID, pb.FromUserID, pb.ToUserID).Scan(&groupRequest).Error "", pb.GroupID, pb.FromUserID, pb.ToUserID).Scan(&groupRequest).Error
if err != nil { if err != nil {
log.ErrorByKv("find group_request info failed", pb.OperationID, "groupId", pb.GroupID, "fromUserId", pb.FromUserID, "toUserId", pb.OwnerID)
return nil, err return nil, err
} }
@ -226,6 +228,7 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and from_user_id = ? and to_user_id = ?", err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and from_user_id = ? and to_user_id = ?",
saveFlag, pb.HandledMsg, pb.OwnerID, groupRequest.GroupID, groupRequest.FromUserID, groupRequest.ToUserID).Error saveFlag, pb.HandledMsg, pb.OwnerID, groupRequest.GroupID, groupRequest.FromUserID, groupRequest.ToUserID).Error
if err != nil { if err != nil {
log.ErrorByKv("update group request failed", pb.OperationID, "groupID", pb.GroupID, "flag", saveFlag, "ownerId", pb.OwnerID, "fromUserId", pb.FromUserID, "toUserID", pb.ToUserID)
return nil, err return nil, err
} }
@ -233,11 +236,13 @@ func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.Gro
if groupRequest.ToUserID == "0" { if groupRequest.ToUserID == "0" {
err = InsertIntoGroupMember(pb.GroupID, pb.FromUserID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0) err = InsertIntoGroupMember(pb.GroupID, pb.FromUserID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0)
if err != nil { if err != nil {
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
return nil, err return nil, err
} }
} else { } else {
err = InsertIntoGroupMember(pb.GroupID, pb.ToUserID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0) err = InsertIntoGroupMember(pb.GroupID, pb.ToUserID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0)
if err != nil { if err != nil {
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
return nil, err return nil, err
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,284 +3,284 @@ option go_package = "group;group";
package group; package group;
message CommonResp{ message CommonResp{
int32 ErrorCode = 1; int32 ErrorCode = 1;
string ErrorMsg = 2; string ErrorMsg = 2;
} }
message CreateGroupReq{ message CreateGroupReq{
repeated GroupAddMemberInfo memberList = 1; repeated GroupAddMemberInfo memberList = 1;
string groupName = 2; string groupName = 2;
string introduction = 3; string introduction = 3;
string notification = 4; string notification = 4;
string faceUrl = 5; string faceUrl = 5;
string token = 6; string token = 6;
string operationID = 7; string operationID = 7;
string ex = 8;
} }
message GroupAddMemberInfo{ message GroupAddMemberInfo{
string uid = 1; string uid = 1;
int32 setRole = 2; int32 setRole = 2;
} }
message CreateGroupResp{ message CreateGroupResp{
int32 ErrorCode = 1; int32 ErrorCode = 1;
string ErrorMsg = 2; string ErrorMsg = 2;
string groupID = 3; string groupID = 3;
} }
message GetGroupsInfoReq{ message GetGroupsInfoReq{
repeated string groupIDList = 1; repeated string groupIDList = 1;
string token = 2; string token = 2;
string operationID = 3; string operationID = 3;
} }
message GetGroupsInfoResp{ message GetGroupsInfoResp{
int32 ErrorCode = 1; int32 ErrorCode = 1;
string ErrorMsg = 2; string ErrorMsg = 2;
repeated GroupInfo data = 3; repeated GroupInfo data = 3;
} }
message SetGroupInfoReq{ message SetGroupInfoReq{
string groupID = 1; string groupID = 1;
string groupName = 2; string groupName = 2;
string notification = 3; string notification = 3;
string introduction = 4; string introduction = 4;
string faceUrl = 5; string faceUrl = 5;
string token = 6; string token = 6;
string operationID = 7; string operationID = 7;
} }
message GetGroupApplicationListReq { message GetGroupApplicationListReq {
string UID = 1; string UID = 1;
string OperationID = 2; string OperationID = 2;
} }
message GetGroupApplicationList_Data_User { message GetGroupApplicationList_Data_User {
string ID = 1; string ID = 1;
string GroupID = 2; string GroupID = 2;
string FromUserID = 3; string FromUserID = 3;
string ToUserID = 4; string ToUserID = 4;
int32 Flag = 5; int32 Flag = 5;
string RequestMsg = 6; string RequestMsg = 6;
string HandledMsg = 7; string HandledMsg = 7;
int64 AddTime = 8; int64 AddTime = 8;
string FromUserNickname = 9; string FromUserNickname = 9;
string ToUserNickname = 10; string ToUserNickname = 10;
string FromUserFaceUrl = 11; string FromUserFaceUrl = 11;
string ToUserFaceUrl = 12; string ToUserFaceUrl = 12;
string HandledUser = 13; string HandledUser = 13;
int32 Type = 14; int32 Type = 14;
int32 HandleStatus = 15; int32 HandleStatus = 15;
int32 HandleResult = 16; int32 HandleResult = 16;
} }
message GetGroupApplicationListData { message GetGroupApplicationListData {
int32 Count = 1; int32 Count = 1;
repeated GetGroupApplicationList_Data_User User = 2; repeated GetGroupApplicationList_Data_User User = 2;
} }
message GetGroupApplicationListResp { message GetGroupApplicationListResp {
int32 ErrCode = 1; int32 ErrCode = 1;
string ErrMsg = 2; string ErrMsg = 2;
GetGroupApplicationListData Data = 3; GetGroupApplicationListData Data = 3;
} }
message TransferGroupOwnerReq { message TransferGroupOwnerReq {
string GroupID = 1; string GroupID = 1;
string OldOwner = 2; string OldOwner = 2;
string NewOwner = 3; string NewOwner = 3;
string OperationID = 4; string OperationID = 4;
} }
message TransferGroupOwnerResp{ message TransferGroupOwnerResp{
int32 ErrCode = 1; int32 ErrCode = 1;
string ErrMsg = 2; string ErrMsg = 2;
} }
message JoinGroupReq{ message JoinGroupReq{
string groupID = 1; string groupID = 1;
string message = 2; string message = 2;
string token = 3; string token = 3;
string OperationID = 4; string OperationID = 4;
} }
message GroupApplicationResponseReq{ message GroupApplicationResponseReq{
string OperationID = 1; string OperationID = 1;
string OwnerID = 2; string OwnerID = 2;
string GroupID = 3; string GroupID = 3;
string FromUserID = 4; string FromUserID = 4;
string FromUserNickName = 5; string FromUserNickName = 5;
string FromUserFaceUrl = 6; string FromUserFaceUrl = 6;
string ToUserID = 7; string ToUserID = 7;
string ToUserNickName = 8; string ToUserNickName = 8;
string ToUserFaceUrl = 9; string ToUserFaceUrl = 9;
int64 AddTime = 10; int64 AddTime = 10;
string RequestMsg = 11; string RequestMsg = 11;
string HandledMsg = 12; string HandledMsg = 12;
int32 Type = 13; int32 Type = 13;
int32 HandleStatus = 14; int32 HandleStatus = 14;
int32 HandleResult = 15; int32 HandleResult = 15;
} }
message GroupApplicationResponseResp{ message GroupApplicationResponseResp{
int32 ErrCode = 1; int32 ErrCode = 1;
string ErrMsg = 2; string ErrMsg = 2;
} }
message SetOwnerGroupNickNameReq{ message SetOwnerGroupNickNameReq{
string groupID = 1; string groupID = 1;
string nickName = 2; string nickName = 2;
string OperationID = 3; string OperationID = 3;
string token = 4; string token = 4;
} }
message QuitGroupReq{ message QuitGroupReq{
string groupID = 1; string groupID = 1;
string operationID = 2; string operationID = 2;
string token = 3; string token = 3;
} }
message GroupApplicationUserInfo{ message GroupApplicationUserInfo{
string groupID = 1; string groupID = 1;
string uid = 2; string uid = 2;
string name = 3; string name = 3;
string icon = 4; string icon = 4;
string reqMsg = 5; string reqMsg = 5;
int64 applicationTime = 6; int64 applicationTime = 6;
int32 flag = 7; int32 flag = 7;
string operatorID = 8; string operatorID = 8;
string handledMsg = 9; string handledMsg = 9;
} }
message GroupMemberFullInfo { message GroupMemberFullInfo {
string userId = 1; string userId = 1;
int32 role = 2; int32 role = 2;
uint64 joinTime = 3; uint64 joinTime = 3;
string nickName = 4; string nickName = 4;
string faceUrl = 5; string faceUrl = 5;
} }
message GetGroupMemberListReq { message GetGroupMemberListReq {
string groupID = 1; string groupID = 1;
string token = 2; string token = 2;
string operationID = 3; string operationID = 3;
int32 filter = 4; int32 filter = 4;
int32 nextSeq = 5; int32 nextSeq = 5;
} }
message GetGroupMemberListResp { message GetGroupMemberListResp {
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated GroupMemberFullInfo memberList = 3; repeated GroupMemberFullInfo memberList = 3;
int32 nextSeq = 4; int32 nextSeq = 4;
} }
message GetGroupMembersInfoReq { message GetGroupMembersInfoReq {
string groupID = 1; string groupID = 1;
repeated string memberList = 2; repeated string memberList = 2;
string token = 3; string token = 3;
string operationID = 4; string operationID = 4;
} }
message GetGroupMembersInfoResp { message GetGroupMembersInfoResp {
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated GroupMemberFullInfo memberList = 3; repeated GroupMemberFullInfo memberList = 3;
} }
message KickGroupMemberReq { message KickGroupMemberReq {
string groupID = 1; string groupID = 1;
repeated GroupMemberFullInfo uidListInfo = 2; repeated GroupMemberFullInfo uidListInfo = 2;
string reason = 3; string reason = 3;
string token = 4; string token = 4;
string operationID = 5; string operationID = 5;
} }
message Id2Result { message Id2Result {
string uId = 1; string uId = 1;
int32 result = 2; //0 ok; -1 error int32 result = 2; //0 ok; -1 error
} }
message KickGroupMemberResp { message KickGroupMemberResp {
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated Id2Result id2result = 3; repeated Id2Result id2result = 3;
} }
message getJoinedGroupListReq { message getJoinedGroupListReq {
string token = 1; string token = 1;
string operationID = 2; string operationID = 2;
} }
message GroupInfo { message GroupInfo {
string groupId = 1; string groupId = 1;
string groupName = 2; string groupName = 2;
string notification = 3; string notification = 3;
string introduction = 4; string introduction = 4;
string faceUrl = 5; string faceUrl = 5;
uint64 createTime = 6; uint64 createTime = 6;
string ownerId = 7; string ownerId = 7;
uint32 memberCount = 8; uint32 memberCount = 8;
} }
message getJoinedGroupListResp{ message getJoinedGroupListResp{
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated GroupInfo groupList = 3; repeated GroupInfo groupList = 3;
} }
message inviteUserToGroupReq { message inviteUserToGroupReq {
string token = 1; string token = 1;
string operationID = 2; string operationID = 2;
string groupID = 3; string groupID = 3;
string reason = 4; string reason = 4;
repeated string uidList = 5; repeated string uidList = 5;
} }
message inviteUserToGroupResp { message inviteUserToGroupResp {
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated Id2Result id2result = 3; // 0 ok, -1 error repeated Id2Result id2result = 3; // 0 ok, -1 error
} }
message GetGroupAllMemberReq { message GetGroupAllMemberReq {
string groupID = 1; string groupID = 1;
string token = 2; string token = 2;
string operationID = 3; string operationID = 3;
} }
message GetGroupAllMemberResp { message GetGroupAllMemberResp {
int32 errorCode = 1; int32 errorCode = 1;
string errorMsg = 2; string errorMsg = 2;
repeated GroupMemberFullInfo memberList = 3; repeated GroupMemberFullInfo memberList = 3;
} }
service group{ service group{
rpc createGroup(CreateGroupReq) returns(CreateGroupResp); rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
rpc joinGroup(JoinGroupReq) returns(CommonResp); rpc joinGroup(JoinGroupReq) returns(CommonResp);
rpc quitGroup(QuitGroupReq) returns(CommonResp); rpc quitGroup(QuitGroupReq) returns(CommonResp);
rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp); rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp);
rpc setGroupInfo(SetGroupInfoReq) returns(CommonResp); rpc setGroupInfo(SetGroupInfoReq) returns(CommonResp);
rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp); rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp);
rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp); rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp);
rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp); rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp);
// rpc setOwnerGroupNickName(SetOwnerGroupNickNameReq) returns(CommonResp); // rpc setOwnerGroupNickName(SetOwnerGroupNickNameReq) returns(CommonResp);
rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp); rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp);
rpc getGroupMembersInfo(GetGroupMembersInfoReq) returns(GetGroupMembersInfoResp); rpc getGroupMembersInfo(GetGroupMembersInfoReq) returns(GetGroupMembersInfoResp);
rpc kickGroupMember(KickGroupMemberReq) returns (KickGroupMemberResp); rpc kickGroupMember(KickGroupMemberReq) returns (KickGroupMemberResp);
rpc getJoinedGroupList(getJoinedGroupListReq) returns (getJoinedGroupListResp); rpc getJoinedGroupList(getJoinedGroupListReq) returns (getJoinedGroupListResp);
rpc inviteUserToGroup(inviteUserToGroupReq) returns (inviteUserToGroupResp); rpc inviteUserToGroup(inviteUserToGroupReq) returns (inviteUserToGroupResp);
rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp); rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp);
} }

View File

@ -76,7 +76,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
} }
//Time stamp + MD5 to generate group chat id //Time stamp + MD5 to generate group chat id
groupId = utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10)) groupId = utils.Md5(strconv.FormatInt(time.Now().UnixNano(), 10))
err = im_mysql_model.InsertIntoGroup(groupId, req.GroupName, req.Introduction, req.Notification, req.FaceUrl) err = im_mysql_model.InsertIntoGroup(groupId, req.GroupName, req.Introduction, req.Notification, req.FaceUrl, req.Ex)
if err != nil { if err != nil {
log.ErrorByKv("create group chat failed", req.OperationID, "err=%s", err.Error()) log.ErrorByKv("create group chat failed", req.OperationID, "err=%s", err.Error())
return &pbGroup.CreateGroupResp{ErrorCode: config.ErrCreateGroup.ErrCode, ErrorMsg: config.ErrCreateGroup.ErrMsg}, nil return &pbGroup.CreateGroupResp{ErrorCode: config.ErrCreateGroup.ErrCode, ErrorMsg: config.ErrCreateGroup.ErrMsg}, nil