Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

 Conflicts:
	pkg/common/db/cache/conversation.go
This commit is contained in:
wangchuxiao 2023-02-07 18:45:54 +08:00
commit 8fc54a7379
33 changed files with 2151 additions and 1722 deletions

View File

@ -1375,7 +1375,7 @@ const docTemplate = `{
"群组相关" "群组相关"
], ],
"summary": "获取用户加入群列表", "summary": "获取用户加入群列表",
"operationId": "GetJoinedGroupList", "operationId": "FindJoinedGroup",
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",

View File

@ -118,7 +118,7 @@ func main() {
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList) groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1 groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1 groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
// groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use // groupRouterGroup.POST("/get_group_member_list", group.FindGroupMemberAll) //no use
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1 groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1 groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1 groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1

120
go.mod
View File

@ -17,16 +17,11 @@ require (
github.com/aws/aws-sdk-go-v2/credentials v1.12.9 github.com/aws/aws-sdk-go-v2/credentials v1.12.9
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9 github.com/aws/aws-sdk-go-v2/service/sts v1.16.9
github.com/bwmarrin/snowflake v0.3.0 github.com/bwmarrin/snowflake v0.3.0
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/dtm-labs/rockscache v0.0.11 github.com/dtm-labs/rockscache v0.0.11
github.com/fatih/structs v1.1.0 github.com/fatih/structs v1.1.0
github.com/gin-gonic/gin v1.8.2 github.com/gin-gonic/gin v1.8.2
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/validator/v10 v10.11.1 github.com/go-playground/validator/v10 v10.11.1
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 github.com/gogo/protobuf v1.3.2
github.com/golang-jwt/jwt/v4 v4.4.2 github.com/golang-jwt/jwt/v4 v4.4.2
github.com/golang/protobuf v1.5.2 github.com/golang/protobuf v1.5.2
@ -34,7 +29,6 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/jinzhu/copier v0.3.5 github.com/jinzhu/copier v0.3.5
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/minio/minio-go/v7 v7.0.22 github.com/minio/minio-go/v7 v7.0.22
github.com/mitchellh/mapstructure v1.4.2 github.com/mitchellh/mapstructure v1.4.2
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
@ -51,26 +45,124 @@ require (
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.428 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.428
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.428 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.428
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
github.com/ugorji/go/codec v1.2.8 // indirect
go.etcd.io/etcd/client/v3 v3.5.6 go.etcd.io/etcd/client/v3 v3.5.6
go.mongodb.org/mongo-driver v1.8.3 go.mongodb.org/mongo-driver v1.8.3
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/image v0.3.0 golang.org/x/image v0.3.0
golang.org/x/net v0.5.0 golang.org/x/net v0.5.0
golang.org/x/tools v0.1.12
google.golang.org/api v0.103.0 google.golang.org/api v0.103.0
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.52.0 google.golang.org/grpc v1.52.0
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.28.1
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.3.5 gorm.io/driver/mysql v1.3.5
gorm.io/gorm v1.23.8 gorm.io/gorm v1.23.8
) )
require (
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.13.0 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/firestore v1.9.0 // indirect
cloud.google.com/go/iam v0.8.0 // indirect
cloud.google.com/go/longrunning v0.3.0 // indirect
cloud.google.com/go/storage v1.27.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/OpenIMSDK/open_log v1.0.0 // indirect
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
github.com/alibabacloud-go/openapi-util v0.0.9 // indirect
github.com/alibabacloud-go/tea-utils v1.3.9 // indirect
github.com/aliyun/credentials-go v1.1.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.14 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.8 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.8 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.11.12 // indirect
github.com/aws/smithy-go v1.12.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/minio/md5-simd v1.1.0 // indirect
github.com/minio/sha256-simd v0.1.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rs/xid v1.2.1 // indirect
github.com/tjfoc/gmsm v1.3.2 // indirect
github.com/ugorji/go/codec v1.2.8 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.0.2 // indirect
github.com/xdg-go/stringprep v1.0.2 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.etcd.io/etcd/api/v3 v3.5.6 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.6 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0 replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0

View File

@ -72,7 +72,7 @@ func KickGroupMember(c *gin.Context) {
client := rpc.NewGroupClient(etcdConn) client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.KickGroupMember(context.Background(), req) RpcResp, err := client.KickGroupMember(context.Background(), req)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String()) log.NewError(req.OperationID, "FindGroupMemberAll failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return return
} }
@ -136,7 +136,7 @@ func GetGroupMembersInfo(c *gin.Context) {
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req) RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String()) log.NewError(req.OperationID, "FindGroupMemberAll failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return return
} }
@ -167,7 +167,7 @@ func GetGroupMemberList(c *gin.Context) {
return return
} }
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String()) log.NewInfo(req.OperationID, "FindGroupMemberAll args ", req.String())
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
if etcdConn == nil { if etcdConn == nil {
@ -180,7 +180,7 @@ func GetGroupMemberList(c *gin.Context) {
RpcResp, err := client.GetGroupMemberList(context.Background(), req) RpcResp, err := client.GetGroupMemberList(context.Background(), req)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetGroupMemberList failed, ", err.Error(), req.String()) log.NewError(req.OperationID, "FindGroupMemberAll failed, ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return return
} }
@ -188,7 +188,7 @@ func GetGroupMemberList(c *gin.Context) {
memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq} memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList) memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
log.NewInfo(req.OperationID, "GetGroupMemberList api return ", memberListResp) log.NewInfo(req.OperationID, "FindGroupMemberAll api return ", memberListResp)
c.JSON(http.StatusOK, memberListResp) c.JSON(http.StatusOK, memberListResp)
} }
@ -280,7 +280,7 @@ func GetJoinedGroupList(c *gin.Context) {
return return
} }
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String()) log.NewInfo(req.OperationID, "FindJoinedGroup args ", req.String())
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID) etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
if etcdConn == nil { if etcdConn == nil {
@ -292,14 +292,14 @@ func GetJoinedGroupList(c *gin.Context) {
client := rpc.NewGroupClient(etcdConn) client := rpc.NewGroupClient(etcdConn)
RpcResp, err := client.GetJoinedGroupList(context.Background(), req) RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetJoinedGroupList failed ", err.Error(), req.String()) log.NewError(req.OperationID, "FindJoinedGroup failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()}) c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return return
} }
GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupList} GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList) GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp) log.NewInfo(req.OperationID, "FindJoinedGroup api return ", GroupListResp)
c.JSON(http.StatusOK, GroupListResp) c.JSON(http.StatusOK, GroupListResp)
} }

View File

@ -0,0 +1,17 @@
package check
import (
server_api_params "Open_IM/pkg/proto/sdk_ws"
"errors"
)
type GroupChecker struct {
}
func NewGroupChecker() *GroupChecker {
return &GroupChecker{}
}
func (g *GroupChecker) GetGroupInfo(groupID string) (*server_api_params.GroupInfo, error) {
return nil, errors.New("TODO:GetUserInfo")
}

View File

@ -207,7 +207,7 @@ func (s *adminCMSServer) GetChatLogs(ctx context.Context, req *pbAdminCMS.GetCha
pbChatLog.SenderNickname = recvUser.Nickname pbChatLog.SenderNickname = recvUser.Nickname
case constant.GroupChatType, constant.SuperGroupChatType: case constant.GroupChatType, constant.SuperGroupChatType:
group, err := s.groupInterface.TakeGroupByID(ctx, chatLog.RecvID) group, err := s.groupInterface.TakeGroup(ctx, chatLog.RecvID)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,17 +1,22 @@
package conversation package conversation
import ( import (
"Open_IM/internal/common/check"
chat "Open_IM/internal/rpc/msg" chat "Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db/cache"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" "Open_IM/pkg/common/db/controller"
rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table"
"Open_IM/pkg/common/db/unrelation"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
promePkg "Open_IM/pkg/common/prometheus" promePkg "Open_IM/pkg/common/prometheus"
"Open_IM/pkg/getcdv3" "Open_IM/pkg/getcdv3"
pbConversation "Open_IM/pkg/proto/conversation" pbConversation "Open_IM/pkg/proto/conversation"
pbUser "Open_IM/pkg/proto/user"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"github.com/dtm-labs/rockscache"
"net" "net"
"strconv" "strconv"
"strings" "strings"
@ -23,156 +28,55 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
type rpcConversation struct { type conversationServer struct {
rpcPort int rpcPort int
rpcRegisterName string rpcRegisterName string
etcdSchema string etcdSchema string
etcdAddr []string etcdAddr []string
groupChecker *check.GroupChecker
controller.ConversationInterface
} }
func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) { func NewConversationServer(port int) *conversationServer {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
resp := &pbConversation.ModifyConversationFieldResp{}
var err error
isSyncConversation := true
if req.Conversation.ConversationType == constant.GroupChatType {
groupInfo, err := imdb.GetGroupInfoByGroupID(req.Conversation.GroupID)
if err != nil {
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", req.Conversation.GroupID, err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
if groupInfo.Status == constant.GroupStatusDismissed && !req.Conversation.IsNotInGroup && req.FieldType != constant.FieldUnread {
errMsg := "group status is dismissed"
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}
return resp, nil
}
}
var conversation imdb.Conversation
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", *req.Conversation, err.Error())
}
haveUserID, _ := imdb.GetExistConversationUserIDList(req.UserIDList, req.Conversation.ConversationID)
switch req.FieldType {
case constant.FieldRecvMsgOpt:
for _, v := range req.UserIDList {
if err = db.DB.SetSingleConversationRecvMsgOpt(v, req.Conversation.ConversationID, req.Conversation.RecvMsgOpt); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
}
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"recv_msg_opt": conversation.RecvMsgOpt})
case constant.FieldGroupAtType:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"group_at_type": conversation.GroupAtType})
case constant.FieldIsNotInGroup:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_not_in_group": conversation.IsNotInGroup})
case constant.FieldIsPinned:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_pinned": conversation.IsPinned})
case constant.FieldIsPrivateChat:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"is_private_chat": conversation.IsPrivateChat})
case constant.FieldEx:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"ex": conversation.Ex})
case constant.FieldAttachedInfo:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
case constant.FieldUnread:
isSyncConversation = false
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": conversation.UpdateUnreadCountTime})
case constant.FieldBurnDuration:
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"burn_duration": conversation.BurnDuration})
}
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
conversation.OwnerUserID = v
err = rocksCache.DelUserConversationIDListFromCache(v)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
}
err := imdb.SetOneConversation(conversation)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
}
// notification
if req.Conversation.ConversationType == constant.SingleChatType && req.FieldType == constant.FieldIsPrivateChat {
//sync peer user conversation if conversation is singleChatType
if err := syncPeerUserConversation(req.Conversation, req.OperationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "syncPeerUserConversation", err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
return resp, nil
}
} else {
if isSyncConversation {
for _, v := range req.UserIDList {
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
}
chat.ConversationChangeNotification(req.OperationID, v)
}
} else {
for _, v := range req.UserIDList {
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
}
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID, conversation.UpdateUnreadCountTime)
}
}
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return", resp.String())
resp.CommonResp = &pbConversation.CommonResp{}
return resp, nil
}
func syncPeerUserConversation(conversation *pbConversation.Conversation, operationID string) error {
peerUserConversation := imdb.Conversation{
OwnerUserID: conversation.UserID,
ConversationID: utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType),
ConversationType: constant.SingleChatType,
UserID: conversation.OwnerUserID,
GroupID: "",
RecvMsgOpt: 0,
UnreadCount: 0,
DraftTextTime: 0,
IsPinned: false,
IsPrivateChat: conversation.IsPrivateChat,
AttachedInfo: "",
Ex: "",
}
err := imdb.PeerUserSetConversation(peerUserConversation)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
return err
}
err = rocksCache.DelConversationFromCache(conversation.UserID, utils.GetConversationIDBySessionType(conversation.OwnerUserID, constant.SingleChatType))
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
}
err = rocksCache.DelConversationFromCache(conversation.OwnerUserID, conversation.ConversationID)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "DelConversationFromCache failed", err.Error(), conversation.OwnerUserID, conversation.ConversationID)
}
chat.ConversationSetPrivateNotification(operationID, conversation.OwnerUserID, conversation.UserID, conversation.IsPrivateChat)
return nil
}
func NewRpcConversationServer(port int) *rpcConversation {
log.NewPrivateLog(constant.LogFileName) log.NewPrivateLog(constant.LogFileName)
return &rpcConversation{ c := conversationServer{
rpcPort: port, rpcPort: port,
rpcRegisterName: config.Config.RpcRegisterName.OpenImConversationName, rpcRegisterName: config.Config.RpcRegisterName.OpenImConversationName,
etcdSchema: config.Config.Etcd.EtcdSchema, etcdSchema: config.Config.Etcd.EtcdSchema,
etcdAddr: config.Config.Etcd.EtcdAddr, etcdAddr: config.Config.Etcd.EtcdAddr,
groupChecker: check.NewGroupChecker(),
} }
var cDB relation.Conversation
var cCache cache.ConversationCache
//mysql init
var mysql relation.Mysql
err := mysql.InitConn().AutoMigrateModel(&table.ConversationModel{})
if err != nil {
panic("db init err:" + err.Error())
}
if mysql.GormConn() != nil {
//get gorm model
cDB = relation.NewConversationGorm(mysql.GormConn())
} else {
panic("db init err:" + "conn is nil")
}
//redis init
var redis cache.RedisClient
redis.InitRedis()
rcClient := rockscache.NewClient(redis.GetClient(), rockscache.Options{
RandomExpireAdjustment: 0.2,
DisableCacheRead: false,
DisableCacheDelete: false,
StrongConsistency: true,
})
cCache = cache.NewConversationRedis(rcClient)
database := controller.NewConversationDataBase(cDB, cCache)
c.ConversationInterface = controller.NewConversationController(database)
return &c
} }
func (rpc *rpcConversation) Run() { func (c *conversationServer) Run() {
log.NewInfo("0", "rpc conversation start...") log.NewInfo("0", "rpc conversation start...")
listenIP := "" listenIP := ""
@ -181,11 +85,11 @@ func (rpc *rpcConversation) Run() {
} else { } else {
listenIP = config.Config.ListenIP listenIP = config.Config.ListenIP
} }
address := listenIP + ":" + strconv.Itoa(rpc.rpcPort) address := listenIP + ":" + strconv.Itoa(c.rpcPort)
listener, err := net.Listen("tcp", address) listener, err := net.Listen("tcp", address)
if err != nil { if err != nil {
panic("listening err:" + err.Error() + rpc.rpcRegisterName) panic("listening err:" + err.Error() + c.rpcRegisterName)
} }
log.NewInfo("0", "listen network success, ", address, listener) log.NewInfo("0", "listen network success, ", address, listener)
//grpc server //grpc server
@ -204,7 +108,7 @@ func (rpc *rpcConversation) Run() {
defer srv.GracefulStop() defer srv.GracefulStop()
//service registers with etcd //service registers with etcd
pbConversation.RegisterConversationServer(srv, rpc) pbConversation.RegisterConversationServer(srv, c)
rpcRegisterIP := config.Config.RpcRegisterIP rpcRegisterIP := config.Config.RpcRegisterIP
if config.Config.RpcRegisterIP == "" { if config.Config.RpcRegisterIP == "" {
rpcRegisterIP, err = utils.GetLocalIP() rpcRegisterIP, err = utils.GetLocalIP()
@ -213,13 +117,13 @@ func (rpc *rpcConversation) Run() {
} }
} }
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP) log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10) err = getcdv3.RegisterEtcd(c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName, 10, "")
if err != nil { if err != nil {
log.NewError("0", "RegisterEtcd failed ", err.Error(), log.NewError("0", "RegisterEtcd failed ", err.Error(),
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName) c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName)
panic(utils.Wrap(err, "register conversation module rpc to etcd err")) panic(utils.Wrap(err, "register conversation module rpc to etcd err"))
} }
log.NewInfo("0", "RegisterConversationServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName) log.NewInfo("0", "RegisterConversationServer ok ", c.etcdSchema, strings.Join(c.etcdAddr, ","), rpcRegisterIP, c.rpcPort, c.rpcRegisterName)
err = srv.Serve(listener) err = srv.Serve(listener)
if err != nil { if err != nil {
log.NewError("0", "Serve failed ", err.Error()) log.NewError("0", "Serve failed ", err.Error())
@ -227,3 +131,141 @@ func (rpc *rpcConversation) Run() {
} }
log.NewInfo("0", "rpc conversation ok") log.NewInfo("0", "rpc conversation ok")
} }
func (c *conversationServer) GetConversation(ctx context.Context, req *pbConversation.GetConversationReq) (*pbConversation.GetConversationResp, error) {
resp := &pbConversation.GetConversationResp{Conversation: &pbConversation.Conversation{}}
conversations, err := c.ConversationInterface.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
if err != nil {
return nil, err
}
if len(conversations) > 0 {
if err := utils.CopyStructFields(resp.Conversation, &conversations[0]); err != nil {
return nil, err
}
return resp, nil
}
return nil, nil
}
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbConversation.GetAllConversationsReq) (*pbConversation.GetAllConversationsResp, error) {
resp := &pbConversation.GetAllConversationsResp{Conversations: []*pbConversation.Conversation{}}
conversations, err := c.ConversationInterface.GetUserAllConversation(ctx, req.OwnerUserID)
if err != nil {
return nil, err
}
if err := utils.CopyStructFields(&resp.Conversations, conversations); err != nil {
return nil, err
}
return resp, nil
}
func (c *conversationServer) GetConversations(ctx context.Context, req *pbConversation.GetConversationsReq) (*pbConversation.GetConversationsResp, error) {
resp := &pbConversation.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
conversations, err := c.ConversationInterface.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
if err != nil {
return nil, err
}
if err := utils.CopyStructFields(&resp.Conversations, conversations); err != nil {
return nil, err
}
return resp, nil
}
func (c *conversationServer) BatchSetConversations(ctx context.Context, req *pbConversation.BatchSetConversationsReq) (*pbConversation.BatchSetConversationsResp, error) {
resp := &pbConversation.BatchSetConversationsResp{}
var conversations []*table.ConversationModel
if err := utils.CopyStructFields(&conversations, req.Conversations); err != nil {
return nil, err
}
err := c.ConversationInterface.SetUserConversations(ctx, req.OwnerUserID, conversations)
if err != nil {
return nil, err
}
chat.ConversationChangeNotification(ctx, req.OwnerUserID)
return resp, nil
}
func (c *conversationServer) SetConversation(ctx context.Context, req *pbConversation.SetConversationReq) (*pbConversation.SetConversationResp, error) {
panic("implement me")
}
func (c *conversationServer) SetRecvMsgOpt(ctx context.Context, req *pbConversation.SetRecvMsgOptReq) (*pbConversation.SetRecvMsgOptResp, error) {
panic("implement me")
}
func (c *conversationServer) ModifyConversationField(ctx context.Context, req *pbConversation.ModifyConversationFieldReq) (*pbConversation.ModifyConversationFieldResp, error) {
resp := &pbConversation.ModifyConversationFieldResp{}
var err error
isSyncConversation := true
if req.Conversation.ConversationType == constant.GroupChatType {
groupInfo, err := c.groupChecker.GetGroupInfo(req.Conversation.GroupID)
if err != nil {
return nil, err
}
if groupInfo.Status == constant.GroupStatusDismissed && req.FieldType != constant.FieldUnread {
return nil, err
}
}
var conversation table.ConversationModel
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
return nil, err
}
if req.FieldType == constant.FieldIsPrivateChat {
err := c.ConversationInterface.SyncPeerUserPrivateConversationTx(ctx, req.Conversation)
if err != nil {
return nil, err
}
chat.ConversationSetPrivateNotification(req.OperationID, req.Conversation.OwnerUserID, req.Conversation.UserID, req.Conversation.IsPrivateChat)
return resp, nil
}
//haveUserID, err := c.ConversationInterface.GetUserIDExistConversation(ctx, req.UserIDList, req.Conversation.ConversationID)
//if err != nil {
// return nil, err
//}
filedMap := make(map[string]interface{})
switch req.FieldType {
case constant.FieldRecvMsgOpt:
filedMap["recv_msg_opt"] = req.Conversation.RecvMsgOpt
case constant.FieldGroupAtType:
filedMap["group_at_type"] = req.Conversation.GroupAtType
case constant.FieldIsNotInGroup:
filedMap["is_not_in_group"] = req.Conversation.IsNotInGroup
case constant.FieldIsPinned:
filedMap["is_pinned"] = req.Conversation.IsPinned
case constant.FieldEx:
filedMap["ex"] = req.Conversation.Ex
case constant.FieldAttachedInfo:
filedMap["attached_info"] = req.Conversation.AttachedInfo
case constant.FieldUnread:
isSyncConversation = false
filedMap["update_unread_count_time"] = req.Conversation.UpdateUnreadCountTime
case constant.FieldBurnDuration:
filedMap["burn_duration"] = req.Conversation.BurnDuration
}
c.ConversationInterface.SetUsersConversationFiledTx(ctx, req.UserIDList, &conversation, filedMap)
err = c.ConversationInterface.UpdateUsersConversationFiled(ctx, haveUserID, req.Conversation.ConversationID, filedMap)
if err != nil {
return nil, err
}
var conversations []*pbConversation.Conversation
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
temp := new(pbConversation.Conversation)
_ = utils.CopyStructFields(temp, req.Conversation)
temp.OwnerUserID = v
conversations = append(conversations, temp)
}
err = c.ConversationInterface.CreateConversation(ctx, conversations)
if err != nil {
return nil, err
}
if isSyncConversation {
for _, v := range req.UserIDList {
chat.ConversationChangeNotification(req.OperationID, v)
}
} else {
for _, v := range req.UserIDList {
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID, req.Conversation.UpdateUnreadCountTime)
}
}
return resp, nil
}

View File

@ -4,7 +4,7 @@ import (
cbApi "Open_IM/pkg/callback_struct" cbApi "Open_IM/pkg/callback_struct"
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
relation "Open_IM/pkg/common/db/mysql" "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/http" "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/common/tracelog" "Open_IM/pkg/common/tracelog"
@ -77,7 +77,7 @@ func callbackBeforeCreateGroup(ctx context.Context, req *pbGroup.CreateGroupReq)
return err return err
} }
func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, groupMember *relation.GroupMember, groupEx string) (err error) { func CallbackBeforeMemberJoinGroup(ctx context.Context, operationID string, groupMember *relation.GroupMemberModel, groupEx string) (err error) {
defer func() { defer func() {
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx) tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "groupMember", *groupMember, "groupEx", groupEx)
}() }()

View File

@ -1 +1,119 @@
package group package group
import (
"Open_IM/pkg/common/db/table/relation"
pbGroup "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"time"
)
func DbToPbGroupInfo(m *relation.GroupModel, ownerUserID string, memberCount uint32) *open_im_sdk.GroupInfo {
return &open_im_sdk.GroupInfo{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
OwnerUserID: ownerUserID,
CreateTime: m.CreateTime.UnixMilli(),
MemberCount: memberCount,
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: m.NotificationUpdateTime.UnixMilli(),
NotificationUserID: m.NotificationUserID,
}
}
func PbToDbGroupRequest(req *pbGroup.GroupApplicationResponseReq, handleUserID string) *relation.GroupRequestModel {
return &relation.GroupRequestModel{
UserID: req.FromUserID,
GroupID: req.GroupID,
HandleResult: req.HandleResult,
HandledMsg: req.HandledMsg,
HandleUserID: handleUserID,
HandledTime: time.Now(),
}
}
func DbToPbCMSGroup(m *relation.GroupModel, ownerUserID string, ownerUserName string, memberCount uint32) *pbGroup.CMSGroup {
return &pbGroup.CMSGroup{
GroupInfo: DbToPbGroupInfo(m, ownerUserID, memberCount),
GroupOwnerUserID: ownerUserID,
GroupOwnerUserName: ownerUserName,
}
}
func DbToPbGroupMembersCMSResp(m *relation.GroupMemberModel) *open_im_sdk.GroupMemberFullInfo {
return &open_im_sdk.GroupMemberFullInfo{
GroupID: m.GroupID,
UserID: m.UserID,
RoleLevel: m.RoleLevel,
JoinTime: m.JoinTime.UnixMilli(),
Nickname: m.Nickname,
FaceURL: m.FaceURL,
//AppMangerLevel: m.AppMangerLevel,
JoinSource: m.JoinSource,
OperatorUserID: m.OperatorUserID,
Ex: m.Ex,
MuteEndTime: m.MuteEndTime.UnixMilli(),
InviterUserID: m.InviterUserID,
}
}
func DbToPbGroupRequest(m *relation.GroupRequestModel, user *open_im_sdk.PublicUserInfo, group *open_im_sdk.GroupInfo) *open_im_sdk.GroupRequest {
return &open_im_sdk.GroupRequest{
UserInfo: user,
GroupInfo: group,
HandleResult: m.HandleResult,
ReqMsg: m.ReqMsg,
HandleMsg: m.HandledMsg,
ReqTime: m.ReqTime.UnixMilli(),
HandleUserID: m.HandleUserID,
HandleTime: m.HandledTime.UnixMilli(),
Ex: m.Ex,
JoinSource: m.JoinSource,
InviterUserID: m.InviterUserID,
}
}
func DbToPbGroupAbstractInfo(groupID string, groupMemberNumber int32, groupMemberListHash uint64) *pbGroup.GroupAbstractInfo {
return &pbGroup.GroupAbstractInfo{
GroupID: groupID,
GroupMemberNumber: groupMemberNumber,
GroupMemberListHash: groupMemberListHash,
}
}
func PbToDBGroupInfo(m *open_im_sdk.GroupInfo) *relation.GroupModel {
return &relation.GroupModel{
GroupID: m.GroupID,
GroupName: m.GroupName,
Notification: m.Notification,
Introduction: m.Introduction,
FaceURL: m.FaceURL,
CreateTime: time.Now(),
Ex: m.Ex,
Status: m.Status,
CreatorUserID: m.CreatorUserID,
GroupType: m.GroupType,
NeedVerification: m.NeedVerification,
LookMemberInfo: m.LookMemberInfo,
ApplyMemberFriend: m.ApplyMemberFriend,
NotificationUpdateTime: time.UnixMilli(m.NotificationUpdateTime),
NotificationUserID: m.NotificationUserID,
}
}
func PbToDbGroupMember(m *open_im_sdk.UserInfo) *relation.GroupMemberModel {
return &relation.GroupMemberModel{
UserID: m.UserID,
Nickname: m.Nickname,
FaceURL: m.FaceURL,
Ex: m.Ex,
}
}

View File

@ -0,0 +1,62 @@
package group
import (
pbGroup "Open_IM/pkg/proto/group"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"time"
)
func UpdateGroupInfoMap(group *open_im_sdk.GroupInfoForSet) map[string]any {
m := make(map[string]any)
if group.GroupName != "" {
m["group_name"] = group.GroupName
}
if group.Notification != "" {
m["notification"] = group.Notification
}
if group.Introduction != "" {
m["introduction"] = group.Introduction
}
if group.FaceURL != "" {
m["face_url"] = group.FaceURL
}
if group.NeedVerification != nil {
m["need_verification"] = group.NeedVerification.Value
}
if group.LookMemberInfo != nil {
m["look_member_info"] = group.LookMemberInfo.Value
}
if group.ApplyMemberFriend != nil {
m["apply_member_friend"] = group.ApplyMemberFriend.Value
}
return m
}
func UpdateGroupStatusMap(status int) map[string]any {
return map[string]any{
"status": status,
}
}
func UpdateGroupMemberMutedTimeMap(t time.Time) map[string]any {
return map[string]any{
"mute_end_time": t,
}
}
func UpdateGroupMemberMap(req *pbGroup.SetGroupMemberInfoReq) map[string]any {
m := make(map[string]any)
if req.Nickname != nil {
m["nickname"] = req.Nickname.Value
}
if req.FaceURL != nil {
m["face_url"] = req.FaceURL.Value
}
if req.RoleLevel != nil {
m["role_level"] = req.RoleLevel.Value
}
if req.Ex != nil {
m["ex"] = req.Ex.Value
}
return m
}

View File

@ -1,56 +1,66 @@
package group package group
import ( import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/tracelog" "Open_IM/pkg/common/tracelog"
pbConversation "Open_IM/pkg/proto/conversation"
sdk_ws "Open_IM/pkg/proto/sdk_ws" sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"errors"
"math/big" "math/big"
"strconv" "strconv"
"time" "time"
) )
//func getDBGroupRequest(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (dbGroupRequest *relation.GroupRequest) { func GetPublicUserInfoOne(ctx context.Context, userID string) (*sdk_ws.PublicUserInfo, error) {
// dbGroupRequest = &relation.GroupRequest{} return nil, errors.New("todo")
// utils.CopyStructFields(&dbGroupRequest, req)
// dbGroupRequest.UserID = req.FromUserID
// dbGroupRequest.HandleUserID = utils.OpUserID(ctx)
// dbGroupRequest.HandledTime = time.Now()
// return dbGroupRequest
//}
//
//func getDBGroupMember(ctx context.Context, groupID, userID string) (dbGroupMember *relation.GroupMember, err error) {
// dbGroupMember = &relation.GroupMember{}
//
// member := relation.GroupMember{}
// member.GroupID = groupID
// member.UserID = userID
// member.RoleLevel = constant.GroupOrdinaryUsers
// member.OperatorUserID = utils.OpUserID(ctx)
//
// member.FaceURL = user.FaceURL
// member.Nickname = user.Nickname
// member.JoinSource = request.JoinSource
// member.InviterUserID = request.InviterUserID
// member.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
//
// return dbGroupMember, nil
//}
func getUsersInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.UserInfo, error) {
return nil, nil
} }
func getUserMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.UserInfo, error) { func GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.UserInfo, error) {
users, err := getUsersInfo(ctx, userIDs) return nil, errors.New("todo")
}
func GetUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.UserInfo, error) {
users, err := GetUsersInfo(ctx, userIDs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
userMap := make(map[string]*sdk_ws.UserInfo) return utils.SliceToMap(users, func(e *sdk_ws.UserInfo) string {
for i, user := range users { return e.UserID
userMap[user.UserID] = users[i] }), nil
}
func GetPublicUserInfo(ctx context.Context, userIDs []string) ([]*sdk_ws.PublicUserInfo, error) {
return nil, errors.New("todo")
}
func GetPublicUserInfoMap(ctx context.Context, userIDs []string) (map[string]*sdk_ws.PublicUserInfo, error) {
users, err := GetPublicUserInfo(ctx, userIDs)
if err != nil {
return nil, err
} }
return userMap, nil return utils.SliceToMap(users, func(e *sdk_ws.PublicUserInfo) string {
return e.UserID
}), nil
}
func GroupNotification(ctx context.Context, groupID string) {
var conversationReq pbConversation.ModifyConversationFieldReq
conversation := pbConversation.Conversation{
OwnerUserID: tracelog.GetOpUserID(ctx),
ConversationID: utils.GetConversationIDBySessionType(groupID, constant.GroupChatType),
ConversationType: constant.GroupChatType,
GroupID: groupID,
}
conversationReq.Conversation = &conversation
conversationReq.OperationID = tracelog.GetOperationID(ctx)
conversationReq.FieldType = constant.FieldGroupAtType
conversation.GroupAtType = constant.GroupNotification
conversationReq.UserIDList = cacheResp.UserIDList
_, err = pbConversation.NewConversationClient(s.etcdConn.GetConn("", config.Config.RpcRegisterName.OpenImConversationName)).ModifyConversationField(ctx, &conversationReq)
tracelog.SetCtxInfo(ctx, "ModifyConversationField", err, "req", &conversationReq, "resp", conversationReply)
} }
func genGroupID(ctx context.Context, groupID string) string { func genGroupID(ctx context.Context, groupID string) string {

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,64 @@
package group package group
import ( import (
rocksCache "Open_IM/pkg/common/db/rocks_cache" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/db/table/relation"
cp "Open_IM/pkg/common/utils"
pbGroup "Open_IM/pkg/proto/group" pbGroup "Open_IM/pkg/proto/group"
commonPb "Open_IM/pkg/proto/sdk_ws" sdk_ws "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"github.com/go-redis/redis/v8"
) )
func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) { func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) resp := &pbGroup.GetJoinedSuperGroupListResp{}
resp := &pbGroup.GetJoinedSuperGroupListResp{CommonResp: &commonPb.CommonResp{}} total, groupIDs, err := s.GroupInterface.FindJoinSuperGroup(ctx, req.UserID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
groupIDList, err := rocksCache.GetJoinedSuperGroupListFromCache(ctx, req.UserID)
if err != nil { if err != nil {
if err == redis.Nil { return nil, err
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID nil ", err.Error(), req.UserID) }
return resp, nil resp.Total = total
} if len(groupIDs) == 0 {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed ", err.Error(), req.UserID)
//resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
//resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
return resp, nil return resp, nil
} }
for _, groupID := range groupIDList { numMap, err := s.GroupInterface.MapSuperGroupMemberNum(ctx, groupIDs)
groupInfoFromCache, err := rocksCache.GetGroupInfoFromCache(ctx, groupID) if err != nil {
if err != nil { return nil, err
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupInfoByGroupID failed", groupID, err.Error())
continue
}
groupInfo := &commonPb.GroupInfo{}
if err := utils.CopyStructFields(groupInfo, groupInfoFromCache); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
}
groupMemberIDList, err := rocksCache.GetGroupMemberIDListFromCache(ctx, groupID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroup failed", groupID, err.Error())
continue
}
groupInfo.MemberCount = uint32(len(groupMemberIDList))
resp.GroupList = append(resp.GroupList, groupInfo)
} }
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) ownerIdMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, groupIDs)
if err != nil {
return nil, err
}
groups, err := s.GroupInterface.FindGroup(ctx, groupIDs)
if err != nil {
return nil, err
}
groupMap := utils.SliceToMap(groups, func(e *relation.GroupModel) string {
return e.GroupID
})
resp.Groups = utils.Slice(groupIDs, func(groupID string) *sdk_ws.GroupInfo {
return DbToPbGroupInfo(groupMap[groupID], ownerIdMap[groupID], numMap[groupID])
})
return resp, nil return resp, nil
} }
func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSuperGroupsInfoReq) (resp *pbGroup.GetSuperGroupsInfoResp, err error) { func (s *groupServer) GetSuperGroupsInfo(ctx context.Context, req *pbGroup.GetSuperGroupsInfoReq) (resp *pbGroup.GetSuperGroupsInfoResp, err error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) resp = &pbGroup.GetSuperGroupsInfoResp{}
resp = &pbGroup.GetSuperGroupsInfoResp{CommonResp: &commonPb.CommonResp{}} if len(req.GroupIDs) == 0 {
groupsInfoList := make([]*commonPb.GroupInfo, 0) return nil, constant.ErrArgs.Wrap("groupIDs empty")
for _, groupID := range req.GroupIDList {
groupInfoFromRedis, err := rocksCache.GetGroupInfoFromCache(ctx, groupID)
if err != nil {
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), groupID)
continue
}
var groupInfo commonPb.GroupInfo
cp.GroupDBCopyOpenIM(&groupInfo, groupInfoFromRedis)
groupsInfoList = append(groupsInfoList, &groupInfo)
} }
resp.GroupInfoList = groupsInfoList groups, err := s.GroupInterface.FindGroup(ctx, req.GroupIDs)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String()) if err != nil {
return nil, err
}
numMap, err := s.GroupInterface.MapSuperGroupMemberNum(ctx, req.GroupIDs)
if err != nil {
return nil, err
}
ownerIdMap, err := s.GroupInterface.MapGroupOwnerUserID(ctx, req.GroupIDs)
if err != nil {
return nil, err
}
resp.GroupInfos = utils.Slice(groups, func(e *relation.GroupModel) *sdk_ws.GroupInfo {
return DbToPbGroupInfo(e, ownerIdMap[e.GroupID], numMap[e.GroupID])
})
return resp, nil return resp, nil
} }

View File

@ -0,0 +1,13 @@
package group
import (
"Open_IM/pkg/common/tracelog"
"gorm.io/gorm"
)
func IsNotFound(err error) bool {
if err == nil {
return false
}
return tracelog.Unwrap(err) == gorm.ErrRecordNotFound
}

View File

@ -6,6 +6,7 @@ import (
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
open_im_sdk "Open_IM/pkg/proto/sdk_ws" open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context"
"github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
@ -59,7 +60,7 @@ func ConversationSetPrivateNotification(operationID, sendID, recvID string, isPr
} }
// 会话改变 // 会话改变
func ConversationChangeNotification(operationID, userID string) { func ConversationChangeNotification(ctx context.Context, userID string) {
log.NewInfo(operationID, utils.GetSelfFuncName()) log.NewInfo(operationID, utils.GetSelfFuncName())
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{ ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
UserID: userID, UserID: userID,

View File

@ -13,18 +13,22 @@ import (
"time" "time"
) )
const ( type DBFun func() (string, error)
conversationKey = "CONVERSATION:"
conversationIDsKey = "CONVERSATION_IDS:"
recvMsgOptKey = "RECV_MSG_OPT:"
superGroupRecvMsgNotNotifyUserIDsKey = "SUPER_GROUP_RECV_MSG_NOT_NOTIFY_USER_IDS:"
conversationExpireTime = time.Second * 60 * 60 * 12
)
type ConversationCache struct { type ConversationCache interface {
conversationDB *relation.ConversationGorm GetUserConversationIDListFromCache(userID string, fn DBFun) ([]string, error)
expireTime time.Duration DelUserConversationIDListFromCache(userID string) error
rcClient *rockscache.Client GetConversationFromCache(ownerUserID, conversationID string, fn DBFun) (*table.ConversationModel, error)
GetConversationsFromCache(ownerUserID string, conversationIDList []string, fn DBFun) ([]*table.ConversationModel, error)
GetUserAllConversationList(ownerUserID string, fn DBFun) ([]*table.ConversationModel, error)
DelConversationFromCache(ownerUserID, conversationID string) error
}
type ConversationRedis struct {
rcClient *rockscache.Client
}
func NewConversationRedis(rcClient *rockscache.Client) *ConversationRedis {
return &ConversationRedis{rcClient: rcClient}
} }
func NewConversationCache(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) *ConversationCache { func NewConversationCache(rdb redis.UniversalClient, conversationDB *relation.ConversationGorm, options rockscache.Options) *ConversationCache {

View File

@ -0,0 +1,119 @@
package controller
import (
"Open_IM/pkg/common/db/cache"
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table"
"context"
)
type ConversationInterface interface {
//GetUserIDExistConversation 获取拥有该会话的的用户ID列表
GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error)
//UpdateUserConversationFiled 更新用户该会话的属性信息
UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error
//CreateConversation 创建一批新的会话
CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error
//FindConversations 根据会话ID获取某个用户的多个会话
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error)
//GetUserAllConversation 获取一个用户在服务器上所有的会话
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error)
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error
}
type ConversationController struct {
database ConversationDataBaseInterface
}
func NewConversationController(database ConversationDataBaseInterface) *ConversationController {
return &ConversationController{database: database}
}
func (c *ConversationController) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) {
return c.database.GetUserIDExistConversation(ctx, userIDList, conversationID)
}
func (c ConversationController) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error {
panic("implement me")
}
func (c ConversationController) CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error {
panic("implement me")
}
func (c ConversationController) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error {
panic("implement me")
}
func (c ConversationController) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error) {
panic("implement me")
}
func (c ConversationController) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error) {
panic("implement me")
}
func (c ConversationController) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error {
panic("implement me")
}
var _ ConversationInterface = (*ConversationController)(nil)
type ConversationDataBaseInterface interface {
//GetUserIDExistConversation 获取拥有该会话的的用户ID列表
GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error)
//UpdateUserConversationFiled 更新用户该会话的属性信息
UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error
//CreateConversation 创建一批新的会话
CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error
//FindConversations 根据会话ID获取某个用户的多个会话
FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error)
//GetUserAllConversation 获取一个用户在服务器上所有的会话
GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error)
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error
}
type ConversationDataBase struct {
db relation.Conversation
cache cache.ConversationCache
}
func (c ConversationDataBase) GetUserIDExistConversation(ctx context.Context, userIDList []string, conversationID string) ([]string, error) {
panic("implement me")
}
func (c ConversationDataBase) UpdateUsersConversationFiled(ctx context.Context, UserIDList []string, conversationID string, args map[string]interface{}) error {
panic("implement me")
}
func (c ConversationDataBase) CreateConversation(ctx context.Context, conversations []*table.ConversationModel) error {
panic("implement me")
}
func (c ConversationDataBase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversation *table.ConversationModel) error {
panic("implement me")
}
func (c ConversationDataBase) FindConversations(ctx context.Context, ownerUserID string, conversationID []string) ([]*table.ConversationModel, error) {
panic("implement me")
}
func (c ConversationDataBase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*table.ConversationModel, error) {
panic("implement me")
}
func (c ConversationDataBase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*table.ConversationModel) error {
panic("implement me")
}
func NewConversationDataBase(db relation.Conversation, cache cache.ConversationCache) *ConversationDataBase {
return &ConversationDataBase{db: db, cache: cache}
}
//func NewConversationController(db *gorm.DB, rdb redis.UniversalClient) ConversationInterface {
// groupController := &ConversationController{database: newGroupDatabase(db, rdb, mgoClient)}
// return groupController
//}

View File

@ -2,8 +2,8 @@ package controller
import ( import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/relation" relation1 "Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table" "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"gorm.io/gorm" "gorm.io/gorm"
@ -15,25 +15,25 @@ type FriendInterface interface {
// AddFriendRequest 增加或者更新好友申请 // AddFriendRequest 增加或者更新好友申请
AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error)
// BecomeFriend 先判断是否在好友表,如果在则不插入 // BecomeFriend 先判断是否在好友表,如果在则不插入
BecomeFriend(ctx context.Context, friends []*table.FriendModel, revFriends []*table.FriendModel) (err error) BecomeFriend(ctx context.Context, friends []*relation.FriendModel, revFriends []*relation.FriendModel) (err error)
// RefuseFriendRequest 拒绝好友申请 // RefuseFriendRequest 拒绝好友申请
RefuseFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
// AgreeFriendRequest 同意好友申请 // AgreeFriendRequest 同意好友申请
AgreeFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
// Delete 删除好友 // Delete 删除好友
Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error)
// UpdateRemark 更新好友备注 // UpdateRemark 更新好友备注
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// FindOwnerFriends 获取ownerUserID的好友列表 // FindOwnerFriends 获取ownerUserID的好友列表
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// FindInWhoseFriends friendUserID在哪些人的好友列表中 // FindInWhoseFriends friendUserID在哪些人的好友列表中
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// FindFriendRequestFromMe 获取我发出去的好友申请 // FindFriendRequestFromMe 获取我发出去的好友申请
FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// FindFriendRequestToMe 获取我收到的的好友申请 // FindFriendRequestToMe 获取我收到的的好友申请
FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// FindFriends 获取某人指定好友的信息 如果有一个不存在也返回错误 // FindFriends 获取某人指定好友的信息 如果有一个不存在也返回错误
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*table.FriendModel, err error) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
} }
type FriendController struct { type FriendController struct {
@ -55,17 +55,17 @@ func (f *FriendController) AddFriendRequest(ctx context.Context, fromUserID, toU
} }
// BecomeFriend 先判断是否在好友表,如果在则不插入 // BecomeFriend 先判断是否在好友表,如果在则不插入
func (f *FriendController) BecomeFriend(ctx context.Context, ownerUserID string, friends []*table.FriendModel) (err error) { func (f *FriendController) BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error) {
return f.database.BecomeFriend(ctx, ownerUserID, friends) return f.database.BecomeFriend(ctx, ownerUserID, friends)
} }
// RefuseFriendRequest 拒绝好友申请 // RefuseFriendRequest 拒绝好友申请
func (f *FriendController) RefuseFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) { func (f *FriendController) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
return f.database.RefuseFriendRequest(ctx, friendRequest) return f.database.RefuseFriendRequest(ctx, friendRequest)
} }
// AgreeFriendRequest 同意好友申请 // AgreeFriendRequest 同意好友申请
func (f *FriendController) AgreeFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) { func (f *FriendController) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
return f.database.AgreeFriendRequest(ctx, friendRequest) return f.database.AgreeFriendRequest(ctx, friendRequest)
} }
@ -80,27 +80,27 @@ func (f *FriendController) UpdateRemark(ctx context.Context, ownerUserID, friend
} }
// FindOwnerFriends 获取ownerUserID的好友列表 // FindOwnerFriends 获取ownerUserID的好友列表
func (f *FriendController) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) { func (f *FriendController) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber) return f.database.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
} }
// FindInWhoseFriends friendUserID在哪些人的好友列表中 // FindInWhoseFriends friendUserID在哪些人的好友列表中
func (f *FriendController) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) { func (f *FriendController) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.database.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber) return f.database.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
} }
// FindFriendRequestFromMe 获取我发出去的好友申请 // FindFriendRequestFromMe 获取我发出去的好友申请
func (f *FriendController) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendController) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.FindFriendRequestFromMe(ctx, userID, pageNumber, showNumber) return f.database.FindFriendRequestFromMe(ctx, userID, pageNumber, showNumber)
} }
// FindFriendRequestToMe 获取我收到的的好友申请 // FindFriendRequestToMe 获取我收到的的好友申请
func (f *FriendController) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendController) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.database.FindFriendRequestToMe(ctx, userID, pageNumber, showNumber) return f.database.FindFriendRequestToMe(ctx, userID, pageNumber, showNumber)
} }
// FindFriends 获取某人指定好友的信息 // FindFriends 获取某人指定好友的信息
func (f *FriendController) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*table.FriendModel, err error) { func (f *FriendController) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
return f.database.FindFriends(ctx, ownerUserID, friendUserIDs) return f.database.FindFriends(ctx, ownerUserID, friendUserIDs)
} }
@ -111,34 +111,34 @@ type FriendDatabaseInterface interface {
// AddFriendRequest 增加或者更新好友申请 // AddFriendRequest 增加或者更新好友申请
AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error)
// BecomeFriend 先判断是否在好友表,如果在则不插入 // BecomeFriend 先判断是否在好友表,如果在则不插入
BecomeFriend(ctx context.Context, ownerUserID string, friends []*table.FriendModel) (err error) BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error)
// RefuseFriendRequest 拒绝好友申请 // RefuseFriendRequest 拒绝好友申请
RefuseFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
// AgreeFriendRequest 同意好友申请 // AgreeFriendRequest 同意好友申请
AgreeFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error)
// Delete 删除好友 // Delete 删除好友
Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error)
// UpdateRemark 更新好友备注 // UpdateRemark 更新好友备注
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
// FindOwnerFriends 获取ownerUserID的好友列表 // FindOwnerFriends 获取ownerUserID的好友列表
FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// FindInWhoseFriends friendUserID在哪些人的好友列表中 // FindInWhoseFriends friendUserID在哪些人的好友列表中
FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error)
// FindFriendRequestFromMe 获取我发出去的好友申请 // FindFriendRequestFromMe 获取我发出去的好友申请
FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// FindFriendRequestToMe 获取我收到的的好友申请 // FindFriendRequestToMe 获取我收到的的好友申请
FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error)
// FindFriends 获取某人指定好友的信息 // FindFriends 获取某人指定好友的信息
FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*table.FriendModel, err error) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error)
} }
type FriendDatabase struct { type FriendDatabase struct {
friend *relation.FriendGorm friend *relation1.FriendGorm
friendRequest *relation.FriendRequestGorm friendRequest *relation1.FriendRequestGorm
} }
func NewFriendDatabase(db *gorm.DB) *FriendDatabase { func NewFriendDatabase(db *gorm.DB) *FriendDatabase {
return &FriendDatabase{friend: relation.NewFriendGorm(db), friendRequest: relation.NewFriendRequestGorm(db)} return &FriendDatabase{friend: relation1.NewFriendGorm(db), friendRequest: relation1.NewFriendRequestGorm(db)}
} }
// CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true) // CheckIn 检查user2是否在user1的好友列表中(inUser1Friends==true) 检查user1是否在user2的好友列表中(inUser2Friends==true)
@ -157,11 +157,31 @@ func (f *FriendDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (
// AddFriendRequest 增加或者更新好友申请 // AddFriendRequest 增加或者更新好友申请
func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) { func (f *FriendDatabase) AddFriendRequest(ctx context.Context, fromUserID, toUserID string, reqMsg string, ex string) (err error) {
return f.friendRequest.DB.Transaction(func(tx *gorm.DB) error {
fq, err := f.friendRequest.Find(ctx, fromUserID, toUserID, tx)
if err != nil {
return err
}
if fq != nil { //
m := make(map[string]interface{}, 1)
m["handle_result"] = 0
m["handle_msg"] = ""
m["req_msg"] = reqMsg
m["ex"] = ex
if err := f.friendRequest.UpdateByMap(ctx, fromUserID, toUserID, m, tx); err != nil {
return err
}
} else {
if err := f.friendRequest.Create(ctx, []*relation.FriendRequestModel{&relation.FriendRequestModel{FromUserID: fromUserID, ToUserID: toUserID, ReqMsg: reqMsg, Ex: ex}}, tx); err != nil {
return err
}
}
return nil
})
} }
// BecomeFriend 先判断是否在好友表,如果在则不插入 // BecomeFriend 先判断是否在好友表,如果在则不插入
func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, friends []*table.FriendModel) (err error) { func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, friends []*relation.FriendModel) (err error) {
return f.friend.DB.Transaction(func(tx *gorm.DB) error { return f.friend.DB.Transaction(func(tx *gorm.DB) error {
//先find 找出重复的 去掉重复的 //先find 找出重复的 去掉重复的
friendUserIDs := make([]string, 0, len(friends)) friendUserIDs := make([]string, 0, len(friends))
@ -173,7 +193,7 @@ func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, f
return err return err
} }
fs1 = append(fs1, friends...) fs1 = append(fs1, friends...)
fs11 := utils.DistinctAny(fs1, func(e *table.FriendModel) string { fs11 := utils.DistinctAny(fs1, func(e *relation.FriendModel) string {
return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID) return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID)
}) })
err = f.friend.Create(ctx, fs11, tx) err = f.friend.Create(ctx, fs11, tx)
@ -185,9 +205,9 @@ func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, f
return err return err
} }
for _, v := range friends { for _, v := range friends {
fs2 = append(fs2, &table.FriendModel{OwnerUserID: v.FriendUserID, FriendUserID: ownerUserID}) fs2 = append(fs2, &relation.FriendModel{OwnerUserID: v.FriendUserID, FriendUserID: ownerUserID})
} }
fs22 := utils.DistinctAny(fs2, func(e *table.FriendModel) string { fs22 := utils.DistinctAny(fs2, func(e *relation.FriendModel) string {
return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID) return utils.UniqueJoin(e.OwnerUserID, e.FriendUserID)
}) })
err = f.friend.Create(ctx, fs22, tx) err = f.friend.Create(ctx, fs22, tx)
@ -199,9 +219,9 @@ func (f *FriendDatabase) BecomeFriend(ctx context.Context, ownerUserID string, f
} }
// RefuseFriendRequest 拒绝好友申请 // RefuseFriendRequest 拒绝好友申请
func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) { func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
friendRequest.HandleResult = constant.FriendResponseRefuse friendRequest.HandleResult = constant.FriendResponseRefuse
err = f.friendRequest.Update(ctx, []*table.FriendRequestModel{friendRequest}) err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest})
if err != nil { if err != nil {
return err return err
} }
@ -209,7 +229,7 @@ func (f *FriendDatabase) RefuseFriendRequest(ctx context.Context, friendRequest
} }
// AgreeFriendRequest 同意好友申请 // AgreeFriendRequest 同意好友申请
func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *table.FriendRequestModel) (err error) { func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *relation.FriendRequestModel) (err error) {
return f.friend.DB.Transaction(func(tx *gorm.DB) error { return f.friend.DB.Transaction(func(tx *gorm.DB) error {
//先find 找出重复的 去掉重复的 //先find 找出重复的 去掉重复的
fs1, err := f.friend.FindFriends(ctx, friendRequest.FromUserID, []string{friendRequest.ToUserID}, tx) fs1, err := f.friend.FindFriends(ctx, friendRequest.FromUserID, []string{friendRequest.ToUserID}, tx)
@ -217,8 +237,8 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
return err return err
} }
if len(fs1) == 0 { if len(fs1) == 0 {
err = f.friend.Create(ctx, []*table.FriendModel{ err = f.friend.Create(ctx, []*relation.FriendModel{
&table.FriendModel{ &relation.FriendModel{
OwnerUserID: friendRequest.FromUserID, OwnerUserID: friendRequest.FromUserID,
FriendUserID: friendRequest.ToUserID, FriendUserID: friendRequest.ToUserID,
OperatorUserID: friendRequest.ToUserID, OperatorUserID: friendRequest.ToUserID,
@ -230,8 +250,8 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
} }
fs2, err := f.friend.FindReversalFriends(ctx, friendRequest.ToUserID, []string{friendRequest.FromUserID}, tx) fs2, err := f.friend.FindReversalFriends(ctx, friendRequest.ToUserID, []string{friendRequest.FromUserID}, tx)
if len(fs2) == 0 { if len(fs2) == 0 {
err = f.friend.Create(ctx, []*table.FriendModel{ err = f.friend.Create(ctx, []*relation.FriendModel{
&table.FriendModel{ &relation.FriendModel{
OwnerUserID: friendRequest.ToUserID, OwnerUserID: friendRequest.ToUserID,
FriendUserID: friendRequest.FromUserID, FriendUserID: friendRequest.FromUserID,
OperatorUserID: friendRequest.ToUserID, OperatorUserID: friendRequest.ToUserID,
@ -242,7 +262,7 @@ func (f *FriendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
} }
} }
friendRequest.HandleResult = constant.FriendResponseAgree friendRequest.HandleResult = constant.FriendResponseAgree
err = f.friendRequest.Update(ctx, []*table.FriendRequestModel{friendRequest}, tx) err = f.friendRequest.Update(ctx, []*relation.FriendRequestModel{friendRequest}, tx)
if err != nil { if err != nil {
return err return err
} }
@ -261,27 +281,27 @@ func (f *FriendDatabase) UpdateRemark(ctx context.Context, ownerUserID, friendUs
} }
// FindOwnerFriends 获取ownerUserID的好友列表 // FindOwnerFriends 获取ownerUserID的好友列表
func (f *FriendDatabase) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) { func (f *FriendDatabase) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber) return f.friend.FindOwnerFriends(ctx, ownerUserID, pageNumber, showNumber)
} }
// FindInWhoseFriends friendUserID在哪些人的好友列表中 // FindInWhoseFriends friendUserID在哪些人的好友列表中
func (f *FriendDatabase) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*table.FriendModel, total int64, err error) { func (f *FriendDatabase) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32) (friends []*relation.FriendModel, total int64, err error) {
return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber) return f.friend.FindInWhoseFriends(ctx, friendUserID, pageNumber, showNumber)
} }
// FindFriendRequestFromMe 获取我发出去的好友申请 // FindFriendRequestFromMe 获取我发出去的好友申请
func (f *FriendDatabase) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendDatabase) FindFriendRequestFromMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber) return f.friendRequest.FindFromUserID(ctx, userID, pageNumber, showNumber)
} }
// FindFriendRequestToMe 获取我收到的的好友申请 // FindFriendRequestToMe 获取我收到的的好友申请
func (f *FriendDatabase) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendDatabase) FindFriendRequestToMe(ctx context.Context, userID string, pageNumber, showNumber int32) (friends []*relation.FriendRequestModel, total int64, err error) {
return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber) return f.friendRequest.FindToUserID(ctx, userID, pageNumber, showNumber)
} }
// FindFriends 获取某人指定好友的信息 如果有一个不存在,也返回错误 // FindFriends 获取某人指定好友的信息 如果有一个不存在,也返回错误
func (f *FriendDatabase) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*table.FriendModel, err error) { func (f *FriendDatabase) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string) (friends []*relation.FriendModel, err error) {
friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs) friends, err = f.friend.FindFriends(ctx, ownerUserID, friendUserIDs)
if err != nil { if err != nil {
return return

View File

@ -1,10 +1,13 @@
package controller package controller
import ( import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/cache" "Open_IM/pkg/common/db/cache"
"Open_IM/pkg/common/db/relation" "Open_IM/pkg/common/db/relation"
relation2 "Open_IM/pkg/common/db/table/relation" relation2 "Open_IM/pkg/common/db/table/relation"
unrelation2 "Open_IM/pkg/common/db/table/unrelation"
"Open_IM/pkg/common/db/unrelation" "Open_IM/pkg/common/db/unrelation"
"Open_IM/pkg/utils"
"context" "context"
"github.com/dtm-labs/rockscache" "github.com/dtm-labs/rockscache"
_ "github.com/dtm-labs/rockscache" _ "github.com/dtm-labs/rockscache"
@ -14,29 +17,43 @@ import (
) )
type GroupInterface interface { type GroupInterface interface {
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) // group
FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
// groupMember
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error)
TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupModel, err error) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error)
GetJoinedGroupList(ctx context.Context, userID string) ([]*relation2.GroupModel, error) FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30)
GetGroupMemberList(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30) FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error)
FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*relation2.GroupMemberModel, err error)
DelGroupMember(ctx context.Context, groupID string, userIDs []string) error
GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error)
GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error)
CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error)
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error)
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error // 转让群
UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error
//mongo CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) // ?
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error)
// superGroup
TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error)
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
DelSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error DeleteSuperGroup(ctx context.Context, groupID string) error
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error)
MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
} }
var _ GroupInterface = (*GroupController)(nil) var _ GroupInterface = (*GroupController)(nil)
@ -45,82 +62,112 @@ type GroupController struct {
database GroupDataBaseInterface database GroupDataBaseInterface
} }
func (g *GroupController) TakeGroupMemberByID(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupModel, err error) { func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) FindGroupMembersByID(ctx context.Context, groupID string, userIDs []string) (groups []*relation2.GroupModel, err error) { func (g *GroupController) SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) DelGroupMember(ctx context.Context, groupID string, userIDs []string) error { func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) { func (g *GroupController) FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
/*
var groupRequestList []db.GroupRequest
memberList, err := GetGroupMemberListByUserID(userID)
if err != nil {
return nil, err
}
for _, v := range memberList {
if v.RoleLevel > constant.GroupOrdinaryUsers {
list, err := GetGroupRequestByGroupID(v.GroupID)
if err != nil {
// fmt.Println("111 GetGroupRequestByGroupID failed ", err.Error())
continue
}
// fmt.Println("222 GetGroupRequestByGroupID ok ", list)
groupRequestList = append(groupRequestList, list...)
// fmt.Println("333 GetGroupRequestByGroupID ok ", groupRequestList)
}
}
return groupRequestList, nil
*/
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) DelSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error { func (g *GroupController) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation2.GroupModel, error) { func (g *GroupController) DismissGroup(ctx context.Context, groupID string) error {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupMemberList(ctx context.Context, groupID string) ([]*relation2.GroupModel, error) { func (g *GroupController) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupMemberListByUserID(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupModel, error) { func (g *GroupController) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupModel, error) { func (g *GroupController) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) { func (g *GroupController) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) { func (g *GroupController) FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func (g *GroupController) CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupModel) error { func (g *GroupController) SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
@ -130,49 +177,98 @@ func (g *GroupController) CreateGroupRequest(ctx context.Context, requests []*re
panic("implement me") panic("implement me")
} }
func (g *GroupController) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) {
//TODO implement me
panic("implement me")
}
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) DeleteSuperGroup(ctx context.Context, groupID string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupController) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error { func (g *GroupController) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me //TODO implement me
panic("implement me") panic("implement me")
} }
func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupInterface { func (g *GroupController) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) {
groupController := &GroupController{database: newGroupDatabase(db, rdb, mgoClient)} //TODO implement me
return groupController panic("implement me")
} }
func (g *GroupController) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { func (g *GroupController) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
return g.database.FindGroupsByID(ctx, groupIDs) //TODO implement me
} panic("implement me")
func (g *GroupController) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupModel) error {
return g.database.CreateGroup(ctx, groups, groupMember)
}
func (g *GroupController) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error {
return g.database.DeleteGroupByIDs(ctx, groupIDs)
}
func (g *GroupController) TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
return g.database.TakeGroupByID(ctx, groupID)
}
func (g *GroupController) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) {
return g.database.GetSuperGroupByID(ctx, groupID)
}
func (g *GroupController) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
return g.database.CreateSuperGroup(ctx, groupID, initMemberIDList)
} }
type GroupDataBaseInterface interface { type GroupDataBaseInterface interface {
FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) // group
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupModel) error FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error)
DeleteGroupByIDs(ctx context.Context, groupIDs []string) error SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error)
GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error)
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
// groupMember
CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMember []*relation2.GroupMemberModel) error
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error)
FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error)
FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error)
FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) // relation.GetGroupMemberByGroupID(req.GroupID, req.Filter, req.NextSeq, 30)
SearchGroupMember(ctx context.Context, groupID, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error)
TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error)
FindGroupOwnerUser(ctx context.Context, groupID []string) ([]*relation2.GroupMemberModel, error)
CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error)
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error)
MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error)
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error // 转让群
UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error
CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error
GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) // ?
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error)
FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error)
// superGroup
TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error)
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
DeleteSuperGroup(ctx context.Context, groupID string) error
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error
FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error)
MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
} }
var _ *GroupDataBase = (GroupDataBaseInterface)(nil)
type GroupDataBase struct { type GroupDataBase struct {
groupDB *relation.GroupGorm groupDB *relation.GroupGorm
groupMemberDB *relation.GroupMemberGorm groupMemberDB *relation.GroupMemberGorm
@ -205,82 +301,270 @@ func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.C
return database return database
} }
func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) { //func (g *GroupDataBase) FindGroupsByID(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) {
return g.cache.GetGroupsInfo(ctx, groupIDs) // return g.cache.GetGroupsInfo(ctx, groupIDs)
//}
//
//func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error {
// return g.db.Transaction(func(tx *gorm.DB) error {
// if len(groups) > 0 {
// if err := g.groupDB.Create(ctx, groups, tx); err != nil {
// return err
// }
// }
// if len(groupMembers) > 0 {
// if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil {
// return err
// }
// }
// return nil
// })
//}
//
//func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error {
// return g.groupDB.DB.Transaction(func(tx *gorm.DB) error {
// if err := g.groupDB.Delete(ctx, groupIDs, tx); err != nil {
// return err
// }
// if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
// return err
// }
// return nil
// })
//}
//
//func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
// return g.cache.GetGroupInfo(ctx, groupID)
//}
//
//func (g *GroupDataBase) Update(ctx context.Context, groups []*relation2.GroupModel) error {
// return g.db.Transaction(func(tx *gorm.DB) error {
// if err := g.groupDB.Update(ctx, groups, tx); err != nil {
// return err
// }
// var groupIDs []string
// for _, group := range groups {
// groupIDs = append(groupIDs, group.GroupID)
// }
// if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
// return err
// }
// return nil
// })
//}
//
//func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation2.GroupModel, error) {
//
// return nil, nil
//}
//
//func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
// sess, err := g.mongoDB.MgoClient.StartSession()
// if err != nil {
// return err
// }
// defer sess.EndSession(ctx)
// sCtx := mongo.NewSessionContext(ctx, sess)
// if err = g.mongoDB.CreateSuperGroup(sCtx, groupID, initMemberIDList); err != nil {
// _ = sess.AbortTransaction(ctx)
// return err
// }
//
// if err = g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil {
// _ = sess.AbortTransaction(ctx)
// return err
// }
// return sess.CommitTransaction(ctx)
//}
//
//func (g *GroupDataBase) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) {
// return g.mongoDB.GetSuperGroup(ctx, groupID)
//}
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relation2.GroupModel, err error) {
return g.groupDB.Find(ctx, groupIDs)
}
func (g *GroupDataBase) SearchGroup(ctx context.Context, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
return g.groupDB.Search(ctx, name, pageNumber, showNumber)
}
func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) {
return g.groupDB.Take(ctx, groupID)
}
func (g *GroupDataBase) FindJoinedGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupModel, error) {
total, members, err := g.groupMemberDB.PageByUser(ctx, userID, pageNumber, showNumber)
if err != nil {
return 0, nil, err
}
if len(members) == 0 {
return total, []*relation2.GroupModel{}, nil
}
groupIDs := utils.Slice(members, func(e *relation2.GroupMemberModel) string {
return e.GroupID
})
groups, err := g.groupDB.Find(ctx, groupIDs)
if err != nil {
return 0, nil, err
}
utils.OrderPtr(groupIDs, &groups, func(e *relation2.GroupModel) string {
return e.GroupID
})
return total, groups, nil
}
func (g *GroupDataBase) UpdateGroup(ctx context.Context, groupID string, data map[string]any) error {
return g.groupDB.UpdateMap(ctx, groupID, data)
}
func (g *GroupDataBase) DismissGroup(ctx context.Context, groupID string) error {
return utils.Wrap(g.db.Transaction(func(tx *gorm.DB) error {
if err := g.groupDB.UpdateStatus(ctx, groupID, constant.GroupStatusDismissed, tx); err != nil {
return err
}
return g.groupMemberDB.DeleteGroup(ctx, []string{groupID}, tx)
}), "")
} }
func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error { func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relation2.GroupModel, groupMembers []*relation2.GroupMemberModel) error {
return g.db.Transaction(func(tx *gorm.DB) error { if len(groups) > 0 && len(groupMembers) > 0 {
if len(groups) > 0 { return g.db.Transaction(func(tx *gorm.DB) error {
if err := g.groupDB.Create(ctx, groups, tx); err != nil { if err := g.groupDB.Create(ctx, groups, tx); err != nil {
return err return err
} }
} return g.groupMemberDB.Create(ctx, groupMembers, tx)
if len(groupMembers) > 0 { })
if err := g.groupMemberDB.Create(ctx, groupMembers, tx); err != nil { }
return err if len(groups) > 0 {
} return g.groupDB.Create(ctx, groups)
} }
return nil if len(groupMembers) > 0 {
}) return g.groupMemberDB.Create(ctx, groupMembers)
}
return nil
} }
func (g *GroupDataBase) DeleteGroupByIDs(ctx context.Context, groupIDs []string) error { func (g *GroupDataBase) TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relation2.GroupMemberModel, err error) {
return g.groupDB.DB.Transaction(func(tx *gorm.DB) error { return g.groupMemberDB.Take(ctx, groupID, userID)
if err := g.groupDB.Delete(ctx, groupIDs, tx); err != nil {
return err
}
if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
return err
}
return nil
})
} }
func (g *GroupDataBase) TakeGroupByID(ctx context.Context, groupID string) (group *relation2.GroupModel, err error) { func (g *GroupDataBase) FindGroupMember(ctx context.Context, groupID string, userIDs []string) ([]*relation2.GroupMemberModel, error) {
return g.cache.GetGroupInfo(ctx, groupID) return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, userIDs, nil)
} }
func (g *GroupDataBase) Update(ctx context.Context, groups []*relation2.GroupModel) error { func (g *GroupDataBase) FindGroupMemberAll(ctx context.Context, groupID string) ([]*relation2.GroupMemberModel, error) {
return g.db.Transaction(func(tx *gorm.DB) error { return g.groupMemberDB.FindGroupUser(ctx, []string{groupID}, nil, nil)
if err := g.groupDB.Update(ctx, groups, tx); err != nil {
return err
}
var groupIDs []string
for _, group := range groups {
groupIDs = append(groupIDs, group.GroupID)
}
if err := g.cache.DelGroupsInfo(ctx, groupIDs); err != nil {
return err
}
return nil
})
} }
func (g *GroupDataBase) GetJoinedGroupList(ctx context.Context, userID string) ([]*relation2.GroupModel, error) { func (g *GroupDataBase) FindGroupMemberFilterList(ctx context.Context, groupID string, filter int32, begin int32, maxNumber int32) ([]*relation2.GroupMemberModel, error) {
//TODO implement me
panic("implement me")
}
return nil, nil func (g *GroupDataBase) SearchGroupMember(ctx context.Context, groupID string, name string, pageNumber, showNumber int32) (int32, []*relation2.GroupMemberModel, error) {
return g.groupMemberDB.SearchMember(ctx, groupID, name, pageNumber, showNumber)
}
func (g *GroupDataBase) TakeGroupOwner(ctx context.Context, groupID string) (*relation2.GroupMemberModel, error) {
return g.groupMemberDB.TakeOwner(ctx, groupID)
}
func (g *GroupDataBase) FindGroupOwnerUser(ctx context.Context, groupIDs []string) ([]*relation2.GroupMemberModel, error) {
return g.groupMemberDB.FindGroupUser(ctx, groupIDs, nil, []int32{constant.GroupOwner})
}
func (g *GroupDataBase) CreateGroupMember(ctx context.Context, groupMember []*relation2.GroupMemberModel) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relation2.GroupMemberModel) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) MapGroupHash(ctx context.Context, groupIDs []string) (map[string]uint64, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]int, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) MapGroupOwnerUserID(ctx context.Context, groupIDs []string) (map[string]string, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) UpdateGroupMember(ctx context.Context, groupID, userID string, data map[string]any) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) CreateGroupRequest(ctx context.Context, requests []*relation2.GroupRequestModel) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) GetGroupRecvApplicationList(ctx context.Context, userID string) ([]*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) FindUserGroupRequest(ctx context.Context, userID string, pageNumber, showNumber int32) (int32, []*relation2.GroupRequestModel, error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) TakeSuperGroup(ctx context.Context, groupID string) (superGroup *unrelation2.SuperGroupModel, err error) {
//TODO implement me
panic("implement me")
} }
func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error { func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error {
sess, err := g.mongoDB.MgoClient.StartSession() //TODO implement me
if err != nil { panic("implement me")
return err
}
defer sess.EndSession(ctx)
sCtx := mongo.NewSessionContext(ctx, sess)
if err = g.mongoDB.CreateSuperGroup(sCtx, groupID, initMemberIDList); err != nil {
_ = sess.AbortTransaction(ctx)
return err
}
if err = g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil {
_ = sess.AbortTransaction(ctx)
return err
}
return sess.CommitTransaction(ctx)
} }
func (g *GroupDataBase) GetSuperGroupByID(ctx context.Context, groupID string) (superGroup *unrelation.SuperGroup, err error) { func (g *GroupDataBase) DeleteSuperGroup(ctx context.Context, groupID string) error {
return g.mongoDB.GetSuperGroup(ctx, groupID) //TODO implement me
panic("implement me")
}
func (g *GroupDataBase) DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) FindJoinSuperGroup(ctx context.Context, userID string, pageNumber, showNumber int32) (total int32, groupIDs []string, err error) {
//TODO implement me
panic("implement me")
}
func (g *GroupDataBase) MapSuperGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error) {
//TODO implement me
panic("implement me")
} }

View File

@ -1,15 +1,35 @@
package relation package relation
import ( import (
"Open_IM/pkg/common/db/table/relation"
"gorm.io/gorm" "gorm.io/gorm"
) )
type ConversationGorm struct { var ConversationDB *gorm.DB
DB *gorm.DB
//type Conversation struct {
// OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
// ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
// ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
// UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
// GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
// RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
// UnreadCount int32 `gorm:"column:unread_count" json:"unreadCount"`
// DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
// IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
// IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
// BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
// GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
// IsNotInGroup bool `gorm:"column:is_not_in_group" json:"isNotInGroup"`
// UpdateUnreadCountTime int64 `gorm:"column:update_unread_count_time" json:"updateUnreadCountTime"`
// AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
// Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
//}
func (Conversation) TableName() string {
return "conversations"
} }
func SetConversation(conversation relation.ConversationModel) (bool, error) { func SetConversation(conversation Conversation) (bool, error) {
var isUpdate bool var isUpdate bool
newConversation := conversation newConversation := conversation
if ConversationDB.Model(&Conversation{}).Find(&newConversation).RowsAffected == 0 { if ConversationDB.Model(&Conversation{}).Find(&newConversation).RowsAffected == 0 {
@ -73,7 +93,7 @@ func GetExistConversationUserIDList(ownerUserIDList []string, conversationID str
return resultArr, nil return resultArr, nil
} }
func GetConversation(OwnerUserID, conversationID string) (relation.ConversationModel, error) { func GetConversation(OwnerUserID, conversationID string) (Conversation, error) {
var conversation Conversation var conversation Conversation
err := ConversationDB.Table("conversations").Where("owner_user_id=? and conversation_id=?", OwnerUserID, conversationID).Take(&conversation).Error err := ConversationDB.Table("conversations").Where("owner_user_id=? and conversation_id=?", OwnerUserID, conversationID).Take(&conversation).Error
return conversation, err return conversation, err
@ -96,7 +116,7 @@ func UpdateColumnsConversations(ownerUserIDList []string, conversationID string,
} }
func GetConversationIDsByUserID(userID string) ([]string, error) { func GetConversationIDListByUserID(userID string) ([]string, error) {
var IDList []string var IDList []string
err := ConversationDB.Model(&Conversation{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &IDList).Error err := ConversationDB.Model(&Conversation{}).Where("owner_user_id=?", userID).Pluck("conversation_id", &IDList).Error
return IDList, err return IDList, err

View File

@ -0,0 +1,73 @@
package relation
import (
"Open_IM/pkg/common/db/table"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
"gorm.io/gorm"
)
type Conversation interface {
TableName() string
Create(ctx context.Context, conversations []*table.ConversationModel) (err error)
Delete(ctx context.Context, groupIDs []string) (err error)
UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error)
Update(ctx context.Context, groups []*table.ConversationModel) (err error)
Find(ctx context.Context, groupIDs []string) (groups []*table.ConversationModel, err error)
Take(ctx context.Context, groupID string) (group *table.ConversationModel, err error)
}
type ConversationGorm struct {
DB *gorm.DB
}
func (c *ConversationGorm) TableName() string {
panic("implement me")
}
func NewConversationGorm(DB *gorm.DB) Conversation {
return &ConversationGorm{DB: DB}
}
func (c *ConversationGorm) Create(ctx context.Context, conversations []*table.ConversationModel) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "conversations", conversations)
}()
return utils.Wrap(getDBConn(g.DB, tx).Create(&conversations).Error, "")
}
func (c *ConversationGorm) Delete(ctx context.Context, groupIDs []string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
}()
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&table.ConversationModel{}).Error, "")
}
func (c *ConversationGorm) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args)
}()
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(g).Updates(args).Error, "")
}
func (c *ConversationGorm) Update(ctx context.Context, groups []*table.ConversationModel) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
}()
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "")
}
func (c *ConversationGorm) Find(ctx context.Context, groupIDs []string) (groups []*table.ConversationModel, err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups)
}()
return groups, utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Find(&groups).Error, "")
}
func (c *ConversationGorm) Take(ctx context.Context, groupID string) (group *table.ConversationModel, err error) {
group = &Group{}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
}()
return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "")
}

View File

@ -1,7 +1,7 @@
package relation package relation
import ( import (
"Open_IM/pkg/common/db/table" "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/tracelog" "Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
@ -9,12 +9,12 @@ import (
) )
type FriendDB interface { type FriendDB interface {
Create(ctx context.Context, friends []*table.FriendModel) (err error) Create(ctx context.Context, friends []*relation.FriendModel) (err error)
Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error) Delete(ctx context.Context, ownerUserID string, friendUserIDs string) (err error)
UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error)
Update(ctx context.Context, friends []*table.FriendModel) (err error) Update(ctx context.Context, friends []*relation.FriendModel) (err error)
UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error) UpdateRemark(ctx context.Context, ownerUserID, friendUserID, remark string) (err error)
FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*table.FriendModel, err error) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*relation.FriendModel, err error)
} }
type FriendGorm struct { type FriendGorm struct {
@ -30,7 +30,7 @@ type FriendUser struct {
Nickname string `gorm:"column:name;size:255"` Nickname string `gorm:"column:name;size:255"`
} }
func (f *FriendGorm) Create(ctx context.Context, friends []*table.FriendModel, tx ...*gorm.DB) (err error) { func (f *FriendGorm) Create(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends)
}() }()
@ -52,7 +52,7 @@ func (f *FriendGorm) UpdateByMap(ctx context.Context, ownerUserID string, args m
return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Updates(args).Error, "") return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Updates(args).Error, "")
} }
func (f *FriendGorm) Update(ctx context.Context, friends []*table.FriendModel, tx ...*gorm.DB) (err error) { func (f *FriendGorm) Update(ctx context.Context, friends []*relation.FriendModel, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends)
}() }()
@ -66,27 +66,27 @@ func (f *FriendGorm) UpdateRemark(ctx context.Context, ownerUserID, friendUserID
return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "") return utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id = ?", ownerUserID, friendUserID).Update("remark", remark).Error, "")
} }
func (f *FriendGorm) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*table.FriendModel, err error) { func (f *FriendGorm) FindOwnerUserID(ctx context.Context, ownerUserID string) (friends []*relation.FriendModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
}() }()
return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "") return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
} }
func (f *FriendGorm) FindFriendUserID(ctx context.Context, friendUserID string) (friends []*table.FriendModel, err error) { func (f *FriendGorm) FindFriendUserID(ctx context.Context, friendUserID string) (friends []*relation.FriendModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends)
}() }()
return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("friend_user_id = ?", friendUserID).Find(&friends).Error, "") return friends, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("friend_user_id = ?", friendUserID).Find(&friends).Error, "")
} }
func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *table.FriendModel, err error) { func (f *FriendGorm) Take(ctx context.Context, ownerUserID, friendUserID string) (friend *relation.FriendModel, err error) {
friend = &table.FriendModel{} friend = &table.FriendModel{}
defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "friend", friend) defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friendUserID", friendUserID, "friend", friend)
return friend, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "") return friend, utils.Wrap(f.DB.Model(&table.FriendModel{}).Where("owner_user_id = ? and friend_user_id", ownerUserID, friendUserID).Take(friend).Error, "")
} }
func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*table.FriendModel, err error) { func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string) (friends []*relation.FriendModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "userID1", userID1, "userID2", userID2) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "userID1", userID1, "userID2", userID2)
}() }()
@ -94,7 +94,7 @@ func (f *FriendGorm) FindUserState(ctx context.Context, userID1, userID2 string)
} }
// 获取 owner的好友列表 如果不存在也不返回错误 // 获取 owner的好友列表 如果不存在也不返回错误
func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (friends []*table.FriendModel, err error) { func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friendUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserIDs", friendUserIDs, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserIDs", friendUserIDs, "friends", friends)
}() }()
@ -102,14 +102,14 @@ func (f *FriendGorm) FindFriends(ctx context.Context, ownerUserID string, friend
} }
// 获取哪些人添加了friendUserID 如果不存在也不返回错误 // 获取哪些人添加了friendUserID 如果不存在也不返回错误
func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string, tx ...*gorm.DB) (friends []*table.FriendModel, err error) { func (f *FriendGorm) FindReversalFriends(ctx context.Context, friendUserID string, ownerUserIDs []string, tx ...*gorm.DB) (friends []*relation.FriendModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "friends", friends)
}() }()
return friends, utils.Wrap(getDBConn(f.DB, tx).Where("friend_user_id = ? AND owner_user_id in (?)", friendUserID, ownerUserIDs).Find(&friends).Error, "") return friends, utils.Wrap(getDBConn(f.DB, tx).Where("friend_user_id = ? AND owner_user_id in (?)", friendUserID, ownerUserIDs).Find(&friends).Error, "")
} }
func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*table.FriendModel, total int64, err error) { func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total)
}() }()
@ -121,7 +121,7 @@ func (f *FriendGorm) FindOwnerFriends(ctx context.Context, ownerUserID string, p
return return
} }
func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*table.FriendModel, total int64, err error) { func (f *FriendGorm) FindInWhoseFriends(ctx context.Context, friendUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendModel, total int64, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendUserID", friendUserID, "pageNumber", pageNumber, "showNumber", showNumber, "friends", friends, "total", total)
}() }()

View File

@ -1,7 +1,7 @@
package relation package relation
import ( import (
"Open_IM/pkg/common/db/table" "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/tracelog" "Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
@ -20,69 +20,68 @@ type FriendRequestGorm struct {
DB *gorm.DB `gorm:"-"` DB *gorm.DB `gorm:"-"`
} }
func (f *FriendRequestGorm) Create(ctx context.Context, friends []*table.FriendRequestModel) (err error) { func (f *FriendRequestGorm) Create(ctx context.Context, friends []*relation.FriendRequestModel, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friends", friends)
}() }()
return utils.Wrap(f.DB.Model(&table.FriendRequestModel{}).Create(&friends).Error, "") return utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Create(&friends).Error, "")
} }
func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) { func (f *FriendRequestGorm) Delete(ctx context.Context, fromUserID, toUserID string) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID)
}() }()
return utils.Wrap(f.DB.Model(&table.FriendRequestModel{}).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Delete(&table.FriendRequestModel{}).Error, "") return utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id = ?", fromUserID, toUserID).Delete(&relation.FriendRequestModel{}).Error, "")
} }
func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, ownerUserID string, args map[string]interface{}) (err error) { func (f *FriendRequestGorm) UpdateByMap(ctx context.Context, formUserID string, toUserID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "args", args) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "formUserID", formUserID, "toUserID", toUserID, "args", args)
}() }()
return utils.Wrap(f.DB.Model(&table.FriendRequestModel{}).Where("owner_user_id = ?", ownerUserID).Updates(args).Error, "") return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? AND to_user_id ", formUserID, toUserID).Updates(args).Error, "")
} }
func (f *FriendRequestGorm) Update(ctx context.Context, friendRequests []*table.FriendRequestModel, tx ...*gorm.DB) (err error) { func (f *FriendRequestGorm) Update(ctx context.Context, friendRequests []*relation.FriendRequestModel, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendRequests", friendRequests) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "friendRequests", friendRequests)
}() }()
return utils.Wrap(getDBConn(f.DB, tx).Model(&table.FriendRequestModel{}).Updates(&friendRequests).Error, "") return utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Updates(&friendRequests).Error, "")
} }
func (f *FriendRequestGorm) Find(ctx context.Context, ownerUserID string) (friends []*table.FriendRequestModel, err error) { func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friend *relation.FriendRequestModel, err error) {
defer func() { friend = &relation.FriendRequestModel{}
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "ownerUserID", ownerUserID, "friends", friends)
}()
return friends, utils.Wrap(f.DB.Model(&table.FriendRequestModel{}).Where("owner_user_id = ?", ownerUserID).Find(&friends).Error, "")
}
func (f *FriendRequestGorm) Take(ctx context.Context, fromUserID, toUserID string) (friend *table.FriendRequestModel, err error) {
friend = &table.FriendRequestModel{}
defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend) defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend)
return friend, utils.Wrap(f.DB.Model(&table.FriendRequestModel{}).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friend).Error, "") return friend, utils.Wrap(f.DB.Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Take(friend).Error, "")
} }
func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendRequestGorm) Find(ctx context.Context, fromUserID, toUserID string, tx ...*gorm.DB) (friend *relation.FriendRequestModel, err error) {
friend = &relation.FriendRequestModel{}
defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "toUserID", toUserID, "friend", friend)
return friend, utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? and to_user_id", fromUserID, toUserID).Find(friend).Error, "")
}
func (f *FriendRequestGorm) FindToUserID(ctx context.Context, toUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendRequestModel, total int64, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "toUserID", toUserID, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "toUserID", toUserID, "friends", friends)
}() }()
err = getDBConn(f.DB, tx).Model(&table.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Count(&total).Error err = getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Count(&total).Error
if err != nil { if err != nil {
return nil, 0, utils.Wrap(err, "") return nil, 0, utils.Wrap(err, "")
} }
err = utils.Wrap(getDBConn(f.DB, tx).Model(&table.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") err = utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("to_user_id = ? ", toUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "")
return return
} }
func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*table.FriendRequestModel, total int64, err error) { func (f *FriendRequestGorm) FindFromUserID(ctx context.Context, fromUserID string, pageNumber, showNumber int32, tx ...*gorm.DB) (friends []*relation.FriendRequestModel, total int64, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "friends", friends) tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "fromUserID", fromUserID, "friends", friends)
}() }()
err = getDBConn(f.DB, tx).Model(&table.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Count(&total).Error err = getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Count(&total).Error
if err != nil { if err != nil {
return nil, 0, utils.Wrap(err, "") return nil, 0, utils.Wrap(err, "")
} }
err = utils.Wrap(getDBConn(f.DB, tx).Model(&table.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "") err = utils.Wrap(getDBConn(f.DB, tx).Model(&relation.FriendRequestModel{}).Where("from_user_id = ? ", fromUserID).Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&friends).Error, "")
return return
} }

View File

@ -37,7 +37,7 @@ package relation
// //
//} //}
// //
//func GetGroupMemberListByUserID(userID string) ([]GroupMember, error) { //func FindGroupMember(userID string) ([]GroupMember, error) {
// var groupMemberList []GroupMember // var groupMemberList []GroupMember
// err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error // err := DB.DB.MysqlDB.DefaultGormDB().Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error
// if err != nil { // if err != nil {
@ -167,7 +167,7 @@ package relation
//} //}
// //
//func GetJoinedGroupIDListByUserID(userID string) ([]string, error) { //func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
// memberList, err := GetGroupMemberListByUserID(userID) // memberList, err := FindGroupMember(userID)
// if err != nil { // if err != nil {
// return nil, err // return nil, err
// } // }

View File

@ -31,6 +31,13 @@ func (g *GroupMemberGorm) Delete(ctx context.Context, groupMembers []*relation.G
return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Delete(groupMembers).Error, "")
} }
func (g *GroupMemberGorm) DeleteGroup(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs)
}()
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupMemberModel{}).Error, "")
}
func (g *GroupMemberGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { func (g *GroupMemberGorm) UpdateByMap(ctx context.Context, groupID string, userID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "args", args)
@ -54,6 +61,23 @@ func (g *GroupMemberGorm) Find(ctx context.Context, groupMembers []*relation.Gro
return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "") return groupList, utils.Wrap(getDBConn(g.DB, tx).Where("(group_id, user_id) in ?", where).Find(&groupList).Error, "")
} }
func (g *GroupMemberGorm) FindGroupUser(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, tx ...*gorm.DB) (groupList []*relation.GroupMemberModel, err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "userIDs", userIDs, "groupList", groupList)
}()
db := getDBConn(g.DB, tx)
if len(groupList) > 0 {
db = db.Where("group_id in (?)", groupIDs)
}
if len(userIDs) > 0 {
db = db.Where("user_id in (?)", userIDs)
}
if len(roleLevels) > 0 {
db = db.Where("role_level in (?)", roleLevels)
}
return groupList, utils.Wrap(db.Find(&groupList).Error, "")
}
func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) { func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
@ -62,7 +86,7 @@ func (g *GroupMemberGorm) Take(ctx context.Context, groupID string, userID strin
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "") return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and user_id = ?", groupID, userID).Take(groupMember).Error, "")
} }
func (g *GroupMemberGorm) TakeOwnerInfo(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) { func (g *GroupMemberGorm) TakeOwner(ctx context.Context, groupID string, tx ...*gorm.DB) (groupMember *relation.GroupMemberModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMember", *groupMember)
}() }()
@ -70,214 +94,16 @@ func (g *GroupMemberGorm) TakeOwnerInfo(ctx context.Context, groupID string, tx
return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "") return groupMember, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ? and role_level = ?", groupID, constant.GroupOwner).Take(groupMember).Error, "")
} }
//func InsertIntoGroupMember(toInsertInfo GroupMemberModel) error { func (g *GroupMemberGorm) PageByUser(ctx context.Context, userID string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) {
// toInsertInfo.JoinTime = time.Now() defer func() {
// if toInsertInfo.RoleLevel == 0 { tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "total", total, "groupList", groupList)
// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers }()
// } return gormPage[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("user_id = ?", userID), pageNumber, showNumber)
// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0) }
// err := GroupMemberDB.Table("group_members").Create(toInsertInfo).Error
// if err != nil { func (g *GroupMemberGorm) SearchMember(ctx context.Context, groupID string, name string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groupList []*relation.GroupMemberModel, err error) {
// return err defer func() {
// } tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "name", name, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groupList", groupList)
// return nil }()
//} return gormSearch[relation.GroupMemberModel](getDBConn(g.DB, tx).Where("group_id = ?", groupID), "nickname", name, pageNumber, showNumber)
// }
//func BatchInsertIntoGroupMember(toInsertInfoList []*GroupMemberModel) error {
// for _, toInsertInfo := range toInsertInfoList {
// toInsertInfo.JoinTime = time.Now()
// if toInsertInfo.RoleLevel == 0 {
// toInsertInfo.RoleLevel = constant.GroupOrdinaryUsers
// }
// toInsertInfo.MuteEndTime = time.Unix(int64(time.Now().Second()), 0)
// }
// return GroupMemberDB.Create(toInsertInfoList).Error
//
//}
//
//func GetGroupMemberListByUserID(userID string) ([]GroupMemberModel, error) {
// var groupMemberList []GroupMemberModel
// err := GroupMemberDB.Table("group_members").Where("user_id=?", userID).Find(&groupMemberList).Error
// if err != nil {
// return nil, err
// }
// return groupMemberList, nil
//}
//
//func GetGroupMemberListByGroupID(groupID string) ([]GroupMemberModel, error) {
// var groupMemberList []GroupMemberModel
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Find(&groupMemberList).Error
// if err != nil {
// return nil, err
// }
// return groupMemberList, nil
//}
//
//func GetGroupMemberIDListByGroupID(groupID string) ([]string, error) {
// var groupMemberIDList []string
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Pluck("user_id", &groupMemberIDList).Error
// if err != nil {
// return nil, err
// }
// return groupMemberIDList, nil
//}
//
//func GetGroupMemberListByGroupIDAndRoleLevel(groupID string, roleLevel int32) ([]GroupMemberModel, error) {
// var groupMemberList []GroupMemberModel
// err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level=?", groupID, roleLevel).Find(&groupMemberList).Error
// if err != nil {
// return nil, err
// }
// return groupMemberList, nil
//}
//
//func GetGroupMemberInfoByGroupIDAndUserID(groupID, userID string) (*GroupMemberModel, error) {
// var groupMember GroupMemberModel
// err := GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Limit(1).Take(&groupMember).Error
// if err != nil {
// return nil, err
// }
// return &groupMember, nil
//}
//
//func DeleteGroupMemberByGroupIDAndUserID(groupID, userID string) error {
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=? ", groupID, userID).Delete(GroupMemberModel{}).Error
//}
//
//func DeleteGroupMemberByGroupID(groupID string) error {
// return GroupMemberDB.Table("group_members").Where("group_id=? ", groupID).Delete(GroupMemberModel{}).Error
//}
//
//func UpdateGroupMemberInfo(groupMemberInfo GroupMemberModel) error {
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(&groupMemberInfo).Error
//}
//
//func UpdateGroupMemberInfoByMap(groupMemberInfo GroupMemberModel, m map[string]interface{}) error {
// return GroupMemberDB.Table("group_members").Where("group_id=? and user_id=?", groupMemberInfo.GroupID, groupMemberInfo.UserID).Updates(m).Error
//}
//
//func GetOwnerManagerByGroupID(groupID string) ([]GroupMemberModel, error) {
// var groupMemberList []GroupMemberModel
// err := GroupMemberDB.Table("group_members").Where("group_id=? and role_level>?", groupID, constant.GroupOrdinaryUsers).Find(&groupMemberList).Error
// if err != nil {
// return nil, err
// }
// return groupMemberList, nil
//}
//
//func GetGroupMemberNumByGroupID(groupID string) (int64, error) {
// var number int64
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Count(&number).Error
// if err != nil {
// return 0, utils.Wrap(err, "")
// }
// return number, nil
//}
//
//func GetGroupOwnerInfoByGroupID(groupID string) (*GroupMemberModel, error) {
// omList, err := GetOwnerManagerByGroupID(groupID)
// if err != nil {
// return nil, err
// }
// for _, v := range omList {
// if v.RoleLevel == constant.GroupOwner {
// return &v, nil
// }
// }
// return nil, utils.Wrap(constant.ErrGroupNoOwner, "")
//}
//
//func IsExistGroupMember(groupID, userID string) bool {
// var number int64
// err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
// if err != nil {
// return false
// }
// if number != 1 {
// return false
// }
// return true
//}
//
//func CheckIsExistGroupMember(ctx context.Context, groupID, userID string) error {
// var number int64
// err := GroupMemberDB.Table("group_members").Where("group_id = ? and user_id = ?", groupID, userID).Count(&number).Error
// if err != nil {
// return constant.ErrDB.Wrap()
// }
// if number != 1 {
// return constant.ErrData.Wrap()
// }
// return nil
//}
//
//func GetGroupMemberByGroupID(groupID string, filter int32, begin int32, maxNumber int32) ([]GroupMember, error) {
// var memberList []GroupMember
// var err error
// if filter >= 0 {
// memberList, err = GetGroupMemberListByGroupIDAndRoleLevel(groupID, filter) //sorted by join time
// } else {
// memberList, err = GetGroupMemberListByGroupID(groupID)
// }
//
// if err != nil {
// return nil, err
// }
// if begin >= int32(len(memberList)) {
// return nil, nil
// }
//
// var end int32
// if begin+int32(maxNumber) < int32(len(memberList)) {
// end = begin + maxNumber
// } else {
// end = int32(len(memberList))
// }
// return memberList[begin:end], nil
//}
//
//func GetJoinedGroupIDListByUserID(userID string) ([]string, error) {
// memberList, err := GetGroupMemberListByUserID(userID)
// if err != nil {
// return nil, err
// }
// var groupIDList []string
// for _, v := range memberList {
// groupIDList = append(groupIDList, v.GroupID)
// }
// return groupIDList, nil
//}
//
//func IsGroupOwnerAdmin(groupID, UserID string) bool {
// groupMemberList, err := GetOwnerManagerByGroupID(groupID)
// if err != nil {
// return false
// }
// for _, v := range groupMemberList {
// if v.UserID == UserID && v.RoleLevel > constant.GroupOrdinaryUsers {
// return true
// }
// }
// return false
//}
//
//func GetGroupMembersByGroupIdCMS(groupId string, userName string, showNumber, pageNumber int32) ([]GroupMember, error) {
// var groupMembers []GroupMember
// err := GroupMemberDB.Table("group_members").Where("group_id=?", groupId).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Limit(int(showNumber)).Offset(int(showNumber * (pageNumber - 1))).Find(&groupMembers).Error
// if err != nil {
// return nil, err
// }
// return groupMembers, nil
//}
//
//func GetGroupMembersCount(groupID, userName string) (int64, error) {
// var count int64
// if err := GroupMemberDB.Table("group_members").Where("group_id=?", groupID).Where(fmt.Sprintf(" nickname like '%%%s%%' ", userName)).Count(&count).Error; err != nil {
// return count, err
// }
// return count, nil
//}
//
//func UpdateGroupMemberInfoDefaultZero(groupMemberInfo GroupMember, args map[string]interface{}) error {
// return GroupMemberDB.Model(groupMemberInfo).Updates(args).Error
//}

View File

@ -30,20 +30,27 @@ func (g *GroupGorm) Delete(ctx context.Context, groupIDs []string, tx ...*gorm.D
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupModel{}).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Where("group_id in (?)", groupIDs).Delete(&relation.GroupModel{}).Error, "")
} }
func (g *GroupGorm) UpdateByMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...*gorm.DB) (err error) { func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[string]interface{}, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "args", args)
}() }()
return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(g).Updates(args).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(args).Error, "")
} }
func (g *GroupGorm) Update(ctx context.Context, groups []*relation.GroupModel, tx ...*gorm.DB) (err error) { func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32, tx ...*gorm.DB) (err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "status", status)
}() }()
return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "") return utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(map[string]any{"status": status}).Error, "")
} }
//func (g *GroupGorm) Update(ctx context.Context, groups []*relation.GroupModel, tx ...*gorm.DB) (err error) {
// defer func() {
// tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groups", groups)
// }()
// return utils.Wrap(getDBConn(g.DB, tx).Updates(&groups).Error, "")
//}
func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groups []*relation.GroupModel, err error) { func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB) (groups []*relation.GroupModel, err error) {
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupIDs", groupIDs, "groups", groups)
@ -54,7 +61,14 @@ func (g *GroupGorm) Find(ctx context.Context, groupIDs []string, tx ...*gorm.DB)
func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *relation.GroupModel, err error) { func (g *GroupGorm) Take(ctx context.Context, groupID string, tx ...*gorm.DB) (group *relation.GroupModel, err error) {
group = &relation.GroupModel{} group = &relation.GroupModel{}
defer func() { defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group) tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", group)
}() }()
return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "") return group, utils.Wrap(getDBConn(g.DB, tx).Where("group_id = ?", groupID).Take(group).Error, "")
} }
func (g *GroupGorm) Search(ctx context.Context, name string, pageNumber, showNumber int32, tx ...*gorm.DB) (total int32, groups []*relation.GroupModel, err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "name", name, "pageNumber", pageNumber, "showNumber", showNumber, "total", total, "groups", groups)
}()
return gormSearch[relation.GroupModel](getDBConn(g.DB, tx), "name", name, pageNumber, showNumber)
}

View File

@ -55,7 +55,7 @@ package relation
//received //received
//func GetRecvGroupApplicationList(userID string) ([]GroupRequest, error) { //func GetRecvGroupApplicationList(userID string) ([]GroupRequest, error) {
// var groupRequestList []GroupRequest // var groupRequestList []GroupRequest
// memberList, err := GetGroupMemberListByUserID(userID) // memberList, err := FindGroupMember(userID)
// if err != nil { // if err != nil {
// return nil, utils.Wrap(err, utils.GetSelfFuncName()) // return nil, utils.Wrap(err, utils.GetSelfFuncName())
// } // }

View File

@ -0,0 +1,25 @@
package relation
import (
"Open_IM/pkg/utils"
"gorm.io/gorm"
)
func gormPage[E any](db *gorm.DB, pageNumber, showNumber int32) (int32, []*E, error) {
var count int64
if err := db.Model(new(E)).Count(&count).Error; err != nil {
return 0, nil, utils.Wrap(err, "")
}
var es []*E
if err := db.Limit(int(showNumber)).Offset(int(pageNumber * showNumber)).Find(&es).Error; err != nil {
return 0, nil, utils.Wrap(err, "")
}
return int32(count), es, nil
}
func gormSearch[E any](db *gorm.DB, field string, value string, pageNumber, showNumber int32) (int32, []*E, error) {
if field != "" && value != "" {
db = db.Where(field+" like ?", "%"+value+"%")
}
return gormPage[E](db, pageNumber, showNumber)
}

View File

@ -12,7 +12,7 @@ type GroupModel struct {
Notification string `gorm:"column:notification;size:255" json:"notification"` Notification string `gorm:"column:notification;size:255" json:"notification"`
Introduction string `gorm:"column:introduction;size:255" json:"introduction"` Introduction string `gorm:"column:introduction;size:255" json:"introduction"`
FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"` FaceURL string `gorm:"column:face_url;size:255" json:"faceURL"`
CreateTime time.Time `gorm:"column:create_time;index:create_time"` CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"` Ex string `gorm:"column:ex" json:"ex;size:1024" json:"ex"`
Status int32 `gorm:"column:status"` Status int32 `gorm:"column:status"`
CreatorUserID string `gorm:"column:creator_user_id;size:64"` CreatorUserID string `gorm:"column:creator_user_id;size:64"`

View File

@ -39,7 +39,7 @@ func (m *CreateGroupReq) Reset() { *m = CreateGroupReq{} }
func (m *CreateGroupReq) String() string { return proto.CompactTextString(m) } func (m *CreateGroupReq) String() string { return proto.CompactTextString(m) }
func (*CreateGroupReq) ProtoMessage() {} func (*CreateGroupReq) ProtoMessage() {}
func (*CreateGroupReq) Descriptor() ([]byte, []int) { func (*CreateGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{0} return fileDescriptor_group_d88c7f5350508ce3, []int{0}
} }
func (m *CreateGroupReq) XXX_Unmarshal(b []byte) error { func (m *CreateGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateGroupReq.Unmarshal(m, b) return xxx_messageInfo_CreateGroupReq.Unmarshal(m, b)
@ -98,7 +98,7 @@ func (m *CreateGroupResp) Reset() { *m = CreateGroupResp{} }
func (m *CreateGroupResp) String() string { return proto.CompactTextString(m) } func (m *CreateGroupResp) String() string { return proto.CompactTextString(m) }
func (*CreateGroupResp) ProtoMessage() {} func (*CreateGroupResp) ProtoMessage() {}
func (*CreateGroupResp) Descriptor() ([]byte, []int) { func (*CreateGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{1} return fileDescriptor_group_d88c7f5350508ce3, []int{1}
} }
func (m *CreateGroupResp) XXX_Unmarshal(b []byte) error { func (m *CreateGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CreateGroupResp.Unmarshal(m, b) return xxx_messageInfo_CreateGroupResp.Unmarshal(m, b)
@ -136,7 +136,7 @@ func (m *GetGroupsInfoReq) Reset() { *m = GetGroupsInfoReq{} }
func (m *GetGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupsInfoReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupsInfoReq) ProtoMessage() {} func (*GetGroupsInfoReq) ProtoMessage() {}
func (*GetGroupsInfoReq) Descriptor() ([]byte, []int) { func (*GetGroupsInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{2} return fileDescriptor_group_d88c7f5350508ce3, []int{2}
} }
func (m *GetGroupsInfoReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupsInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupsInfoReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupsInfoReq.Unmarshal(m, b)
@ -174,7 +174,7 @@ func (m *GetGroupsInfoResp) Reset() { *m = GetGroupsInfoResp{} }
func (m *GetGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupsInfoResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupsInfoResp) ProtoMessage() {} func (*GetGroupsInfoResp) ProtoMessage() {}
func (*GetGroupsInfoResp) Descriptor() ([]byte, []int) { func (*GetGroupsInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{3} return fileDescriptor_group_d88c7f5350508ce3, []int{3}
} }
func (m *GetGroupsInfoResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupsInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupsInfoResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupsInfoResp.Unmarshal(m, b)
@ -212,7 +212,7 @@ func (m *SetGroupInfoReq) Reset() { *m = SetGroupInfoReq{} }
func (m *SetGroupInfoReq) String() string { return proto.CompactTextString(m) } func (m *SetGroupInfoReq) String() string { return proto.CompactTextString(m) }
func (*SetGroupInfoReq) ProtoMessage() {} func (*SetGroupInfoReq) ProtoMessage() {}
func (*SetGroupInfoReq) Descriptor() ([]byte, []int) { func (*SetGroupInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{4} return fileDescriptor_group_d88c7f5350508ce3, []int{4}
} }
func (m *SetGroupInfoReq) XXX_Unmarshal(b []byte) error { func (m *SetGroupInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupInfoReq.Unmarshal(m, b) return xxx_messageInfo_SetGroupInfoReq.Unmarshal(m, b)
@ -249,7 +249,7 @@ func (m *SetGroupInfoResp) Reset() { *m = SetGroupInfoResp{} }
func (m *SetGroupInfoResp) String() string { return proto.CompactTextString(m) } func (m *SetGroupInfoResp) String() string { return proto.CompactTextString(m) }
func (*SetGroupInfoResp) ProtoMessage() {} func (*SetGroupInfoResp) ProtoMessage() {}
func (*SetGroupInfoResp) Descriptor() ([]byte, []int) { func (*SetGroupInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{5} return fileDescriptor_group_d88c7f5350508ce3, []int{5}
} }
func (m *SetGroupInfoResp) XXX_Unmarshal(b []byte) error { func (m *SetGroupInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupInfoResp.Unmarshal(m, b) return xxx_messageInfo_SetGroupInfoResp.Unmarshal(m, b)
@ -281,7 +281,7 @@ func (m *GetGroupApplicationListReq) Reset() { *m = GetGroupApplicationL
func (m *GetGroupApplicationListReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupApplicationListReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupApplicationListReq) ProtoMessage() {} func (*GetGroupApplicationListReq) ProtoMessage() {}
func (*GetGroupApplicationListReq) Descriptor() ([]byte, []int) { func (*GetGroupApplicationListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{6} return fileDescriptor_group_d88c7f5350508ce3, []int{6}
} }
func (m *GetGroupApplicationListReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupApplicationListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupApplicationListReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupApplicationListReq.Unmarshal(m, b)
@ -327,7 +327,7 @@ func (m *GetGroupApplicationListResp) Reset() { *m = GetGroupApplication
func (m *GetGroupApplicationListResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupApplicationListResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupApplicationListResp) ProtoMessage() {} func (*GetGroupApplicationListResp) ProtoMessage() {}
func (*GetGroupApplicationListResp) Descriptor() ([]byte, []int) { func (*GetGroupApplicationListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{7} return fileDescriptor_group_d88c7f5350508ce3, []int{7}
} }
func (m *GetGroupApplicationListResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupApplicationListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupApplicationListResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupApplicationListResp.Unmarshal(m, b)
@ -373,7 +373,7 @@ func (m *GetUserReqApplicationListReq) Reset() { *m = GetUserReqApplicat
func (m *GetUserReqApplicationListReq) String() string { return proto.CompactTextString(m) } func (m *GetUserReqApplicationListReq) String() string { return proto.CompactTextString(m) }
func (*GetUserReqApplicationListReq) ProtoMessage() {} func (*GetUserReqApplicationListReq) ProtoMessage() {}
func (*GetUserReqApplicationListReq) Descriptor() ([]byte, []int) { func (*GetUserReqApplicationListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{8} return fileDescriptor_group_d88c7f5350508ce3, []int{8}
} }
func (m *GetUserReqApplicationListReq) XXX_Unmarshal(b []byte) error { func (m *GetUserReqApplicationListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserReqApplicationListReq.Unmarshal(m, b) return xxx_messageInfo_GetUserReqApplicationListReq.Unmarshal(m, b)
@ -419,7 +419,7 @@ func (m *GetUserReqApplicationListResp) Reset() { *m = GetUserReqApplica
func (m *GetUserReqApplicationListResp) String() string { return proto.CompactTextString(m) } func (m *GetUserReqApplicationListResp) String() string { return proto.CompactTextString(m) }
func (*GetUserReqApplicationListResp) ProtoMessage() {} func (*GetUserReqApplicationListResp) ProtoMessage() {}
func (*GetUserReqApplicationListResp) Descriptor() ([]byte, []int) { func (*GetUserReqApplicationListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{9} return fileDescriptor_group_d88c7f5350508ce3, []int{9}
} }
func (m *GetUserReqApplicationListResp) XXX_Unmarshal(b []byte) error { func (m *GetUserReqApplicationListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserReqApplicationListResp.Unmarshal(m, b) return xxx_messageInfo_GetUserReqApplicationListResp.Unmarshal(m, b)
@ -466,7 +466,7 @@ func (m *TransferGroupOwnerReq) Reset() { *m = TransferGroupOwnerReq{} }
func (m *TransferGroupOwnerReq) String() string { return proto.CompactTextString(m) } func (m *TransferGroupOwnerReq) String() string { return proto.CompactTextString(m) }
func (*TransferGroupOwnerReq) ProtoMessage() {} func (*TransferGroupOwnerReq) ProtoMessage() {}
func (*TransferGroupOwnerReq) Descriptor() ([]byte, []int) { func (*TransferGroupOwnerReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{10} return fileDescriptor_group_d88c7f5350508ce3, []int{10}
} }
func (m *TransferGroupOwnerReq) XXX_Unmarshal(b []byte) error { func (m *TransferGroupOwnerReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TransferGroupOwnerReq.Unmarshal(m, b) return xxx_messageInfo_TransferGroupOwnerReq.Unmarshal(m, b)
@ -517,7 +517,7 @@ func (m *TransferGroupOwnerResp) Reset() { *m = TransferGroupOwnerResp{}
func (m *TransferGroupOwnerResp) String() string { return proto.CompactTextString(m) } func (m *TransferGroupOwnerResp) String() string { return proto.CompactTextString(m) }
func (*TransferGroupOwnerResp) ProtoMessage() {} func (*TransferGroupOwnerResp) ProtoMessage() {}
func (*TransferGroupOwnerResp) Descriptor() ([]byte, []int) { func (*TransferGroupOwnerResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{11} return fileDescriptor_group_d88c7f5350508ce3, []int{11}
} }
func (m *TransferGroupOwnerResp) XXX_Unmarshal(b []byte) error { func (m *TransferGroupOwnerResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_TransferGroupOwnerResp.Unmarshal(m, b) return xxx_messageInfo_TransferGroupOwnerResp.Unmarshal(m, b)
@ -551,7 +551,7 @@ func (m *JoinGroupReq) Reset() { *m = JoinGroupReq{} }
func (m *JoinGroupReq) String() string { return proto.CompactTextString(m) } func (m *JoinGroupReq) String() string { return proto.CompactTextString(m) }
func (*JoinGroupReq) ProtoMessage() {} func (*JoinGroupReq) ProtoMessage() {}
func (*JoinGroupReq) Descriptor() ([]byte, []int) { func (*JoinGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{12} return fileDescriptor_group_d88c7f5350508ce3, []int{12}
} }
func (m *JoinGroupReq) XXX_Unmarshal(b []byte) error { func (m *JoinGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_JoinGroupReq.Unmarshal(m, b) return xxx_messageInfo_JoinGroupReq.Unmarshal(m, b)
@ -609,7 +609,7 @@ func (m *JoinGroupResp) Reset() { *m = JoinGroupResp{} }
func (m *JoinGroupResp) String() string { return proto.CompactTextString(m) } func (m *JoinGroupResp) String() string { return proto.CompactTextString(m) }
func (*JoinGroupResp) ProtoMessage() {} func (*JoinGroupResp) ProtoMessage() {}
func (*JoinGroupResp) Descriptor() ([]byte, []int) { func (*JoinGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{13} return fileDescriptor_group_d88c7f5350508ce3, []int{13}
} }
func (m *JoinGroupResp) XXX_Unmarshal(b []byte) error { func (m *JoinGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_JoinGroupResp.Unmarshal(m, b) return xxx_messageInfo_JoinGroupResp.Unmarshal(m, b)
@ -643,7 +643,7 @@ func (m *GroupApplicationResponseReq) Reset() { *m = GroupApplicationRes
func (m *GroupApplicationResponseReq) String() string { return proto.CompactTextString(m) } func (m *GroupApplicationResponseReq) String() string { return proto.CompactTextString(m) }
func (*GroupApplicationResponseReq) ProtoMessage() {} func (*GroupApplicationResponseReq) ProtoMessage() {}
func (*GroupApplicationResponseReq) Descriptor() ([]byte, []int) { func (*GroupApplicationResponseReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{14} return fileDescriptor_group_d88c7f5350508ce3, []int{14}
} }
func (m *GroupApplicationResponseReq) XXX_Unmarshal(b []byte) error { func (m *GroupApplicationResponseReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupApplicationResponseReq.Unmarshal(m, b) return xxx_messageInfo_GroupApplicationResponseReq.Unmarshal(m, b)
@ -701,7 +701,7 @@ func (m *GroupApplicationResponseResp) Reset() { *m = GroupApplicationRe
func (m *GroupApplicationResponseResp) String() string { return proto.CompactTextString(m) } func (m *GroupApplicationResponseResp) String() string { return proto.CompactTextString(m) }
func (*GroupApplicationResponseResp) ProtoMessage() {} func (*GroupApplicationResponseResp) ProtoMessage() {}
func (*GroupApplicationResponseResp) Descriptor() ([]byte, []int) { func (*GroupApplicationResponseResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{15} return fileDescriptor_group_d88c7f5350508ce3, []int{15}
} }
func (m *GroupApplicationResponseResp) XXX_Unmarshal(b []byte) error { func (m *GroupApplicationResponseResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupApplicationResponseResp.Unmarshal(m, b) return xxx_messageInfo_GroupApplicationResponseResp.Unmarshal(m, b)
@ -732,7 +732,7 @@ func (m *QuitGroupReq) Reset() { *m = QuitGroupReq{} }
func (m *QuitGroupReq) String() string { return proto.CompactTextString(m) } func (m *QuitGroupReq) String() string { return proto.CompactTextString(m) }
func (*QuitGroupReq) ProtoMessage() {} func (*QuitGroupReq) ProtoMessage() {}
func (*QuitGroupReq) Descriptor() ([]byte, []int) { func (*QuitGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{16} return fileDescriptor_group_d88c7f5350508ce3, []int{16}
} }
func (m *QuitGroupReq) XXX_Unmarshal(b []byte) error { func (m *QuitGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QuitGroupReq.Unmarshal(m, b) return xxx_messageInfo_QuitGroupReq.Unmarshal(m, b)
@ -769,7 +769,7 @@ func (m *QuitGroupResp) Reset() { *m = QuitGroupResp{} }
func (m *QuitGroupResp) String() string { return proto.CompactTextString(m) } func (m *QuitGroupResp) String() string { return proto.CompactTextString(m) }
func (*QuitGroupResp) ProtoMessage() {} func (*QuitGroupResp) ProtoMessage() {}
func (*QuitGroupResp) Descriptor() ([]byte, []int) { func (*QuitGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{17} return fileDescriptor_group_d88c7f5350508ce3, []int{17}
} }
func (m *QuitGroupResp) XXX_Unmarshal(b []byte) error { func (m *QuitGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QuitGroupResp.Unmarshal(m, b) return xxx_messageInfo_QuitGroupResp.Unmarshal(m, b)
@ -802,7 +802,7 @@ func (m *GetGroupMemberListReq) Reset() { *m = GetGroupMemberListReq{} }
func (m *GetGroupMemberListReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupMemberListReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupMemberListReq) ProtoMessage() {} func (*GetGroupMemberListReq) ProtoMessage() {}
func (*GetGroupMemberListReq) Descriptor() ([]byte, []int) { func (*GetGroupMemberListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{18} return fileDescriptor_group_d88c7f5350508ce3, []int{18}
} }
func (m *GetGroupMemberListReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupMemberListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMemberListReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupMemberListReq.Unmarshal(m, b)
@ -855,7 +855,7 @@ func (m *GetGroupMemberListResp) Reset() { *m = GetGroupMemberListResp{}
func (m *GetGroupMemberListResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupMemberListResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupMemberListResp) ProtoMessage() {} func (*GetGroupMemberListResp) ProtoMessage() {}
func (*GetGroupMemberListResp) Descriptor() ([]byte, []int) { func (*GetGroupMemberListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{19} return fileDescriptor_group_d88c7f5350508ce3, []int{19}
} }
func (m *GetGroupMemberListResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupMemberListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMemberListResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupMemberListResp.Unmarshal(m, b)
@ -901,7 +901,7 @@ func (m *GetGroupMembersInfoReq) Reset() { *m = GetGroupMembersInfoReq{}
func (m *GetGroupMembersInfoReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupMembersInfoReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupMembersInfoReq) ProtoMessage() {} func (*GetGroupMembersInfoReq) ProtoMessage() {}
func (*GetGroupMembersInfoReq) Descriptor() ([]byte, []int) { func (*GetGroupMembersInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{20} return fileDescriptor_group_d88c7f5350508ce3, []int{20}
} }
func (m *GetGroupMembersInfoReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupMembersInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMembersInfoReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupMembersInfoReq.Unmarshal(m, b)
@ -946,7 +946,7 @@ func (m *GetGroupMembersInfoResp) Reset() { *m = GetGroupMembersInfoResp
func (m *GetGroupMembersInfoResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupMembersInfoResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupMembersInfoResp) ProtoMessage() {} func (*GetGroupMembersInfoResp) ProtoMessage() {}
func (*GetGroupMembersInfoResp) Descriptor() ([]byte, []int) { func (*GetGroupMembersInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{21} return fileDescriptor_group_d88c7f5350508ce3, []int{21}
} }
func (m *GetGroupMembersInfoResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupMembersInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMembersInfoResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupMembersInfoResp.Unmarshal(m, b)
@ -986,7 +986,7 @@ func (m *KickGroupMemberReq) Reset() { *m = KickGroupMemberReq{} }
func (m *KickGroupMemberReq) String() string { return proto.CompactTextString(m) } func (m *KickGroupMemberReq) String() string { return proto.CompactTextString(m) }
func (*KickGroupMemberReq) ProtoMessage() {} func (*KickGroupMemberReq) ProtoMessage() {}
func (*KickGroupMemberReq) Descriptor() ([]byte, []int) { func (*KickGroupMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{22} return fileDescriptor_group_d88c7f5350508ce3, []int{22}
} }
func (m *KickGroupMemberReq) XXX_Unmarshal(b []byte) error { func (m *KickGroupMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_KickGroupMemberReq.Unmarshal(m, b) return xxx_messageInfo_KickGroupMemberReq.Unmarshal(m, b)
@ -1037,7 +1037,7 @@ func (m *KickGroupMemberResp) Reset() { *m = KickGroupMemberResp{} }
func (m *KickGroupMemberResp) String() string { return proto.CompactTextString(m) } func (m *KickGroupMemberResp) String() string { return proto.CompactTextString(m) }
func (*KickGroupMemberResp) ProtoMessage() {} func (*KickGroupMemberResp) ProtoMessage() {}
func (*KickGroupMemberResp) Descriptor() ([]byte, []int) { func (*KickGroupMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{23} return fileDescriptor_group_d88c7f5350508ce3, []int{23}
} }
func (m *KickGroupMemberResp) XXX_Unmarshal(b []byte) error { func (m *KickGroupMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_KickGroupMemberResp.Unmarshal(m, b) return xxx_messageInfo_KickGroupMemberResp.Unmarshal(m, b)
@ -1069,7 +1069,7 @@ func (m *GetJoinedGroupListReq) Reset() { *m = GetJoinedGroupListReq{} }
func (m *GetJoinedGroupListReq) String() string { return proto.CompactTextString(m) } func (m *GetJoinedGroupListReq) String() string { return proto.CompactTextString(m) }
func (*GetJoinedGroupListReq) ProtoMessage() {} func (*GetJoinedGroupListReq) ProtoMessage() {}
func (*GetJoinedGroupListReq) Descriptor() ([]byte, []int) { func (*GetJoinedGroupListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{24} return fileDescriptor_group_d88c7f5350508ce3, []int{24}
} }
func (m *GetJoinedGroupListReq) XXX_Unmarshal(b []byte) error { func (m *GetJoinedGroupListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetJoinedGroupListReq.Unmarshal(m, b) return xxx_messageInfo_GetJoinedGroupListReq.Unmarshal(m, b)
@ -1115,7 +1115,7 @@ func (m *GetJoinedGroupListResp) Reset() { *m = GetJoinedGroupListResp{}
func (m *GetJoinedGroupListResp) String() string { return proto.CompactTextString(m) } func (m *GetJoinedGroupListResp) String() string { return proto.CompactTextString(m) }
func (*GetJoinedGroupListResp) ProtoMessage() {} func (*GetJoinedGroupListResp) ProtoMessage() {}
func (*GetJoinedGroupListResp) Descriptor() ([]byte, []int) { func (*GetJoinedGroupListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{25} return fileDescriptor_group_d88c7f5350508ce3, []int{25}
} }
func (m *GetJoinedGroupListResp) XXX_Unmarshal(b []byte) error { func (m *GetJoinedGroupListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetJoinedGroupListResp.Unmarshal(m, b) return xxx_messageInfo_GetJoinedGroupListResp.Unmarshal(m, b)
@ -1162,7 +1162,7 @@ func (m *InviteUserToGroupReq) Reset() { *m = InviteUserToGroupReq{} }
func (m *InviteUserToGroupReq) String() string { return proto.CompactTextString(m) } func (m *InviteUserToGroupReq) String() string { return proto.CompactTextString(m) }
func (*InviteUserToGroupReq) ProtoMessage() {} func (*InviteUserToGroupReq) ProtoMessage() {}
func (*InviteUserToGroupReq) Descriptor() ([]byte, []int) { func (*InviteUserToGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{26} return fileDescriptor_group_d88c7f5350508ce3, []int{26}
} }
func (m *InviteUserToGroupReq) XXX_Unmarshal(b []byte) error { func (m *InviteUserToGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_InviteUserToGroupReq.Unmarshal(m, b) return xxx_messageInfo_InviteUserToGroupReq.Unmarshal(m, b)
@ -1213,7 +1213,7 @@ func (m *InviteUserToGroupResp) Reset() { *m = InviteUserToGroupResp{} }
func (m *InviteUserToGroupResp) String() string { return proto.CompactTextString(m) } func (m *InviteUserToGroupResp) String() string { return proto.CompactTextString(m) }
func (*InviteUserToGroupResp) ProtoMessage() {} func (*InviteUserToGroupResp) ProtoMessage() {}
func (*InviteUserToGroupResp) Descriptor() ([]byte, []int) { func (*InviteUserToGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{27} return fileDescriptor_group_d88c7f5350508ce3, []int{27}
} }
func (m *InviteUserToGroupResp) XXX_Unmarshal(b []byte) error { func (m *InviteUserToGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_InviteUserToGroupResp.Unmarshal(m, b) return xxx_messageInfo_InviteUserToGroupResp.Unmarshal(m, b)
@ -1245,7 +1245,7 @@ func (m *GetGroupAllMemberReq) Reset() { *m = GetGroupAllMemberReq{} }
func (m *GetGroupAllMemberReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupAllMemberReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupAllMemberReq) ProtoMessage() {} func (*GetGroupAllMemberReq) ProtoMessage() {}
func (*GetGroupAllMemberReq) Descriptor() ([]byte, []int) { func (*GetGroupAllMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{28} return fileDescriptor_group_d88c7f5350508ce3, []int{28}
} }
func (m *GetGroupAllMemberReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupAllMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupAllMemberReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupAllMemberReq.Unmarshal(m, b)
@ -1290,7 +1290,7 @@ func (m *GetGroupAllMemberResp) Reset() { *m = GetGroupAllMemberResp{} }
func (m *GetGroupAllMemberResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupAllMemberResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupAllMemberResp) ProtoMessage() {} func (*GetGroupAllMemberResp) ProtoMessage() {}
func (*GetGroupAllMemberResp) Descriptor() ([]byte, []int) { func (*GetGroupAllMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{29} return fileDescriptor_group_d88c7f5350508ce3, []int{29}
} }
func (m *GetGroupAllMemberResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupAllMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupAllMemberResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupAllMemberResp.Unmarshal(m, b)
@ -1330,7 +1330,7 @@ func (m *CMSGroup) Reset() { *m = CMSGroup{} }
func (m *CMSGroup) String() string { return proto.CompactTextString(m) } func (m *CMSGroup) String() string { return proto.CompactTextString(m) }
func (*CMSGroup) ProtoMessage() {} func (*CMSGroup) ProtoMessage() {}
func (*CMSGroup) Descriptor() ([]byte, []int) { func (*CMSGroup) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{30} return fileDescriptor_group_d88c7f5350508ce3, []int{30}
} }
func (m *CMSGroup) XXX_Unmarshal(b []byte) error { func (m *CMSGroup) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMSGroup.Unmarshal(m, b) return xxx_messageInfo_CMSGroup.Unmarshal(m, b)
@ -1384,7 +1384,7 @@ func (m *GetGroupsReq) Reset() { *m = GetGroupsReq{} }
func (m *GetGroupsReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupsReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupsReq) ProtoMessage() {} func (*GetGroupsReq) ProtoMessage() {}
func (*GetGroupsReq) Descriptor() ([]byte, []int) { func (*GetGroupsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{31} return fileDescriptor_group_d88c7f5350508ce3, []int{31}
} }
func (m *GetGroupsReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupsReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupsReq.Unmarshal(m, b)
@ -1437,7 +1437,7 @@ func (m *GetGroupsResp) Reset() { *m = GetGroupsResp{} }
func (m *GetGroupsResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupsResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupsResp) ProtoMessage() {} func (*GetGroupsResp) ProtoMessage() {}
func (*GetGroupsResp) Descriptor() ([]byte, []int) { func (*GetGroupsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{32} return fileDescriptor_group_d88c7f5350508ce3, []int{32}
} }
func (m *GetGroupsResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupsResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupsResp.Unmarshal(m, b)
@ -1482,7 +1482,7 @@ func (m *GetGroupMemberReq) Reset() { *m = GetGroupMemberReq{} }
func (m *GetGroupMemberReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupMemberReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupMemberReq) ProtoMessage() {} func (*GetGroupMemberReq) ProtoMessage() {}
func (*GetGroupMemberReq) Descriptor() ([]byte, []int) { func (*GetGroupMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{33} return fileDescriptor_group_d88c7f5350508ce3, []int{33}
} }
func (m *GetGroupMemberReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMemberReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupMemberReq.Unmarshal(m, b)
@ -1522,7 +1522,7 @@ func (m *GetGroupMembersCMSReq) Reset() { *m = GetGroupMembersCMSReq{} }
func (m *GetGroupMembersCMSReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupMembersCMSReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupMembersCMSReq) ProtoMessage() {} func (*GetGroupMembersCMSReq) ProtoMessage() {}
func (*GetGroupMembersCMSReq) Descriptor() ([]byte, []int) { func (*GetGroupMembersCMSReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{34} return fileDescriptor_group_d88c7f5350508ce3, []int{34}
} }
func (m *GetGroupMembersCMSReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupMembersCMSReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMembersCMSReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupMembersCMSReq.Unmarshal(m, b)
@ -1565,8 +1565,7 @@ func (m *GetGroupMembersCMSReq) GetPagination() *sdk_ws.RequestPagination {
type GetGroupMembersCMSResp struct { type GetGroupMembersCMSResp struct {
Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"` Members []*sdk_ws.GroupMemberFullInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"`
Pagination *sdk_ws.ResponsePagination `protobuf:"bytes,2,opt,name=pagination" json:"pagination,omitempty"` MemberNums int32 `protobuf:"varint,2,opt,name=memberNums" json:"memberNums,omitempty"`
MemberNums int32 `protobuf:"varint,3,opt,name=memberNums" json:"memberNums,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -1576,7 +1575,7 @@ func (m *GetGroupMembersCMSResp) Reset() { *m = GetGroupMembersCMSResp{}
func (m *GetGroupMembersCMSResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupMembersCMSResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupMembersCMSResp) ProtoMessage() {} func (*GetGroupMembersCMSResp) ProtoMessage() {}
func (*GetGroupMembersCMSResp) Descriptor() ([]byte, []int) { func (*GetGroupMembersCMSResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{35} return fileDescriptor_group_d88c7f5350508ce3, []int{35}
} }
func (m *GetGroupMembersCMSResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupMembersCMSResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupMembersCMSResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupMembersCMSResp.Unmarshal(m, b)
@ -1603,13 +1602,6 @@ func (m *GetGroupMembersCMSResp) GetMembers() []*sdk_ws.GroupMemberFullInfo {
return nil return nil
} }
func (m *GetGroupMembersCMSResp) GetPagination() *sdk_ws.ResponsePagination {
if m != nil {
return m.Pagination
}
return nil
}
func (m *GetGroupMembersCMSResp) GetMemberNums() int32 { func (m *GetGroupMembersCMSResp) GetMemberNums() int32 {
if m != nil { if m != nil {
return m.MemberNums return m.MemberNums
@ -1628,7 +1620,7 @@ func (m *DismissGroupReq) Reset() { *m = DismissGroupReq{} }
func (m *DismissGroupReq) String() string { return proto.CompactTextString(m) } func (m *DismissGroupReq) String() string { return proto.CompactTextString(m) }
func (*DismissGroupReq) ProtoMessage() {} func (*DismissGroupReq) ProtoMessage() {}
func (*DismissGroupReq) Descriptor() ([]byte, []int) { func (*DismissGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{36} return fileDescriptor_group_d88c7f5350508ce3, []int{36}
} }
func (m *DismissGroupReq) XXX_Unmarshal(b []byte) error { func (m *DismissGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DismissGroupReq.Unmarshal(m, b) return xxx_messageInfo_DismissGroupReq.Unmarshal(m, b)
@ -1665,7 +1657,7 @@ func (m *DismissGroupResp) Reset() { *m = DismissGroupResp{} }
func (m *DismissGroupResp) String() string { return proto.CompactTextString(m) } func (m *DismissGroupResp) String() string { return proto.CompactTextString(m) }
func (*DismissGroupResp) ProtoMessage() {} func (*DismissGroupResp) ProtoMessage() {}
func (*DismissGroupResp) Descriptor() ([]byte, []int) { func (*DismissGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{37} return fileDescriptor_group_d88c7f5350508ce3, []int{37}
} }
func (m *DismissGroupResp) XXX_Unmarshal(b []byte) error { func (m *DismissGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DismissGroupResp.Unmarshal(m, b) return xxx_messageInfo_DismissGroupResp.Unmarshal(m, b)
@ -1698,7 +1690,7 @@ func (m *MuteGroupMemberReq) Reset() { *m = MuteGroupMemberReq{} }
func (m *MuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (m *MuteGroupMemberReq) String() string { return proto.CompactTextString(m) }
func (*MuteGroupMemberReq) ProtoMessage() {} func (*MuteGroupMemberReq) ProtoMessage() {}
func (*MuteGroupMemberReq) Descriptor() ([]byte, []int) { func (*MuteGroupMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{38} return fileDescriptor_group_d88c7f5350508ce3, []int{38}
} }
func (m *MuteGroupMemberReq) XXX_Unmarshal(b []byte) error { func (m *MuteGroupMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MuteGroupMemberReq.Unmarshal(m, b) return xxx_messageInfo_MuteGroupMemberReq.Unmarshal(m, b)
@ -1749,7 +1741,7 @@ func (m *MuteGroupMemberResp) Reset() { *m = MuteGroupMemberResp{} }
func (m *MuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (m *MuteGroupMemberResp) String() string { return proto.CompactTextString(m) }
func (*MuteGroupMemberResp) ProtoMessage() {} func (*MuteGroupMemberResp) ProtoMessage() {}
func (*MuteGroupMemberResp) Descriptor() ([]byte, []int) { func (*MuteGroupMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{39} return fileDescriptor_group_d88c7f5350508ce3, []int{39}
} }
func (m *MuteGroupMemberResp) XXX_Unmarshal(b []byte) error { func (m *MuteGroupMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MuteGroupMemberResp.Unmarshal(m, b) return xxx_messageInfo_MuteGroupMemberResp.Unmarshal(m, b)
@ -1781,7 +1773,7 @@ func (m *CancelMuteGroupMemberReq) Reset() { *m = CancelMuteGroupMemberR
func (m *CancelMuteGroupMemberReq) String() string { return proto.CompactTextString(m) } func (m *CancelMuteGroupMemberReq) String() string { return proto.CompactTextString(m) }
func (*CancelMuteGroupMemberReq) ProtoMessage() {} func (*CancelMuteGroupMemberReq) ProtoMessage() {}
func (*CancelMuteGroupMemberReq) Descriptor() ([]byte, []int) { func (*CancelMuteGroupMemberReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{40} return fileDescriptor_group_d88c7f5350508ce3, []int{40}
} }
func (m *CancelMuteGroupMemberReq) XXX_Unmarshal(b []byte) error { func (m *CancelMuteGroupMemberReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelMuteGroupMemberReq.Unmarshal(m, b) return xxx_messageInfo_CancelMuteGroupMemberReq.Unmarshal(m, b)
@ -1825,7 +1817,7 @@ func (m *CancelMuteGroupMemberResp) Reset() { *m = CancelMuteGroupMember
func (m *CancelMuteGroupMemberResp) String() string { return proto.CompactTextString(m) } func (m *CancelMuteGroupMemberResp) String() string { return proto.CompactTextString(m) }
func (*CancelMuteGroupMemberResp) ProtoMessage() {} func (*CancelMuteGroupMemberResp) ProtoMessage() {}
func (*CancelMuteGroupMemberResp) Descriptor() ([]byte, []int) { func (*CancelMuteGroupMemberResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{41} return fileDescriptor_group_d88c7f5350508ce3, []int{41}
} }
func (m *CancelMuteGroupMemberResp) XXX_Unmarshal(b []byte) error { func (m *CancelMuteGroupMemberResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelMuteGroupMemberResp.Unmarshal(m, b) return xxx_messageInfo_CancelMuteGroupMemberResp.Unmarshal(m, b)
@ -1856,7 +1848,7 @@ func (m *MuteGroupReq) Reset() { *m = MuteGroupReq{} }
func (m *MuteGroupReq) String() string { return proto.CompactTextString(m) } func (m *MuteGroupReq) String() string { return proto.CompactTextString(m) }
func (*MuteGroupReq) ProtoMessage() {} func (*MuteGroupReq) ProtoMessage() {}
func (*MuteGroupReq) Descriptor() ([]byte, []int) { func (*MuteGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{42} return fileDescriptor_group_d88c7f5350508ce3, []int{42}
} }
func (m *MuteGroupReq) XXX_Unmarshal(b []byte) error { func (m *MuteGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MuteGroupReq.Unmarshal(m, b) return xxx_messageInfo_MuteGroupReq.Unmarshal(m, b)
@ -1893,7 +1885,7 @@ func (m *MuteGroupResp) Reset() { *m = MuteGroupResp{} }
func (m *MuteGroupResp) String() string { return proto.CompactTextString(m) } func (m *MuteGroupResp) String() string { return proto.CompactTextString(m) }
func (*MuteGroupResp) ProtoMessage() {} func (*MuteGroupResp) ProtoMessage() {}
func (*MuteGroupResp) Descriptor() ([]byte, []int) { func (*MuteGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{43} return fileDescriptor_group_d88c7f5350508ce3, []int{43}
} }
func (m *MuteGroupResp) XXX_Unmarshal(b []byte) error { func (m *MuteGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MuteGroupResp.Unmarshal(m, b) return xxx_messageInfo_MuteGroupResp.Unmarshal(m, b)
@ -1924,7 +1916,7 @@ func (m *CancelMuteGroupReq) Reset() { *m = CancelMuteGroupReq{} }
func (m *CancelMuteGroupReq) String() string { return proto.CompactTextString(m) } func (m *CancelMuteGroupReq) String() string { return proto.CompactTextString(m) }
func (*CancelMuteGroupReq) ProtoMessage() {} func (*CancelMuteGroupReq) ProtoMessage() {}
func (*CancelMuteGroupReq) Descriptor() ([]byte, []int) { func (*CancelMuteGroupReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{44} return fileDescriptor_group_d88c7f5350508ce3, []int{44}
} }
func (m *CancelMuteGroupReq) XXX_Unmarshal(b []byte) error { func (m *CancelMuteGroupReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelMuteGroupReq.Unmarshal(m, b) return xxx_messageInfo_CancelMuteGroupReq.Unmarshal(m, b)
@ -1961,7 +1953,7 @@ func (m *CancelMuteGroupResp) Reset() { *m = CancelMuteGroupResp{} }
func (m *CancelMuteGroupResp) String() string { return proto.CompactTextString(m) } func (m *CancelMuteGroupResp) String() string { return proto.CompactTextString(m) }
func (*CancelMuteGroupResp) ProtoMessage() {} func (*CancelMuteGroupResp) ProtoMessage() {}
func (*CancelMuteGroupResp) Descriptor() ([]byte, []int) { func (*CancelMuteGroupResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{45} return fileDescriptor_group_d88c7f5350508ce3, []int{45}
} }
func (m *CancelMuteGroupResp) XXX_Unmarshal(b []byte) error { func (m *CancelMuteGroupResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelMuteGroupResp.Unmarshal(m, b) return xxx_messageInfo_CancelMuteGroupResp.Unmarshal(m, b)
@ -1994,7 +1986,7 @@ func (m *SetGroupMemberNicknameReq) Reset() { *m = SetGroupMemberNicknam
func (m *SetGroupMemberNicknameReq) String() string { return proto.CompactTextString(m) } func (m *SetGroupMemberNicknameReq) String() string { return proto.CompactTextString(m) }
func (*SetGroupMemberNicknameReq) ProtoMessage() {} func (*SetGroupMemberNicknameReq) ProtoMessage() {}
func (*SetGroupMemberNicknameReq) Descriptor() ([]byte, []int) { func (*SetGroupMemberNicknameReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{46} return fileDescriptor_group_d88c7f5350508ce3, []int{46}
} }
func (m *SetGroupMemberNicknameReq) XXX_Unmarshal(b []byte) error { func (m *SetGroupMemberNicknameReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupMemberNicknameReq.Unmarshal(m, b) return xxx_messageInfo_SetGroupMemberNicknameReq.Unmarshal(m, b)
@ -2045,7 +2037,7 @@ func (m *SetGroupMemberNicknameResp) Reset() { *m = SetGroupMemberNickna
func (m *SetGroupMemberNicknameResp) String() string { return proto.CompactTextString(m) } func (m *SetGroupMemberNicknameResp) String() string { return proto.CompactTextString(m) }
func (*SetGroupMemberNicknameResp) ProtoMessage() {} func (*SetGroupMemberNicknameResp) ProtoMessage() {}
func (*SetGroupMemberNicknameResp) Descriptor() ([]byte, []int) { func (*SetGroupMemberNicknameResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{47} return fileDescriptor_group_d88c7f5350508ce3, []int{47}
} }
func (m *SetGroupMemberNicknameResp) XXX_Unmarshal(b []byte) error { func (m *SetGroupMemberNicknameResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupMemberNicknameResp.Unmarshal(m, b) return xxx_messageInfo_SetGroupMemberNicknameResp.Unmarshal(m, b)
@ -2077,7 +2069,7 @@ func (m *GetJoinedSuperGroupListReq) Reset() { *m = GetJoinedSuperGroupL
func (m *GetJoinedSuperGroupListReq) String() string { return proto.CompactTextString(m) } func (m *GetJoinedSuperGroupListReq) String() string { return proto.CompactTextString(m) }
func (*GetJoinedSuperGroupListReq) ProtoMessage() {} func (*GetJoinedSuperGroupListReq) ProtoMessage() {}
func (*GetJoinedSuperGroupListReq) Descriptor() ([]byte, []int) { func (*GetJoinedSuperGroupListReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{48} return fileDescriptor_group_d88c7f5350508ce3, []int{48}
} }
func (m *GetJoinedSuperGroupListReq) XXX_Unmarshal(b []byte) error { func (m *GetJoinedSuperGroupListReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetJoinedSuperGroupListReq.Unmarshal(m, b) return xxx_messageInfo_GetJoinedSuperGroupListReq.Unmarshal(m, b)
@ -2123,7 +2115,7 @@ func (m *GetJoinedSuperGroupListResp) Reset() { *m = GetJoinedSuperGroup
func (m *GetJoinedSuperGroupListResp) String() string { return proto.CompactTextString(m) } func (m *GetJoinedSuperGroupListResp) String() string { return proto.CompactTextString(m) }
func (*GetJoinedSuperGroupListResp) ProtoMessage() {} func (*GetJoinedSuperGroupListResp) ProtoMessage() {}
func (*GetJoinedSuperGroupListResp) Descriptor() ([]byte, []int) { func (*GetJoinedSuperGroupListResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{49} return fileDescriptor_group_d88c7f5350508ce3, []int{49}
} }
func (m *GetJoinedSuperGroupListResp) XXX_Unmarshal(b []byte) error { func (m *GetJoinedSuperGroupListResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetJoinedSuperGroupListResp.Unmarshal(m, b) return xxx_messageInfo_GetJoinedSuperGroupListResp.Unmarshal(m, b)
@ -2168,7 +2160,7 @@ func (m *GetSuperGroupsInfoReq) Reset() { *m = GetSuperGroupsInfoReq{} }
func (m *GetSuperGroupsInfoReq) String() string { return proto.CompactTextString(m) } func (m *GetSuperGroupsInfoReq) String() string { return proto.CompactTextString(m) }
func (*GetSuperGroupsInfoReq) ProtoMessage() {} func (*GetSuperGroupsInfoReq) ProtoMessage() {}
func (*GetSuperGroupsInfoReq) Descriptor() ([]byte, []int) { func (*GetSuperGroupsInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{50} return fileDescriptor_group_d88c7f5350508ce3, []int{50}
} }
func (m *GetSuperGroupsInfoReq) XXX_Unmarshal(b []byte) error { func (m *GetSuperGroupsInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSuperGroupsInfoReq.Unmarshal(m, b) return xxx_messageInfo_GetSuperGroupsInfoReq.Unmarshal(m, b)
@ -2206,7 +2198,7 @@ func (m *GetSuperGroupsInfoResp) Reset() { *m = GetSuperGroupsInfoResp{}
func (m *GetSuperGroupsInfoResp) String() string { return proto.CompactTextString(m) } func (m *GetSuperGroupsInfoResp) String() string { return proto.CompactTextString(m) }
func (*GetSuperGroupsInfoResp) ProtoMessage() {} func (*GetSuperGroupsInfoResp) ProtoMessage() {}
func (*GetSuperGroupsInfoResp) Descriptor() ([]byte, []int) { func (*GetSuperGroupsInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{51} return fileDescriptor_group_d88c7f5350508ce3, []int{51}
} }
func (m *GetSuperGroupsInfoResp) XXX_Unmarshal(b []byte) error { func (m *GetSuperGroupsInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetSuperGroupsInfoResp.Unmarshal(m, b) return xxx_messageInfo_GetSuperGroupsInfoResp.Unmarshal(m, b)
@ -2249,7 +2241,7 @@ func (m *SetGroupMemberInfoReq) Reset() { *m = SetGroupMemberInfoReq{} }
func (m *SetGroupMemberInfoReq) String() string { return proto.CompactTextString(m) } func (m *SetGroupMemberInfoReq) String() string { return proto.CompactTextString(m) }
func (*SetGroupMemberInfoReq) ProtoMessage() {} func (*SetGroupMemberInfoReq) ProtoMessage() {}
func (*SetGroupMemberInfoReq) Descriptor() ([]byte, []int) { func (*SetGroupMemberInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{52} return fileDescriptor_group_d88c7f5350508ce3, []int{52}
} }
func (m *SetGroupMemberInfoReq) XXX_Unmarshal(b []byte) error { func (m *SetGroupMemberInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupMemberInfoReq.Unmarshal(m, b) return xxx_messageInfo_SetGroupMemberInfoReq.Unmarshal(m, b)
@ -2321,7 +2313,7 @@ func (m *SetGroupMemberInfoResp) Reset() { *m = SetGroupMemberInfoResp{}
func (m *SetGroupMemberInfoResp) String() string { return proto.CompactTextString(m) } func (m *SetGroupMemberInfoResp) String() string { return proto.CompactTextString(m) }
func (*SetGroupMemberInfoResp) ProtoMessage() {} func (*SetGroupMemberInfoResp) ProtoMessage() {}
func (*SetGroupMemberInfoResp) Descriptor() ([]byte, []int) { func (*SetGroupMemberInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{53} return fileDescriptor_group_d88c7f5350508ce3, []int{53}
} }
func (m *SetGroupMemberInfoResp) XXX_Unmarshal(b []byte) error { func (m *SetGroupMemberInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGroupMemberInfoResp.Unmarshal(m, b) return xxx_messageInfo_SetGroupMemberInfoResp.Unmarshal(m, b)
@ -2352,7 +2344,7 @@ func (m *GetGroupAbstractInfoReq) Reset() { *m = GetGroupAbstractInfoReq
func (m *GetGroupAbstractInfoReq) String() string { return proto.CompactTextString(m) } func (m *GetGroupAbstractInfoReq) String() string { return proto.CompactTextString(m) }
func (*GetGroupAbstractInfoReq) ProtoMessage() {} func (*GetGroupAbstractInfoReq) ProtoMessage() {}
func (*GetGroupAbstractInfoReq) Descriptor() ([]byte, []int) { func (*GetGroupAbstractInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{54} return fileDescriptor_group_d88c7f5350508ce3, []int{54}
} }
func (m *GetGroupAbstractInfoReq) XXX_Unmarshal(b []byte) error { func (m *GetGroupAbstractInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupAbstractInfoReq.Unmarshal(m, b) return xxx_messageInfo_GetGroupAbstractInfoReq.Unmarshal(m, b)
@ -2392,7 +2384,7 @@ func (m *GroupAbstractInfo) Reset() { *m = GroupAbstractInfo{} }
func (m *GroupAbstractInfo) String() string { return proto.CompactTextString(m) } func (m *GroupAbstractInfo) String() string { return proto.CompactTextString(m) }
func (*GroupAbstractInfo) ProtoMessage() {} func (*GroupAbstractInfo) ProtoMessage() {}
func (*GroupAbstractInfo) Descriptor() ([]byte, []int) { func (*GroupAbstractInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{55} return fileDescriptor_group_d88c7f5350508ce3, []int{55}
} }
func (m *GroupAbstractInfo) XXX_Unmarshal(b []byte) error { func (m *GroupAbstractInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GroupAbstractInfo.Unmarshal(m, b) return xxx_messageInfo_GroupAbstractInfo.Unmarshal(m, b)
@ -2444,7 +2436,7 @@ func (m *GetGroupAbstractInfoResp) Reset() { *m = GetGroupAbstractInfoRe
func (m *GetGroupAbstractInfoResp) String() string { return proto.CompactTextString(m) } func (m *GetGroupAbstractInfoResp) String() string { return proto.CompactTextString(m) }
func (*GetGroupAbstractInfoResp) ProtoMessage() {} func (*GetGroupAbstractInfoResp) ProtoMessage() {}
func (*GetGroupAbstractInfoResp) Descriptor() ([]byte, []int) { func (*GetGroupAbstractInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{56} return fileDescriptor_group_d88c7f5350508ce3, []int{56}
} }
func (m *GetGroupAbstractInfoResp) XXX_Unmarshal(b []byte) error { func (m *GetGroupAbstractInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetGroupAbstractInfoResp.Unmarshal(m, b) return xxx_messageInfo_GetGroupAbstractInfoResp.Unmarshal(m, b)
@ -2483,7 +2475,7 @@ func (m *GetUserInGroupMembersReq) Reset() { *m = GetUserInGroupMembersR
func (m *GetUserInGroupMembersReq) String() string { return proto.CompactTextString(m) } func (m *GetUserInGroupMembersReq) String() string { return proto.CompactTextString(m) }
func (*GetUserInGroupMembersReq) ProtoMessage() {} func (*GetUserInGroupMembersReq) ProtoMessage() {}
func (*GetUserInGroupMembersReq) Descriptor() ([]byte, []int) { func (*GetUserInGroupMembersReq) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{57} return fileDescriptor_group_d88c7f5350508ce3, []int{57}
} }
func (m *GetUserInGroupMembersReq) XXX_Unmarshal(b []byte) error { func (m *GetUserInGroupMembersReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserInGroupMembersReq.Unmarshal(m, b) return xxx_messageInfo_GetUserInGroupMembersReq.Unmarshal(m, b)
@ -2528,7 +2520,7 @@ func (m *GetUserInGroupMembersResp) Reset() { *m = GetUserInGroupMembers
func (m *GetUserInGroupMembersResp) String() string { return proto.CompactTextString(m) } func (m *GetUserInGroupMembersResp) String() string { return proto.CompactTextString(m) }
func (*GetUserInGroupMembersResp) ProtoMessage() {} func (*GetUserInGroupMembersResp) ProtoMessage() {}
func (*GetUserInGroupMembersResp) Descriptor() ([]byte, []int) { func (*GetUserInGroupMembersResp) Descriptor() ([]byte, []int) {
return fileDescriptor_group_5c8d3aafef0e7d21, []int{58} return fileDescriptor_group_d88c7f5350508ce3, []int{58}
} }
func (m *GetUserInGroupMembersResp) XXX_Unmarshal(b []byte) error { func (m *GetUserInGroupMembersResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUserInGroupMembersResp.Unmarshal(m, b) return xxx_messageInfo_GetUserInGroupMembersResp.Unmarshal(m, b)
@ -3166,7 +3158,7 @@ func _Group_GetGroupMemberList_Handler(srv interface{}, ctx context.Context, dec
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/group.group/GetGroupMemberList", FullMethod: "/group.group/FindGroupMemberAll",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupServer).GetGroupMemberList(ctx, req.(*GetGroupMemberListReq)) return srv.(GroupServer).GetGroupMemberList(ctx, req.(*GetGroupMemberListReq))
@ -3220,7 +3212,7 @@ func _Group_GetJoinedGroupList_Handler(srv interface{}, ctx context.Context, dec
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/group.group/GetJoinedGroupList", FullMethod: "/group.group/FindJoinedGroup",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GroupServer).GetJoinedGroupList(ctx, req.(*GetJoinedGroupListReq)) return srv.(GroupServer).GetJoinedGroupList(ctx, req.(*GetJoinedGroupListReq))
@ -3597,124 +3589,123 @@ var _Group_serviceDesc = grpc.ServiceDesc{
Metadata: "group/group.proto", Metadata: "group/group.proto",
} }
func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_5c8d3aafef0e7d21) } func init() { proto.RegisterFile("group/group.proto", fileDescriptor_group_d88c7f5350508ce3) }
var fileDescriptor_group_5c8d3aafef0e7d21 = []byte{ var fileDescriptor_group_d88c7f5350508ce3 = []byte{
// 1851 bytes of a gzipped FileDescriptorProto // 1835 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x5f, 0x53, 0xe4, 0xc6, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x59, 0x5f, 0x53, 0xdc, 0xc8,
0x11, 0x2f, 0x2d, 0x07, 0x77, 0xf4, 0x81, 0xe1, 0x06, 0x16, 0x74, 0x82, 0x03, 0x3c, 0x26, 0x0e, 0x11, 0x2f, 0x2d, 0x06, 0x9b, 0x36, 0x1c, 0x30, 0xb0, 0x20, 0x04, 0x06, 0x6e, 0x8e, 0xba, 0x50,
0x95, 0xf8, 0x96, 0xd4, 0x5d, 0xe2, 0xca, 0x1f, 0x57, 0x39, 0x36, 0xd8, 0x98, 0x84, 0x85, 0x9c, 0xc9, 0x79, 0x49, 0xd9, 0xc9, 0x55, 0xfe, 0x5c, 0xd5, 0xc5, 0x86, 0x18, 0x93, 0xb0, 0x10, 0x6b,
0x16, 0x3b, 0x15, 0xa7, 0x5c, 0x44, 0xec, 0x0e, 0xb2, 0x0e, 0xad, 0x34, 0x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67, 0x87,
0x35, 0x2a, 0x3a, 0x6b, 0x61, 0xca, 0x87, 0xdb, 0x9f, 0x3f, 0x3b, 0xa3, 0x24, 0xba, 0x38, 0x6e, 0x4d, 0xe5, 0x1f, 0x9a, 0x5c, 0xe8, 0xe7, 0xfc, 0xf7, 0x7c, 0x8a, 0x93, 0x1e, 0xff, 0x2f, 0x00,
0x6b, 0x7f, 0x8c, 0x72, 0xa1, 0x9f, 0xf1, 0xdf, 0xcb, 0x39, 0x4e, 0x7a, 0xf9, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xd2, 0xc8, 0xfe, 0x43, 0x1d, 0x00, 0x00,
0x00, 0xff, 0xff, 0x4a, 0x6c, 0x49, 0xeb, 0x8b, 0x1d, 0x00, 0x00,
} }

View File

@ -181,8 +181,7 @@ message GetGroupMembersCMSReq {
message GetGroupMembersCMSResp { message GetGroupMembersCMSResp {
repeated server_api_params.GroupMemberFullInfo members = 1; repeated server_api_params.GroupMemberFullInfo members = 1;
server_api_params.ResponsePagination pagination = 2; int32 memberNums = 2;
int32 memberNums = 3;
} }
message DismissGroupReq{ message DismissGroupReq{

View File

@ -5,7 +5,7 @@ import (
"sort" "sort"
) )
// DistinctAny remove duplicate elements // DistinctAny 去重
func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E { func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E {
v := make([]E, 0, len(es)) v := make([]E, 0, len(es))
tmp := map[K]struct{}{} tmp := map[K]struct{}{}
@ -20,14 +20,14 @@ func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E {
return v return v
} }
// Distinct remove duplicate elements // Distinct 去重
func Distinct[T comparable](ts []T) []T { func Distinct[T comparable](ts []T) []T {
return DistinctAny(ts, func(t T) T { return DistinctAny(ts, func(t T) T {
return t return t
}) })
} }
// Delete delete slice element, support negative number to delete the penultimate // Delete 删除切片元素, 支持负数删除倒数第几个
func Delete[E any](es []E, index ...int) []E { func Delete[E any](es []E, index ...int) []E {
switch len(index) { switch len(index) {
case 0: case 0:
@ -59,7 +59,7 @@ func Delete[E any](es []E, index ...int) []E {
} }
} }
// DeleteAt delete slice element, support negative number to delete the penultimate // DeleteAt 删除切片元素, 支持负数删除倒数第几个
func DeleteAt[E any](es *[]E, index ...int) []E { func DeleteAt[E any](es *[]E, index ...int) []E {
v := Delete(*es, index...) v := Delete(*es, index...)
*es = v *es = v
@ -67,7 +67,7 @@ func DeleteAt[E any](es *[]E, index ...int) []E {
} }
// IndexAny get the index of the element // IndexAny get the index of the element
func IndexAny[E any, K comparable](es []E, e E, fn func(e E) K) int { func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int {
k := fn(e) k := fn(e)
for i := 0; i < len(es); i++ { for i := 0; i < len(es); i++ {
if fn(es[i]) == k { if fn(es[i]) == k {
@ -78,18 +78,18 @@ func IndexAny[E any, K comparable](es []E, e E, fn func(e E) K) int {
} }
// IndexOf get the index of the element // IndexOf get the index of the element
func IndexOf[E comparable](es []E, e E) int { func IndexOf[E comparable](e E, es ...E) int {
return IndexAny(es, e, func(t E) E { return IndexAny(e, es, func(t E) E {
return t return t
}) })
} }
// Contain include element or not // Contain 是否包含
func Contain[E comparable](es []E, e E) bool { func Contain[E comparable](e E, es ...E) bool {
return IndexOf(es, e) >= 0 return IndexOf(e, es...) >= 0
} }
// DuplicateAny judge whether it is repeated // DuplicateAny 是否有重复的
func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool { func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool {
t := make(map[K]struct{}) t := make(map[K]struct{})
for _, e := range es { for _, e := range es {
@ -102,14 +102,14 @@ func DuplicateAny[E any, K comparable](es []E, fn func(e E) K) bool {
return false return false
} }
// Duplicate judge whether it is repeated // Duplicate 是否有重复的
func Duplicate[E comparable](es []E) bool { func Duplicate[E comparable](es []E) bool {
return DuplicateAny(es, func(e E) E { return DuplicateAny(es, func(e E) E {
return e return e
}) })
} }
// SliceToMapOkAny slice to map // SliceToMapOkAny slice to map (自定义类型, 筛选)
func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V { func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V {
kv := make(map[K]V) kv := make(map[K]V)
for i := 0; i < len(es); i++ { for i := 0; i < len(es); i++ {
@ -121,7 +121,7 @@ func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, boo
return kv return kv
} }
// SliceToMapAny slice to map // SliceToMapAny slice to map (自定义类型)
func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V { func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V {
return SliceToMapOkAny(es, func(e E) (K, V, bool) { return SliceToMapOkAny(es, func(e E) (K, V, bool) {
k, v := fn(e) k, v := fn(e)
@ -144,6 +144,15 @@ func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{} {
}) })
} }
// Slice 批量转换切片类型
func Slice[E any, T any](es []E, fn func(e E) T) []T {
v := make([]T, len(es))
for i := 0; i < len(es); i++ {
v = append(v, fn(es[i]))
}
return v
}
// SliceSet slice to map[E]struct{} // SliceSet slice to map[E]struct{}
func SliceSet[E comparable](es []E) map[E]struct{} { func SliceSet[E comparable](es []E) map[E]struct{} {
return SliceSetAny(es, func(e E) E { return SliceSetAny(es, func(e E) E {
@ -182,7 +191,7 @@ func Max[E Ordered](e ...E) E {
return v return v
} }
// BothExistAny get elements common to multiple slices // BothExistAny 获取切片中共同存在的元素(交集)
func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E { func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E {
if len(es) == 0 { if len(es) == 0 {
return []E{} return []E{}
@ -225,43 +234,40 @@ func BothExistAny[E any, K comparable](es [][]E, fn func(e E) K) []E {
return v return v
} }
// BothExist get elements common to multiple slices // BothExist 获取切片中共同存在的元素(交集)
func BothExist[E comparable](es ...[]E) []E { func BothExist[E comparable](es ...[]E) []E {
return BothExistAny(es, func(e E) E { return BothExistAny(es, func(e E) E {
return e return e
}) })
} }
// CompleteAny complete inclusion //// CompleteAny a中存在b的所有元素, 同时b中的所有元素a
func CompleteAny[K comparable, E any](ks []K, es []E, fn func(e E) K) bool { //func CompleteAny[K comparable, E any](ks []K, es []E, fn func(e E) K) bool {
a := SliceSetAny(es, fn) // if len(ks) == 0 && len(es) == 0 {
for k := range SliceSet(ks) { // return true
if !HasKey(a, k) { // }
return false // kn := make(map[K]uint8)
} // for _, e := range Distinct(ks) {
delete(a, k) // kn[e]++
} // }
return len(a) == 0 // for k := range SliceSetAny(es, fn) {
} // kn[k]++
// }
// for _, n := range kn {
// if n != 2 {
// return false
// }
// }
// return true
//}
// Complete a和b去重后是否相等(忽略顺序)
func Complete[E comparable](a []E, b []E) bool { func Complete[E comparable](a []E, b []E) bool {
if len(a) == 0 && len(b) == 0 { return len(Single(a, b)) == 0
return true
}
if (len(a) == 0 && len(b) != 0) || (len(a) != 0 && len(b) == 0) {
return false
}
t := SliceSet(a)
for _, e := range b {
if _, ok := t[e]; !ok {
return false
}
}
return true
} }
// MapKey get map keys // Keys get map keys
func MapKey[K comparable, V any](kv map[K]V) []K { func Keys[K comparable, V any](kv map[K]V) []K {
ks := make([]K, 0, len(kv)) ks := make([]K, 0, len(kv))
for k := range kv { for k := range kv {
ks = append(ks, k) ks = append(ks, k)
@ -269,8 +275,8 @@ func MapKey[K comparable, V any](kv map[K]V) []K {
return ks return ks
} }
// MapValue get map values // Values get map values
func MapValue[K comparable, V any](kv map[K]V) []V { func Values[K comparable, V any](kv map[K]V) []V {
vs := make([]V, 0, len(kv)) vs := make([]V, 0, len(kv))
for k := range kv { for k := range kv {
vs = append(vs, kv[k]) vs = append(vs, kv[k])
@ -306,6 +312,7 @@ func If[T any](isa bool, a, b T) T {
return b return b
} }
// Equal 比较切片是否相对(包括元素顺序)
func Equal[E comparable](a []E, b []E) bool { func Equal[E comparable](a []E, b []E) bool {
if len(a) != len(b) { if len(a) != len(b) {
return false return false
@ -318,11 +325,50 @@ func Equal[E comparable](a []E, b []E) bool {
return true return true
} }
// Single // Single a中存在,b中不存在 或 b中存在,a中不存在
func Single[E comparable](a, b []E) []E { func Single[E comparable](a, b []E) []E {
kn := make(map[E]uint8)
for _, e := range Distinct(a) {
kn[e]++
}
for _, e := range Distinct(b) {
kn[e]++
}
v := make([]E, 0, len(kn))
for k, n := range kn {
if n == 1 {
v = append(v, k)
}
}
return v
}
return nil // Order 将ts按es排序
func Order[E comparable, T any](es []E, ts []T, fn func(t T) E) []T {
if len(es) == 0 || len(ts) == 0 {
return ts
}
kv := make(map[E][]T)
for i := 0; i < len(ts); i++ {
t := ts[i]
k := fn(t)
kv[k] = append(kv[k], t)
}
rs := make([]T, 0, len(ts))
for _, e := range es {
vs := kv[e]
delete(kv, e)
rs = append(rs, vs...)
}
for k := range kv {
rs = append(rs, kv[k]...)
}
return rs
}
func OrderPtr[E comparable, T any](es []E, ts *[]T, fn func(t T) E) []T {
*ts = Order(es, *ts, fn)
return *ts
} }
func UniqueJoin(s ...string) string { func UniqueJoin(s ...string) string {

View File

@ -75,9 +75,9 @@ func TestCompleteAny(t *testing.T) {
DeleteAt(&list, -1) DeleteAt(&list, -1)
DeleteAt(&ids, -1) DeleteAt(&ids, -1)
ok := CompleteAny(ids, list, func(t Item) int { ok := Complete(ids, Slice(list, func(t Item) int {
return t.ID return t.ID
}) }))
fmt.Printf("%+v\n", ok) fmt.Printf("%+v\n", ok)