mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-19 16:29:01 +08:00
merge newest branch
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
_, b, _, _ = runtime.Caller(0)
|
||||
// Root folder of this project
|
||||
Root = filepath.Join(filepath.Dir(b), "../../..")
|
||||
)
|
||||
|
||||
var Config config
|
||||
|
||||
type config struct {
|
||||
ServerIP string `yaml:"serverip"`
|
||||
ServerVersion string `yaml:"serverversion"`
|
||||
Api struct {
|
||||
GinPort []int `yaml:"openImApiPort"`
|
||||
}
|
||||
Sdk struct {
|
||||
WsPort []int `yaml:"openImSdkWsPort"`
|
||||
}
|
||||
Credential struct {
|
||||
Tencent struct {
|
||||
AppID string `yaml:"appID"`
|
||||
Region string `yaml:"region"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
SecretID string `yaml:"secretID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
}
|
||||
|
||||
Mysql struct {
|
||||
DBAddress []string `yaml:"dbMysqlAddress"`
|
||||
DBUserName string `yaml:"dbMysqlUserName"`
|
||||
DBPassword string `yaml:"dbMysqlPassword"`
|
||||
DBDatabaseName string `yaml:"dbMysqlDatabaseName"`
|
||||
DBTableName string `yaml:"DBTableName"`
|
||||
DBMsgTableNum int `yaml:"dbMsgTableNum"`
|
||||
DBMaxOpenConns int `yaml:"dbMaxOpenConns"`
|
||||
DBMaxIdleConns int `yaml:"dbMaxIdleConns"`
|
||||
DBMaxLifeTime int `yaml:"dbMaxLifeTime"`
|
||||
}
|
||||
Mongo struct {
|
||||
DBAddress []string `yaml:"dbAddress"`
|
||||
DBDirect bool `yaml:"dbDirect"`
|
||||
DBTimeout int `yaml:"dbTimeout"`
|
||||
DBDatabase string `yaml:"dbDatabase"`
|
||||
DBSource string `yaml:"dbSource"`
|
||||
DBUserName string `yaml:"dbUserName"`
|
||||
DBPassword string `yaml:"dbPassword"`
|
||||
DBMaxPoolSize int `yaml:"dbMaxPoolSize"`
|
||||
DBRetainChatRecords int `yaml:"dbRetainChatRecords"`
|
||||
}
|
||||
Redis struct {
|
||||
DBAddress string `yaml:"dbAddress"`
|
||||
DBMaxIdle int `yaml:"dbMaxIdle"`
|
||||
DBMaxActive int `yaml:"dbMaxActive"`
|
||||
DBIdleTimeout int `yaml:"dbIdleTimeout"`
|
||||
DBPassWord string `yaml:"dbPassWord"`
|
||||
}
|
||||
RpcPort struct {
|
||||
OpenImUserPort []int `yaml:"openImUserPort"`
|
||||
openImFriendPort []int `yaml:"openImFriendPort"`
|
||||
RpcMessagePort []int `yaml:"rpcMessagePort"`
|
||||
RpcPushMessagePort []int `yaml:"rpcPushMessagePort"`
|
||||
OpenImGroupPort []int `yaml:"openImGroupPort"`
|
||||
RpcModifyUserInfoPort []int `yaml:"rpcModifyUserInfoPort"`
|
||||
RpcGetTokenPort []int `yaml:"rpcGetTokenPort"`
|
||||
}
|
||||
RpcRegisterName struct {
|
||||
OpenImUserName string `yaml:"openImUserName"`
|
||||
OpenImFriendName string `yaml:"openImFriendName"`
|
||||
OpenImOfflineMessageName string `yaml:"openImOfflineMessageName"`
|
||||
OpenImPushName string `yaml:"openImPushName"`
|
||||
OpenImOnlineMessageRelayName string `yaml:"openImOnlineMessageRelayName"`
|
||||
OpenImGroupName string `yaml:"openImGroupName"`
|
||||
OpenImAuthName string `yaml:"openImAuthName"`
|
||||
}
|
||||
Etcd struct {
|
||||
EtcdSchema string `yaml:"etcdSchema"`
|
||||
EtcdAddr []string `yaml:"etcdAddr"`
|
||||
}
|
||||
Log struct {
|
||||
StorageLocation string `yaml:"storageLocation"`
|
||||
RotationTime int `yaml:"rotationTime"`
|
||||
RemainRotationCount uint `yaml:"remainRotationCount"`
|
||||
RemainLogLevel uint `yaml:"remainLogLevel"`
|
||||
ElasticSearchSwitch bool `yaml:"elasticSearchSwitch"`
|
||||
ElasticSearchAddr []string `yaml:"elasticSearchAddr"`
|
||||
ElasticSearchUser string `yaml:"elasticSearchUser"`
|
||||
ElasticSearchPassword string `yaml:"elasticSearchPassword"`
|
||||
}
|
||||
ModuleName struct {
|
||||
LongConnSvrName string `yaml:"longConnSvrName"`
|
||||
MsgTransferName string `yaml:"msgTransferName"`
|
||||
PushName string `yaml:"pushName"`
|
||||
}
|
||||
LongConnSvr struct {
|
||||
WebsocketPort []int `yaml:"openImWsPort"`
|
||||
WebsocketMaxConnNum int `yaml:"websocketMaxConnNum"`
|
||||
WebsocketMaxMsgLen int `yaml:"websocketMaxMsgLen"`
|
||||
WebsocketTimeOut int `yaml:"websocketTimeOut"`
|
||||
}
|
||||
|
||||
Push struct {
|
||||
Tpns struct {
|
||||
Ios struct {
|
||||
AccessID string `yaml:"accessID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
Android struct {
|
||||
AccessID string `yaml:"accessID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
}
|
||||
}
|
||||
Jpns struct {
|
||||
AppKey string `yaml:"appKey"`
|
||||
MasterSecret string `yaml:"masterSecret"`
|
||||
PushUrl string `yaml:"pushUrl"`
|
||||
}
|
||||
}
|
||||
Manager struct {
|
||||
AppManagerUid []string `yaml:"appManagerUid"`
|
||||
Secrets []string `yaml:"secrets"`
|
||||
}
|
||||
Kafka struct {
|
||||
Ws2mschat struct {
|
||||
Addr []string `yaml:"addr"`
|
||||
Topic string `yaml:"topic"`
|
||||
}
|
||||
Ms2pschat struct {
|
||||
Addr []string `yaml:"addr"`
|
||||
Topic string `yaml:"topic"`
|
||||
}
|
||||
ConsumerGroupID struct {
|
||||
MsgToMongo string `yaml:"msgToMongo"`
|
||||
MsgToMySql string `yaml:"msgToMySql"`
|
||||
MsgToPush string `yaml:"msgToPush"`
|
||||
}
|
||||
}
|
||||
Secret string `yaml:"secret"`
|
||||
MultiLoginPolicy struct {
|
||||
OnlyOneTerminalAccess bool `yaml:"onlyOneTerminalAccess"`
|
||||
MobileAndPCTerminalAccessButOtherTerminalKickEachOther bool `yaml:"mobileAndPCTerminalAccessButOtherTerminalKickEachOther"`
|
||||
AllTerminalAccess bool `yaml:"allTerminalAccess"`
|
||||
}
|
||||
TokenPolicy struct {
|
||||
AccessSecret string `yaml:"accessSecret"`
|
||||
AccessExpire int64 `yaml:"accessExpire"`
|
||||
}
|
||||
MessageCallBack struct {
|
||||
CallbackSwitch bool `yaml:"callbackSwitch"`
|
||||
CallbackUrl string `yaml:"callbackUrl"`
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
//path, _ := os.Getwd()
|
||||
//bytes, err := ioutil.ReadFile(path + "/config/config.yaml")
|
||||
// if we cd Open-IM-Server/src/utils and run go test
|
||||
// it will panic cannot find config/config.yaml
|
||||
bytes, err := ioutil.ReadFile(Root + "/config/config.yaml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err = yaml.Unmarshal(bytes, &Config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
// key = errCode, string = errMsg
|
||||
type ErrInfo struct {
|
||||
ErrCode int32
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
var (
|
||||
OK = ErrInfo{0, ""}
|
||||
|
||||
ErrMysql = ErrInfo{100, ""}
|
||||
ErrMongo = ErrInfo{110, ""}
|
||||
ErrRedis = ErrInfo{120, ""}
|
||||
ErrParseToken = ErrInfo{200, "Parse token failed"}
|
||||
ErrCreateToken = ErrInfo{201, "Create token failed"}
|
||||
ErrAppServerKey = ErrInfo{300, "key error"}
|
||||
ErrTencentCredential = ErrInfo{400, ""}
|
||||
|
||||
ErrorUserRegister = ErrInfo{600, "User registration failed"}
|
||||
ErrAccountExists = ErrInfo{601, "The account is already registered and cannot be registered again"}
|
||||
ErrUserPassword = ErrInfo{602, "User password error"}
|
||||
ErrTokenIncorrect = ErrInfo{603, "Invalid token"}
|
||||
ErrTokenExpired = ErrInfo{604, "Expired token"}
|
||||
ErrRefreshToken = ErrInfo{605, "Failed to refresh token"}
|
||||
ErrAddFriend = ErrInfo{606, "Failed to add friends"}
|
||||
ErrAgreeToAddFriend = ErrInfo{607, "Failed to agree application"}
|
||||
ErrAddFriendToBlack = ErrInfo{608, "Failed to add friends to the blacklist"}
|
||||
ErrGetBlackList = ErrInfo{609, "Failed to get blacklist"}
|
||||
ErrDeleteFriend = ErrInfo{610, "Failed to delete friend"}
|
||||
ErrGetFriendApplyList = ErrInfo{611, "Failed to get friend application list"}
|
||||
ErrGetFriendList = ErrInfo{612, "Failed to get friend list"}
|
||||
ErrRemoveBlackList = ErrInfo{613, "Failed to remove blacklist"}
|
||||
ErrSearchUserInfo = ErrInfo{614, "Can't find the user information"}
|
||||
ErrDelAppleDeviceToken = ErrInfo{615, ""}
|
||||
ErrModifyUserInfo = ErrInfo{616, "update user some attribute failed"}
|
||||
ErrSetFriendComment = ErrInfo{617, "set friend comment failed"}
|
||||
ErrSearchUserInfoFromTheGroup = ErrInfo{618, "There is no such group or the user not in the group"}
|
||||
ErrCreateGroup = ErrInfo{619, "create group chat failed"}
|
||||
ErrJoinGroupApplication = ErrInfo{620, "Failed to apply to join the group"}
|
||||
ErrQuitGroup = ErrInfo{621, "Failed to quit the group"}
|
||||
ErrSetGroupInfo = ErrInfo{622, "Failed to set group info"}
|
||||
ErrParam = ErrInfo{ErrCode: 700, ErrMsg: "param failed"}
|
||||
|
||||
ErrAccess = ErrInfo{ErrCode: 800, ErrMsg: "no permission"}
|
||||
|
||||
ErrDb = ErrInfo{ErrCode: 900, ErrMsg: "db failed"}
|
||||
)
|
||||
@@ -0,0 +1,82 @@
|
||||
package constant
|
||||
|
||||
const (
|
||||
|
||||
//group admin
|
||||
OrdinaryMember = 0
|
||||
GroupOwner = 1
|
||||
Administrator = 2
|
||||
//group application
|
||||
Application = 0
|
||||
AgreeApplication = 1
|
||||
|
||||
//feiend related
|
||||
BlackListFlag = 1
|
||||
ApplicationFriendFlag = 0
|
||||
FriendFlag = 1
|
||||
RefuseFriendFlag = -1
|
||||
|
||||
//Websocket Protocol
|
||||
WSGetNewestSeq = 1001
|
||||
WSPullMsg = 1002
|
||||
WSSendMsg = 1003
|
||||
WSPullMsgBySeqList = 1004
|
||||
WSPushMsg = 2001
|
||||
WSDataError = 3001
|
||||
|
||||
///ContentType
|
||||
//UserRelated
|
||||
Text = 101
|
||||
Picture = 102
|
||||
Voice = 103
|
||||
Video = 104
|
||||
File = 105
|
||||
AtText = 106
|
||||
Custom = 110
|
||||
HasReadReceipt = 112
|
||||
Typing = 113
|
||||
Common = 200
|
||||
GroupMsg = 201
|
||||
|
||||
//SysRelated
|
||||
AcceptFriendApplicationTip = 201
|
||||
AddFriendTip = 202
|
||||
RefuseFriendApplicationTip = 203
|
||||
SetSelfInfoTip = 204
|
||||
Revoke = 205
|
||||
C2CMessageAsRead = 206
|
||||
|
||||
KickOnlineTip = 303
|
||||
|
||||
TransferGroupOwnerTip = 501
|
||||
CreateGroupTip = 502
|
||||
GroupApplicationResponseTip = 503
|
||||
JoinGroupTip = 504
|
||||
QuitGroupTip = 505
|
||||
SetGroupInfoTip = 506
|
||||
AcceptGroupApplicationTip = 507
|
||||
RefuseGroupApplicationTip = 508
|
||||
KickGroupMemberTip = 509
|
||||
InviteUserToGroupTip = 510
|
||||
|
||||
//MsgFrom
|
||||
UserMsgType = 100
|
||||
SysMsgType = 200
|
||||
|
||||
//SessionType
|
||||
SingleChatType = 1
|
||||
GroupChatType = 2
|
||||
)
|
||||
|
||||
var ContentType2PushContent = map[int64]string{
|
||||
Picture: "[图片]",
|
||||
Voice: "[语音]",
|
||||
Video: "[视频]",
|
||||
File: "[文件]",
|
||||
Text: "你收到了一条文本消息",
|
||||
AtText: "[有人@你]",
|
||||
GroupMsg: "你收到一条群聊消息",
|
||||
Common: "你收到一条新消息",
|
||||
}
|
||||
|
||||
const FriendAcceptTip = "You have successfully become friends, so start chatting"
|
||||
@@ -0,0 +1,64 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"gopkg.in/mgo.v2"
|
||||
"time"
|
||||
)
|
||||
|
||||
var DB DataBases
|
||||
|
||||
type DataBases struct {
|
||||
MysqlDB mysqlDB
|
||||
mgoSession *mgo.Session
|
||||
redisPool *redis.Pool
|
||||
}
|
||||
|
||||
func key(dbAddress, dbName string) string {
|
||||
return dbAddress + "_" + dbName
|
||||
}
|
||||
|
||||
func init() {
|
||||
//mysql init
|
||||
initMysqlDB()
|
||||
mgoDailInfo := &mgo.DialInfo{
|
||||
Addrs: config.Config.Mongo.DBAddress,
|
||||
Direct: config.Config.Mongo.DBDirect,
|
||||
Timeout: time.Second * time.Duration(config.Config.Mongo.DBTimeout),
|
||||
Database: config.Config.Mongo.DBDatabase,
|
||||
Source: config.Config.Mongo.DBSource,
|
||||
Username: config.Config.Mongo.DBUserName,
|
||||
Password: config.Config.Mongo.DBPassword,
|
||||
PoolLimit: config.Config.Mongo.DBMaxPoolSize,
|
||||
}
|
||||
mgoSession, err := mgo.DialWithInfo(mgoDailInfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
DB.mgoSession = mgoSession
|
||||
DB.mgoSession.SetMode(mgo.Monotonic, true)
|
||||
c := DB.mgoSession.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
err = c.EnsureIndexKey("uid")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// redis pool init
|
||||
DB.redisPool = &redis.Pool{
|
||||
MaxIdle: config.Config.Redis.DBMaxIdle,
|
||||
MaxActive: config.Config.Redis.DBMaxActive,
|
||||
IdleTimeout: time.Duration(config.Config.Redis.DBIdleTimeout) * time.Second,
|
||||
Dial: func() (redis.Conn, error) {
|
||||
return redis.Dial(
|
||||
"tcp",
|
||||
config.Config.Redis.DBAddress,
|
||||
redis.DialReadTimeout(time.Duration(1000)*time.Millisecond),
|
||||
redis.DialWriteTimeout(time.Duration(1000)*time.Millisecond),
|
||||
redis.DialConnectTimeout(time.Duration(1000)*time.Millisecond),
|
||||
redis.DialDatabase(0),
|
||||
redis.DialPassword(config.Config.Redis.DBPassWord),
|
||||
)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"errors"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const cChat = "chat"
|
||||
const cGroup = "group"
|
||||
const singleGocMsgNum = 5000
|
||||
|
||||
type MsgInfo struct {
|
||||
SendTime int64
|
||||
Msg []byte
|
||||
}
|
||||
|
||||
type UserChat struct {
|
||||
UID string
|
||||
Msg []MsgInfo
|
||||
}
|
||||
|
||||
type GroupMember struct {
|
||||
GroupID string
|
||||
UIDList []string
|
||||
}
|
||||
|
||||
func (d *DataBases) GetMsgBySeqRange(uid string, seqBegin, seqEnd int64) (SingleMsg []*pbMsg.MsgFormat, GroupMsg []*pbMsg.MsgFormat, MaxSeq int64, MinSeq int64, err error) {
|
||||
var count int64
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return nil, nil, MaxSeq, MinSeq, errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
|
||||
sChat := UserChat{}
|
||||
if err = c.Find(bson.M{"uid": uid}).One(&sChat); err != nil {
|
||||
return nil, nil, MaxSeq, MinSeq, err
|
||||
}
|
||||
pChat := pbMsg.MsgSvrToPushSvrChatMsg{}
|
||||
for i := 0; i < len(sChat.Msg); i++ {
|
||||
temp := new(pbMsg.MsgFormat)
|
||||
if err = proto.Unmarshal(sChat.Msg[i].Msg, &pChat); err != nil {
|
||||
return nil, nil, MaxSeq, MinSeq, err
|
||||
}
|
||||
if pChat.RecvSeq >= seqBegin && pChat.RecvSeq <= seqEnd {
|
||||
temp.SendID = pChat.SendID
|
||||
temp.RecvID = pChat.RecvID
|
||||
temp.MsgFrom = pChat.MsgFrom
|
||||
temp.Seq = pChat.RecvSeq
|
||||
temp.ServerMsgID = pChat.MsgID
|
||||
temp.SendTime = pChat.SendTime
|
||||
temp.Content = pChat.Content
|
||||
temp.ContentType = pChat.ContentType
|
||||
temp.SenderPlatformID = pChat.PlatformID
|
||||
temp.ClientMsgID = pChat.ClientMsgID
|
||||
temp.SenderFaceURL = pChat.SenderFaceURL
|
||||
temp.SenderNickName = pChat.SenderNickName
|
||||
if pChat.RecvSeq > MaxSeq {
|
||||
MaxSeq = pChat.RecvSeq
|
||||
}
|
||||
if count == 0 {
|
||||
MinSeq = pChat.RecvSeq
|
||||
}
|
||||
if pChat.RecvSeq < MinSeq {
|
||||
MinSeq = pChat.RecvSeq
|
||||
}
|
||||
if pChat.SessionType == constant.SingleChatType {
|
||||
SingleMsg = append(SingleMsg, temp)
|
||||
} else {
|
||||
GroupMsg = append(GroupMsg, temp)
|
||||
}
|
||||
count++
|
||||
if count == (seqEnd - seqBegin + 1) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SingleMsg, GroupMsg, MaxSeq, MinSeq, nil
|
||||
}
|
||||
func (d *DataBases) GetMinSeqFromMongo(uid string) (MinSeq int64, err error) {
|
||||
var i int64
|
||||
var seqUid string
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return MinSeq, errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
MaxSeq, err := d.GetUserMaxSeq(uid)
|
||||
if err != nil && err != redis.ErrNil {
|
||||
return MinSeq, err
|
||||
}
|
||||
NB := MaxSeq / singleGocMsgNum
|
||||
for i = 0; i <= NB; i++ {
|
||||
seqUid = indexGen(uid, i)
|
||||
n, err := c.Find(bson.M{"uid": seqUid}).Count()
|
||||
if err == nil && n != 0 {
|
||||
if i == 0 {
|
||||
MinSeq = 1
|
||||
} else {
|
||||
MinSeq = i * singleGocMsgNum
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return MinSeq, nil
|
||||
}
|
||||
func (d *DataBases) GetMsgBySeqList(uid string, seqList []int64) (SingleMsg []*pbMsg.MsgFormat, GroupMsg []*pbMsg.MsgFormat, MaxSeq int64, MinSeq int64, err error) {
|
||||
allCount := 0
|
||||
singleCount := 0
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return nil, nil, MaxSeq, MinSeq, errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
m := func(uid string, seqList []int64) map[string][]int64 {
|
||||
t := make(map[string][]int64)
|
||||
for i := 0; i < len(seqList); i++ {
|
||||
seqUid := getSeqUid(uid, seqList[i])
|
||||
if value, ok := t[seqUid]; !ok {
|
||||
var temp []int64
|
||||
t[seqUid] = append(temp, seqList[i])
|
||||
} else {
|
||||
t[seqUid] = append(value, seqList[i])
|
||||
}
|
||||
}
|
||||
return t
|
||||
}(uid, seqList)
|
||||
sChat := UserChat{}
|
||||
pChat := pbMsg.MsgSvrToPushSvrChatMsg{}
|
||||
for seqUid, value := range m {
|
||||
if err = c.Find(bson.M{"uid": seqUid}).One(&sChat); err != nil {
|
||||
log.NewError("", "not find seqUid", seqUid, value, uid, seqList)
|
||||
continue
|
||||
}
|
||||
singleCount = 0
|
||||
for i := 0; i < len(sChat.Msg); i++ {
|
||||
temp := new(pbMsg.MsgFormat)
|
||||
if err = proto.Unmarshal(sChat.Msg[i].Msg, &pChat); err != nil {
|
||||
log.NewError("", "not find seqUid", seqUid, value, uid, seqList)
|
||||
return nil, nil, MaxSeq, MinSeq, err
|
||||
}
|
||||
if isContainInt64(pChat.RecvSeq, value) {
|
||||
temp.SendID = pChat.SendID
|
||||
temp.RecvID = pChat.RecvID
|
||||
temp.MsgFrom = pChat.MsgFrom
|
||||
temp.Seq = pChat.RecvSeq
|
||||
temp.ServerMsgID = pChat.MsgID
|
||||
temp.SendTime = pChat.SendTime
|
||||
temp.Content = pChat.Content
|
||||
temp.ContentType = pChat.ContentType
|
||||
temp.SenderPlatformID = pChat.PlatformID
|
||||
temp.ClientMsgID = pChat.ClientMsgID
|
||||
temp.SenderFaceURL = pChat.SenderFaceURL
|
||||
temp.SenderNickName = pChat.SenderNickName
|
||||
if pChat.RecvSeq > MaxSeq {
|
||||
MaxSeq = pChat.RecvSeq
|
||||
}
|
||||
if allCount == 0 {
|
||||
MinSeq = pChat.RecvSeq
|
||||
}
|
||||
if pChat.RecvSeq < MinSeq {
|
||||
MinSeq = pChat.RecvSeq
|
||||
}
|
||||
if pChat.SessionType == constant.SingleChatType {
|
||||
SingleMsg = append(SingleMsg, temp)
|
||||
} else {
|
||||
GroupMsg = append(GroupMsg, temp)
|
||||
}
|
||||
allCount++
|
||||
singleCount++
|
||||
if singleCount == len(value) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SingleMsg, GroupMsg, MaxSeq, MinSeq, nil
|
||||
}
|
||||
func (d *DataBases) SaveUserChat(uid string, sendTime int64, m *pbMsg.MsgSvrToPushSvrChatMsg) error {
|
||||
var seqUid string
|
||||
newTime := getCurrentTimestampByMill()
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
log.NewInfo("", "get mgoSession cost time", getCurrentTimestampByMill()-newTime)
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
seqUid = getSeqUid(uid, m.RecvSeq)
|
||||
n, err := c.Find(bson.M{"uid": seqUid}).Count()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.NewInfo("", "find mgo uid cost time", getCurrentTimestampByMill()-newTime)
|
||||
sMsg := MsgInfo{}
|
||||
sMsg.SendTime = sendTime
|
||||
if sMsg.Msg, err = proto.Marshal(m); err != nil {
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
sChat := UserChat{}
|
||||
sChat.UID = seqUid
|
||||
sChat.Msg = append(sChat.Msg, sMsg)
|
||||
err = c.Insert(&sChat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = c.Update(bson.M{"uid": seqUid}, bson.M{"$push": bson.M{"msg": sMsg}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.NewInfo("", "insert mgo data cost time", getCurrentTimestampByMill()-newTime)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) DelUserChat(uid string) error {
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
|
||||
delTime := time.Now().Unix() - int64(config.Config.Mongo.DBRetainChatRecords)*24*3600
|
||||
if err := c.Update(bson.M{"uid": uid}, bson.M{"$pull": bson.M{"msg": bson.M{"sendtime": bson.M{"$lte": delTime}}}}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) MgoUserCount() (int, error) {
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return 0, errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
|
||||
return c.Find(nil).Count()
|
||||
}
|
||||
|
||||
func (d *DataBases) MgoSkipUID(count int) (string, error) {
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return "", errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cChat)
|
||||
|
||||
sChat := UserChat{}
|
||||
c.Find(nil).Skip(count).Limit(1).One(&sChat)
|
||||
return sChat.UID, nil
|
||||
}
|
||||
|
||||
func (d *DataBases) GetGroupMember(groupID string) []string {
|
||||
groupInfo := GroupMember{}
|
||||
groupInfo.GroupID = groupID
|
||||
groupInfo.UIDList = make([]string, 0)
|
||||
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return groupInfo.UIDList
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
||||
|
||||
if err := c.Find(bson.M{"groupid": groupInfo.GroupID}).One(&groupInfo); err != nil {
|
||||
return groupInfo.UIDList
|
||||
}
|
||||
|
||||
return groupInfo.UIDList
|
||||
}
|
||||
|
||||
func (d *DataBases) AddGroupMember(groupID, uid string) error {
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
||||
|
||||
n, err := c.Find(bson.M{"groupid": groupID}).Count()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
groupInfo := GroupMember{}
|
||||
groupInfo.GroupID = groupID
|
||||
groupInfo.UIDList = append(groupInfo.UIDList, uid)
|
||||
err = c.Insert(&groupInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
err = c.Update(bson.M{"groupid": groupID}, bson.M{"$addToSet": bson.M{"uidlist": uid}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataBases) DelGroupMember(groupID, uid string) error {
|
||||
session := d.mgoSession.Clone()
|
||||
if session == nil {
|
||||
return errors.New("session == nil")
|
||||
}
|
||||
defer session.Close()
|
||||
|
||||
c := session.DB(config.Config.Mongo.DBDatabase).C(cGroup)
|
||||
|
||||
if err := c.Update(bson.M{"groupid": groupID}, bson.M{"$pull": bson.M{"uidlist": uid}}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCurrentTimestampByMill() int64 {
|
||||
return time.Now().UnixNano() / 1e6
|
||||
}
|
||||
func getSeqUid(uid string, seq int64) string {
|
||||
seqSuffix := seq / singleGocMsgNum
|
||||
return indexGen(uid, seqSuffix)
|
||||
}
|
||||
func isContainInt64(target int64, List []int64) bool {
|
||||
|
||||
for _, element := range List {
|
||||
|
||||
if target == element {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
func indexGen(uid string, seqSuffix int64) string {
|
||||
return uid + ":" + strconv.FormatInt(seqSuffix, 10)
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"fmt"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type mysqlDB struct {
|
||||
sync.RWMutex
|
||||
dbMap map[string]*gorm.DB
|
||||
}
|
||||
|
||||
func initMysqlDB() {
|
||||
//When there is no open IM database, connect to the mysql built-in database to create openIM database
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
|
||||
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], "mysql")
|
||||
|
||||
db, err := gorm.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
log.Error("", "", dsn)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//Check the database and table during initialization
|
||||
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s ;", config.Config.Mysql.DBDatabaseName)
|
||||
err = db.Exec(sql).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
db.Close()
|
||||
|
||||
dsn = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
|
||||
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
|
||||
db, err = gorm.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable := "CREATE TABLE IF NOT EXISTS `user` (" +
|
||||
" `uid` varchar(64) NOT NULL," +
|
||||
" `name` varchar(64) DEFAULT NULL," +
|
||||
" `icon` varchar(1024) DEFAULT NULL," +
|
||||
" `gender` tinyint(4) unsigned zerofill DEFAULT NULL," +
|
||||
" `mobile` varchar(32) DEFAULT NULL," +
|
||||
" `birth` varchar(16) DEFAULT NULL," +
|
||||
" `email` varchar(64) DEFAULT NULL," +
|
||||
" `ex` varchar(1024) DEFAULT NULL," +
|
||||
" `create_time` datetime DEFAULT NULL," +
|
||||
" PRIMARY KEY (`uid`)," +
|
||||
" UNIQUE KEY `uk_uid` (`uid`)" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `friend` (" +
|
||||
" `owner_id` varchar(64) NOT NULL," +
|
||||
" `friend_id` varchar(64) NOT NULL," +
|
||||
" `comment` varchar(255) DEFAULT NULL," +
|
||||
" `friend_flag` int(11) NOT NULL," +
|
||||
" `create_time` datetime NOT NULL," +
|
||||
" PRIMARY KEY (`owner_id`,`friend_id`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `friend_request` (" +
|
||||
" `req_id` varchar(64) NOT NULL," +
|
||||
" `user_id` varchar(64) NOT NULL," +
|
||||
" `flag` int(11) NOT NULL DEFAULT '0'," +
|
||||
" `req_message` varchar(255) DEFAULT NULL," +
|
||||
" `create_time` datetime NOT NULL," +
|
||||
" PRIMARY KEY (`user_id`,`req_id`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `black_list` (" +
|
||||
" `uid` varchar(32) NOT NULL COMMENT 'uid'," +
|
||||
" `begin_disable_time` datetime DEFAULT NULL," +
|
||||
" `end_disable_time` datetime DEFAULT NULL," +
|
||||
" `ex` varchar(1024) DEFAULT NULL," +
|
||||
" PRIMARY KEY (`uid`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `user_black_list` (" +
|
||||
" `owner_id` varchar(64) NOT NULL," +
|
||||
" `block_id` varchar(64) NOT NULL," +
|
||||
" `create_time` datetime NOT NULL," +
|
||||
" PRIMARY KEY (`owner_id`,`block_id`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group` (" +
|
||||
" `group_id` varchar(64) NOT NULL," +
|
||||
" `name` varchar(255) DEFAULT NULL," +
|
||||
" `introduction` varchar(255) DEFAULT NULL," +
|
||||
" `notification` varchar(255) DEFAULT NULL," +
|
||||
" `face_url` varchar(255) DEFAULT NULL," +
|
||||
" `create_time` datetime DEFAULT NULL," +
|
||||
" `ex` varchar(255) DEFAULT NULL," +
|
||||
" PRIMARY KEY (`group_id`)" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group_member` (" +
|
||||
" `group_id` varchar(64) NOT NULL," +
|
||||
" `uid` varchar(64) NOT NULL," +
|
||||
" `nickname` varchar(255) DEFAULT NULL," +
|
||||
" `user_group_face_url` varchar(255) DEFAULT NULL," +
|
||||
" `administrator_level` int(11) NOT NULL," +
|
||||
" `join_time` datetime NOT NULL," +
|
||||
" PRIMARY KEY (`group_id`,`uid`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `group_request` (" +
|
||||
" `id` int(11) NOT NULL AUTO_INCREMENT," +
|
||||
" `group_id` varchar(64) NOT NULL," +
|
||||
" `from_user_id` varchar(255) NOT NULL," +
|
||||
" `to_user_id` varchar(255) NOT NULL," +
|
||||
" `flag` int(10) NOT NULL DEFAULT '0'," +
|
||||
" `req_msg` varchar(255) DEFAULT ''," +
|
||||
" `handled_msg` varchar(255) DEFAULT ''," +
|
||||
" `create_time` datetime NOT NULL," +
|
||||
" `from_user_nickname` varchar(255) DEFAULT ''," +
|
||||
" `to_user_nickname` varchar(255) DEFAULT NULL," +
|
||||
" `from_user_face_url` varchar(255) DEFAULT ''," +
|
||||
" `to_user_face_url` varchar(255) DEFAULT ''," +
|
||||
" `handled_user` varchar(255) DEFAULT ''," +
|
||||
" PRIMARY KEY (`id`)" +
|
||||
" ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sqlTable = "CREATE TABLE IF NOT EXISTS `chat_log` (" +
|
||||
" `msg_id` varchar(128) NOT NULL," +
|
||||
" `send_id` varchar(255) NOT NULL," +
|
||||
" `session_type` int(11) NOT NULL," +
|
||||
" `recv_id` varchar(255) NOT NULL," +
|
||||
" `content_type` int(11) NOT NULL," +
|
||||
" `msg_from` int(11) NOT NULL," +
|
||||
" `content` varchar(1000) NOT NULL," +
|
||||
" `remark` varchar(100) DEFAULT NULL," +
|
||||
" `sender_platform_id` int(11) NOT NULL," +
|
||||
" `send_time` datetime NOT NULL," +
|
||||
" PRIMARY KEY (`msg_id`) USING BTREE" +
|
||||
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
|
||||
err = db.Exec(sqlTable).Error
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (m *mysqlDB) DefaultGormDB() (*gorm.DB, error) {
|
||||
return m.GormDB(config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
|
||||
}
|
||||
|
||||
func (m *mysqlDB) GormDB(dbAddress, dbName string) (*gorm.DB, error) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
k := key(dbAddress, dbName)
|
||||
if _, ok := m.dbMap[k]; !ok {
|
||||
if err := m.open(dbAddress, dbName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return m.dbMap[k], nil
|
||||
}
|
||||
|
||||
func (m *mysqlDB) open(dbAddress, dbName string) error {
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=true&loc=Local",
|
||||
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, dbAddress, dbName)
|
||||
db, err := gorm.Open("mysql", dsn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
db.SingularTable(true)
|
||||
db.DB().SetMaxOpenConns(config.Config.Mysql.DBMaxOpenConns)
|
||||
db.DB().SetMaxIdleConns(config.Config.Mysql.DBMaxIdleConns)
|
||||
db.DB().SetConnMaxLifetime(time.Duration(config.Config.Mysql.DBMaxLifeTime) * time.Second)
|
||||
|
||||
if m.dbMap == nil {
|
||||
m.dbMap = make(map[string]*gorm.DB)
|
||||
}
|
||||
k := key(dbAddress, dbName)
|
||||
m.dbMap[k] = db
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertToFriend(ownerId, friendId string, flag int32) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
toInsertFollow := Friend{
|
||||
OwnerId: ownerId,
|
||||
FriendId: friendId,
|
||||
FriendFlag: flag,
|
||||
CreateTime: time.Now(),
|
||||
}
|
||||
err = dbConn.Table("friend").Create(toInsertFollow).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindFriendRelationshipFromFriend(ownerId, friendId string) (*Friend, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var friend Friend
|
||||
err = dbConn.Table("friend").Where("owner_id=? and friend_id=?", ownerId, friendId).Find(&friend).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &friend, err
|
||||
}
|
||||
|
||||
func FindUserInfoFromFriend(ownerId string) ([]Friend, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var friends []Friend
|
||||
err = dbConn.Table("friend").Where("owner_id=?", ownerId).Find(&friends).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return friends, nil
|
||||
}
|
||||
|
||||
func UpdateFriendComment(ownerId, friendId, comment string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("update friend set comment=? where owner_id=? and friend_id=?", comment, ownerId, friendId).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func DeleteSingleFriendInfo(ownerId, friendId string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Table("friend").Where("owner_id=? and friend_id=?", ownerId, friendId).Delete(Friend{}).Error
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ReplaceIntoFriendReq(reqId, userId string, flag int32, reqMessage string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("replace into friend_request(req_id,user_id,flag,req_message,create_time) values(?,?,?,?,?)", reqId, userId, flag, reqMessage, time.Now()).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindFriendsApplyFromFriendReq(userId string) ([]FriendRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var usersInfo []FriendRequest
|
||||
//dbConn.LogMode(true)
|
||||
err = dbConn.Table("friend_request").Where("user_id=?", userId).Find(&usersInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usersInfo, nil
|
||||
}
|
||||
|
||||
func FindSelfApplyFromFriendReq(userId string) ([]FriendRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var usersInfo []FriendRequest
|
||||
err = dbConn.Table("friend_request").Where("req_id=?", userId).Find(&usersInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usersInfo, nil
|
||||
}
|
||||
|
||||
func FindFriendApplyFromFriendReqByUid(reqId, userId string) (*FriendRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var friendRequest FriendRequest
|
||||
err = dbConn.Table("friend_request").Where("req_id=? and user_id=?", reqId, userId).Find(&friendRequest).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &friendRequest, nil
|
||||
}
|
||||
|
||||
func UpdateFriendRelationshipToFriendReq(reqId, userId string, flag int32) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("update friend_request set flag=? where req_id=? and user_id=?", flag, reqId, userId).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertIntoGroupMember(groupId, uid, nickName, userGroupFaceUrl string, administratorLevel int32) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
toInsertInfo := GroupMember{GroupId: groupId, Uid: uid, NickName: nickName, AdministratorLevel: administratorLevel, JoinTime: time.Now(), UserGroupFaceUrl: userGroupFaceUrl}
|
||||
err = dbConn.Table("group_member").Create(toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindGroupMemberListByUserId(uid string) ([]GroupMember, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMemberList []GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where uid=?", uid).Find(&groupMemberList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groupMemberList, nil
|
||||
}
|
||||
|
||||
func FindGroupMemberListByGroupId(groupId string) ([]GroupMember, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMemberList []GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=?", groupId).Find(&groupMemberList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groupMemberList, nil
|
||||
}
|
||||
|
||||
func FindGroupMemberListByGroupIdAndFilterInfo(groupId string, filter int32) ([]GroupMember, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
dbConn.LogMode(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMemberList []GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=? and administrator_level=?", groupId, filter).Find(&groupMemberList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groupMemberList, nil
|
||||
}
|
||||
func FindGroupMemberInfoByGroupIdAndUserId(groupId, uid string) (*GroupMember, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMember GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=? and uid=? limit 1", groupId, uid).Scan(&groupMember).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &groupMember, nil
|
||||
}
|
||||
|
||||
func DeleteGroupMemberByGroupIdAndUserId(groupId, uid string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("delete from `group_member` where group_id=? and uid=?", groupId, uid).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateOwnerGroupNickName(groupId, userId, groupNickName string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("update `group_member` set nickname=? where group_id=? and uid=?", groupNickName, groupId, userId).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SelectGroupList(groupID string) ([]string, error) {
|
||||
var groupUserID string
|
||||
var groupList []string
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return groupList, err
|
||||
}
|
||||
|
||||
rows, err := dbConn.Model(&GroupMember{}).Where("group_id = ?", groupID).Select("user_id").Rows()
|
||||
if err != nil {
|
||||
return groupList, err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rows.Scan(&groupUserID)
|
||||
groupList = append(groupList, groupUserID)
|
||||
}
|
||||
return groupList, nil
|
||||
}
|
||||
|
||||
func UpdateTheUserAdministratorLevel(groupId, uid string, administratorLevel int64) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("update `group_member` set administrator_level=? where group_id=? and uid=?", administratorLevel, groupId, uid).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetOwnerManagerByGroupId(groupId string) ([]GroupMember, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupMemberList []GroupMember
|
||||
err = dbConn.Raw("select * from `group_member` where group_id=? and administrator_level > 0", groupId).Find(&groupMemberList).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groupMemberList, nil
|
||||
}
|
||||
|
||||
func IsExistGroupMember(groupId, uid string) bool {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
var number int32
|
||||
err = dbConn.Raw("select count(*) from `group_member` where group_id = ? and uid = ?", groupId, uid).Count(&number).Error
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if number != 1 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func RemoveGroupMember(groupId string, memberId string) error {
|
||||
return DeleteGroupMemberByGroupIdAndUserId(groupId, memberId)
|
||||
}
|
||||
|
||||
func GetMemberInfoById(groupId string, memberId string) (*GroupMember, error) {
|
||||
return FindGroupMemberInfoByGroupIdAndUserId(groupId, memberId)
|
||||
}
|
||||
|
||||
func GetGroupMemberByGroupId(groupId string, filter int32, begin int32, maxNumber int32) ([]GroupMember, error) {
|
||||
memberList, err := FindGroupMemberListByGroupId(groupId) //sorted by join time
|
||||
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 GetJoinedGroupIdListByMemberId(memberId string) ([]GroupMember, error) {
|
||||
return FindGroupMemberListByUserId(memberId)
|
||||
}
|
||||
|
||||
func GetGroupMemberNumByGroupId(groupId string) int32 {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
var number int32
|
||||
err = dbConn.Raw("select count(*) from `group_member` where group_id=? ", groupId).Count(&number).Error
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return number
|
||||
}
|
||||
|
||||
func GetGroupOwnerByGroupId(groupId string) string {
|
||||
omList, err := GetOwnerManagerByGroupId(groupId)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, v := range omList {
|
||||
if v.AdministratorLevel == 1 {
|
||||
return v.Uid
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func InsertGroupMember(groupId, userId, nickName, userFaceUrl string, role int32) error {
|
||||
return InsertIntoGroupMember(groupId, userId, nickName, userFaceUrl, role)
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/proto/group"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertIntoGroup(groupId, name, introduction, notification, faceUrl, ex string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//Default group name
|
||||
if name == "" {
|
||||
name = "groupChat"
|
||||
}
|
||||
toInsertInfo := Group{GroupId: groupId, Name: name, Introduction: introduction, Notification: notification, FaceUrl: faceUrl, CreateTime: time.Now(), Ex: ex}
|
||||
err = dbConn.Table("group").Create(toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindGroupInfoByGroupId(groupId string) (*Group, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupInfo Group
|
||||
err = dbConn.Raw("select * from `group` where group_id=?", groupId).Scan(&groupInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &groupInfo, nil
|
||||
}
|
||||
|
||||
func SetGroupInfo(groupId, groupName, introduction, notification, groupFaceUrl, ex string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
dbConn.LogMode(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if groupName != "" {
|
||||
if err = dbConn.Exec("update `group` set name=? where group_id=?", groupName, groupId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if introduction != "" {
|
||||
if err = dbConn.Exec("update `group` set introduction=? where group_id=?", introduction, groupId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if notification != "" {
|
||||
if err = dbConn.Exec("update `group` set notification=? where group_id=?", notification, groupId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if groupFaceUrl != "" {
|
||||
if err = dbConn.Exec("update `group` set face_url=? where group_id=?", groupFaceUrl, groupId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if ex != "" {
|
||||
if err = dbConn.Exec("update `group` set ex=? where group_id=?", ex, groupId).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetGroupApplicationList(uid string) (*group.GetGroupApplicationListResp, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var gID string
|
||||
var gIDs []string
|
||||
rows, err := dbConn.Raw("select group_id from `group_member` where uid = ? and administrator_level > 0", uid).Rows()
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
rows.Scan(&gID)
|
||||
gIDs = append(gIDs, gID)
|
||||
}
|
||||
|
||||
if len(gIDs) == 0 {
|
||||
return &group.GetGroupApplicationListResp{}, nil
|
||||
}
|
||||
|
||||
sql := "select id, group_id, from_user_id, to_user_id, flag, req_msg, handled_msg, create_time, " +
|
||||
"from_user_nickname, to_user_nickname, from_user_face_url, to_user_face_url, handled_user from `group_request` where group_id in ( "
|
||||
for i := 0; i < len(gIDs); i++ {
|
||||
if i == len(gIDs)-1 {
|
||||
sql = sql + "\"" + gIDs[i] + "\"" + " )"
|
||||
} else {
|
||||
sql = sql + "\"" + gIDs[i] + "\"" + ", "
|
||||
}
|
||||
}
|
||||
|
||||
var groupRequest GroupRequest
|
||||
var groupRequests []GroupRequest
|
||||
log.Info("", "", sql)
|
||||
rows, err = dbConn.Raw(sql).Rows()
|
||||
defer rows.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
rows.Scan(&groupRequest.ID, &groupRequest.GroupID, &groupRequest.FromUserID, &groupRequest.ToUserID, &groupRequest.Flag, &groupRequest.ReqMsg,
|
||||
&groupRequest.HandledMsg, &groupRequest.CreateTime, &groupRequest.FromUserNickname, &groupRequest.ToUserNickname,
|
||||
&groupRequest.FromUserFaceUrl, &groupRequest.ToUserFaceUrl, &groupRequest.HandledUser)
|
||||
groupRequests = append(groupRequests, groupRequest)
|
||||
}
|
||||
|
||||
reply := &group.GetGroupApplicationListResp{}
|
||||
reply.Data = &group.GetGroupApplicationListData{}
|
||||
reply.Data.Count = int32(len(groupRequests))
|
||||
for i := 0; i < int(reply.Data.Count); i++ {
|
||||
addUser := group.GetGroupApplicationList_Data_User{
|
||||
ID: groupRequests[i].ID,
|
||||
GroupID: groupRequests[i].GroupID,
|
||||
FromUserID: groupRequests[i].FromUserID,
|
||||
FromUserNickname: groupRequests[i].FromUserNickname,
|
||||
FromUserFaceUrl: groupRequests[i].FromUserFaceUrl,
|
||||
ToUserID: groupRequests[i].ToUserID,
|
||||
AddTime: groupRequests[i].CreateTime.Unix(),
|
||||
RequestMsg: groupRequests[i].ReqMsg,
|
||||
HandledMsg: groupRequests[i].HandledMsg,
|
||||
Flag: groupRequests[i].Flag,
|
||||
ToUserNickname: groupRequests[i].ToUserNickname,
|
||||
ToUserFaceUrl: groupRequests[i].ToUserFaceUrl,
|
||||
HandledUser: groupRequests[i].HandledUser,
|
||||
Type: 0,
|
||||
HandleStatus: 0,
|
||||
HandleResult: 0,
|
||||
}
|
||||
|
||||
if addUser.ToUserID != "0" {
|
||||
addUser.Type = 1
|
||||
}
|
||||
|
||||
if len(groupRequests[i].HandledUser) > 0 {
|
||||
if groupRequests[i].HandledUser == uid {
|
||||
addUser.HandleStatus = 2
|
||||
} else {
|
||||
addUser.HandleStatus = 1
|
||||
}
|
||||
}
|
||||
|
||||
if groupRequests[i].Flag == 1 {
|
||||
addUser.HandleResult = 1
|
||||
}
|
||||
|
||||
reply.Data.User = append(reply.Data.User, &addUser)
|
||||
}
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func TransferGroupOwner(pb *group.TransferGroupOwnerReq) (*group.TransferGroupOwnerResp, error) {
|
||||
oldOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OldOwner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newOwner, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.NewOwner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if oldOwner.Uid == newOwner.Uid {
|
||||
return nil, errors.New("the self")
|
||||
}
|
||||
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwner, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = UpdateTheUserAdministratorLevel(pb.GroupID, pb.NewOwner, 1); err != nil {
|
||||
UpdateTheUserAdministratorLevel(pb.GroupID, pb.OldOwner, 1)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &group.TransferGroupOwnerResp{}, nil
|
||||
}
|
||||
|
||||
func GroupApplicationResponse(pb *group.GroupApplicationResponseReq) (*group.GroupApplicationResponseResp, error) {
|
||||
|
||||
ownerUser, err := FindGroupMemberInfoByGroupIdAndUserId(pb.GroupID, pb.OwnerID)
|
||||
if err != nil {
|
||||
log.ErrorByKv("FindGroupMemberInfoByGroupIdAndUserId failed", pb.OperationID, "groupId", pb.GroupID, "ownerID", pb.OwnerID)
|
||||
return nil, err
|
||||
}
|
||||
if ownerUser.AdministratorLevel <= 0 {
|
||||
return nil, errors.New("insufficient permissions")
|
||||
}
|
||||
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var groupRequest GroupRequest
|
||||
err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and from_user_id = ? and to_user_id = ?",
|
||||
"", pb.GroupID, pb.FromUserID, pb.ToUserID).Scan(&groupRequest).Error
|
||||
if err != nil {
|
||||
log.ErrorByKv("find group_request info failed", pb.OperationID, "groupId", pb.GroupID, "fromUserId", pb.FromUserID, "toUserId", pb.OwnerID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if groupRequest.Flag != 0 {
|
||||
return nil, errors.New("application has already handle")
|
||||
}
|
||||
|
||||
var saveFlag int
|
||||
if pb.HandleResult == 0 {
|
||||
saveFlag = -1
|
||||
} else if pb.HandleResult == 1 {
|
||||
saveFlag = 1
|
||||
} else {
|
||||
return nil, errors.New("parma HandleResult error")
|
||||
}
|
||||
err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and from_user_id = ? and to_user_id = ?",
|
||||
saveFlag, pb.HandledMsg, pb.OwnerID, groupRequest.GroupID, groupRequest.FromUserID, groupRequest.ToUserID).Error
|
||||
if err != nil {
|
||||
log.ErrorByKv("update group request failed", pb.OperationID, "groupID", pb.GroupID, "flag", saveFlag, "ownerId", pb.OwnerID, "fromUserId", pb.FromUserID, "toUserID", pb.ToUserID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if saveFlag == 1 {
|
||||
if groupRequest.ToUserID == "0" {
|
||||
err = InsertIntoGroupMember(pb.GroupID, pb.FromUserID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0)
|
||||
if err != nil {
|
||||
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err = InsertIntoGroupMember(pb.GroupID, pb.ToUserID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0)
|
||||
if err != nil {
|
||||
log.ErrorByKv("InsertIntoGroupMember failed", pb.OperationID, "groupID", pb.GroupID, "fromUserId", pb.FromUserID)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if err != nil {
|
||||
// err = dbConn.Raw("select * from `group_request` where handled_user = ? and group_id = ? and to_user_id = ? and from_user_id = ?", "", pb.GroupID, "0", pb.UID).Scan(&groupRequest).Error
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// if pb.Flag == 1 {
|
||||
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ? and from_user_id = ?",
|
||||
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, "0", pb.UID).Error
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// // add to group member
|
||||
// err = InsertIntoGroupMember(pb.GroupID, pb.UID, groupRequest.FromUserNickname, groupRequest.FromUserFaceUrl, 0)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// } else if pb.Flag == -1 {
|
||||
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ? and from_user_id = ?",
|
||||
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, "0", pb.UID).Error
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// } else {
|
||||
// return nil, errors.New("flag error")
|
||||
// }
|
||||
//} else {
|
||||
// if pb.Flag == 1 {
|
||||
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ?",
|
||||
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, pb.UID).Error
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// // add to group member
|
||||
// err = InsertIntoGroupMember(pb.GroupID, pb.UID, groupRequest.ToUserNickname, groupRequest.ToUserFaceUrl, 0)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// } else if pb.Flag == -1 {
|
||||
// err = dbConn.Exec("update `group_request` set flag = ?, handled_msg = ?, handled_user = ? where group_id = ? and to_user_id = ?",
|
||||
// pb.Flag, pb.RespMsg, pb.OwnerID, pb.GroupID, pb.UID).Error
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// } else {
|
||||
// return nil, errors.New("flag error")
|
||||
// }
|
||||
//}
|
||||
|
||||
return &group.GroupApplicationResponseResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertIntoGroupRequest(groupId, fromUserId, toUserId, reqMsg, fromUserNickName, fromUserFaceUrl string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
toInsertInfo := GroupRequest{GroupID: groupId, FromUserID: fromUserId, ToUserID: toUserId, ReqMsg: reqMsg, FromUserNickname: fromUserNickName, FromUserFaceUrl: fromUserFaceUrl, CreateTime: time.Now()}
|
||||
err = dbConn.Table("group_request").Create(&toInsertInfo).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindGroupRequestUserInfoByGroupIDAndUid(groupId, uid string) (*GroupRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var requestUserInfo GroupRequest
|
||||
err = dbConn.Table("group_request").Where("from_user_id=? and group_id=?", uid, groupId).Find(&requestUserInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &requestUserInfo, nil
|
||||
}
|
||||
|
||||
func DelGroupRequest(groupId, fromUserId, toUserId string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("delete from group_request where group_id=? and from_user_id=? and to_user_id=?", groupId, fromUserId, toUserId).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func FindGroupBeInvitedRequestInfoByUidAndGroupID(groupId, uid string) (*GroupRequest, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var beInvitedRequestUserInfo GroupRequest
|
||||
err = dbConn.Table("group_request").Where("to_user_id=? and group_id=?", uid, groupId).Find(&beInvitedRequestUserInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &beInvitedRequestUserInfo, nil
|
||||
|
||||
}
|
||||
|
||||
func InsertGroupRequest(groupId, fromUser, fromUserNickName, fromUserFaceUrl, toUser, requestMsg, handledMsg string, handleStatus int) error {
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package im_mysql_model
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
UID string `gorm:"column:uid;primaryKey;"`
|
||||
Name string `gorm:"column:name"`
|
||||
Icon string `gorm:"column:icon"`
|
||||
Gender int32 `gorm:"column:gender"`
|
||||
Mobile string `gorm:"column:mobile"`
|
||||
Birth string `gorm:"column:birth"`
|
||||
Email string `gorm:"column:email"`
|
||||
Ex string `gorm:"column:ex"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
}
|
||||
|
||||
type Friend struct {
|
||||
OwnerId string `gorm:"column:owner_id"`
|
||||
FriendId string `gorm:"column:friend_id"`
|
||||
Comment string `gorm:"column:comment"`
|
||||
FriendFlag int32 `gorm:"column:friend_flag"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
}
|
||||
type FriendRequest struct {
|
||||
ReqId string `gorm:"column:req_id"`
|
||||
Uid string `gorm:"column:user_id"`
|
||||
Flag int32 `gorm:"column:flag"`
|
||||
ReqMessage string `gorm:"column:req_message"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
}
|
||||
type BlackList struct {
|
||||
OwnerId string `gorm:"column:owner_id"`
|
||||
BlockId string `gorm:"column:block_id"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
GroupId string `gorm:"column:group_id"`
|
||||
Name string `gorm:"column:name"`
|
||||
Introduction string `gorm:"column:introduction"`
|
||||
Notification string `gorm:"column:notification"`
|
||||
FaceUrl string `gorm:"column:face_url"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
Ex string `gorm:"column:ex"`
|
||||
}
|
||||
|
||||
type GroupMember struct {
|
||||
GroupId string `gorm:"column:group_id"`
|
||||
Uid string `gorm:"column:uid"`
|
||||
NickName string `gorm:"column:nickname"`
|
||||
AdministratorLevel int32 `gorm:"column:administrator_level"`
|
||||
JoinTime time.Time `gorm:"column:join_time"`
|
||||
UserGroupFaceUrl string `gorm:"user_group_face_url"`
|
||||
}
|
||||
|
||||
type GroupRequest struct {
|
||||
ID string `gorm:"column:id"`
|
||||
GroupID string `gorm:"column:group_id"`
|
||||
FromUserID string `gorm:"column:from_user_id"`
|
||||
ToUserID string `gorm:"column:to_user_id"`
|
||||
Flag int32 `gorm:"column:flag"`
|
||||
ReqMsg string `gorm:"column:req_msg"`
|
||||
HandledMsg string `gorm:"column:handled_msg"`
|
||||
CreateTime time.Time `gorm:"column:create_time"`
|
||||
FromUserNickname string `gorm:"from_user_nickname"`
|
||||
ToUserNickname string `gorm:"to_user_nickname"`
|
||||
FromUserFaceUrl string `gorm:"from_user_face_url"`
|
||||
ToUserFaceUrl string `gorm:"to_user_face_url"`
|
||||
HandledUser string `gorm:"handled_user"`
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InsertInToUserBlackList(ownerID, blockID string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
toInsertInfo := BlackList{OwnerId: ownerID, BlockId: blockID, CreateTime: time.Now()}
|
||||
err = dbConn.Table("user_black_list").Create(toInsertInfo).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func FindRelationshipFromBlackList(ownerID, blockID string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var blackList BlackList
|
||||
err = dbConn.Table("user_black_list").Where("owner_id=? and block_id=?", ownerID, blockID).Find(&blackList).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func RemoveBlackList(ownerID, blockID string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Exec("delete from user_black_list where owner_id=? and block_id=?", ownerID, blockID).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func GetBlackListByUID(ownerID string) ([]BlackList, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var blackListUsersInfo []BlackList
|
||||
err = dbConn.Table("user_black_list").Where("owner_id=?", ownerID).Find(&blackListUsersInfo).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return blackListUsersInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package im_mysql_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
pbAuth "Open_IM/pkg/proto/auth"
|
||||
"Open_IM/pkg/utils"
|
||||
"fmt"
|
||||
_ "github.com/jinzhu/gorm/dialects/mysql"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
//init managers
|
||||
var pb pbAuth.UserRegisterReq
|
||||
for k, v := range config.Config.Manager.AppManagerUid {
|
||||
if !IsExistUser(v) {
|
||||
pb.UID = v
|
||||
pb.Name = "AppManager" + utils.IntToString(k+1)
|
||||
err := UserRegister(&pb)
|
||||
if err != nil {
|
||||
fmt.Println("AppManager insert error", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func UserRegister(pb *pbAuth.UserRegisterReq) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
addUser := User{
|
||||
UID: pb.UID,
|
||||
Name: pb.Name,
|
||||
Icon: pb.Icon,
|
||||
Gender: pb.Gender,
|
||||
Mobile: pb.Mobile,
|
||||
Birth: pb.Birth,
|
||||
Email: pb.Email,
|
||||
Ex: pb.Ex,
|
||||
CreateTime: time.Now(),
|
||||
}
|
||||
err = dbConn.Table("user").Create(&addUser).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func UserDelete(uid string) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = dbConn.Table("user").Where("uid=?", uid).Delete(User{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func FindUserByUID(uid string) (*User, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var user User
|
||||
err = dbConn.Table("user").Where("uid=?", uid).First(&user).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func UpDateUserInfo(uid, name, headUrl, mobilePhoneNum, birth, email, extendInfo string, gender int32) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if name != "" {
|
||||
if err = dbConn.Exec("update user set name=? where uid=?", name, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if headUrl != "" {
|
||||
if err = dbConn.Exec("update user set icon=? where uid=?", headUrl, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if mobilePhoneNum != "" {
|
||||
if err = dbConn.Exec("update user set mobile=? where uid=?", mobilePhoneNum, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if birth != "" {
|
||||
if err = dbConn.Exec("update user set birth=? where uid=?", birth, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if email != "" {
|
||||
if err = dbConn.Exec("update user set email=? where uid=?", email, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if extendInfo != "" {
|
||||
if err = dbConn.Exec("update user set ex=? where uid=?", extendInfo, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if gender != 0 {
|
||||
if err = dbConn.Exec("update user set gender=? where uid=?", gender, uid).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func SelectAllUID() ([]string, error) {
|
||||
var uid []string
|
||||
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return uid, err
|
||||
}
|
||||
rows, _ := dbConn.Raw("select uid from user").Rows()
|
||||
defer rows.Close()
|
||||
var strUID string
|
||||
for rows.Next() {
|
||||
rows.Scan(&strUID)
|
||||
uid = append(uid, strUID)
|
||||
}
|
||||
return uid, nil
|
||||
}
|
||||
|
||||
func IsExistUser(uid string) bool {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
var number int32
|
||||
err = dbConn.Raw("select count(*) from `user` where uid = ?", uid).Count(&number).Error
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if number != 1 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/4 11:18).
|
||||
*/
|
||||
package im_mysql_msg_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ChatLog Chat information table structure
|
||||
type ChatLog struct {
|
||||
MsgId string `gorm:"primary_key"` // Chat history primary key ID
|
||||
SendID string `gorm:"column:send_id"` // Send ID
|
||||
RecvID string `gorm:"column:recv_id"` //Receive ID
|
||||
SendTime time.Time `gorm:"column:send_time"` // Send time
|
||||
SessionType int32 `gorm:"column:session_type"` // Session type
|
||||
ContentType int32 `gorm:"column:content_type"` // Message content type
|
||||
MsgFrom int32 `gorm:"column:msg_from"` // Source, user, system
|
||||
Content string `gorm:"column:content"` // Chat content
|
||||
SenderPlatformID int32 `gorm:"column:sender_platform_id"` //The sender's platform ID
|
||||
Remark sql.NullString `gorm:"column:remark"` // remark
|
||||
}
|
||||
|
||||
func InsertMessageToChatLog(msgData pbMsg.WSToMsgSvrChatMsg) error {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chatLog := ChatLog{
|
||||
MsgId: msgData.MsgID,
|
||||
SendID: msgData.SendID,
|
||||
RecvID: msgData.RecvID,
|
||||
SendTime: utils.UnixNanoSecondToTime(msgData.SendTime),
|
||||
SessionType: msgData.SessionType,
|
||||
ContentType: msgData.ContentType,
|
||||
MsgFrom: msgData.MsgFrom,
|
||||
Content: msgData.Content,
|
||||
SenderPlatformID: msgData.PlatformID,
|
||||
}
|
||||
return dbConn.Table("chat_log").Create(chatLog).Error
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package im_mysql_msg_model
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"hash/crc32"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func getHashMsgDBAddr(userID string) string {
|
||||
hCode := crc32.ChecksumIEEE([]byte(userID))
|
||||
return config.Config.Mysql.DBAddress[hCode%uint32(len(config.Config.Mysql.DBAddress))]
|
||||
}
|
||||
|
||||
func getHashMsgTableIndex(userID string) int {
|
||||
hCode := crc32.ChecksumIEEE([]byte(userID))
|
||||
return int(hCode % uint32(config.Config.Mysql.DBMsgTableNum))
|
||||
}
|
||||
|
||||
func QueryUserMsgID(userID string) ([]string, error) {
|
||||
dbAddress, dbTableIndex := getHashMsgDBAddr(userID), getHashMsgTableIndex(userID)
|
||||
dbTableName := "receive" + strconv.Itoa(dbTableIndex)
|
||||
|
||||
dbConn, _ := db.DB.MysqlDB.GormDB(dbAddress, config.Config.Mysql.DBTableName)
|
||||
|
||||
var msgID string
|
||||
var msgIDList []string
|
||||
rows, _ := dbConn.Raw("select msg_id from ? where user_id = ?", dbTableName, userID).Rows()
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
rows.Scan(&msgID)
|
||||
msgIDList = append(msgIDList, msgID)
|
||||
}
|
||||
|
||||
return msgIDList, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/4 11:18).
|
||||
*/
|
||||
package im_mysql_msg_model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Receive Inbox table structure
|
||||
type Receive struct {
|
||||
UserId string `gorm:"primary_key"` // 收件箱主键ID
|
||||
Seq int64 `gorm:"primary_key"` // 收件箱主键ID
|
||||
MsgId string
|
||||
CreateTime *time.Time
|
||||
}
|
||||
|
||||
//func InsertMessageToReceive(seq int64, userid, msgid string) error {
|
||||
// conn := db.NewDbConnection()
|
||||
// receive := Receive{
|
||||
// UID: userid,
|
||||
// Seq: seq,
|
||||
// MsgId: msgid,
|
||||
// }
|
||||
// err := conn.Table("receive").Create(&receive).Error
|
||||
// return err
|
||||
//}
|
||||
//func GetBiggestSeqFromReceive(userid string) (seq int64, err error) {
|
||||
// //得到数据库的连接(并非真连接,调用时才连接,由gorm自动维护数据库连接池)
|
||||
// conn := db.NewDbConnection()
|
||||
// err = conn.Raw("select max(seq) from receive where user_id = ?", userid).Row().Scan(&seq)
|
||||
// return seq, err
|
||||
//}
|
||||
@@ -0,0 +1,106 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq
|
||||
appleDeviceToken = "DEVICE_TOKEN"
|
||||
lastGetSeq = "LAST_GET_SEQ"
|
||||
userMinSeq = "REDIS_USER_MIN_SEQ:"
|
||||
)
|
||||
|
||||
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
|
||||
con := d.redisPool.Get()
|
||||
if err := con.Err(); err != nil {
|
||||
log2.Error("", "", "redis cmd = %v, err = %v", cmd, err)
|
||||
return nil, err
|
||||
}
|
||||
defer con.Close()
|
||||
|
||||
params := make([]interface{}, 0)
|
||||
params = append(params, key)
|
||||
|
||||
if len(args) > 0 {
|
||||
for _, v := range args {
|
||||
params = append(params, v)
|
||||
}
|
||||
}
|
||||
|
||||
return con.Do(cmd, params...)
|
||||
}
|
||||
|
||||
//Perform seq auto-increment operation of user messages
|
||||
func (d *DataBases) IncrUserSeq(uid string) (int64, error) {
|
||||
key := userIncrSeq + uid
|
||||
return redis.Int64(d.Exec("INCR", key))
|
||||
}
|
||||
|
||||
//Get the largest Seq
|
||||
func (d *DataBases) GetUserMaxSeq(uid string) (int64, error) {
|
||||
key := userIncrSeq + uid
|
||||
return redis.Int64(d.Exec("GET", key))
|
||||
}
|
||||
|
||||
//Set the user's minimum seq
|
||||
func (d *DataBases) SetUserMinSeq(uid string, minSeq int64) (err error) {
|
||||
key := userMinSeq + uid
|
||||
_, err = d.Exec("SET", key, minSeq)
|
||||
return err
|
||||
}
|
||||
|
||||
//Get the smallest Seq
|
||||
func (d *DataBases) GetUserMinSeq(uid string) (int64, error) {
|
||||
key := userMinSeq + uid
|
||||
return redis.Int64(d.Exec("GET", key))
|
||||
}
|
||||
|
||||
//Store Apple's device token to redis
|
||||
func (d *DataBases) SetAppleDeviceToken(accountAddress, value string) (err error) {
|
||||
key := appleDeviceToken + accountAddress
|
||||
_, err = d.Exec("SET", key, value)
|
||||
return err
|
||||
}
|
||||
|
||||
//Delete Apple device token
|
||||
func (d *DataBases) DelAppleDeviceToken(accountAddress string) (err error) {
|
||||
key := appleDeviceToken + accountAddress
|
||||
_, err = d.Exec("DEL", key)
|
||||
return err
|
||||
}
|
||||
|
||||
//Record the last time the user actively pulled the value of Seq
|
||||
func (d *DataBases) SetLastGetSeq(uid string) (err error) {
|
||||
key := lastGetSeq + uid
|
||||
_, err = d.Exec("SET", key)
|
||||
return err
|
||||
}
|
||||
|
||||
//Get the value of the user's last active pull Seq
|
||||
func (d *DataBases) GetLastGetSeq(uid string) (int64, error) {
|
||||
key := lastGetSeq + uid
|
||||
return redis.Int64(d.Exec("GET", key))
|
||||
}
|
||||
|
||||
//Store userid and platform class to redis
|
||||
func (d *DataBases) SetUserIDAndPlatform(userID, platformClass, value string, ttl int64) error {
|
||||
key := userID + platformClass
|
||||
_, err := d.Exec("SET", key, value, "EX", ttl)
|
||||
return err
|
||||
}
|
||||
|
||||
//Check exists userid and platform class from redis
|
||||
func (d *DataBases) ExistsUserIDAndPlatform(userID, platformClass string) (interface{}, error) {
|
||||
key := userID + platformClass
|
||||
exists, err := d.Exec("EXISTS", key)
|
||||
return exists, err
|
||||
}
|
||||
|
||||
//Get platform class Token
|
||||
func (d *DataBases) GetPlatformToken(userID, platformClass string) (interface{}, error) {
|
||||
key := userID + platformClass
|
||||
token, err := d.Exec("GET", key)
|
||||
return token, err
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('open-im,www.open-im.io').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/27 10:31).
|
||||
*/
|
||||
package http
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Get(url string) (response []byte, err error) {
|
||||
client := http.Client{Timeout: 5 * time.Second}
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return body, nil
|
||||
}
|
||||
|
||||
//application/json; charset=utf-8
|
||||
func Post(url string, data interface{}, contentType string) (content []byte, err error) {
|
||||
jsonStr, _ := json.Marshal(data)
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Add("content-type", contentType)
|
||||
defer req.Body.Close()
|
||||
|
||||
client := &http.Client{Timeout: 5 * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
result, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package kafka
|
||||
|
||||
import (
|
||||
"github.com/Shopify/sarama"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Consumer struct {
|
||||
addr []string
|
||||
WG sync.WaitGroup
|
||||
Topic string
|
||||
PartitionList []int32
|
||||
Consumer sarama.Consumer
|
||||
}
|
||||
|
||||
func NewKafkaConsumer(addr []string, topic string) *Consumer {
|
||||
p := Consumer{}
|
||||
p.Topic = topic
|
||||
p.addr = addr
|
||||
|
||||
consumer, err := sarama.NewConsumer(p.addr, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil
|
||||
}
|
||||
p.Consumer = consumer
|
||||
|
||||
partitionList, err := consumer.Partitions(p.Topic)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil
|
||||
}
|
||||
p.PartitionList = partitionList
|
||||
|
||||
return &p
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/5/11 9:36).
|
||||
*/
|
||||
package kafka
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/Shopify/sarama"
|
||||
)
|
||||
|
||||
type MConsumerGroup struct {
|
||||
sarama.ConsumerGroup
|
||||
groupID string
|
||||
topics []string
|
||||
}
|
||||
|
||||
type MConsumerGroupConfig struct {
|
||||
KafkaVersion sarama.KafkaVersion
|
||||
OffsetsInitial int64
|
||||
IsReturnErr bool
|
||||
}
|
||||
|
||||
func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addr []string, groupID string) *MConsumerGroup {
|
||||
config := sarama.NewConfig()
|
||||
config.Version = consumerConfig.KafkaVersion
|
||||
config.Consumer.Offsets.Initial = consumerConfig.OffsetsInitial
|
||||
config.Consumer.Return.Errors = consumerConfig.IsReturnErr
|
||||
client, err := sarama.NewClient(addr, config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
consumerGroup, err := sarama.NewConsumerGroupFromClient(groupID, client)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &MConsumerGroup{
|
||||
consumerGroup,
|
||||
groupID,
|
||||
topics,
|
||||
}
|
||||
}
|
||||
func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroupHandler) {
|
||||
ctx := context.Background()
|
||||
for {
|
||||
err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package kafka
|
||||
|
||||
import (
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"github.com/Shopify/sarama"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type Producer struct {
|
||||
topic string
|
||||
addr []string
|
||||
config *sarama.Config
|
||||
producer sarama.SyncProducer
|
||||
}
|
||||
|
||||
func NewKafkaProducer(addr []string, topic string) *Producer {
|
||||
p := Producer{}
|
||||
p.config = sarama.NewConfig() //Instantiate a sarama Config
|
||||
p.config.Producer.Return.Successes = true //Whether to enable the successes channel to be notified after the message is sent successfully
|
||||
p.config.Producer.RequiredAcks = sarama.WaitForAll //Set producer Message Reply level 0 1 all
|
||||
p.config.Producer.Partitioner = sarama.NewHashPartitioner //Set the hash-key automatic hash partition. When sending a message, you must specify the key value of the message. If there is no key, the partition will be selected randomly
|
||||
|
||||
p.addr = addr
|
||||
p.topic = topic
|
||||
|
||||
producer, err := sarama.NewSyncProducer(p.addr, p.config) //Initialize the client
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil
|
||||
}
|
||||
p.producer = producer
|
||||
return &p
|
||||
}
|
||||
|
||||
func (p *Producer) SendMessage(m proto.Message, key ...string) (int32, int64, error) {
|
||||
kMsg := &sarama.ProducerMessage{}
|
||||
kMsg.Topic = p.topic
|
||||
if len(key) == 1 {
|
||||
kMsg.Key = sarama.StringEncoder(key[0])
|
||||
}
|
||||
bMsg, err := proto.Marshal(m)
|
||||
if err != nil {
|
||||
log2.Error("", "", "proto marshal err = %s", err.Error())
|
||||
return -1, -1, err
|
||||
}
|
||||
kMsg.Value = sarama.ByteEncoder(bMsg)
|
||||
|
||||
return p.producer.SendMessage(kMsg)
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
** description("Send logs to elasticsearch hook").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/26 17:05).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"context"
|
||||
"fmt"
|
||||
elasticV7 "github.com/olivere/elastic/v7"
|
||||
"github.com/sirupsen/logrus"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//esHook CUSTOMIZED ES hook
|
||||
type esHook struct {
|
||||
moduleName string
|
||||
client *elasticV7.Client
|
||||
}
|
||||
|
||||
//newEsHook Initialization
|
||||
func newEsHook(moduleName string) *esHook {
|
||||
//https://github.com/sohlich/elogrus
|
||||
//client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))
|
||||
//if err != nil {
|
||||
// log.Panic(err)
|
||||
//}
|
||||
//hook, err := elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
|
||||
//if err != nil {
|
||||
// log.Panic(err)
|
||||
//}
|
||||
es, err := elasticV7.NewClient(
|
||||
elasticV7.SetURL(config.Config.Log.ElasticSearchAddr...),
|
||||
elasticV7.SetBasicAuth(config.Config.Log.ElasticSearchUser, config.Config.Log.ElasticSearchPassword),
|
||||
elasticV7.SetSniff(false),
|
||||
elasticV7.SetHealthcheckInterval(60*time.Second),
|
||||
elasticV7.SetErrorLog(log.New(os.Stderr, "ES:", log.LstdFlags)),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("failed to create Elastic V7 Client: ", err)
|
||||
}
|
||||
|
||||
//info, code, err := es.Ping(logConfig.ElasticSearch.EsAddr[0]).Do(context.Background())
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Printf("Elasticsearch returned with code %d and version %s\n", code, info.Version.Number)
|
||||
//
|
||||
//esversion, err := es.ElasticsearchVersion(logConfig.ElasticSearch.EsAddr[0])
|
||||
//if err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
//fmt.Printf("Elasticsearch version %s\n", esversion)
|
||||
return &esHook{client: es, moduleName: moduleName}
|
||||
}
|
||||
|
||||
//Fire log hook interface 方法
|
||||
func (hook *esHook) Fire(entry *logrus.Entry) error {
|
||||
doc := newEsLog(entry)
|
||||
go hook.sendEs(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
//Levels log hook interface 方法,此hook影响的日志
|
||||
func (hook *esHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
//sendEs 异步发送日志到es
|
||||
func (hook *esHook) sendEs(doc appLogDocModel) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Println("send entry to es failed: ", r)
|
||||
}
|
||||
}()
|
||||
_, err := hook.client.Index().Index(hook.moduleName).Type(doc.indexName()).BodyJson(doc).Do(context.Background())
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//appLogDocModel es model
|
||||
type appLogDocModel map[string]interface{}
|
||||
|
||||
func newEsLog(e *logrus.Entry) appLogDocModel {
|
||||
ins := make(map[string]interface{})
|
||||
ins["level"] = strings.ToUpper(e.Level.String())
|
||||
ins["time"] = e.Time.Format("2006-01-02 15:04:05")
|
||||
for kk, vv := range e.Data {
|
||||
ins[kk] = vv
|
||||
}
|
||||
ins["tipInfo"] = e.Message
|
||||
|
||||
return ins
|
||||
}
|
||||
|
||||
// indexName es index name 时间分割
|
||||
func (m *appLogDocModel) indexName() string {
|
||||
return time.Now().Format("2006-01-02")
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
** description("get the name and line number of the calling file hook").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/3/16 11:26).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type fileHook struct{}
|
||||
|
||||
func newFileHook() *fileHook {
|
||||
return &fileHook{}
|
||||
}
|
||||
|
||||
func (f *fileHook) Levels() []logrus.Level {
|
||||
return logrus.AllLevels
|
||||
}
|
||||
|
||||
func (f *fileHook) Fire(entry *logrus.Entry) error {
|
||||
entry.Data["FilePath"] = findCaller(5)
|
||||
return nil
|
||||
}
|
||||
|
||||
func findCaller(skip int) string {
|
||||
file := ""
|
||||
line := 0
|
||||
for i := 0; i < 10; i++ {
|
||||
file, line = getCaller(skip + i)
|
||||
if !strings.HasPrefix(file, "log") {
|
||||
break
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s:%d", file, line)
|
||||
}
|
||||
|
||||
func getCaller(skip int) (string, int) {
|
||||
_, file, line, ok := runtime.Caller(skip)
|
||||
if !ok {
|
||||
return "", 0
|
||||
}
|
||||
|
||||
n := 0
|
||||
for i := len(file) - 1; i > 0; i-- {
|
||||
if file[i] == '/' {
|
||||
n++
|
||||
if n >= 2 {
|
||||
file = file[i+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return file, line
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"bufio"
|
||||
"fmt"
|
||||
nested "github.com/antonfisher/nested-logrus-formatter"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
"github.com/rifflock/lfshook"
|
||||
"github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
var logger *Logger
|
||||
|
||||
type Logger struct {
|
||||
*logrus.Logger
|
||||
Pid int
|
||||
}
|
||||
|
||||
func init() {
|
||||
logger = loggerInit("")
|
||||
|
||||
}
|
||||
func NewPrivateLog(moduleName string) {
|
||||
logger = loggerInit(moduleName)
|
||||
}
|
||||
|
||||
func loggerInit(moduleName string) *Logger {
|
||||
var logger = logrus.New()
|
||||
//All logs will be printed
|
||||
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
|
||||
//Close std console output
|
||||
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
writer := bufio.NewWriter(src)
|
||||
logger.SetOutput(writer)
|
||||
//Log Console Print Style Setting
|
||||
logger.SetFormatter(&nested.Formatter{
|
||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||
HideKeys: false,
|
||||
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||
})
|
||||
//File name and line number display hook
|
||||
logger.AddHook(newFileHook())
|
||||
|
||||
//Send logs to elasticsearch hook
|
||||
if config.Config.Log.ElasticSearchSwitch {
|
||||
logger.AddHook(newEsHook(moduleName))
|
||||
}
|
||||
//Log file segmentation hook
|
||||
hook := NewLfsHook(time.Duration(config.Config.Log.RotationTime)*time.Hour, config.Config.Log.RemainRotationCount, moduleName)
|
||||
logger.AddHook(hook)
|
||||
return &Logger{
|
||||
logger,
|
||||
os.Getpid(),
|
||||
}
|
||||
}
|
||||
func NewLfsHook(rotationTime time.Duration, maxRemainNum uint, moduleName string) logrus.Hook {
|
||||
lfsHook := lfshook.NewHook(lfshook.WriterMap{
|
||||
logrus.DebugLevel: initRotateLogs(rotationTime, maxRemainNum, "debug", moduleName),
|
||||
logrus.InfoLevel: initRotateLogs(rotationTime, maxRemainNum, "info", moduleName),
|
||||
logrus.WarnLevel: initRotateLogs(rotationTime, maxRemainNum, "warn", moduleName),
|
||||
logrus.ErrorLevel: initRotateLogs(rotationTime, maxRemainNum, "error", moduleName),
|
||||
}, &nested.Formatter{
|
||||
TimestampFormat: "2006-01-02 15:04:05.000",
|
||||
HideKeys: false,
|
||||
FieldsOrder: []string{"PID", "FilePath", "OperationID"},
|
||||
})
|
||||
return lfsHook
|
||||
}
|
||||
func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string, moduleName string) *rotatelogs.RotateLogs {
|
||||
if moduleName != "" {
|
||||
moduleName = moduleName + "."
|
||||
}
|
||||
writer, err := rotatelogs.New(
|
||||
config.Config.Log.StorageLocation+moduleName+level+"."+"%Y-%m-%d",
|
||||
rotatelogs.WithRotationTime(rotationTime),
|
||||
rotatelogs.WithRotationCount(maxRemainNum),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return writer
|
||||
}
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Info(token, OperationID, format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Infof(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Error(token, OperationID, format string, args ...interface{}) {
|
||||
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Errorf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Debug(token, OperationID, format string, args ...interface{}) {
|
||||
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Debugf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func Warning(token, OperationID, format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"PID": logger.Pid,
|
||||
"OperationID": OperationID,
|
||||
}).Warningf(format, args...)
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func InfoByArgs(format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{}).Infof(format, args)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func ErrorByArgs(format string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{}).Errorf(format, args...)
|
||||
}
|
||||
|
||||
//Print log information in k, v format,
|
||||
//kv is best to appear in pairs. tipInfo is the log prompt information for printing,
|
||||
//and kv is the key and value for printing.
|
||||
//Deprecated
|
||||
func InfoByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Info(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func ErrorByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Error(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func DebugByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Debug(tipInfo)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func WarnByKv(tipInfo, OperationID string, args ...interface{}) {
|
||||
fields := make(logrus.Fields)
|
||||
argsHandle(OperationID, fields, args)
|
||||
logger.WithFields(fields).Warn(tipInfo)
|
||||
}
|
||||
|
||||
//internal method
|
||||
func argsHandle(OperationID string, fields logrus.Fields, args []interface{}) {
|
||||
for i := 0; i < len(args); i += 2 {
|
||||
if i+1 < len(args) {
|
||||
fields[fmt.Sprintf("%v", args[i])] = args[i+1]
|
||||
} else {
|
||||
fields[fmt.Sprintf("%v", args[i])] = ""
|
||||
}
|
||||
}
|
||||
fields["OperationID"] = OperationID
|
||||
fields["PID"] = logger.Pid
|
||||
}
|
||||
func NewInfo(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Infoln(args)
|
||||
}
|
||||
func NewError(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Errorln(args)
|
||||
}
|
||||
func NewDebug(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Debugln(args)
|
||||
}
|
||||
func NewWarn(OperationID string, args ...interface{}) {
|
||||
logger.WithFields(logrus.Fields{
|
||||
"OperationID": OperationID,
|
||||
"PID": logger.Pid,
|
||||
}).Warnln(args)
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/2/22 11:52).
|
||||
*/
|
||||
package log
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
TimeOffset = 8 * 3600 //8 hour offset
|
||||
HalfOffset = 12 * 3600 //Half-day hourly offset
|
||||
)
|
||||
|
||||
//Get the current timestamp
|
||||
func GetCurrentTimestamp() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
//Get the current 0 o'clock timestamp
|
||||
func GetCurDayZeroTimestamp() int64 {
|
||||
timeStr := time.Now().Format("2006-01-02")
|
||||
t, _ := time.Parse("2006-01-02", timeStr)
|
||||
return t.Unix() - TimeOffset
|
||||
}
|
||||
|
||||
//Get the timestamp at 12 o'clock on the day
|
||||
func GetCurDayHalfTimestamp() int64 {
|
||||
return GetCurDayZeroTimestamp() + HalfOffset
|
||||
|
||||
}
|
||||
|
||||
//Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
|
||||
func GetCurDayZeroTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp(), 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
|
||||
//Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
|
||||
func GetCurDayHalfTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp()+HalfOffset, 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
func GetTimeStampByFormat(datetime string) string {
|
||||
timeLayout := "2006-01-02 15:04:05" //转化所需模板
|
||||
loc, _ := time.LoadLocation("Local") //获取时区
|
||||
tmp, _ := time.ParseInLocation(timeLayout, datetime, loc)
|
||||
timestamp := tmp.Unix() //转化为时间戳 类型是int64
|
||||
return strconv.FormatInt(timestamp, 10)
|
||||
}
|
||||
|
||||
func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64 {
|
||||
tm, _ := time.Parse(timeFormat, timeSrc)
|
||||
return tm.Unix()
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package multi_terminal_login
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/content_struct"
|
||||
"Open_IM/internal/push/logic"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/utils"
|
||||
)
|
||||
|
||||
func MultiTerminalLoginChecker(uid, token string, platformID int32) error {
|
||||
// 1.check userid and platform class 0 not exists and 1 exists
|
||||
existsInterface, err := db.DB.ExistsUserIDAndPlatform(uid, utils.PlatformNameToClass(utils.PlatformIDToName(platformID)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
exists := existsInterface.(int64)
|
||||
//get config multi login policy
|
||||
if config.Config.MultiLoginPolicy.OnlyOneTerminalAccess {
|
||||
//OnlyOneTerminalAccess policy need to check all terminal
|
||||
if utils.PlatformNameToClass(utils.PlatformIDToName(platformID)) == "PC" {
|
||||
existsInterface, err = db.DB.ExistsUserIDAndPlatform(uid, "Mobile")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
existsInterface, err = db.DB.ExistsUserIDAndPlatform(uid, "PC")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
exists = existsInterface.(int64)
|
||||
if exists == 1 {
|
||||
err := db.DB.SetUserIDAndPlatform(uid, utils.PlatformNameToClass(utils.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PushMessageToTheTerminal(uid, platformID)
|
||||
return nil
|
||||
}
|
||||
} else if config.Config.MultiLoginPolicy.MobileAndPCTerminalAccessButOtherTerminalKickEachOther {
|
||||
// common terminal need to kick eich other
|
||||
if exists == 1 {
|
||||
err := db.DB.SetUserIDAndPlatform(uid, utils.PlatformNameToClass(utils.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PushMessageToTheTerminal(uid, platformID)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
err = db.DB.SetUserIDAndPlatform(uid, utils.PlatformNameToClass(utils.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
PushMessageToTheTerminal(uid, platformID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func PushMessageToTheTerminal(uid string, platform int32) {
|
||||
|
||||
logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
|
||||
SendID: uid,
|
||||
RecvID: uid,
|
||||
Content: content_struct.NewContentStructString(1, "", "Your account is already logged on other terminal,please confirm"),
|
||||
SendTime: utils.GetCurrentTimestampBySecond(),
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.KickOnlineTip,
|
||||
PlatformID: platform,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
// Package grpcpool provides a pool of grpc clients
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrClosed is the error when the client pool is closed
|
||||
ErrClosed = errors.New("grpc pool: client pool is closed")
|
||||
// ErrTimeout is the error when the client pool timed out
|
||||
ErrTimeout = errors.New("grpc pool: client pool timed out")
|
||||
// ErrAlreadyClosed is the error when the client conn was already closed
|
||||
ErrAlreadyClosed = errors.New("grpc pool: the connection was already closed")
|
||||
// ErrFullPool is the error when the pool is already full
|
||||
ErrFullPool = errors.New("grpc pool: closing a ClientConn into a full pool")
|
||||
)
|
||||
|
||||
// Factory is a function type creating a grpc client
|
||||
type Factory func(schema, etcdaddr, servicename string) (*grpc.ClientConn, error)
|
||||
|
||||
// FactoryWithContext is a function type creating a grpc client
|
||||
// that accepts the context parameter that could be passed from
|
||||
// Get or NewWithContext method.
|
||||
type FactoryWithContext func(context.Context) (*grpc.ClientConn, error)
|
||||
|
||||
// Pool is the grpc client pool
|
||||
type Pool struct {
|
||||
clients chan ClientConn
|
||||
factory FactoryWithContext
|
||||
idleTimeout time.Duration
|
||||
maxLifeDuration time.Duration
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// ClientConn is the wrapper for a grpc client conn
|
||||
type ClientConn struct {
|
||||
*grpc.ClientConn
|
||||
pool *Pool
|
||||
timeUsed time.Time
|
||||
timeInitiated time.Time
|
||||
unhealthy bool
|
||||
}
|
||||
|
||||
// New creates a new clients pool with the given initial and maximum capacity,
|
||||
// and the timeout for the idle clients. Returns an error if the initial
|
||||
// clients could not be created
|
||||
func New(factory Factory, schema, etcdaddr, servicename string, init, capacity int, idleTimeout time.Duration,
|
||||
maxLifeDuration ...time.Duration) (*Pool, error) {
|
||||
return NewWithContext(context.Background(), func(ctx context.Context) (*grpc.ClientConn, error) { return factory(schema, etcdaddr, servicename) },
|
||||
init, capacity, idleTimeout, maxLifeDuration...)
|
||||
}
|
||||
|
||||
// NewWithContext creates a new clients pool with the given initial and maximum
|
||||
// capacity, and the timeout for the idle clients. The context parameter would
|
||||
// be passed to the factory method during initialization. Returns an error if the
|
||||
// initial clients could not be created.
|
||||
func NewWithContext(ctx context.Context, factory FactoryWithContext, init, capacity int, idleTimeout time.Duration,
|
||||
maxLifeDuration ...time.Duration) (*Pool, error) {
|
||||
|
||||
if capacity <= 0 {
|
||||
capacity = 1
|
||||
}
|
||||
if init < 0 {
|
||||
init = 0
|
||||
}
|
||||
if init > capacity {
|
||||
init = capacity
|
||||
}
|
||||
p := &Pool{
|
||||
clients: make(chan ClientConn, capacity),
|
||||
factory: factory,
|
||||
idleTimeout: idleTimeout,
|
||||
}
|
||||
if len(maxLifeDuration) > 0 {
|
||||
p.maxLifeDuration = maxLifeDuration[0]
|
||||
}
|
||||
for i := 0; i < init; i++ {
|
||||
c, err := factory(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.clients <- ClientConn{
|
||||
ClientConn: c,
|
||||
pool: p,
|
||||
timeUsed: time.Now(),
|
||||
timeInitiated: time.Now(),
|
||||
}
|
||||
}
|
||||
// Fill the rest of the pool with empty clients
|
||||
for i := 0; i < capacity-init; i++ {
|
||||
p.clients <- ClientConn{
|
||||
pool: p,
|
||||
}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (p *Pool) getClients() chan ClientConn {
|
||||
p.mu.RLock()
|
||||
defer p.mu.RUnlock()
|
||||
|
||||
return p.clients
|
||||
}
|
||||
|
||||
// Close empties the pool calling Close on all its clients.
|
||||
// You can call Close while there are outstanding clients.
|
||||
// The pool channel is then closed, and Get will not be allowed anymore
|
||||
func (p *Pool) Close() {
|
||||
p.mu.Lock()
|
||||
clients := p.clients
|
||||
p.clients = nil
|
||||
p.mu.Unlock()
|
||||
|
||||
if clients == nil {
|
||||
return
|
||||
}
|
||||
|
||||
close(clients)
|
||||
for client := range clients {
|
||||
if client.ClientConn == nil {
|
||||
continue
|
||||
}
|
||||
client.ClientConn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// IsClosed returns true if the client pool is closed.
|
||||
func (p *Pool) IsClosed() bool {
|
||||
return p == nil || p.getClients() == nil
|
||||
}
|
||||
|
||||
// Get will return the next available client. If capacity
|
||||
// has not been reached, it will create a new one using the factory. Otherwise,
|
||||
// it will wait till the next client becomes available or a timeout.
|
||||
// A timeout of 0 is an indefinite wait
|
||||
func (p *Pool) Get(ctx context.Context) (*ClientConn, error) {
|
||||
clients := p.getClients()
|
||||
if clients == nil {
|
||||
return nil, ErrClosed
|
||||
}
|
||||
|
||||
wrapper := ClientConn{
|
||||
pool: p,
|
||||
}
|
||||
select {
|
||||
case wrapper = <-clients:
|
||||
// All good
|
||||
case <-ctx.Done():
|
||||
return nil, ErrTimeout // it would better returns ctx.Err()
|
||||
}
|
||||
|
||||
// If the wrapper was idle too long, close the connection and create a new
|
||||
// one. It's safe to assume that there isn't any newer client as the client
|
||||
// we fetched is the first in the channel
|
||||
idleTimeout := p.idleTimeout
|
||||
if wrapper.ClientConn != nil && idleTimeout > 0 &&
|
||||
wrapper.timeUsed.Add(idleTimeout).Before(time.Now()) {
|
||||
|
||||
wrapper.ClientConn.Close()
|
||||
wrapper.ClientConn = nil
|
||||
}
|
||||
|
||||
var err error
|
||||
if wrapper.ClientConn == nil {
|
||||
wrapper.ClientConn, err = p.factory(ctx)
|
||||
if err != nil {
|
||||
// If there was an error, we want to put back a placeholder
|
||||
// client in the channel
|
||||
clients <- ClientConn{
|
||||
pool: p,
|
||||
}
|
||||
}
|
||||
// This is a new connection, reset its initiated time
|
||||
wrapper.timeInitiated = time.Now()
|
||||
}
|
||||
|
||||
return &wrapper, err
|
||||
}
|
||||
|
||||
// Unhealthy marks the client conn as unhealthy, so that the connection
|
||||
// gets reset when closed
|
||||
func (c *ClientConn) Unhealthy() {
|
||||
c.unhealthy = true
|
||||
}
|
||||
|
||||
// Close returns a ClientConn to the pool. It is safe to call multiple time,
|
||||
// but will return an error after first time
|
||||
func (c *ClientConn) Close() error {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
if c.ClientConn == nil {
|
||||
return ErrAlreadyClosed
|
||||
}
|
||||
if c.pool.IsClosed() {
|
||||
return ErrClosed
|
||||
}
|
||||
// If the wrapper connection has become too old, we want to recycle it. To
|
||||
// clarify the logic: if the sum of the initialization time and the max
|
||||
// duration is before Now(), it means the initialization is so old adding
|
||||
// the maximum duration couldn't put in the future. This sum therefore
|
||||
// corresponds to the cut-off point: if it's in the future we still have
|
||||
// time, if it's in the past it's too old
|
||||
maxDuration := c.pool.maxLifeDuration
|
||||
if maxDuration > 0 && c.timeInitiated.Add(maxDuration).Before(time.Now()) {
|
||||
c.Unhealthy()
|
||||
}
|
||||
|
||||
// We're cloning the wrapper so we can set ClientConn to nil in the one
|
||||
// used by the user
|
||||
wrapper := ClientConn{
|
||||
pool: c.pool,
|
||||
ClientConn: c.ClientConn,
|
||||
timeUsed: time.Now(),
|
||||
}
|
||||
if c.unhealthy {
|
||||
wrapper.ClientConn.Close()
|
||||
wrapper.ClientConn = nil
|
||||
} else {
|
||||
wrapper.timeInitiated = c.timeInitiated
|
||||
}
|
||||
select {
|
||||
case c.pool.clients <- wrapper:
|
||||
// All good
|
||||
default:
|
||||
return ErrFullPool
|
||||
}
|
||||
|
||||
c.ClientConn = nil // Mark as closed
|
||||
return nil
|
||||
}
|
||||
|
||||
// Capacity returns the capacity
|
||||
func (p *Pool) Capacity() int {
|
||||
if p.IsClosed() {
|
||||
return 0
|
||||
}
|
||||
return cap(p.clients)
|
||||
}
|
||||
|
||||
// Available returns the number of currently unused clients
|
||||
func (p *Pool) Available() int {
|
||||
if p.IsClosed() {
|
||||
return 0
|
||||
}
|
||||
return len(p.clients)
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type RegEtcd struct {
|
||||
cli *clientv3.Client
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
key string
|
||||
}
|
||||
|
||||
var rEtcd *RegEtcd
|
||||
|
||||
// "%s:///%s/"
|
||||
func GetPrefix(schema, serviceName string) string {
|
||||
return fmt.Sprintf("%s:///%s/", schema, serviceName)
|
||||
}
|
||||
|
||||
// "%s:///%s"
|
||||
func GetPrefix4Unique(schema, serviceName string) string {
|
||||
return fmt.Sprintf("%s:///%s", schema, serviceName)
|
||||
}
|
||||
|
||||
// "%s:///%s/" -> "%s:///%s:ip:port"
|
||||
func RegisterEtcd4Unique(schema, etcdAddr, myHost string, myPort int, serviceName string, ttl int) error {
|
||||
serviceName = serviceName + ":" + net.JoinHostPort(myHost, strconv.Itoa(myPort))
|
||||
return RegisterEtcd(schema, etcdAddr, myHost, myPort, serviceName, ttl)
|
||||
}
|
||||
|
||||
//etcdAddr separated by commas
|
||||
func RegisterEtcd(schema, etcdAddr, myHost string, myPort int, serviceName string, ttl int) error {
|
||||
cli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: strings.Split(etcdAddr, ","),
|
||||
})
|
||||
fmt.Println("RegisterEtcd")
|
||||
if err != nil {
|
||||
// return fmt.Errorf("grpclb: create clientv3 client failed: %v", err)
|
||||
return fmt.Errorf("create etcd clientv3 client failed, errmsg:%v, etcd addr:%s", err, etcdAddr)
|
||||
}
|
||||
|
||||
//lease
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
resp, err := cli.Grant(ctx, int64(ttl))
|
||||
if err != nil {
|
||||
return fmt.Errorf("grant failed")
|
||||
}
|
||||
|
||||
// schema:///serviceName/ip:port ->ip:port
|
||||
serviceValue := net.JoinHostPort(myHost, strconv.Itoa(myPort))
|
||||
serviceKey := GetPrefix(schema, serviceName) + serviceValue
|
||||
|
||||
//set key->value
|
||||
if _, err := cli.Put(ctx, serviceKey, serviceValue, clientv3.WithLease(resp.ID)); err != nil {
|
||||
return fmt.Errorf("put failed, errmsg:%v, key:%s, value:%s", err, serviceKey, serviceValue)
|
||||
}
|
||||
|
||||
//keepalive
|
||||
kresp, err := cli.KeepAlive(ctx, resp.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("keepalive faild, errmsg:%v, lease id:%d", err, resp.ID)
|
||||
}
|
||||
|
||||
go func() {
|
||||
FLOOP:
|
||||
for {
|
||||
select {
|
||||
case _, ok := <-kresp:
|
||||
if ok == true {
|
||||
} else {
|
||||
break FLOOP
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
rEtcd = &RegEtcd{ctx: ctx,
|
||||
cli: cli,
|
||||
cancel: cancel,
|
||||
key: serviceKey}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func UnRegisterEtcd() {
|
||||
//delete
|
||||
rEtcd.cancel()
|
||||
rEtcd.cli.Delete(rEtcd.ctx, rEtcd.key)
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package getcdv3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go.etcd.io/etcd/clientv3"
|
||||
"go.etcd.io/etcd/mvcc/mvccpb"
|
||||
//"google.golang.org/genproto/googleapis/ads/googleads/v1/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/balancer/roundrobin"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Resolver struct {
|
||||
cc resolver.ClientConn
|
||||
serviceName string
|
||||
grpcClientConn *grpc.ClientConn
|
||||
cli *clientv3.Client
|
||||
schema string
|
||||
etcdAddr string
|
||||
watchStartRevision int64
|
||||
}
|
||||
|
||||
var (
|
||||
nameResolver = make(map[string]*Resolver)
|
||||
rwNameResolverMutex sync.RWMutex
|
||||
)
|
||||
|
||||
func NewResolver(schema, etcdAddr, serviceName string) (*Resolver, error) {
|
||||
etcdCli, err := clientv3.New(clientv3.Config{
|
||||
Endpoints: strings.Split(etcdAddr, ","),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var r Resolver
|
||||
r.serviceName = serviceName
|
||||
r.cli = etcdCli
|
||||
r.schema = schema
|
||||
r.etcdAddr = etcdAddr
|
||||
resolver.Register(&r)
|
||||
|
||||
conn, err := grpc.Dial(
|
||||
GetPrefix(schema, serviceName),
|
||||
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, roundrobin.Name)),
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTimeout(time.Duration(5)*time.Second),
|
||||
)
|
||||
if err == nil {
|
||||
r.grpcClientConn = conn
|
||||
}
|
||||
return &r, err
|
||||
}
|
||||
|
||||
func (r1 *Resolver) ResolveNow(rn resolver.ResolveNowOptions) {
|
||||
}
|
||||
|
||||
func (r1 *Resolver) Close() {
|
||||
}
|
||||
|
||||
func GetConn(schema, etcdaddr, serviceName string) *grpc.ClientConn {
|
||||
rwNameResolverMutex.RLock()
|
||||
r, ok := nameResolver[schema+serviceName]
|
||||
rwNameResolverMutex.RUnlock()
|
||||
if ok {
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
rwNameResolverMutex.Lock()
|
||||
r, ok = nameResolver[schema+serviceName]
|
||||
if ok {
|
||||
rwNameResolverMutex.Unlock()
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
r, err := NewResolver(schema, etcdaddr, serviceName)
|
||||
if err != nil {
|
||||
rwNameResolverMutex.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
nameResolver[schema+serviceName] = r
|
||||
rwNameResolverMutex.Unlock()
|
||||
return r.grpcClientConn
|
||||
}
|
||||
|
||||
func (r *Resolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
|
||||
if r.cli == nil {
|
||||
return nil, fmt.Errorf("etcd clientv3 client failed, etcd:%s", target)
|
||||
}
|
||||
r.cc = cc
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
// "%s:///%s"
|
||||
prefix := GetPrefix(r.schema, r.serviceName)
|
||||
// get key first
|
||||
resp, err := r.cli.Get(ctx, prefix, clientv3.WithPrefix())
|
||||
if err == nil {
|
||||
var addrList []resolver.Address
|
||||
for i := range resp.Kvs {
|
||||
fmt.Println("init addr: ", string(resp.Kvs[i].Value))
|
||||
addrList = append(addrList, resolver.Address{Addr: string(resp.Kvs[i].Value)})
|
||||
}
|
||||
r.cc.UpdateState(resolver.State{Addresses: addrList})
|
||||
r.watchStartRevision = resp.Header.Revision + 1
|
||||
go r.watch(prefix, addrList)
|
||||
} else {
|
||||
return nil, fmt.Errorf("etcd get failed, prefix: %s", prefix)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) Scheme() string {
|
||||
return r.schema
|
||||
}
|
||||
|
||||
func exists(addrList []resolver.Address, addr string) bool {
|
||||
for _, v := range addrList {
|
||||
if v.Addr == addr {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func remove(s []resolver.Address, addr string) ([]resolver.Address, bool) {
|
||||
for i := range s {
|
||||
if s[i].Addr == addr {
|
||||
s[i] = s[len(s)-1]
|
||||
return s[:len(s)-1], true
|
||||
}
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (r *Resolver) watch(prefix string, addrList []resolver.Address) {
|
||||
rch := r.cli.Watch(context.Background(), prefix, clientv3.WithPrefix(), clientv3.WithPrefix())
|
||||
for n := range rch {
|
||||
flag := 0
|
||||
for _, ev := range n.Events {
|
||||
switch ev.Type {
|
||||
case mvccpb.PUT:
|
||||
if !exists(addrList, string(ev.Kv.Value)) {
|
||||
flag = 1
|
||||
addrList = append(addrList, resolver.Address{Addr: string(ev.Kv.Value)})
|
||||
fmt.Println("after add, new list: ", addrList)
|
||||
}
|
||||
case mvccpb.DELETE:
|
||||
fmt.Println("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value))
|
||||
i := strings.LastIndexAny(string(ev.Kv.Key), "/")
|
||||
if i < 0 {
|
||||
return
|
||||
}
|
||||
t := string(ev.Kv.Key)[i+1:]
|
||||
fmt.Println("remove addr key: ", string(ev.Kv.Key), "value:", string(ev.Kv.Value), "addr:", t)
|
||||
if s, ok := remove(addrList, t); ok {
|
||||
flag = 1
|
||||
addrList = s
|
||||
fmt.Println("after remove, new list: ", addrList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if flag == 1 {
|
||||
r.cc.UpdateState(resolver.State{Addresses: addrList})
|
||||
fmt.Println("update: ", addrList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetConn4Unique(schema, etcdaddr, servicename string) []*grpc.ClientConn {
|
||||
gEtcdCli, err := clientv3.New(clientv3.Config{Endpoints: strings.Split(etcdaddr, ",")})
|
||||
if err != nil {
|
||||
fmt.Println("eeeeeeeeeeeee", err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
// "%s:///%s"
|
||||
prefix := GetPrefix4Unique(schema, servicename)
|
||||
|
||||
resp, err := gEtcdCli.Get(ctx, prefix, clientv3.WithPrefix())
|
||||
// "%s:///%s:ip:port" -> %s:ip:port
|
||||
allService := make([]string, 0)
|
||||
if err == nil {
|
||||
for i := range resp.Kvs {
|
||||
k := string(resp.Kvs[i].Key)
|
||||
|
||||
b := strings.LastIndex(k, "///")
|
||||
k1 := k[b+len("///"):]
|
||||
|
||||
e := strings.Index(k1, "/")
|
||||
k2 := k1[:e]
|
||||
allService = append(allService, k2)
|
||||
}
|
||||
} else {
|
||||
gEtcdCli.Close()
|
||||
fmt.Println("rrrrrrrrrrr", err.Error())
|
||||
return nil
|
||||
}
|
||||
gEtcdCli.Close()
|
||||
|
||||
allConn := make([]*grpc.ClientConn, 0)
|
||||
for _, v := range allService {
|
||||
r := GetConn(schema, etcdaddr, v)
|
||||
allConn = append(allConn, r)
|
||||
}
|
||||
|
||||
return allConn
|
||||
}
|
||||
|
||||
var (
|
||||
service2pool = make(map[string]*Pool)
|
||||
service2poolMu sync.Mutex
|
||||
)
|
||||
|
||||
func GetconnFactory(schema, etcdaddr, servicename string) (*grpc.ClientConn, error) {
|
||||
c := GetConn(schema, etcdaddr, servicename)
|
||||
if c != nil {
|
||||
return c, nil
|
||||
} else {
|
||||
return c, fmt.Errorf("GetConn failed")
|
||||
}
|
||||
}
|
||||
|
||||
func GetConnPool(schema, etcdaddr, servicename string) (*ClientConn, error) {
|
||||
//get pool
|
||||
p := NewPool(schema, etcdaddr, servicename)
|
||||
//poo->get
|
||||
|
||||
ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(1000*time.Millisecond))
|
||||
|
||||
c, err := p.Get(ctx)
|
||||
fmt.Println(err)
|
||||
return c, err
|
||||
|
||||
}
|
||||
|
||||
func NewPool(schema, etcdaddr, servicename string) *Pool {
|
||||
|
||||
if _, ok := service2pool[schema+servicename]; !ok {
|
||||
//
|
||||
service2poolMu.Lock()
|
||||
if _, ok1 := service2pool[schema+servicename]; !ok1 {
|
||||
p, err := New(GetconnFactory, schema, etcdaddr, servicename, 5, 10, 1)
|
||||
if err == nil {
|
||||
service2pool[schema+servicename] = p
|
||||
}
|
||||
}
|
||||
service2poolMu.Unlock()
|
||||
}
|
||||
|
||||
return service2pool[schema+servicename]
|
||||
}
|
||||
func GetGrpcConn(schema, etcdaddr, servicename string) *grpc.ClientConn {
|
||||
return nameResolver[schema+servicename].grpcClientConn
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: auth/auth.proto
|
||||
|
||||
package pbAuth // import "./auth"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type UserRegisterReq struct {
|
||||
UID string `protobuf:"bytes,1,opt,name=UID" json:"UID,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=Name" json:"Name,omitempty"`
|
||||
Icon string `protobuf:"bytes,3,opt,name=Icon" json:"Icon,omitempty"`
|
||||
Gender int32 `protobuf:"varint,4,opt,name=Gender" json:"Gender,omitempty"`
|
||||
Mobile string `protobuf:"bytes,5,opt,name=Mobile" json:"Mobile,omitempty"`
|
||||
Birth string `protobuf:"bytes,6,opt,name=Birth" json:"Birth,omitempty"`
|
||||
Email string `protobuf:"bytes,7,opt,name=Email" json:"Email,omitempty"`
|
||||
Ex string `protobuf:"bytes,8,opt,name=Ex" json:"Ex,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) Reset() { *m = UserRegisterReq{} }
|
||||
func (m *UserRegisterReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserRegisterReq) ProtoMessage() {}
|
||||
func (*UserRegisterReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_auth_d2199f7b1388fd2f, []int{0}
|
||||
}
|
||||
func (m *UserRegisterReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserRegisterReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserRegisterReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserRegisterReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserRegisterReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserRegisterReq.Merge(dst, src)
|
||||
}
|
||||
func (m *UserRegisterReq) XXX_Size() int {
|
||||
return xxx_messageInfo_UserRegisterReq.Size(m)
|
||||
}
|
||||
func (m *UserRegisterReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserRegisterReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserRegisterReq proto.InternalMessageInfo
|
||||
|
||||
func (m *UserRegisterReq) GetUID() string {
|
||||
if m != nil {
|
||||
return m.UID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetIcon() string {
|
||||
if m != nil {
|
||||
return m.Icon
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetGender() int32 {
|
||||
if m != nil {
|
||||
return m.Gender
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetMobile() string {
|
||||
if m != nil {
|
||||
return m.Mobile
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetBirth() string {
|
||||
if m != nil {
|
||||
return m.Birth
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetEmail() string {
|
||||
if m != nil {
|
||||
return m.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserRegisterReq) GetEx() string {
|
||||
if m != nil {
|
||||
return m.Ex
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserRegisterResp struct {
|
||||
Success bool `protobuf:"varint,1,opt,name=Success" json:"Success,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserRegisterResp) Reset() { *m = UserRegisterResp{} }
|
||||
func (m *UserRegisterResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserRegisterResp) ProtoMessage() {}
|
||||
func (*UserRegisterResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_auth_d2199f7b1388fd2f, []int{1}
|
||||
}
|
||||
func (m *UserRegisterResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserRegisterResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserRegisterResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserRegisterResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserRegisterResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserRegisterResp.Merge(dst, src)
|
||||
}
|
||||
func (m *UserRegisterResp) XXX_Size() int {
|
||||
return xxx_messageInfo_UserRegisterResp.Size(m)
|
||||
}
|
||||
func (m *UserRegisterResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserRegisterResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserRegisterResp proto.InternalMessageInfo
|
||||
|
||||
func (m *UserRegisterResp) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type UserTokenReq struct {
|
||||
Platform int32 `protobuf:"varint,1,opt,name=Platform" json:"Platform,omitempty"`
|
||||
UID string `protobuf:"bytes,2,opt,name=UID" json:"UID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserTokenReq) Reset() { *m = UserTokenReq{} }
|
||||
func (m *UserTokenReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserTokenReq) ProtoMessage() {}
|
||||
func (*UserTokenReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_auth_d2199f7b1388fd2f, []int{2}
|
||||
}
|
||||
func (m *UserTokenReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserTokenReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserTokenReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserTokenReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserTokenReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserTokenReq.Merge(dst, src)
|
||||
}
|
||||
func (m *UserTokenReq) XXX_Size() int {
|
||||
return xxx_messageInfo_UserTokenReq.Size(m)
|
||||
}
|
||||
func (m *UserTokenReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserTokenReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserTokenReq proto.InternalMessageInfo
|
||||
|
||||
func (m *UserTokenReq) GetPlatform() int32 {
|
||||
if m != nil {
|
||||
return m.Platform
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserTokenReq) GetUID() string {
|
||||
if m != nil {
|
||||
return m.UID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserTokenResp struct {
|
||||
ErrCode int32 `protobuf:"varint,1,opt,name=ErrCode" json:"ErrCode,omitempty"`
|
||||
ErrMsg string `protobuf:"bytes,2,opt,name=ErrMsg" json:"ErrMsg,omitempty"`
|
||||
Token string `protobuf:"bytes,3,opt,name=Token" json:"Token,omitempty"`
|
||||
ExpiredTime int64 `protobuf:"varint,4,opt,name=ExpiredTime" json:"ExpiredTime,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserTokenResp) Reset() { *m = UserTokenResp{} }
|
||||
func (m *UserTokenResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserTokenResp) ProtoMessage() {}
|
||||
func (*UserTokenResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_auth_d2199f7b1388fd2f, []int{3}
|
||||
}
|
||||
func (m *UserTokenResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserTokenResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserTokenResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserTokenResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserTokenResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserTokenResp.Merge(dst, src)
|
||||
}
|
||||
func (m *UserTokenResp) XXX_Size() int {
|
||||
return xxx_messageInfo_UserTokenResp.Size(m)
|
||||
}
|
||||
func (m *UserTokenResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserTokenResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserTokenResp proto.InternalMessageInfo
|
||||
|
||||
func (m *UserTokenResp) GetErrCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserTokenResp) GetErrMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserTokenResp) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserTokenResp) GetExpiredTime() int64 {
|
||||
if m != nil {
|
||||
return m.ExpiredTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*UserRegisterReq)(nil), "pbAuth.UserRegisterReq")
|
||||
proto.RegisterType((*UserRegisterResp)(nil), "pbAuth.UserRegisterResp")
|
||||
proto.RegisterType((*UserTokenReq)(nil), "pbAuth.UserTokenReq")
|
||||
proto.RegisterType((*UserTokenResp)(nil), "pbAuth.UserTokenResp")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for Auth service
|
||||
|
||||
type AuthClient interface {
|
||||
UserRegister(ctx context.Context, in *UserRegisterReq, opts ...grpc.CallOption) (*UserRegisterResp, error)
|
||||
UserToken(ctx context.Context, in *UserTokenReq, opts ...grpc.CallOption) (*UserTokenResp, error)
|
||||
}
|
||||
|
||||
type authClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewAuthClient(cc *grpc.ClientConn) AuthClient {
|
||||
return &authClient{cc}
|
||||
}
|
||||
|
||||
func (c *authClient) UserRegister(ctx context.Context, in *UserRegisterReq, opts ...grpc.CallOption) (*UserRegisterResp, error) {
|
||||
out := new(UserRegisterResp)
|
||||
err := grpc.Invoke(ctx, "/pbAuth.Auth/UserRegister", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authClient) UserToken(ctx context.Context, in *UserTokenReq, opts ...grpc.CallOption) (*UserTokenResp, error) {
|
||||
out := new(UserTokenResp)
|
||||
err := grpc.Invoke(ctx, "/pbAuth.Auth/UserToken", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Auth service
|
||||
|
||||
type AuthServer interface {
|
||||
UserRegister(context.Context, *UserRegisterReq) (*UserRegisterResp, error)
|
||||
UserToken(context.Context, *UserTokenReq) (*UserTokenResp, error)
|
||||
}
|
||||
|
||||
func RegisterAuthServer(s *grpc.Server, srv AuthServer) {
|
||||
s.RegisterService(&_Auth_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Auth_UserRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UserRegisterReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServer).UserRegister(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pbAuth.Auth/UserRegister",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServer).UserRegister(ctx, req.(*UserRegisterReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Auth_UserToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UserTokenReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AuthServer).UserToken(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pbAuth.Auth/UserToken",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthServer).UserToken(ctx, req.(*UserTokenReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Auth_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pbAuth.Auth",
|
||||
HandlerType: (*AuthServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UserRegister",
|
||||
Handler: _Auth_UserRegister_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UserToken",
|
||||
Handler: _Auth_UserToken_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "auth/auth.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("auth/auth.proto", fileDescriptor_auth_d2199f7b1388fd2f) }
|
||||
|
||||
var fileDescriptor_auth_d2199f7b1388fd2f = []byte{
|
||||
// 348 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x41, 0x4f, 0xf2, 0x40,
|
||||
0x10, 0x86, 0xd3, 0x42, 0x0b, 0xcc, 0xf7, 0x21, 0x64, 0x82, 0xba, 0xe1, 0x44, 0x7a, 0xe2, 0x60,
|
||||
0x6a, 0xa2, 0x17, 0x13, 0xbd, 0x80, 0x36, 0x86, 0x03, 0xc6, 0x54, 0xb8, 0x78, 0x2b, 0xb0, 0x42,
|
||||
0x23, 0x65, 0xeb, 0x6e, 0x49, 0xf0, 0xec, 0x8f, 0xf2, 0xef, 0x99, 0x9d, 0xdd, 0x12, 0x34, 0x5c,
|
||||
0xda, 0x79, 0x9f, 0x9d, 0xc9, 0xee, 0x3b, 0x33, 0xd0, 0x4a, 0xb6, 0xc5, 0xea, 0x52, 0x7f, 0xc2,
|
||||
0x5c, 0x8a, 0x42, 0xa0, 0x9f, 0xcf, 0x06, 0xdb, 0x62, 0x15, 0x7c, 0x3b, 0xd0, 0x9a, 0x2a, 0x2e,
|
||||
0x63, 0xbe, 0x4c, 0x55, 0xa1, 0xff, 0x1f, 0xd8, 0x86, 0xca, 0x74, 0xf4, 0xc0, 0x9c, 0x9e, 0xd3,
|
||||
0x6f, 0xc4, 0x3a, 0x44, 0x84, 0xea, 0x53, 0x92, 0x71, 0xe6, 0x12, 0xa2, 0x58, 0xb3, 0xd1, 0x5c,
|
||||
0x6c, 0x58, 0xc5, 0x30, 0x1d, 0xe3, 0x19, 0xf8, 0x8f, 0x7c, 0xb3, 0xe0, 0x92, 0x55, 0x7b, 0x4e,
|
||||
0xdf, 0x8b, 0xad, 0xd2, 0x7c, 0x2c, 0x66, 0xe9, 0x9a, 0x33, 0x8f, 0xb2, 0xad, 0xc2, 0x0e, 0x78,
|
||||
0xc3, 0x54, 0x16, 0x2b, 0xe6, 0x13, 0x36, 0x42, 0xd3, 0x28, 0x4b, 0xd2, 0x35, 0xab, 0x19, 0x4a,
|
||||
0x02, 0x4f, 0xc0, 0x8d, 0x76, 0xac, 0x4e, 0xc8, 0x8d, 0x76, 0xc1, 0x05, 0xb4, 0x7f, 0x3f, 0x5c,
|
||||
0xe5, 0xc8, 0xa0, 0xf6, 0xb2, 0x9d, 0xcf, 0xb9, 0x52, 0xf4, 0xfa, 0x7a, 0x5c, 0xca, 0xe0, 0x0e,
|
||||
0xfe, 0xeb, 0xec, 0x89, 0x78, 0xe7, 0x1b, 0xed, 0xb1, 0x0b, 0xf5, 0xe7, 0x75, 0x52, 0xbc, 0x09,
|
||||
0x99, 0x51, 0xaa, 0x17, 0xef, 0x75, 0xe9, 0xdf, 0xdd, 0xfb, 0x0f, 0x3e, 0xa1, 0x79, 0x50, 0x6d,
|
||||
0x2e, 0x8a, 0xa4, 0xbc, 0x17, 0x0b, 0x6e, 0xab, 0x4b, 0xa9, 0xad, 0x46, 0x52, 0x8e, 0xd5, 0xd2,
|
||||
0xd6, 0x5b, 0xa5, 0x4d, 0x51, 0xb9, 0xed, 0x97, 0x11, 0xd8, 0x83, 0x7f, 0xd1, 0x2e, 0x4f, 0x25,
|
||||
0x5f, 0x4c, 0xd2, 0x8c, 0x53, 0xd7, 0x2a, 0xf1, 0x21, 0xba, 0xfa, 0x72, 0xa0, 0xaa, 0x27, 0x85,
|
||||
0x03, 0xe3, 0xa0, 0xf4, 0x8b, 0xe7, 0xa1, 0x19, 0x61, 0xf8, 0x67, 0x7c, 0x5d, 0x76, 0xfc, 0x40,
|
||||
0xe5, 0x78, 0x03, 0x8d, 0xbd, 0x0d, 0xec, 0x1c, 0xa6, 0x95, 0x7d, 0xe9, 0x9e, 0x1e, 0xa1, 0x2a,
|
||||
0x1f, 0xb6, 0x5e, 0x9b, 0x21, 0xad, 0xcf, 0xad, 0x39, 0x9e, 0xf9, 0xb4, 0x46, 0xd7, 0x3f, 0x01,
|
||||
0x00, 0x00, 0xff, 0xff, 0x15, 0x5d, 0xc8, 0xb6, 0x59, 0x02, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
syntax = "proto3";
|
||||
package pbAuth;
|
||||
option go_package = "./auth;pbAuth";
|
||||
|
||||
message UserRegisterReq {
|
||||
string UID = 1;
|
||||
string Name = 2;
|
||||
string Icon = 3;
|
||||
int32 Gender = 4;
|
||||
string Mobile = 5;
|
||||
string Birth = 6;
|
||||
string Email = 7;
|
||||
string Ex = 8;
|
||||
}
|
||||
|
||||
message UserRegisterResp {
|
||||
bool Success = 1;
|
||||
}
|
||||
|
||||
message UserTokenReq {
|
||||
int32 Platform = 1;
|
||||
string UID = 2;
|
||||
}
|
||||
|
||||
message UserTokenResp {
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
string Token = 3;
|
||||
int64 ExpiredTime = 4;
|
||||
}
|
||||
|
||||
service Auth {
|
||||
rpc UserRegister(UserRegisterReq) returns(UserRegisterResp);
|
||||
rpc UserToken(UserTokenReq) returns(UserTokenResp);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ./proto_dir.cfg
|
||||
|
||||
for ((i = 0; i < ${#all_proto[*]}; i++)); do
|
||||
proto=${all_proto[$i]}
|
||||
protoc --go_out=plugins=grpc:. $proto
|
||||
s=`echo $proto | sed 's/ //g'`
|
||||
v=${s//proto/pb.go}
|
||||
protoc-go-inject-tag -input=./$v
|
||||
echo "protoc --go_out=plugins=grpc:." $proto
|
||||
done
|
||||
echo "proto file generate success..."
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,147 @@
|
||||
syntax = "proto3";
|
||||
package pbChat;//The package name to which the proto file belongs
|
||||
option go_package = "./chat;pbChat";//The generated go pb file is in the current directory, and the package name is pbChat
|
||||
|
||||
message WSToMsgSvrChatMsg{
|
||||
string SendID = 1;
|
||||
string RecvID = 2;
|
||||
string Content = 3;
|
||||
int64 SendTime = 4;
|
||||
int32 MsgFrom = 5;
|
||||
string SenderNickName = 6;
|
||||
string SenderFaceURL = 7;
|
||||
int32 ContentType = 8;
|
||||
int32 SessionType = 9;
|
||||
string OperationID = 10;
|
||||
string MsgID = 11;
|
||||
string Token = 12;
|
||||
string OfflineInfo =13;
|
||||
string Options = 14;
|
||||
int32 PlatformID =15;
|
||||
repeated string ForceList = 16;
|
||||
string ClientMsgID = 17;
|
||||
}
|
||||
|
||||
|
||||
message MsgSvrToPushSvrChatMsg {
|
||||
string SendID = 1;
|
||||
string RecvID = 2;
|
||||
string Content = 3;
|
||||
int64 RecvSeq = 4;
|
||||
int64 SendTime = 5;
|
||||
int32 MsgFrom = 6;
|
||||
string SenderNickName = 7;
|
||||
string SenderFaceURL = 8;
|
||||
int32 ContentType = 9;
|
||||
int32 SessionType = 10;
|
||||
string OperationID = 11;
|
||||
string MsgID = 12;
|
||||
string OfflineInfo = 13;
|
||||
string Options =14;
|
||||
int32 PlatformID =15;
|
||||
string ClientMsgID = 16;
|
||||
|
||||
}
|
||||
|
||||
message PullMessageReq {
|
||||
string UserID = 1;
|
||||
int64 SeqBegin = 2;
|
||||
int64 SeqEnd = 3;
|
||||
string OperationID = 4;
|
||||
}
|
||||
|
||||
message PullMessageResp {
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
int64 MaxSeq = 3;
|
||||
int64 MinSeq = 4;
|
||||
repeated GatherFormat SingleUserMsg = 5;
|
||||
repeated GatherFormat GroupUserMsg = 6;
|
||||
}
|
||||
message PullMessageBySeqListReq{
|
||||
string UserID = 1;
|
||||
string OperationID = 2;
|
||||
repeated int64 seqList =3;
|
||||
}
|
||||
message GetMaxAndMinSeqReq {
|
||||
string UserID = 1;
|
||||
string OperationID = 2;
|
||||
}
|
||||
message GetMaxAndMinSeqResp {
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
int64 MaxSeq = 3;
|
||||
int64 MinSeq = 4;
|
||||
}
|
||||
message GatherFormat{
|
||||
// @inject_tag: json:"id"
|
||||
string ID = 1;
|
||||
// @inject_tag: json:"list"
|
||||
repeated MsgFormat List = 2;//detail msg
|
||||
}
|
||||
message MsgFormat{
|
||||
// @inject_tag: json:"sendID"
|
||||
string SendID = 1;
|
||||
// @inject_tag: json:"recvID"
|
||||
string RecvID = 2;
|
||||
// @inject_tag: json:"msgFrom"
|
||||
int32 MsgFrom = 3;
|
||||
// @inject_tag: json:"contentType"
|
||||
int32 ContentType = 4;
|
||||
// @inject_tag: json:"serverMsgID"
|
||||
string ServerMsgID = 5;
|
||||
// @inject_tag: json:"content"
|
||||
string Content = 6;
|
||||
// @inject_tag: json:"seq"
|
||||
int64 Seq = 7;
|
||||
// @inject_tag: json:"sendTime"
|
||||
int64 SendTime = 8;
|
||||
// @inject_tag: json:"senderPlatformID"
|
||||
int32 SenderPlatformID = 9;
|
||||
// @inject_tag: json:"senderNickName"
|
||||
string SenderNickName = 10;
|
||||
// @inject_tag: json:"senderFaceUrl"
|
||||
string SenderFaceURL = 11;
|
||||
// @inject_tag: json:"clientMsgID"
|
||||
string ClientMsgID = 12;
|
||||
}
|
||||
|
||||
message UserSendMsgReq {
|
||||
|
||||
int32 ReqIdentifier = 1;
|
||||
string Token = 2;
|
||||
string SendID = 3;
|
||||
string OperationID = 4;
|
||||
string SenderNickName = 5;
|
||||
string SenderFaceURL = 6;
|
||||
int32 PlatformID = 7;
|
||||
int32 SessionType = 8;
|
||||
int32 MsgFrom = 9;
|
||||
int32 ContentType = 10;
|
||||
string RecvID = 11;
|
||||
repeated string ForceList = 12;
|
||||
string Content = 13;
|
||||
string Options = 14;
|
||||
string ClientMsgID = 15;
|
||||
string OffLineInfo = 16;
|
||||
string Ex = 17;
|
||||
int64 sendTime = 18;
|
||||
|
||||
|
||||
}
|
||||
|
||||
message UserSendMsgResp {
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
int32 ReqIdentifier = 3;
|
||||
string ServerMsgID = 4;
|
||||
string ClientMsgID = 5;
|
||||
int64 sendTime = 6;
|
||||
|
||||
}
|
||||
service Chat {
|
||||
rpc GetMaxAndMinSeq(GetMaxAndMinSeqReq) returns(GetMaxAndMinSeqResp);
|
||||
rpc PullMessage(PullMessageReq) returns(PullMessageResp);
|
||||
rpc PullMessageBySeqList(PullMessageBySeqListReq) returns(PullMessageResp);
|
||||
rpc UserSendMsg(UserSendMsgReq) returns(UserSendMsgResp);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,183 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./friend;friend";
|
||||
package friend;
|
||||
|
||||
message CommonResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
}
|
||||
|
||||
message GetFriendsInfoReq{
|
||||
string uid = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
}
|
||||
message GetFriendInfoResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
GetFriendData Data = 3;
|
||||
}
|
||||
|
||||
message GetFriendData{
|
||||
string uid = 1;
|
||||
string icon = 2;
|
||||
string name = 3;
|
||||
int32 gender = 4;
|
||||
string mobile = 5;
|
||||
string birth = 6;
|
||||
string email = 7;
|
||||
string ex = 8;
|
||||
string comment = 9;
|
||||
int32 isFriend = 10;
|
||||
int32 isInBlackList = 11;
|
||||
}
|
||||
|
||||
message AddFriendReq{
|
||||
string uid = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
string ReqMessage = 4;
|
||||
}
|
||||
|
||||
|
||||
message ImportFriendReq{
|
||||
repeated string uidList = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
string OwnerUid = 4;
|
||||
}
|
||||
message ImportFriendResp{
|
||||
CommonResp commonResp = 1;
|
||||
repeated string failedUidList = 2;
|
||||
}
|
||||
|
||||
message GetFriendApplyReq{
|
||||
string OperationID = 1;
|
||||
string Token = 2;
|
||||
}
|
||||
message GetFriendApplyResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated ApplyUserInfo data = 4;
|
||||
}
|
||||
|
||||
message ApplyUserInfo{
|
||||
string uid = 1;
|
||||
string name = 2;
|
||||
string icon = 3;
|
||||
int32 gender = 4;
|
||||
string mobile = 5;
|
||||
string birth = 6;
|
||||
string email = 7;
|
||||
string ex = 8;
|
||||
int32 flag = 9;
|
||||
string applyTime = 10;
|
||||
string reqMessage = 11;
|
||||
}
|
||||
|
||||
|
||||
message getFriendListReq{
|
||||
string OperationID = 1;
|
||||
string Token = 2;
|
||||
}
|
||||
message getFriendListResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated UserInfo data = 3;
|
||||
}
|
||||
message UserInfo{
|
||||
string uid = 1;
|
||||
string name = 3;
|
||||
string icon = 2;
|
||||
int32 gender = 4;
|
||||
string mobile = 5;
|
||||
string birth = 6;
|
||||
string email = 7;
|
||||
string ex = 8;
|
||||
string comment = 9;
|
||||
int32 isInBlackList = 10;
|
||||
}
|
||||
|
||||
message AddBlacklistReq{
|
||||
string uid = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
string OwnerUid = 4;
|
||||
}
|
||||
|
||||
|
||||
message RemoveBlacklistReq{
|
||||
string uid = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
}
|
||||
|
||||
|
||||
message GetBlacklistReq{
|
||||
string OperationID = 1;
|
||||
string token = 2;
|
||||
}
|
||||
message GetBlacklistResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated UserInfo data = 3;
|
||||
}
|
||||
|
||||
message IsFriendReq{
|
||||
string token = 1;
|
||||
string receiveUid = 2;
|
||||
string OperationID = 3;
|
||||
}
|
||||
message IsFriendResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
int32 shipType = 3;
|
||||
}
|
||||
message IsInBlackListReq{
|
||||
string sendUid = 1;
|
||||
string receiveUid = 2;
|
||||
string OperationID = 3;
|
||||
}
|
||||
message IsInBlackListResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
bool response = 3;
|
||||
}
|
||||
|
||||
message DeleteFriendReq{
|
||||
string uid = 1;
|
||||
string OperationID = 2;
|
||||
string Token = 3;
|
||||
}
|
||||
|
||||
|
||||
message AddFriendResponseReq{
|
||||
string uid = 1;
|
||||
int32 flag = 2;
|
||||
string OperationID = 3;
|
||||
string Token = 4;
|
||||
}
|
||||
|
||||
message SetFriendCommentReq{
|
||||
string uid = 1;
|
||||
string operationID = 2;
|
||||
string comment = 3;
|
||||
string token = 4;
|
||||
}
|
||||
|
||||
service friend{
|
||||
rpc getFriendsInfo(GetFriendsInfoReq) returns(GetFriendInfoResp);
|
||||
rpc addFriend(AddFriendReq) returns(CommonResp);
|
||||
rpc getFriendApplyList(GetFriendApplyReq) returns(GetFriendApplyResp);
|
||||
rpc getSelfApplyList(GetFriendApplyReq) returns(GetFriendApplyResp);
|
||||
rpc getFriendList(getFriendListReq) returns(getFriendListResp);
|
||||
rpc addBlacklist(AddBlacklistReq) returns(CommonResp);
|
||||
rpc removeBlacklist(RemoveBlacklistReq) returns(CommonResp);
|
||||
rpc isFriend(IsFriendReq) returns(IsFriendResp);
|
||||
rpc isInBlackList(IsInBlackListReq) returns(IsInBlackListResp);
|
||||
rpc getBlacklist(GetBlacklistReq) returns(GetBlacklistResp);
|
||||
rpc deleteFriend(DeleteFriendReq) returns(CommonResp);
|
||||
rpc addFriendResponse(AddFriendResponseReq) returns(CommonResp);
|
||||
rpc setFriendComment(SetFriendCommentReq) returns(CommonResp);
|
||||
rpc ImportFriend(ImportFriendReq) returns(ImportFriendResp);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,291 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./group;group";
|
||||
package group;
|
||||
|
||||
message CommonResp{
|
||||
int32 ErrorCode = 1;
|
||||
string ErrorMsg = 2;
|
||||
}
|
||||
|
||||
message CreateGroupReq{
|
||||
repeated GroupAddMemberInfo memberList = 1;
|
||||
string groupName = 2;
|
||||
string introduction = 3;
|
||||
string notification = 4;
|
||||
string faceUrl = 5;
|
||||
string token = 6;
|
||||
string operationID = 7;
|
||||
string ex = 8;
|
||||
}
|
||||
message GroupAddMemberInfo{
|
||||
string uid = 1;
|
||||
int32 setRole = 2;
|
||||
}
|
||||
message CreateGroupResp{
|
||||
int32 ErrorCode = 1;
|
||||
string ErrorMsg = 2;
|
||||
string groupID = 3;
|
||||
}
|
||||
|
||||
message GetGroupsInfoReq{
|
||||
repeated string groupIDList = 1;
|
||||
string token = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
message GetGroupsInfoResp{
|
||||
int32 ErrorCode = 1;
|
||||
string ErrorMsg = 2;
|
||||
repeated GroupInfo data = 3;
|
||||
}
|
||||
|
||||
message SetGroupInfoReq{
|
||||
string groupID = 1;
|
||||
string groupName = 2;
|
||||
string notification = 3;
|
||||
string introduction = 4;
|
||||
string faceUrl = 5;
|
||||
string token = 6;
|
||||
string operationID = 7;
|
||||
}
|
||||
|
||||
|
||||
message GetGroupApplicationListReq {
|
||||
string UID = 1;
|
||||
string OperationID = 2;
|
||||
}
|
||||
|
||||
message GetGroupApplicationList_Data_User {
|
||||
string ID = 1;
|
||||
string GroupID = 2;
|
||||
string FromUserID = 3;
|
||||
string ToUserID = 4;
|
||||
int32 Flag = 5;
|
||||
string RequestMsg = 6;
|
||||
string HandledMsg = 7;
|
||||
int64 AddTime = 8;
|
||||
string FromUserNickname = 9;
|
||||
string ToUserNickname = 10;
|
||||
string FromUserFaceUrl = 11;
|
||||
string ToUserFaceUrl = 12;
|
||||
string HandledUser = 13;
|
||||
int32 Type = 14;
|
||||
int32 HandleStatus = 15;
|
||||
int32 HandleResult = 16;
|
||||
}
|
||||
|
||||
message GetGroupApplicationListData {
|
||||
int32 Count = 1;
|
||||
repeated GetGroupApplicationList_Data_User User = 2;
|
||||
}
|
||||
|
||||
message GetGroupApplicationListResp {
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
GetGroupApplicationListData Data = 3;
|
||||
}
|
||||
|
||||
message TransferGroupOwnerReq {
|
||||
string GroupID = 1;
|
||||
string OldOwner = 2;
|
||||
string NewOwner = 3;
|
||||
string OperationID = 4;
|
||||
}
|
||||
|
||||
message TransferGroupOwnerResp{
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
}
|
||||
|
||||
message JoinGroupReq{
|
||||
string groupID = 1;
|
||||
string message = 2;
|
||||
string token = 3;
|
||||
string OperationID = 4;
|
||||
}
|
||||
|
||||
message GroupApplicationResponseReq{
|
||||
string OperationID = 1;
|
||||
string OwnerID = 2;
|
||||
string GroupID = 3;
|
||||
string FromUserID = 4;
|
||||
string FromUserNickName = 5;
|
||||
string FromUserFaceUrl = 6;
|
||||
string ToUserID = 7;
|
||||
string ToUserNickName = 8;
|
||||
string ToUserFaceUrl = 9;
|
||||
int64 AddTime = 10;
|
||||
string RequestMsg = 11;
|
||||
string HandledMsg = 12;
|
||||
int32 Type = 13;
|
||||
int32 HandleStatus = 14;
|
||||
int32 HandleResult = 15;
|
||||
}
|
||||
|
||||
message GroupApplicationResponseResp{
|
||||
int32 ErrCode = 1;
|
||||
string ErrMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message SetOwnerGroupNickNameReq{
|
||||
string groupID = 1;
|
||||
string nickName = 2;
|
||||
string OperationID = 3;
|
||||
string token = 4;
|
||||
}
|
||||
|
||||
|
||||
message QuitGroupReq{
|
||||
string groupID = 1;
|
||||
string operationID = 2;
|
||||
string token = 3;
|
||||
}
|
||||
|
||||
|
||||
message GroupApplicationUserInfo{
|
||||
string groupID = 1;
|
||||
string uid = 2;
|
||||
string name = 3;
|
||||
string icon = 4;
|
||||
string reqMsg = 5;
|
||||
int64 applicationTime = 6;
|
||||
int32 flag = 7;
|
||||
string operatorID = 8;
|
||||
string handledMsg = 9;
|
||||
}
|
||||
|
||||
message GroupMemberFullInfo {
|
||||
string userId = 1;
|
||||
int32 role = 2;
|
||||
uint64 joinTime = 3;
|
||||
string nickName = 4;
|
||||
string faceUrl = 5;
|
||||
}
|
||||
|
||||
message GetGroupMemberListReq {
|
||||
string groupID = 1;
|
||||
string token = 2;
|
||||
string operationID = 3;
|
||||
int32 filter = 4;
|
||||
int32 nextSeq = 5;
|
||||
}
|
||||
|
||||
message GetGroupMemberListResp {
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated GroupMemberFullInfo memberList = 3;
|
||||
int32 nextSeq = 4;
|
||||
}
|
||||
|
||||
|
||||
|
||||
message GetGroupMembersInfoReq {
|
||||
string groupID = 1;
|
||||
repeated string memberList = 2;
|
||||
string token = 3;
|
||||
string operationID = 4;
|
||||
}
|
||||
|
||||
message GetGroupMembersInfoResp {
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated GroupMemberFullInfo memberList = 3;
|
||||
|
||||
}
|
||||
|
||||
message KickGroupMemberReq {
|
||||
string groupID = 1;
|
||||
repeated GroupMemberFullInfo uidListInfo = 2;
|
||||
string reason = 3;
|
||||
string token = 4;
|
||||
string operationID = 5;
|
||||
}
|
||||
|
||||
message Id2Result {
|
||||
string uId = 1;
|
||||
int32 result = 2; //0 ok; -1 error
|
||||
}
|
||||
|
||||
message KickGroupMemberResp {
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated Id2Result id2result = 3;
|
||||
}
|
||||
|
||||
|
||||
message getJoinedGroupListReq {
|
||||
string token = 1;
|
||||
string operationID = 2;
|
||||
}
|
||||
|
||||
message GroupInfo {
|
||||
string groupId = 1;
|
||||
string groupName = 2;
|
||||
string notification = 3;
|
||||
string introduction = 4;
|
||||
string faceUrl = 5;
|
||||
uint64 createTime = 6;
|
||||
string ownerId = 7;
|
||||
uint32 memberCount = 8;
|
||||
}
|
||||
|
||||
message getJoinedGroupListResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated GroupInfo groupList = 3;
|
||||
}
|
||||
|
||||
|
||||
message inviteUserToGroupReq {
|
||||
string token = 1;
|
||||
string operationID = 2;
|
||||
string groupID = 3;
|
||||
string reason = 4;
|
||||
repeated string uidList = 5;
|
||||
}
|
||||
|
||||
message inviteUserToGroupResp {
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated Id2Result id2result = 3; // 0 ok, -1 error
|
||||
}
|
||||
|
||||
message GetGroupAllMemberReq {
|
||||
string groupID = 1;
|
||||
string token = 2;
|
||||
string operationID = 3;
|
||||
}
|
||||
|
||||
message GetGroupAllMemberResp {
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated GroupMemberFullInfo memberList = 3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
service group{
|
||||
rpc createGroup(CreateGroupReq) returns(CreateGroupResp);
|
||||
rpc joinGroup(JoinGroupReq) returns(CommonResp);
|
||||
rpc quitGroup(QuitGroupReq) returns(CommonResp);
|
||||
rpc getGroupsInfo(GetGroupsInfoReq) returns(GetGroupsInfoResp);
|
||||
rpc setGroupInfo(SetGroupInfoReq) returns(CommonResp);
|
||||
rpc getGroupApplicationList(GetGroupApplicationListReq) returns(GetGroupApplicationListResp);
|
||||
rpc transferGroupOwner(TransferGroupOwnerReq) returns(TransferGroupOwnerResp);
|
||||
rpc groupApplicationResponse(GroupApplicationResponseReq) returns(GroupApplicationResponseResp);
|
||||
// rpc setOwnerGroupNickName(SetOwnerGroupNickNameReq) returns(CommonResp);
|
||||
rpc getGroupMemberList(GetGroupMemberListReq) returns(GetGroupMemberListResp);
|
||||
rpc getGroupMembersInfo(GetGroupMembersInfoReq) returns(GetGroupMembersInfoResp);
|
||||
rpc kickGroupMember(KickGroupMemberReq) returns (KickGroupMemberResp);
|
||||
rpc getJoinedGroupList(getJoinedGroupListReq) returns (getJoinedGroupListResp);
|
||||
rpc inviteUserToGroup(inviteUserToGroupReq) returns (inviteUserToGroupResp);
|
||||
|
||||
rpc getGroupAllMember(GetGroupAllMemberReq) returns(GetGroupAllMemberResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
all_proto=(
|
||||
auth/auth.proto
|
||||
friend/friend.proto
|
||||
group/group.proto
|
||||
user/user.proto
|
||||
chat/chat.proto
|
||||
push/push.proto
|
||||
relay/relay.proto
|
||||
sdk_ws/ws.proto
|
||||
)
|
||||
@@ -0,0 +1,327 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: push/push.proto
|
||||
|
||||
package pbPush // import "./push"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type PushMsgReq struct {
|
||||
SendID string `protobuf:"bytes,1,opt,name=SendID" json:"SendID,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
Content string `protobuf:"bytes,3,opt,name=Content" json:"Content,omitempty"`
|
||||
RecvSeq int64 `protobuf:"varint,4,opt,name=RecvSeq" json:"RecvSeq,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,5,opt,name=SendTime" json:"SendTime,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,6,opt,name=MsgFrom" json:"MsgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,7,opt,name=ContentType" json:"ContentType,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,8,opt,name=SessionType" json:"SessionType,omitempty"`
|
||||
OperationID string `protobuf:"bytes,9,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
MsgID string `protobuf:"bytes,10,opt,name=MsgID" json:"MsgID,omitempty"`
|
||||
OfflineInfo string `protobuf:"bytes,11,opt,name=OfflineInfo" json:"OfflineInfo,omitempty"`
|
||||
Options string `protobuf:"bytes,12,opt,name=Options" json:"Options,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,13,opt,name=PlatformID" json:"PlatformID,omitempty"`
|
||||
SenderNickName string `protobuf:"bytes,14,opt,name=SenderNickName" json:"SenderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,15,opt,name=SenderFaceURL" json:"SenderFaceURL,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,16,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) Reset() { *m = PushMsgReq{} }
|
||||
func (m *PushMsgReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgReq) ProtoMessage() {}
|
||||
func (*PushMsgReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_4f08d2ff54ba8af2, []int{0}
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PushMsgReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PushMsgReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PushMsgReq.Merge(dst, src)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_Size() int {
|
||||
return xxx_messageInfo_PushMsgReq.Size(m)
|
||||
}
|
||||
func (m *PushMsgReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PushMsgReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PushMsgReq proto.InternalMessageInfo
|
||||
|
||||
func (m *PushMsgReq) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetRecvSeq() int64 {
|
||||
if m != nil {
|
||||
return m.RecvSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetMsgID() string {
|
||||
if m != nil {
|
||||
return m.MsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetOfflineInfo() string {
|
||||
if m != nil {
|
||||
return m.OfflineInfo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetOptions() string {
|
||||
if m != nil {
|
||||
return m.Options
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.PlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PushMsgReq) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type PushMsgResp struct {
|
||||
ResultCode int32 `protobuf:"varint,1,opt,name=ResultCode" json:"ResultCode,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PushMsgResp) Reset() { *m = PushMsgResp{} }
|
||||
func (m *PushMsgResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*PushMsgResp) ProtoMessage() {}
|
||||
func (*PushMsgResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_push_4f08d2ff54ba8af2, []int{1}
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PushMsgResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PushMsgResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PushMsgResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PushMsgResp.Merge(dst, src)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_Size() int {
|
||||
return xxx_messageInfo_PushMsgResp.Size(m)
|
||||
}
|
||||
func (m *PushMsgResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PushMsgResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PushMsgResp proto.InternalMessageInfo
|
||||
|
||||
func (m *PushMsgResp) GetResultCode() int32 {
|
||||
if m != nil {
|
||||
return m.ResultCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PushMsgReq)(nil), "push.PushMsgReq")
|
||||
proto.RegisterType((*PushMsgResp)(nil), "push.PushMsgResp")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for PushMsgService service
|
||||
|
||||
type PushMsgServiceClient interface {
|
||||
PushMsg(ctx context.Context, in *PushMsgReq, opts ...grpc.CallOption) (*PushMsgResp, error)
|
||||
}
|
||||
|
||||
type pushMsgServiceClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewPushMsgServiceClient(cc *grpc.ClientConn) PushMsgServiceClient {
|
||||
return &pushMsgServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *pushMsgServiceClient) PushMsg(ctx context.Context, in *PushMsgReq, opts ...grpc.CallOption) (*PushMsgResp, error) {
|
||||
out := new(PushMsgResp)
|
||||
err := grpc.Invoke(ctx, "/push.PushMsgService/PushMsg", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for PushMsgService service
|
||||
|
||||
type PushMsgServiceServer interface {
|
||||
PushMsg(context.Context, *PushMsgReq) (*PushMsgResp, error)
|
||||
}
|
||||
|
||||
func RegisterPushMsgServiceServer(s *grpc.Server, srv PushMsgServiceServer) {
|
||||
s.RegisterService(&_PushMsgService_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _PushMsgService_PushMsg_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PushMsgReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PushMsgServiceServer).PushMsg(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/push.PushMsgService/PushMsg",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PushMsgServiceServer).PushMsg(ctx, req.(*PushMsgReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _PushMsgService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "push.PushMsgService",
|
||||
HandlerType: (*PushMsgServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "PushMsg",
|
||||
Handler: _PushMsgService_PushMsg_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "push/push.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("push/push.proto", fileDescriptor_push_4f08d2ff54ba8af2) }
|
||||
|
||||
var fileDescriptor_push_4f08d2ff54ba8af2 = []byte{
|
||||
// 378 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x5d, 0xeb, 0xda, 0x30,
|
||||
0x14, 0xc6, 0xe9, 0xb4, 0xbe, 0x1c, 0xe7, 0xcb, 0xc2, 0x18, 0xc1, 0x8b, 0x51, 0x64, 0x0c, 0x6f,
|
||||
0xd6, 0xc1, 0x76, 0xb9, 0x9b, 0x31, 0x8b, 0x50, 0x98, 0x2f, 0xa4, 0xee, 0x66, 0x77, 0xb5, 0x9e,
|
||||
0x6a, 0x59, 0x9b, 0xc4, 0xa6, 0x0a, 0xfb, 0xd2, 0xfb, 0x0c, 0x23, 0x49, 0xd5, 0xfe, 0xbd, 0x29,
|
||||
0x7d, 0x7e, 0xe7, 0x39, 0x87, 0x27, 0xc9, 0x81, 0xb1, 0xbc, 0xa8, 0xd3, 0x67, 0xfd, 0xf1, 0x65,
|
||||
0x29, 0x2a, 0x41, 0xda, 0xfa, 0x7f, 0xf6, 0xaf, 0x05, 0xb0, 0xbd, 0xa8, 0xd3, 0x4a, 0x1d, 0x19,
|
||||
0x9e, 0xc9, 0x3b, 0xe8, 0x44, 0xc8, 0x0f, 0x61, 0x40, 0x1d, 0xcf, 0x99, 0xf7, 0x59, 0xad, 0x34,
|
||||
0x67, 0x98, 0x5c, 0xc3, 0x80, 0xbe, 0xb2, 0xdc, 0x2a, 0x42, 0xa1, 0xbb, 0x10, 0xbc, 0x42, 0x5e,
|
||||
0xd1, 0x96, 0x29, 0xdc, 0xa4, 0xae, 0x68, 0x4f, 0x84, 0x67, 0xda, 0xf6, 0x9c, 0x79, 0x8b, 0xdd,
|
||||
0x24, 0x99, 0x42, 0x4f, 0x4f, 0xdd, 0x65, 0x05, 0x52, 0xd7, 0x94, 0xee, 0x5a, 0x77, 0xad, 0xd4,
|
||||
0x71, 0x59, 0x8a, 0x82, 0x76, 0x3c, 0x67, 0xee, 0xb2, 0x9b, 0x24, 0x1e, 0x0c, 0xea, 0xd1, 0xbb,
|
||||
0xbf, 0x12, 0x69, 0xd7, 0x54, 0x9b, 0x48, 0x3b, 0x22, 0x54, 0x2a, 0x13, 0xdc, 0x38, 0x7a, 0xd6,
|
||||
0xd1, 0x40, 0xda, 0xb1, 0x91, 0x58, 0xc6, 0x55, 0x26, 0x78, 0x18, 0xd0, 0xbe, 0x49, 0xdc, 0x44,
|
||||
0xe4, 0x2d, 0xb8, 0x2b, 0x75, 0x0c, 0x03, 0x0a, 0xa6, 0x66, 0x85, 0xe9, 0x4b, 0xd3, 0x3c, 0xe3,
|
||||
0x18, 0xf2, 0x54, 0xd0, 0x41, 0xdd, 0xf7, 0x40, 0x3a, 0xf7, 0x46, 0xea, 0x19, 0x8a, 0xbe, 0xb6,
|
||||
0xf7, 0x50, 0x4b, 0xf2, 0x1e, 0x60, 0x9b, 0xc7, 0x55, 0x2a, 0xca, 0x22, 0x0c, 0xe8, 0xd0, 0x84,
|
||||
0x6a, 0x10, 0xf2, 0x11, 0x46, 0xfa, 0xf4, 0x58, 0xae, 0xb3, 0xe4, 0xcf, 0x3a, 0x2e, 0x90, 0x8e,
|
||||
0xcc, 0x80, 0x27, 0x4a, 0x3e, 0xc0, 0xd0, 0x92, 0x65, 0x9c, 0xe0, 0x2f, 0xf6, 0x93, 0x8e, 0x8d,
|
||||
0xed, 0x25, 0x34, 0xb7, 0x94, 0x67, 0xc8, 0x2b, 0x7b, 0x8a, 0x89, 0x4d, 0xda, 0x40, 0xb3, 0x4f,
|
||||
0x30, 0xb8, 0xbf, 0xb7, 0x92, 0x3a, 0x1e, 0x43, 0x75, 0xc9, 0xab, 0x85, 0x38, 0xa0, 0x79, 0x74,
|
||||
0x97, 0x35, 0xc8, 0x97, 0xef, 0x30, 0xaa, 0xed, 0x11, 0x96, 0xd7, 0x2c, 0x41, 0xe2, 0x43, 0xb7,
|
||||
0x26, 0x64, 0xe2, 0x9b, 0x7d, 0x7a, 0xec, 0xcf, 0xf4, 0xcd, 0x13, 0x51, 0xf2, 0xc7, 0xf8, 0xf7,
|
||||
0xd0, 0x37, 0x7b, 0xf7, 0x4d, 0xee, 0x35, 0xdf, 0x77, 0xcc, 0xfe, 0x7d, 0xfd, 0x1f, 0x00, 0x00,
|
||||
0xff, 0xff, 0x6b, 0x53, 0xf4, 0xd4, 0x92, 0x02, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./push;pbPush";
|
||||
package push;
|
||||
|
||||
message PushMsgReq {
|
||||
string SendID = 1;
|
||||
string RecvID = 2;
|
||||
string Content = 3;
|
||||
int64 RecvSeq = 4;
|
||||
int64 SendTime = 5;
|
||||
int32 MsgFrom = 6;
|
||||
int32 ContentType = 7;
|
||||
int32 SessionType = 8;
|
||||
string OperationID = 9;
|
||||
string MsgID = 10;
|
||||
string OfflineInfo = 11;
|
||||
string Options =12;
|
||||
int32 PlatformID =13;
|
||||
string SenderNickName = 14;
|
||||
string SenderFaceURL = 15;
|
||||
string ClientMsgID = 16;
|
||||
}
|
||||
message PushMsgResp{
|
||||
int32 ResultCode = 1;
|
||||
}
|
||||
//message InternalPushMsgReq{
|
||||
// int32 ReqIdentifier = 1;
|
||||
// string Token = 2;
|
||||
// string SendID = 3;
|
||||
// string OperationID = 4;
|
||||
// int32 MsgIncr = 5;
|
||||
// int32 PlatformID = 6;
|
||||
// int32 SessionType = 7;
|
||||
// int32 MsgFrom = 8;
|
||||
// int32 ContentType = 9;
|
||||
// string RecvID = 10;
|
||||
// repeated string ForceList = 11;
|
||||
// string Content = 12;
|
||||
// string Options = 13;
|
||||
// string ClientMsgID = 14;
|
||||
// string OffLineInfo = 15;
|
||||
// string Ex = 16;
|
||||
//
|
||||
//}
|
||||
|
||||
service PushMsgService {
|
||||
rpc PushMsg(PushMsgReq) returns(PushMsgResp);
|
||||
// rpc InternalPushMsg(InternalPushMsgReq)returns(PushMsgResp);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: relay/relay.proto
|
||||
|
||||
package pbRelay // import "./relay"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type MsgToUserReq struct {
|
||||
SendID string `protobuf:"bytes,1,opt,name=SendID" json:"SendID,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
Content string `protobuf:"bytes,5,opt,name=Content" json:"Content,omitempty"`
|
||||
RecvSeq int64 `protobuf:"varint,6,opt,name=RecvSeq" json:"RecvSeq,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,7,opt,name=SendTime" json:"SendTime,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,8,opt,name=MsgFrom" json:"MsgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,9,opt,name=ContentType" json:"ContentType,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,10,opt,name=SessionType" json:"SessionType,omitempty"`
|
||||
OperationID string `protobuf:"bytes,11,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
ServerMsgID string `protobuf:"bytes,12,opt,name=ServerMsgID" json:"ServerMsgID,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,13,opt,name=PlatformID" json:"PlatformID,omitempty"`
|
||||
SenderNickName string `protobuf:"bytes,14,opt,name=SenderNickName" json:"SenderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,15,opt,name=SenderFaceURL" json:"SenderFaceURL,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,16,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) Reset() { *m = MsgToUserReq{} }
|
||||
func (m *MsgToUserReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgToUserReq) ProtoMessage() {}
|
||||
func (*MsgToUserReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{0}
|
||||
}
|
||||
func (m *MsgToUserReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgToUserReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgToUserReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgToUserReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgToUserReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgToUserReq.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgToUserReq) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgToUserReq.Size(m)
|
||||
}
|
||||
func (m *MsgToUserReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgToUserReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgToUserReq proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgToUserReq) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetRecvSeq() int64 {
|
||||
if m != nil {
|
||||
return m.RecvSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.PlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgToUserReq) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type MsgToUserResp struct {
|
||||
Resp []*SingleMsgToUser `protobuf:"bytes,1,rep,name=resp" json:"resp,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgToUserResp) Reset() { *m = MsgToUserResp{} }
|
||||
func (m *MsgToUserResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgToUserResp) ProtoMessage() {}
|
||||
func (*MsgToUserResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{1}
|
||||
}
|
||||
func (m *MsgToUserResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgToUserResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgToUserResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgToUserResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgToUserResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgToUserResp.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgToUserResp) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgToUserResp.Size(m)
|
||||
}
|
||||
func (m *MsgToUserResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgToUserResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgToUserResp proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgToUserResp) GetResp() []*SingleMsgToUser {
|
||||
if m != nil {
|
||||
return m.Resp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// message SendMsgByWSReq{
|
||||
// string SendID = 1;
|
||||
// string RecvID = 2;
|
||||
// string Content = 3;
|
||||
// int64 SendTime = 4;
|
||||
// int64 MsgFrom = 5;
|
||||
// int64 ContentType = 6;
|
||||
// int64 SessionType = 7;
|
||||
// string OperationID = 8;
|
||||
// int64 PlatformID = 9;
|
||||
// }
|
||||
type SingleMsgToUser struct {
|
||||
ResultCode int64 `protobuf:"varint,1,opt,name=ResultCode" json:"ResultCode,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
RecvPlatFormID int32 `protobuf:"varint,3,opt,name=RecvPlatFormID" json:"RecvPlatFormID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SingleMsgToUser) Reset() { *m = SingleMsgToUser{} }
|
||||
func (m *SingleMsgToUser) String() string { return proto.CompactTextString(m) }
|
||||
func (*SingleMsgToUser) ProtoMessage() {}
|
||||
func (*SingleMsgToUser) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_relay_ff2396ffa84abfa7, []int{2}
|
||||
}
|
||||
func (m *SingleMsgToUser) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SingleMsgToUser.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SingleMsgToUser) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SingleMsgToUser.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *SingleMsgToUser) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SingleMsgToUser.Merge(dst, src)
|
||||
}
|
||||
func (m *SingleMsgToUser) XXX_Size() int {
|
||||
return xxx_messageInfo_SingleMsgToUser.Size(m)
|
||||
}
|
||||
func (m *SingleMsgToUser) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SingleMsgToUser.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SingleMsgToUser proto.InternalMessageInfo
|
||||
|
||||
func (m *SingleMsgToUser) GetResultCode() int64 {
|
||||
if m != nil {
|
||||
return m.ResultCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SingleMsgToUser) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SingleMsgToUser) GetRecvPlatFormID() int32 {
|
||||
if m != nil {
|
||||
return m.RecvPlatFormID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgToUserReq)(nil), "relay.MsgToUserReq")
|
||||
proto.RegisterType((*MsgToUserResp)(nil), "relay.MsgToUserResp")
|
||||
proto.RegisterType((*SingleMsgToUser)(nil), "relay.SingleMsgToUser")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for OnlineMessageRelayService service
|
||||
|
||||
type OnlineMessageRelayServiceClient interface {
|
||||
MsgToUser(ctx context.Context, in *MsgToUserReq, opts ...grpc.CallOption) (*MsgToUserResp, error)
|
||||
}
|
||||
|
||||
type onlineMessageRelayServiceClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewOnlineMessageRelayServiceClient(cc *grpc.ClientConn) OnlineMessageRelayServiceClient {
|
||||
return &onlineMessageRelayServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *onlineMessageRelayServiceClient) MsgToUser(ctx context.Context, in *MsgToUserReq, opts ...grpc.CallOption) (*MsgToUserResp, error) {
|
||||
out := new(MsgToUserResp)
|
||||
err := grpc.Invoke(ctx, "/relay.OnlineMessageRelayService/MsgToUser", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for OnlineMessageRelayService service
|
||||
|
||||
type OnlineMessageRelayServiceServer interface {
|
||||
MsgToUser(context.Context, *MsgToUserReq) (*MsgToUserResp, error)
|
||||
}
|
||||
|
||||
func RegisterOnlineMessageRelayServiceServer(s *grpc.Server, srv OnlineMessageRelayServiceServer) {
|
||||
s.RegisterService(&_OnlineMessageRelayService_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _OnlineMessageRelayService_MsgToUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MsgToUserReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(OnlineMessageRelayServiceServer).MsgToUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/relay.OnlineMessageRelayService/MsgToUser",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(OnlineMessageRelayServiceServer).MsgToUser(ctx, req.(*MsgToUserReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _OnlineMessageRelayService_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "relay.OnlineMessageRelayService",
|
||||
HandlerType: (*OnlineMessageRelayServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "MsgToUser",
|
||||
Handler: _OnlineMessageRelayService_MsgToUser_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "relay/relay.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("relay/relay.proto", fileDescriptor_relay_ff2396ffa84abfa7) }
|
||||
|
||||
var fileDescriptor_relay_ff2396ffa84abfa7 = []byte{
|
||||
// 414 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x6b, 0xdb, 0x30,
|
||||
0x14, 0xc6, 0xf1, 0xbc, 0xa4, 0xcd, 0x4b, 0x93, 0xac, 0xda, 0x28, 0x5a, 0x0f, 0xc3, 0x84, 0x51,
|
||||
0xc2, 0x0e, 0x19, 0x74, 0xb0, 0x4b, 0x6f, 0xab, 0x09, 0x18, 0xe6, 0x76, 0xc8, 0xe9, 0x65, 0x37,
|
||||
0xd7, 0x7d, 0x33, 0x62, 0xb6, 0xe4, 0x48, 0x5e, 0xa1, 0xff, 0xdd, 0xfe, 0xb4, 0xa1, 0xa7, 0x64,
|
||||
0xd1, 0x32, 0x7a, 0x31, 0xfe, 0x7e, 0xef, 0xf3, 0xf3, 0xa7, 0xa7, 0x07, 0xa7, 0x06, 0x9b, 0xf2,
|
||||
0xe9, 0x23, 0x3d, 0x97, 0x9d, 0xd1, 0xbd, 0x66, 0x03, 0x12, 0xf3, 0xdf, 0x31, 0x9c, 0xe4, 0xb6,
|
||||
0x5e, 0xeb, 0x3b, 0x8b, 0x46, 0xe0, 0x86, 0x9d, 0xc1, 0xb0, 0x40, 0xf5, 0x90, 0xa5, 0x3c, 0x4a,
|
||||
0xa2, 0xc5, 0x48, 0x6c, 0x95, 0xe3, 0x02, 0xab, 0xc7, 0x2c, 0xe5, 0x2f, 0x3c, 0xf7, 0x8a, 0x71,
|
||||
0x38, 0xba, 0xd6, 0xaa, 0x47, 0xd5, 0xf3, 0x01, 0x15, 0x76, 0xd2, 0x55, 0x9c, 0xa7, 0xc0, 0x0d,
|
||||
0x1f, 0x26, 0xd1, 0x22, 0x16, 0x3b, 0xc9, 0xce, 0xe1, 0xd8, 0x75, 0x5d, 0xcb, 0x16, 0xf9, 0x11,
|
||||
0x95, 0xfe, 0x6a, 0xf7, 0x55, 0x6e, 0xeb, 0x95, 0xd1, 0x2d, 0x3f, 0x4e, 0xa2, 0xc5, 0x40, 0xec,
|
||||
0x24, 0x4b, 0x60, 0xbc, 0x6d, 0xbd, 0x7e, 0xea, 0x90, 0x8f, 0xa8, 0x1a, 0x22, 0xe7, 0x28, 0xd0,
|
||||
0x5a, 0xa9, 0x15, 0x39, 0xc0, 0x3b, 0x02, 0xe4, 0x1c, 0xb7, 0x1d, 0x9a, 0xb2, 0x97, 0x5a, 0x65,
|
||||
0x29, 0x1f, 0x53, 0xe2, 0x10, 0xf9, 0x1e, 0xe6, 0x11, 0x4d, 0x6e, 0xeb, 0x2c, 0xe5, 0x27, 0xde,
|
||||
0x11, 0x20, 0xf6, 0x0e, 0xe0, 0x5b, 0x53, 0xf6, 0x3f, 0xb4, 0x69, 0xb3, 0x94, 0x4f, 0xe8, 0x27,
|
||||
0x01, 0x61, 0x17, 0x30, 0x75, 0xa7, 0x41, 0x73, 0x23, 0xab, 0x9f, 0x37, 0x65, 0x8b, 0x7c, 0x4a,
|
||||
0x4d, 0x0e, 0x28, 0x7b, 0x0f, 0x13, 0x4f, 0x56, 0x65, 0x85, 0x77, 0xe2, 0x2b, 0x9f, 0x91, 0xed,
|
||||
0x5f, 0x48, 0xa7, 0x6e, 0x24, 0xaa, 0xde, 0xe7, 0x79, 0xe5, 0xf3, 0x04, 0x68, 0x7e, 0x05, 0x93,
|
||||
0xe0, 0x06, 0x6d, 0xc7, 0x3e, 0xc0, 0x4b, 0x83, 0xb6, 0xe3, 0x51, 0x12, 0x2f, 0xc6, 0x97, 0x67,
|
||||
0x4b, 0x7f, 0xed, 0x85, 0x54, 0x75, 0x83, 0x7b, 0x27, 0x79, 0xe6, 0x1b, 0x98, 0x1d, 0x14, 0xdc,
|
||||
0xf9, 0x04, 0xda, 0x5f, 0x4d, 0x7f, 0xad, 0x1f, 0x90, 0xb6, 0x20, 0x16, 0x01, 0x79, 0x76, 0x13,
|
||||
0x2e, 0x60, 0xea, 0xde, 0xdc, 0x24, 0x56, 0x7e, 0x36, 0x31, 0xcd, 0xe6, 0x80, 0x5e, 0x16, 0xf0,
|
||||
0xf6, 0x56, 0x35, 0x52, 0x61, 0x8e, 0xd6, 0x96, 0x35, 0x0a, 0x17, 0xcf, 0x0d, 0x58, 0x56, 0xc8,
|
||||
0x3e, 0xc3, 0x68, 0x9f, 0xe4, 0xf5, 0x36, 0x7a, 0xb8, 0xa0, 0xe7, 0x6f, 0xfe, 0x87, 0xb6, 0xfb,
|
||||
0x72, 0xfa, 0x7d, 0xb6, 0xf4, 0xfb, 0x7d, 0xd5, 0xdd, 0x53, 0xc7, 0xfb, 0x21, 0x2d, 0xfa, 0xa7,
|
||||
0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x9b, 0x83, 0x12, 0xfd, 0x02, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./relay;pbRelay";
|
||||
package relay;
|
||||
|
||||
message MsgToUserReq {
|
||||
string SendID = 1;
|
||||
string RecvID = 2;
|
||||
string Content = 5;
|
||||
int64 RecvSeq = 6;
|
||||
int64 SendTime = 7;
|
||||
int32 MsgFrom = 8;
|
||||
int32 ContentType = 9;
|
||||
int32 SessionType = 10;
|
||||
string OperationID = 11;
|
||||
string ServerMsgID = 12;
|
||||
int32 PlatformID = 13;
|
||||
string SenderNickName = 14;
|
||||
string SenderFaceURL = 15;
|
||||
string ClientMsgID = 16;
|
||||
}
|
||||
message MsgToUserResp{
|
||||
repeated SingleMsgToUser resp = 1;
|
||||
}
|
||||
//message SendMsgByWSReq{
|
||||
// string SendID = 1;
|
||||
// string RecvID = 2;
|
||||
// string Content = 3;
|
||||
// int64 SendTime = 4;
|
||||
// int64 MsgFrom = 5;
|
||||
// int64 ContentType = 6;
|
||||
// int64 SessionType = 7;
|
||||
// string OperationID = 8;
|
||||
// int64 PlatformID = 9;
|
||||
//}
|
||||
message SingleMsgToUser{
|
||||
int64 ResultCode = 1;
|
||||
string RecvID = 2;
|
||||
int32 RecvPlatFormID = 3;
|
||||
}
|
||||
service OnlineMessageRelayService {
|
||||
rpc MsgToUser(MsgToUserReq) returns(MsgToUserResp);
|
||||
// rpc SendMsgByWS(SendMsgByWSReq) returns(MsgToUserResp);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,753 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: sdk_ws/ws.proto
|
||||
|
||||
package open_im_sdk // import "./sdk_ws"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type PullMessageBySeqListResp struct {
|
||||
MaxSeq int64 `protobuf:"varint,1,opt,name=MaxSeq" json:"MaxSeq,omitempty"`
|
||||
MinSeq int64 `protobuf:"varint,2,opt,name=MinSeq" json:"MinSeq,omitempty"`
|
||||
SingleUserMsg []*GatherFormat `protobuf:"bytes,3,rep,name=SingleUserMsg" json:"SingleUserMsg,omitempty"`
|
||||
GroupUserMsg []*GatherFormat `protobuf:"bytes,4,rep,name=GroupUserMsg" json:"GroupUserMsg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) Reset() { *m = PullMessageBySeqListResp{} }
|
||||
func (m *PullMessageBySeqListResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*PullMessageBySeqListResp) ProtoMessage() {}
|
||||
func (*PullMessageBySeqListResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{0}
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PullMessageBySeqListResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PullMessageBySeqListResp.Merge(dst, src)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_Size() int {
|
||||
return xxx_messageInfo_PullMessageBySeqListResp.Size(m)
|
||||
}
|
||||
func (m *PullMessageBySeqListResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PullMessageBySeqListResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PullMessageBySeqListResp proto.InternalMessageInfo
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetMaxSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MaxSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetMinSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MinSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetSingleUserMsg() []*GatherFormat {
|
||||
if m != nil {
|
||||
return m.SingleUserMsg
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListResp) GetGroupUserMsg() []*GatherFormat {
|
||||
if m != nil {
|
||||
return m.GroupUserMsg
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PullMessageBySeqListReq struct {
|
||||
SeqList []int64 `protobuf:"varint,1,rep,packed,name=seqList" json:"seqList,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PullMessageBySeqListReq) Reset() { *m = PullMessageBySeqListReq{} }
|
||||
func (m *PullMessageBySeqListReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*PullMessageBySeqListReq) ProtoMessage() {}
|
||||
func (*PullMessageBySeqListReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{1}
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *PullMessageBySeqListReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PullMessageBySeqListReq.Merge(dst, src)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_Size() int {
|
||||
return xxx_messageInfo_PullMessageBySeqListReq.Size(m)
|
||||
}
|
||||
func (m *PullMessageBySeqListReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PullMessageBySeqListReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PullMessageBySeqListReq proto.InternalMessageInfo
|
||||
|
||||
func (m *PullMessageBySeqListReq) GetSeqList() []int64 {
|
||||
if m != nil {
|
||||
return m.SeqList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetMaxAndMinSeqReq struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqReq) Reset() { *m = GetMaxAndMinSeqReq{} }
|
||||
func (m *GetMaxAndMinSeqReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetMaxAndMinSeqReq) ProtoMessage() {}
|
||||
func (*GetMaxAndMinSeqReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{2}
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetMaxAndMinSeqReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetMaxAndMinSeqReq.Merge(dst, src)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_Size() int {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqReq.Size(m)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetMaxAndMinSeqReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetMaxAndMinSeqReq proto.InternalMessageInfo
|
||||
|
||||
type GetMaxAndMinSeqResp struct {
|
||||
MaxSeq int64 `protobuf:"varint,1,opt,name=maxSeq" json:"maxSeq,omitempty"`
|
||||
MinSeq int64 `protobuf:"varint,2,opt,name=minSeq" json:"minSeq,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) Reset() { *m = GetMaxAndMinSeqResp{} }
|
||||
func (m *GetMaxAndMinSeqResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetMaxAndMinSeqResp) ProtoMessage() {}
|
||||
func (*GetMaxAndMinSeqResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{3}
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetMaxAndMinSeqResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetMaxAndMinSeqResp.Merge(dst, src)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_Size() int {
|
||||
return xxx_messageInfo_GetMaxAndMinSeqResp.Size(m)
|
||||
}
|
||||
func (m *GetMaxAndMinSeqResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetMaxAndMinSeqResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetMaxAndMinSeqResp proto.InternalMessageInfo
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) GetMaxSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MaxSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *GetMaxAndMinSeqResp) GetMinSeq() int64 {
|
||||
if m != nil {
|
||||
return m.MinSeq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type GatherFormat struct {
|
||||
// @inject_tag: json:"id"
|
||||
ID string `protobuf:"bytes,1,opt,name=ID" json:"id"`
|
||||
// @inject_tag: json:"list"
|
||||
List []*MsgFormat `protobuf:"bytes,2,rep,name=List" json:"list"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GatherFormat) Reset() { *m = GatherFormat{} }
|
||||
func (m *GatherFormat) String() string { return proto.CompactTextString(m) }
|
||||
func (*GatherFormat) ProtoMessage() {}
|
||||
func (*GatherFormat) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{4}
|
||||
}
|
||||
func (m *GatherFormat) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GatherFormat.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GatherFormat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GatherFormat.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GatherFormat) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GatherFormat.Merge(dst, src)
|
||||
}
|
||||
func (m *GatherFormat) XXX_Size() int {
|
||||
return xxx_messageInfo_GatherFormat.Size(m)
|
||||
}
|
||||
func (m *GatherFormat) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GatherFormat.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GatherFormat proto.InternalMessageInfo
|
||||
|
||||
func (m *GatherFormat) GetID() string {
|
||||
if m != nil {
|
||||
return m.ID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GatherFormat) GetList() []*MsgFormat {
|
||||
if m != nil {
|
||||
return m.List
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MsgFormat struct {
|
||||
// @inject_tag: json:"sendID"
|
||||
SendID string `protobuf:"bytes,1,opt,name=SendID" json:"sendID"`
|
||||
// @inject_tag: json:"recvID"
|
||||
RecvID string `protobuf:"bytes,2,opt,name=RecvID" json:"recvID"`
|
||||
// @inject_tag: json:"msgFrom"
|
||||
MsgFrom int32 `protobuf:"varint,3,opt,name=MsgFrom" json:"msgFrom"`
|
||||
// @inject_tag: json:"contentType"
|
||||
ContentType int32 `protobuf:"varint,4,opt,name=ContentType" json:"contentType"`
|
||||
// @inject_tag: json:"serverMsgID"
|
||||
ServerMsgID string `protobuf:"bytes,5,opt,name=ServerMsgID" json:"serverMsgID"`
|
||||
// @inject_tag: json:"content"
|
||||
Content string `protobuf:"bytes,6,opt,name=Content" json:"content"`
|
||||
// @inject_tag: json:"seq"
|
||||
Seq int64 `protobuf:"varint,7,opt,name=Seq" json:"seq"`
|
||||
// @inject_tag: json:"sendTime"
|
||||
SendTime int64 `protobuf:"varint,8,opt,name=SendTime" json:"sendTime"`
|
||||
// @inject_tag: json:"senderPlatformID"
|
||||
SenderPlatformID int32 `protobuf:"varint,9,opt,name=SenderPlatformID" json:"senderPlatformID"`
|
||||
// @inject_tag: json:"senderNickName"
|
||||
SenderNickName string `protobuf:"bytes,10,opt,name=SenderNickName" json:"senderNickName"`
|
||||
// @inject_tag: json:"senderFaceUrl"
|
||||
SenderFaceURL string `protobuf:"bytes,11,opt,name=SenderFaceURL" json:"senderFaceUrl"`
|
||||
// @inject_tag: json:"clientMsgID"
|
||||
ClientMsgID string `protobuf:"bytes,12,opt,name=ClientMsgID" json:"clientMsgID"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgFormat) Reset() { *m = MsgFormat{} }
|
||||
func (m *MsgFormat) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgFormat) ProtoMessage() {}
|
||||
func (*MsgFormat) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{5}
|
||||
}
|
||||
func (m *MsgFormat) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgFormat.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgFormat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgFormat.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgFormat) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgFormat.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgFormat) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgFormat.Size(m)
|
||||
}
|
||||
func (m *MsgFormat) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgFormat.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgFormat proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgFormat) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSeq() int64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.SenderPlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgFormat) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserSendMsgReq struct {
|
||||
Options map[string]int32 `protobuf:"bytes,1,rep,name=Options" json:"Options,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
SenderNickName string `protobuf:"bytes,2,opt,name=SenderNickName" json:"SenderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,3,opt,name=SenderFaceURL" json:"SenderFaceURL,omitempty"`
|
||||
PlatformID int32 `protobuf:"varint,4,opt,name=PlatformID" json:"PlatformID,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,5,opt,name=SessionType" json:"SessionType,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,6,opt,name=MsgFrom" json:"MsgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,7,opt,name=ContentType" json:"ContentType,omitempty"`
|
||||
RecvID string `protobuf:"bytes,8,opt,name=RecvID" json:"RecvID,omitempty"`
|
||||
ForceList []string `protobuf:"bytes,9,rep,name=ForceList" json:"ForceList,omitempty"`
|
||||
Content string `protobuf:"bytes,10,opt,name=Content" json:"Content,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,11,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) Reset() { *m = UserSendMsgReq{} }
|
||||
func (m *UserSendMsgReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserSendMsgReq) ProtoMessage() {}
|
||||
func (*UserSendMsgReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{6}
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserSendMsgReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserSendMsgReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserSendMsgReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserSendMsgReq.Merge(dst, src)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_Size() int {
|
||||
return xxx_messageInfo_UserSendMsgReq.Size(m)
|
||||
}
|
||||
func (m *UserSendMsgReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserSendMsgReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserSendMsgReq proto.InternalMessageInfo
|
||||
|
||||
func (m *UserSendMsgReq) GetOptions() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.Options
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.PlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetForceList() []string {
|
||||
if m != nil {
|
||||
return m.ForceList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgReq) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UserSendMsgResp struct {
|
||||
ServerMsgID string `protobuf:"bytes,1,opt,name=ServerMsgID" json:"ServerMsgID,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,2,opt,name=ClientMsgID" json:"ClientMsgID,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,3,opt,name=sendTime" json:"sendTime,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) Reset() { *m = UserSendMsgResp{} }
|
||||
func (m *UserSendMsgResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserSendMsgResp) ProtoMessage() {}
|
||||
func (*UserSendMsgResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{7}
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserSendMsgResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserSendMsgResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserSendMsgResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserSendMsgResp.Merge(dst, src)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_Size() int {
|
||||
return xxx_messageInfo_UserSendMsgResp.Size(m)
|
||||
}
|
||||
func (m *UserSendMsgResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserSendMsgResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserSendMsgResp proto.InternalMessageInfo
|
||||
|
||||
func (m *UserSendMsgResp) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserSendMsgResp) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MsgData struct {
|
||||
SendID string `protobuf:"bytes,1,opt,name=sendID" json:"sendID,omitempty"`
|
||||
RecvID string `protobuf:"bytes,2,opt,name=recvID" json:"recvID,omitempty"`
|
||||
SessionType int32 `protobuf:"varint,3,opt,name=sessionType" json:"sessionType,omitempty"`
|
||||
MsgFrom int32 `protobuf:"varint,4,opt,name=msgFrom" json:"msgFrom,omitempty"`
|
||||
ContentType int32 `protobuf:"varint,5,opt,name=contentType" json:"contentType,omitempty"`
|
||||
ServerMsgID string `protobuf:"bytes,6,opt,name=serverMsgID" json:"serverMsgID,omitempty"`
|
||||
Content string `protobuf:"bytes,7,opt,name=content" json:"content,omitempty"`
|
||||
SendTime int64 `protobuf:"varint,8,opt,name=sendTime" json:"sendTime,omitempty"`
|
||||
Seq int64 `protobuf:"varint,9,opt,name=seq" json:"seq,omitempty"`
|
||||
SenderPlatformID int32 `protobuf:"varint,10,opt,name=senderPlatformID" json:"senderPlatformID,omitempty"`
|
||||
SenderNickName string `protobuf:"bytes,11,opt,name=senderNickName" json:"senderNickName,omitempty"`
|
||||
SenderFaceURL string `protobuf:"bytes,12,opt,name=senderFaceURL" json:"senderFaceURL,omitempty"`
|
||||
ClientMsgID string `protobuf:"bytes,13,opt,name=clientMsgID" json:"clientMsgID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *MsgData) Reset() { *m = MsgData{} }
|
||||
func (m *MsgData) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgData) ProtoMessage() {}
|
||||
func (*MsgData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_ws_f143de4f947df40f, []int{8}
|
||||
}
|
||||
func (m *MsgData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_MsgData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *MsgData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_MsgData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *MsgData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgData.Merge(dst, src)
|
||||
}
|
||||
func (m *MsgData) XXX_Size() int {
|
||||
return xxx_messageInfo_MsgData.Size(m)
|
||||
}
|
||||
func (m *MsgData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgData proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgData) GetSendID() string {
|
||||
if m != nil {
|
||||
return m.SendID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetRecvID() string {
|
||||
if m != nil {
|
||||
return m.RecvID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSessionType() int32 {
|
||||
if m != nil {
|
||||
return m.SessionType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetMsgFrom() int32 {
|
||||
if m != nil {
|
||||
return m.MsgFrom
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetContentType() int32 {
|
||||
if m != nil {
|
||||
return m.ContentType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetServerMsgID() string {
|
||||
if m != nil {
|
||||
return m.ServerMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSendTime() int64 {
|
||||
if m != nil {
|
||||
return m.SendTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSeq() int64 {
|
||||
if m != nil {
|
||||
return m.Seq
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderPlatformID() int32 {
|
||||
if m != nil {
|
||||
return m.SenderPlatformID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderNickName() string {
|
||||
if m != nil {
|
||||
return m.SenderNickName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetSenderFaceURL() string {
|
||||
if m != nil {
|
||||
return m.SenderFaceURL
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MsgData) GetClientMsgID() string {
|
||||
if m != nil {
|
||||
return m.ClientMsgID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*PullMessageBySeqListResp)(nil), "open_im_sdk.PullMessageBySeqListResp")
|
||||
proto.RegisterType((*PullMessageBySeqListReq)(nil), "open_im_sdk.PullMessageBySeqListReq")
|
||||
proto.RegisterType((*GetMaxAndMinSeqReq)(nil), "open_im_sdk.GetMaxAndMinSeqReq")
|
||||
proto.RegisterType((*GetMaxAndMinSeqResp)(nil), "open_im_sdk.GetMaxAndMinSeqResp")
|
||||
proto.RegisterType((*GatherFormat)(nil), "open_im_sdk.GatherFormat")
|
||||
proto.RegisterType((*MsgFormat)(nil), "open_im_sdk.MsgFormat")
|
||||
proto.RegisterType((*UserSendMsgReq)(nil), "open_im_sdk.UserSendMsgReq")
|
||||
proto.RegisterMapType((map[string]int32)(nil), "open_im_sdk.UserSendMsgReq.OptionsEntry")
|
||||
proto.RegisterType((*UserSendMsgResp)(nil), "open_im_sdk.UserSendMsgResp")
|
||||
proto.RegisterType((*MsgData)(nil), "open_im_sdk.MsgData")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("sdk_ws/ws.proto", fileDescriptor_ws_f143de4f947df40f) }
|
||||
|
||||
var fileDescriptor_ws_f143de4f947df40f = []byte{
|
||||
// 739 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4b, 0x6b, 0xdb, 0x4a,
|
||||
0x14, 0x46, 0x52, 0xfc, 0xd0, 0xb1, 0xf3, 0x60, 0x6e, 0xc8, 0xd5, 0x0d, 0x97, 0x8b, 0x11, 0x97,
|
||||
0x62, 0xb2, 0x70, 0x20, 0xd9, 0x94, 0x94, 0x52, 0x9a, 0x3a, 0x09, 0x2e, 0x71, 0x1a, 0xc6, 0xc9,
|
||||
0xa6, 0x9b, 0xa0, 0xda, 0x53, 0x57, 0xd8, 0x7a, 0x58, 0x47, 0x79, 0xf8, 0xc7, 0xf4, 0x0f, 0x75,
|
||||
0xd1, 0x7f, 0x54, 0x28, 0x67, 0x46, 0x72, 0x66, 0x6c, 0xd3, 0x76, 0x37, 0xe7, 0xd3, 0x9c, 0x99,
|
||||
0x39, 0xdf, 0x03, 0xc1, 0x36, 0x8e, 0x26, 0x77, 0x8f, 0x78, 0xf8, 0x88, 0x9d, 0x34, 0x4b, 0xf2,
|
||||
0x84, 0x35, 0x92, 0x54, 0xc4, 0x77, 0x61, 0x74, 0x87, 0xa3, 0x89, 0xff, 0xcd, 0x02, 0xef, 0xfa,
|
||||
0x7e, 0x3a, 0xed, 0x0b, 0xc4, 0x60, 0x2c, 0x4e, 0xe7, 0x03, 0x31, 0xbb, 0x0c, 0x31, 0xe7, 0x02,
|
||||
0x53, 0xb6, 0x07, 0xd5, 0x7e, 0xf0, 0x34, 0x10, 0x33, 0xcf, 0x6a, 0x59, 0x6d, 0x87, 0x17, 0x95,
|
||||
0xc4, 0xc3, 0x98, 0x70, 0xbb, 0xc0, 0x65, 0xc5, 0xde, 0xc0, 0xe6, 0x20, 0x8c, 0xc7, 0x53, 0x71,
|
||||
0x8b, 0x22, 0xeb, 0xe3, 0xd8, 0x73, 0x5a, 0x4e, 0xbb, 0x71, 0xf4, 0x4f, 0x47, 0xbb, 0xb1, 0x73,
|
||||
0x11, 0xe4, 0x5f, 0x44, 0x76, 0x9e, 0x64, 0x51, 0x90, 0x73, 0x73, 0x3f, 0x7b, 0x0d, 0xcd, 0x8b,
|
||||
0x2c, 0xb9, 0x4f, 0xcb, 0xfe, 0x8d, 0xdf, 0xf5, 0x1b, 0xdb, 0xfd, 0x63, 0xf8, 0x7b, 0xfd, 0x2c,
|
||||
0x33, 0xe6, 0x41, 0x0d, 0x55, 0xe5, 0x59, 0x2d, 0xa7, 0xed, 0xf0, 0xb2, 0xf4, 0x77, 0x81, 0x5d,
|
||||
0x88, 0xbc, 0x1f, 0x3c, 0xbd, 0x8d, 0x47, 0x6a, 0x0e, 0x2e, 0x66, 0xfe, 0x19, 0xfc, 0xb5, 0x82,
|
||||
0x2a, 0x46, 0x22, 0x83, 0x91, 0x68, 0xc1, 0x48, 0x64, 0x30, 0xa2, 0x2a, 0xff, 0x3d, 0x34, 0xf5,
|
||||
0xf7, 0xb2, 0x2d, 0xb0, 0x7b, 0x5d, 0xd9, 0xeb, 0x72, 0xbb, 0xd7, 0x65, 0x07, 0xb0, 0x21, 0xdf,
|
||||
0x64, 0xcb, 0x41, 0xf7, 0x8c, 0x41, 0xfb, 0x38, 0x2e, 0xa6, 0x94, 0x7b, 0xfc, 0x1f, 0x36, 0xb8,
|
||||
0x0b, 0x8c, 0x6e, 0x1c, 0x88, 0x78, 0xb4, 0x38, 0xad, 0xa8, 0x08, 0xe7, 0x62, 0xf8, 0xd0, 0xeb,
|
||||
0xca, 0x97, 0xb8, 0xbc, 0xa8, 0x88, 0x00, 0x6a, 0xce, 0x92, 0xc8, 0x73, 0x5a, 0x56, 0xbb, 0xc2,
|
||||
0xcb, 0x92, 0xb5, 0xa0, 0xf1, 0x2e, 0x89, 0x73, 0x11, 0xe7, 0x37, 0xf3, 0x54, 0x78, 0x1b, 0xf2,
|
||||
0xab, 0x0e, 0xd1, 0x8e, 0x81, 0xc8, 0x1e, 0x24, 0xc9, 0xbd, 0xae, 0x57, 0x91, 0x07, 0xeb, 0x10,
|
||||
0x9d, 0x5e, 0x34, 0x78, 0x55, 0xf9, 0xb5, 0x2c, 0xd9, 0x0e, 0x38, 0x44, 0x4b, 0x4d, 0xd2, 0x42,
|
||||
0x4b, 0xb6, 0x0f, 0x75, 0x7a, 0xeb, 0x4d, 0x18, 0x09, 0xaf, 0x2e, 0xe1, 0x45, 0xcd, 0x0e, 0x60,
|
||||
0x87, 0xd6, 0x22, 0xbb, 0x9e, 0x06, 0xf9, 0xe7, 0x24, 0x8b, 0x7a, 0x5d, 0xcf, 0x95, 0x0f, 0x5a,
|
||||
0xc1, 0xd9, 0x0b, 0xd8, 0x52, 0xd8, 0x55, 0x38, 0x9c, 0x5c, 0x05, 0x91, 0xf0, 0x40, 0x5e, 0xbd,
|
||||
0x84, 0xb2, 0xff, 0x61, 0x53, 0x21, 0xe7, 0xc1, 0x50, 0xdc, 0xf2, 0x4b, 0xaf, 0x21, 0xb7, 0x99,
|
||||
0xa0, 0x64, 0x61, 0x1a, 0x8a, 0x38, 0x57, 0x33, 0x36, 0xd5, 0x8c, 0x1a, 0xe4, 0x7f, 0x77, 0x60,
|
||||
0x8b, 0x9c, 0x46, 0x7d, 0x7d, 0x1c, 0x93, 0xab, 0x4e, 0xa1, 0xf6, 0x21, 0xcd, 0xc3, 0x24, 0x46,
|
||||
0xe9, 0xaa, 0xc6, 0x51, 0xdb, 0x50, 0xd0, 0xdc, 0xdd, 0x29, 0xb6, 0x9e, 0xc5, 0x79, 0x36, 0xe7,
|
||||
0x65, 0xe3, 0x9a, 0x31, 0xec, 0x3f, 0x1b, 0xc3, 0x59, 0x37, 0xc6, 0x7f, 0x00, 0x1a, 0x75, 0x4a,
|
||||
0x4b, 0x0d, 0x51, 0x52, 0x22, 0x86, 0x49, 0x2c, 0xc5, 0xae, 0x28, 0xb1, 0x35, 0x48, 0x37, 0x4a,
|
||||
0xf5, 0x97, 0x46, 0xa9, 0xad, 0x1a, 0xe5, 0xd9, 0x7c, 0x75, 0xc3, 0x7c, 0xff, 0x82, 0x7b, 0x9e,
|
||||
0x64, 0x43, 0x21, 0xbd, 0xee, 0xb6, 0x9c, 0xb6, 0xcb, 0x9f, 0x01, 0xdd, 0x3c, 0x60, 0x9a, 0x67,
|
||||
0x49, 0x94, 0xc6, 0x8a, 0x28, 0xfb, 0x27, 0xd0, 0xd4, 0x69, 0x25, 0xbb, 0x4d, 0xc4, 0xbc, 0xc8,
|
||||
0x04, 0x2d, 0xd9, 0x2e, 0x54, 0x1e, 0x82, 0xe9, 0xbd, 0xa2, 0xb5, 0xc2, 0x55, 0x71, 0x62, 0xbf,
|
||||
0xb4, 0xfc, 0x19, 0x6c, 0x1b, 0x0a, 0x61, 0xba, 0xec, 0x74, 0x6b, 0xd5, 0xe9, 0x4b, 0x4f, 0xb2,
|
||||
0x57, 0x9e, 0x44, 0xfe, 0xc6, 0xd2, 0xdf, 0x8e, 0xf2, 0x77, 0x59, 0xfb, 0x5f, 0x1d, 0xc9, 0x6e,
|
||||
0x37, 0xc8, 0x03, 0x22, 0x0b, 0x8d, 0x04, 0xe3, 0x22, 0xc1, 0x99, 0x91, 0x60, 0x55, 0xd1, 0xcd,
|
||||
0xa8, 0x49, 0xa7, 0x52, 0xac, 0x43, 0x44, 0x64, 0x54, 0x48, 0xa7, 0x94, 0x2f, 0x4b, 0xea, 0x1d,
|
||||
0x6a, 0xd2, 0x15, 0xb2, 0x0f, 0xcd, 0x8c, 0xa3, 0x36, 0xb9, 0x4a, 0xb1, 0x0e, 0xd1, 0xe9, 0x45,
|
||||
0x83, 0x94, 0xde, 0xe5, 0x65, 0x69, 0x4c, 0x5c, 0x37, 0x27, 0x26, 0x41, 0x50, 0xcc, 0x64, 0x88,
|
||||
0x1d, 0x4e, 0x4b, 0xca, 0x38, 0x2e, 0x67, 0x1c, 0x54, 0xc6, 0x71, 0x4d, 0xc6, 0xd1, 0x0c, 0x87,
|
||||
0xf2, 0xc0, 0x12, 0x4a, 0xe1, 0x40, 0x23, 0x1c, 0x2a, 0xbf, 0x26, 0x28, 0x59, 0xd0, 0xb4, 0xdb,
|
||||
0x54, 0x33, 0x6a, 0xd0, 0xe9, 0xde, 0xc7, 0xdd, 0xce, 0xa1, 0xfa, 0x61, 0xbe, 0xd2, 0x92, 0xfc,
|
||||
0xa9, 0x2a, 0x7f, 0x9d, 0xc7, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x38, 0x51, 0xff, 0xb4, 0x4d,
|
||||
0x07, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
syntax = "proto3";
|
||||
package open_im_sdk;//The package name to which the proto file belongs
|
||||
option go_package = "./sdk_ws;open_im_sdk";//The generated go pb file is in the current directory, and the package name is open_im_sdk
|
||||
|
||||
|
||||
message PullMessageBySeqListResp {
|
||||
int64 MaxSeq = 1;
|
||||
int64 MinSeq = 2;
|
||||
repeated GatherFormat SingleUserMsg = 3;
|
||||
repeated GatherFormat GroupUserMsg = 4;
|
||||
}
|
||||
message PullMessageBySeqListReq{
|
||||
repeated int64 seqList =1;
|
||||
}
|
||||
message GetMaxAndMinSeqReq {
|
||||
}
|
||||
message GetMaxAndMinSeqResp {
|
||||
int64 maxSeq = 1;
|
||||
int64 minSeq = 2;
|
||||
}
|
||||
message GatherFormat{
|
||||
// @inject_tag: json:"id"
|
||||
string ID = 1;
|
||||
// @inject_tag: json:"list"
|
||||
repeated MsgFormat List = 2;//detail msg
|
||||
}
|
||||
message MsgFormat{
|
||||
// @inject_tag: json:"sendID"
|
||||
string SendID = 1;
|
||||
// @inject_tag: json:"recvID"
|
||||
string RecvID = 2;
|
||||
// @inject_tag: json:"msgFrom"
|
||||
int32 MsgFrom = 3;
|
||||
// @inject_tag: json:"contentType"
|
||||
int32 ContentType = 4;
|
||||
// @inject_tag: json:"serverMsgID"
|
||||
string ServerMsgID = 5;
|
||||
// @inject_tag: json:"content"
|
||||
string Content = 6;
|
||||
// @inject_tag: json:"seq"
|
||||
int64 Seq = 7;
|
||||
// @inject_tag: json:"sendTime"
|
||||
int64 SendTime = 8;
|
||||
// @inject_tag: json:"senderPlatformID"
|
||||
int32 SenderPlatformID = 9;
|
||||
// @inject_tag: json:"senderNickName"
|
||||
string SenderNickName = 10;
|
||||
// @inject_tag: json:"senderFaceUrl"
|
||||
string SenderFaceURL = 11;
|
||||
// @inject_tag: json:"clientMsgID"
|
||||
string ClientMsgID = 12;
|
||||
}
|
||||
|
||||
message UserSendMsgReq {
|
||||
map<string,int32> Options= 1;
|
||||
string SenderNickName = 2;
|
||||
string SenderFaceURL = 3;
|
||||
int32 PlatformID = 4;
|
||||
int32 SessionType = 5;
|
||||
int32 MsgFrom = 6;
|
||||
int32 ContentType = 7;
|
||||
string RecvID = 8;
|
||||
repeated string ForceList = 9;
|
||||
string Content = 10;
|
||||
string ClientMsgID = 11;
|
||||
}
|
||||
|
||||
message UserSendMsgResp {
|
||||
string ServerMsgID = 1;
|
||||
string ClientMsgID = 2;
|
||||
int64 sendTime = 3;
|
||||
|
||||
}
|
||||
message MsgData {
|
||||
string sendID = 1;
|
||||
string recvID = 2;
|
||||
int32 sessionType = 3;
|
||||
int32 msgFrom = 4;
|
||||
int32 contentType = 5;
|
||||
string serverMsgID = 6;
|
||||
string content =7;
|
||||
int64 sendTime =8;
|
||||
int64 seq =9;
|
||||
int32 senderPlatformID =10;
|
||||
string senderNickName =11;
|
||||
string senderFaceURL =12;
|
||||
string clientMsgID =13;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,846 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: user/user.proto
|
||||
|
||||
package user // import "./user"
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type CommonResp struct {
|
||||
ErrorCode int32 `protobuf:"varint,1,opt,name=errorCode" json:"errorCode,omitempty"`
|
||||
ErrorMsg string `protobuf:"bytes,2,opt,name=errorMsg" json:"errorMsg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CommonResp) Reset() { *m = CommonResp{} }
|
||||
func (m *CommonResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*CommonResp) ProtoMessage() {}
|
||||
func (*CommonResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{0}
|
||||
}
|
||||
func (m *CommonResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CommonResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CommonResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CommonResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *CommonResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CommonResp.Merge(dst, src)
|
||||
}
|
||||
func (m *CommonResp) XXX_Size() int {
|
||||
return xxx_messageInfo_CommonResp.Size(m)
|
||||
}
|
||||
func (m *CommonResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CommonResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CommonResp proto.InternalMessageInfo
|
||||
|
||||
func (m *CommonResp) GetErrorCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrorCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *CommonResp) GetErrorMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrorMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeleteUsersResp struct {
|
||||
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
|
||||
FailedUidList []string `protobuf:"bytes,2,rep,name=failedUidList" json:"failedUidList,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteUsersResp) Reset() { *m = DeleteUsersResp{} }
|
||||
func (m *DeleteUsersResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteUsersResp) ProtoMessage() {}
|
||||
func (*DeleteUsersResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{1}
|
||||
}
|
||||
func (m *DeleteUsersResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteUsersResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteUsersResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteUsersResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *DeleteUsersResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteUsersResp.Merge(dst, src)
|
||||
}
|
||||
func (m *DeleteUsersResp) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteUsersResp.Size(m)
|
||||
}
|
||||
func (m *DeleteUsersResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteUsersResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteUsersResp proto.InternalMessageInfo
|
||||
|
||||
func (m *DeleteUsersResp) GetCommonResp() *CommonResp {
|
||||
if m != nil {
|
||||
return m.CommonResp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DeleteUsersResp) GetFailedUidList() []string {
|
||||
if m != nil {
|
||||
return m.FailedUidList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUsersReq struct {
|
||||
DeleteUidList []string `protobuf:"bytes,2,rep,name=deleteUidList" json:"deleteUidList,omitempty"`
|
||||
Token string `protobuf:"bytes,3,opt,name=token" json:"token,omitempty"`
|
||||
OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteUsersReq) Reset() { *m = DeleteUsersReq{} }
|
||||
func (m *DeleteUsersReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteUsersReq) ProtoMessage() {}
|
||||
func (*DeleteUsersReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{2}
|
||||
}
|
||||
func (m *DeleteUsersReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteUsersReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteUsersReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteUsersReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *DeleteUsersReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteUsersReq.Merge(dst, src)
|
||||
}
|
||||
func (m *DeleteUsersReq) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteUsersReq.Size(m)
|
||||
}
|
||||
func (m *DeleteUsersReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteUsersReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteUsersReq proto.InternalMessageInfo
|
||||
|
||||
func (m *DeleteUsersReq) GetDeleteUidList() []string {
|
||||
if m != nil {
|
||||
return m.DeleteUidList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DeleteUsersReq) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DeleteUsersReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetAllUsersUidReq struct {
|
||||
Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
|
||||
OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetAllUsersUidReq) Reset() { *m = GetAllUsersUidReq{} }
|
||||
func (m *GetAllUsersUidReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetAllUsersUidReq) ProtoMessage() {}
|
||||
func (*GetAllUsersUidReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{3}
|
||||
}
|
||||
func (m *GetAllUsersUidReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetAllUsersUidReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetAllUsersUidReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetAllUsersUidReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetAllUsersUidReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetAllUsersUidReq.Merge(dst, src)
|
||||
}
|
||||
func (m *GetAllUsersUidReq) XXX_Size() int {
|
||||
return xxx_messageInfo_GetAllUsersUidReq.Size(m)
|
||||
}
|
||||
func (m *GetAllUsersUidReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetAllUsersUidReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetAllUsersUidReq proto.InternalMessageInfo
|
||||
|
||||
func (m *GetAllUsersUidReq) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetAllUsersUidReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetAllUsersUidResp struct {
|
||||
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
|
||||
UidList []string `protobuf:"bytes,2,rep,name=uidList" json:"uidList,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetAllUsersUidResp) Reset() { *m = GetAllUsersUidResp{} }
|
||||
func (m *GetAllUsersUidResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetAllUsersUidResp) ProtoMessage() {}
|
||||
func (*GetAllUsersUidResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{4}
|
||||
}
|
||||
func (m *GetAllUsersUidResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetAllUsersUidResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetAllUsersUidResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetAllUsersUidResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetAllUsersUidResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetAllUsersUidResp.Merge(dst, src)
|
||||
}
|
||||
func (m *GetAllUsersUidResp) XXX_Size() int {
|
||||
return xxx_messageInfo_GetAllUsersUidResp.Size(m)
|
||||
}
|
||||
func (m *GetAllUsersUidResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetAllUsersUidResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetAllUsersUidResp proto.InternalMessageInfo
|
||||
|
||||
func (m *GetAllUsersUidResp) GetCommonResp() *CommonResp {
|
||||
if m != nil {
|
||||
return m.CommonResp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetAllUsersUidResp) GetUidList() []string {
|
||||
if m != nil {
|
||||
return m.UidList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUserInfoReq struct {
|
||||
UserIDList []string `protobuf:"bytes,1,rep,name=userIDList" json:"userIDList,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
|
||||
OperationID string `protobuf:"bytes,3,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUserInfoReq) Reset() { *m = GetUserInfoReq{} }
|
||||
func (m *GetUserInfoReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUserInfoReq) ProtoMessage() {}
|
||||
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{5}
|
||||
}
|
||||
func (m *GetUserInfoReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUserInfoReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUserInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUserInfoReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUserInfoReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUserInfoReq.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUserInfoReq) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUserInfoReq.Size(m)
|
||||
}
|
||||
func (m *GetUserInfoReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUserInfoReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUserInfoReq proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUserInfoReq) GetUserIDList() []string {
|
||||
if m != nil {
|
||||
return m.UserIDList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetUserInfoReq) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUserInfoReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUserInfoResp struct {
|
||||
ErrorCode int32 `protobuf:"varint,1,opt,name=errorCode" json:"errorCode,omitempty"`
|
||||
ErrorMsg string `protobuf:"bytes,2,opt,name=errorMsg" json:"errorMsg,omitempty"`
|
||||
Data []*UserInfo `protobuf:"bytes,3,rep,name=Data" json:"Data,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetUserInfoResp) Reset() { *m = GetUserInfoResp{} }
|
||||
func (m *GetUserInfoResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetUserInfoResp) ProtoMessage() {}
|
||||
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{6}
|
||||
}
|
||||
func (m *GetUserInfoResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetUserInfoResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetUserInfoResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetUserInfoResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *GetUserInfoResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetUserInfoResp.Merge(dst, src)
|
||||
}
|
||||
func (m *GetUserInfoResp) XXX_Size() int {
|
||||
return xxx_messageInfo_GetUserInfoResp.Size(m)
|
||||
}
|
||||
func (m *GetUserInfoResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetUserInfoResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetUserInfoResp proto.InternalMessageInfo
|
||||
|
||||
func (m *GetUserInfoResp) GetErrorCode() int32 {
|
||||
if m != nil {
|
||||
return m.ErrorCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *GetUserInfoResp) GetErrorMsg() string {
|
||||
if m != nil {
|
||||
return m.ErrorMsg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *GetUserInfoResp) GetData() []*UserInfo {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UserInfo struct {
|
||||
Uid string `protobuf:"bytes,1,opt,name=uid" json:"uid,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
||||
Icon string `protobuf:"bytes,3,opt,name=icon" json:"icon,omitempty"`
|
||||
Gender int32 `protobuf:"varint,4,opt,name=gender" json:"gender,omitempty"`
|
||||
Mobile string `protobuf:"bytes,5,opt,name=mobile" json:"mobile,omitempty"`
|
||||
Birth string `protobuf:"bytes,6,opt,name=birth" json:"birth,omitempty"`
|
||||
Email string `protobuf:"bytes,7,opt,name=email" json:"email,omitempty"`
|
||||
Ex string `protobuf:"bytes,8,opt,name=ex" json:"ex,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UserInfo) Reset() { *m = UserInfo{} }
|
||||
func (m *UserInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*UserInfo) ProtoMessage() {}
|
||||
func (*UserInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{7}
|
||||
}
|
||||
func (m *UserInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UserInfo.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UserInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UserInfo.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UserInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UserInfo.Merge(dst, src)
|
||||
}
|
||||
func (m *UserInfo) XXX_Size() int {
|
||||
return xxx_messageInfo_UserInfo.Size(m)
|
||||
}
|
||||
func (m *UserInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UserInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UserInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *UserInfo) GetUid() string {
|
||||
if m != nil {
|
||||
return m.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetIcon() string {
|
||||
if m != nil {
|
||||
return m.Icon
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetGender() int32 {
|
||||
if m != nil {
|
||||
return m.Gender
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetMobile() string {
|
||||
if m != nil {
|
||||
return m.Mobile
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetBirth() string {
|
||||
if m != nil {
|
||||
return m.Birth
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetEmail() string {
|
||||
if m != nil {
|
||||
return m.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UserInfo) GetEx() string {
|
||||
if m != nil {
|
||||
return m.Ex
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type LogoutReq struct {
|
||||
OperationID string `protobuf:"bytes,1,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *LogoutReq) Reset() { *m = LogoutReq{} }
|
||||
func (m *LogoutReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*LogoutReq) ProtoMessage() {}
|
||||
func (*LogoutReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{8}
|
||||
}
|
||||
func (m *LogoutReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_LogoutReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *LogoutReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_LogoutReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *LogoutReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_LogoutReq.Merge(dst, src)
|
||||
}
|
||||
func (m *LogoutReq) XXX_Size() int {
|
||||
return xxx_messageInfo_LogoutReq.Size(m)
|
||||
}
|
||||
func (m *LogoutReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_LogoutReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_LogoutReq proto.InternalMessageInfo
|
||||
|
||||
func (m *LogoutReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *LogoutReq) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UpdateUserInfoReq struct {
|
||||
Icon string `protobuf:"bytes,1,opt,name=icon" json:"icon,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
||||
Gender int32 `protobuf:"varint,3,opt,name=gender" json:"gender,omitempty"`
|
||||
Mobile string `protobuf:"bytes,4,opt,name=mobile" json:"mobile,omitempty"`
|
||||
Birth string `protobuf:"bytes,5,opt,name=birth" json:"birth,omitempty"`
|
||||
Email string `protobuf:"bytes,6,opt,name=email" json:"email,omitempty"`
|
||||
Ex string `protobuf:"bytes,7,opt,name=ex" json:"ex,omitempty"`
|
||||
Token string `protobuf:"bytes,8,opt,name=token" json:"token,omitempty"`
|
||||
OperationID string `protobuf:"bytes,9,opt,name=OperationID" json:"OperationID,omitempty"`
|
||||
Uid string `protobuf:"bytes,10,opt,name=Uid" json:"Uid,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) Reset() { *m = UpdateUserInfoReq{} }
|
||||
func (m *UpdateUserInfoReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*UpdateUserInfoReq) ProtoMessage() {}
|
||||
func (*UpdateUserInfoReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_user_9e1dacb346b997d7, []int{9}
|
||||
}
|
||||
func (m *UpdateUserInfoReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_UpdateUserInfoReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *UpdateUserInfoReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_UpdateUserInfoReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *UpdateUserInfoReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_UpdateUserInfoReq.Merge(dst, src)
|
||||
}
|
||||
func (m *UpdateUserInfoReq) XXX_Size() int {
|
||||
return xxx_messageInfo_UpdateUserInfoReq.Size(m)
|
||||
}
|
||||
func (m *UpdateUserInfoReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_UpdateUserInfoReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_UpdateUserInfoReq proto.InternalMessageInfo
|
||||
|
||||
func (m *UpdateUserInfoReq) GetIcon() string {
|
||||
if m != nil {
|
||||
return m.Icon
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetGender() int32 {
|
||||
if m != nil {
|
||||
return m.Gender
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetMobile() string {
|
||||
if m != nil {
|
||||
return m.Mobile
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetBirth() string {
|
||||
if m != nil {
|
||||
return m.Birth
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetEmail() string {
|
||||
if m != nil {
|
||||
return m.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetEx() string {
|
||||
if m != nil {
|
||||
return m.Ex
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetToken() string {
|
||||
if m != nil {
|
||||
return m.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetOperationID() string {
|
||||
if m != nil {
|
||||
return m.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *UpdateUserInfoReq) GetUid() string {
|
||||
if m != nil {
|
||||
return m.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*CommonResp)(nil), "user.CommonResp")
|
||||
proto.RegisterType((*DeleteUsersResp)(nil), "user.DeleteUsersResp")
|
||||
proto.RegisterType((*DeleteUsersReq)(nil), "user.DeleteUsersReq")
|
||||
proto.RegisterType((*GetAllUsersUidReq)(nil), "user.GetAllUsersUidReq")
|
||||
proto.RegisterType((*GetAllUsersUidResp)(nil), "user.GetAllUsersUidResp")
|
||||
proto.RegisterType((*GetUserInfoReq)(nil), "user.GetUserInfoReq")
|
||||
proto.RegisterType((*GetUserInfoResp)(nil), "user.GetUserInfoResp")
|
||||
proto.RegisterType((*UserInfo)(nil), "user.UserInfo")
|
||||
proto.RegisterType((*LogoutReq)(nil), "user.LogoutReq")
|
||||
proto.RegisterType((*UpdateUserInfoReq)(nil), "user.UpdateUserInfoReq")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for User service
|
||||
|
||||
type UserClient interface {
|
||||
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
|
||||
UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*CommonResp, error)
|
||||
DeleteUsers(ctx context.Context, in *DeleteUsersReq, opts ...grpc.CallOption) (*DeleteUsersResp, error)
|
||||
GetAllUsersUid(ctx context.Context, in *GetAllUsersUidReq, opts ...grpc.CallOption) (*GetAllUsersUidResp, error)
|
||||
}
|
||||
|
||||
type userClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewUserClient(cc *grpc.ClientConn) UserClient {
|
||||
return &userClient{cc}
|
||||
}
|
||||
|
||||
func (c *userClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
|
||||
out := new(GetUserInfoResp)
|
||||
err := grpc.Invoke(ctx, "/user.user/getUserInfo", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*CommonResp, error) {
|
||||
out := new(CommonResp)
|
||||
err := grpc.Invoke(ctx, "/user.user/UpdateUserInfo", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userClient) DeleteUsers(ctx context.Context, in *DeleteUsersReq, opts ...grpc.CallOption) (*DeleteUsersResp, error) {
|
||||
out := new(DeleteUsersResp)
|
||||
err := grpc.Invoke(ctx, "/user.user/DeleteUsers", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userClient) GetAllUsersUid(ctx context.Context, in *GetAllUsersUidReq, opts ...grpc.CallOption) (*GetAllUsersUidResp, error) {
|
||||
out := new(GetAllUsersUidResp)
|
||||
err := grpc.Invoke(ctx, "/user.user/GetAllUsersUid", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for User service
|
||||
|
||||
type UserServer interface {
|
||||
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
|
||||
UpdateUserInfo(context.Context, *UpdateUserInfoReq) (*CommonResp, error)
|
||||
DeleteUsers(context.Context, *DeleteUsersReq) (*DeleteUsersResp, error)
|
||||
GetAllUsersUid(context.Context, *GetAllUsersUidReq) (*GetAllUsersUidResp, error)
|
||||
}
|
||||
|
||||
func RegisterUserServer(s *grpc.Server, srv UserServer) {
|
||||
s.RegisterService(&_User_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _User_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUserInfoReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServer).GetUserInfo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/user.user/GetUserInfo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _User_UpdateUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateUserInfoReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServer).UpdateUserInfo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/user.user/UpdateUserInfo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServer).UpdateUserInfo(ctx, req.(*UpdateUserInfoReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _User_DeleteUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteUsersReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServer).DeleteUsers(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/user.user/DeleteUsers",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServer).DeleteUsers(ctx, req.(*DeleteUsersReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _User_GetAllUsersUid_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetAllUsersUidReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServer).GetAllUsersUid(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/user.user/GetAllUsersUid",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServer).GetAllUsersUid(ctx, req.(*GetAllUsersUidReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _User_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "user.user",
|
||||
HandlerType: (*UserServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "getUserInfo",
|
||||
Handler: _User_GetUserInfo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateUserInfo",
|
||||
Handler: _User_UpdateUserInfo_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteUsers",
|
||||
Handler: _User_DeleteUsers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAllUsersUid",
|
||||
Handler: _User_GetAllUsersUid_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "user/user.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_9e1dacb346b997d7) }
|
||||
|
||||
var fileDescriptor_user_9e1dacb346b997d7 = []byte{
|
||||
// 562 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0x95, 0xed, 0x24, 0x8d, 0x27, 0x6a, 0x92, 0xae, 0x0a, 0xac, 0x22, 0x84, 0x22, 0x8b, 0x43,
|
||||
0x4e, 0x01, 0x85, 0x1b, 0x3d, 0x41, 0x22, 0xaa, 0x88, 0xa2, 0x4a, 0x96, 0x7c, 0xe1, 0x84, 0xd3,
|
||||
0x9d, 0xa6, 0x2b, 0x1c, 0xaf, 0xb1, 0x37, 0x52, 0x8f, 0xfc, 0x24, 0xfe, 0x1a, 0xff, 0x00, 0xed,
|
||||
0x38, 0x4e, 0xfc, 0x55, 0x0e, 0x70, 0xb1, 0x76, 0xde, 0xae, 0xdf, 0xdb, 0x37, 0x33, 0x3b, 0x30,
|
||||
0xda, 0x67, 0x98, 0xbe, 0x31, 0x9f, 0x79, 0x92, 0x2a, 0xad, 0x58, 0xc7, 0xac, 0xbd, 0x4f, 0x00,
|
||||
0x4b, 0xb5, 0xdb, 0xa9, 0xd8, 0xc7, 0x2c, 0x61, 0x2f, 0xc1, 0xc5, 0x34, 0x55, 0xe9, 0x52, 0x09,
|
||||
0xe4, 0xd6, 0xd4, 0x9a, 0x75, 0xfd, 0x13, 0xc0, 0x26, 0xd0, 0xa7, 0xe0, 0x4b, 0xb6, 0xe5, 0xf6,
|
||||
0xd4, 0x9a, 0xb9, 0xfe, 0x31, 0xf6, 0x24, 0x8c, 0x56, 0x18, 0xa1, 0xc6, 0x20, 0xc3, 0x34, 0x23,
|
||||
0xb2, 0xb7, 0x00, 0x77, 0x47, 0x6a, 0x62, 0x1b, 0x2c, 0xc6, 0x73, 0xba, 0xc1, 0x49, 0xd2, 0x2f,
|
||||
0x9d, 0x61, 0xaf, 0xe1, 0xfc, 0x3e, 0x94, 0x11, 0x8a, 0x40, 0x8a, 0x1b, 0x99, 0x69, 0x6e, 0x4f,
|
||||
0x9d, 0x99, 0xeb, 0x57, 0x41, 0x2f, 0x86, 0x61, 0x45, 0xea, 0x87, 0xf9, 0x4f, 0xe4, 0x48, 0xf5,
|
||||
0xbf, 0x0a, 0xc8, 0x2e, 0xa1, 0xab, 0xd5, 0x77, 0x8c, 0xb9, 0x43, 0x77, 0xcf, 0x03, 0x36, 0x85,
|
||||
0xc1, 0x6d, 0x82, 0x69, 0xa8, 0xa5, 0x8a, 0xd7, 0x2b, 0xde, 0xa1, 0xbd, 0x32, 0xe4, 0x7d, 0x86,
|
||||
0x8b, 0x6b, 0xd4, 0x1f, 0xa2, 0x88, 0xf4, 0x02, 0x29, 0x8c, 0xe4, 0x91, 0xcc, 0xae, 0x91, 0xa9,
|
||||
0x12, 0x59, 0x2e, 0x54, 0x86, 0xbc, 0x6f, 0xc0, 0xea, 0x64, 0xff, 0x94, 0x2a, 0x0e, 0x67, 0xfb,
|
||||
0x8a, 0xd9, 0x22, 0xf4, 0x1e, 0x60, 0x78, 0x8d, 0xda, 0xd0, 0xaf, 0xe3, 0x7b, 0x65, 0xee, 0xfa,
|
||||
0x0a, 0xc0, 0x50, 0xad, 0x57, 0x74, 0xdc, 0xa2, 0xe3, 0x25, 0xe4, 0x69, 0x2f, 0xb7, 0x4d, 0x2f,
|
||||
0xe5, 0xc4, 0x28, 0x18, 0x55, 0x94, 0xfe, 0xa7, 0x81, 0x98, 0x07, 0x9d, 0x55, 0xa8, 0x43, 0xee,
|
||||
0x4c, 0x9d, 0xd9, 0x60, 0x31, 0xcc, 0xcd, 0x1f, 0xb9, 0x69, 0xcf, 0xfb, 0x65, 0x41, 0xbf, 0x80,
|
||||
0xd8, 0x18, 0x9c, 0xbd, 0x14, 0x24, 0xe2, 0xfa, 0x66, 0xc9, 0x18, 0x74, 0xe2, 0x70, 0x87, 0x07,
|
||||
0x6a, 0x5a, 0x1b, 0x4c, 0xde, 0xa9, 0xa2, 0xe6, 0xb4, 0x66, 0xcf, 0xa1, 0xb7, 0xc5, 0x58, 0x60,
|
||||
0x4a, 0xd5, 0xee, 0xfa, 0x87, 0xc8, 0xe0, 0x3b, 0xb5, 0x91, 0x11, 0xf2, 0x2e, 0x9d, 0x3e, 0x44,
|
||||
0x26, 0x3f, 0x1b, 0x99, 0xea, 0x07, 0xde, 0xcb, 0xf3, 0x43, 0x81, 0x41, 0x71, 0x17, 0xca, 0x88,
|
||||
0x9f, 0xe5, 0x28, 0x05, 0x6c, 0x08, 0x36, 0x3e, 0xf2, 0x3e, 0x41, 0x36, 0x3e, 0x7a, 0x4b, 0x70,
|
||||
0x6f, 0xd4, 0x56, 0xed, 0xb5, 0x29, 0x44, 0x2d, 0xa5, 0x56, 0x23, 0xa5, 0xed, 0xa5, 0xf0, 0x7e,
|
||||
0x5b, 0x70, 0x11, 0x24, 0x22, 0xcc, 0x5b, 0xbe, 0x28, 0x6b, 0x61, 0xcd, 0x2a, 0x59, 0x6b, 0x4b,
|
||||
0xc1, 0xc9, 0xae, 0xf3, 0x84, 0xdd, 0x4e, 0xbb, 0xdd, 0x6e, 0xab, 0xdd, 0x5e, 0xd3, 0xee, 0x59,
|
||||
0x61, 0xf7, 0x74, 0xff, 0xfe, 0x5f, 0x5a, 0xc9, 0x6d, 0xfa, 0x1e, 0x83, 0x13, 0x48, 0xc1, 0x21,
|
||||
0x2f, 0x66, 0x20, 0xc5, 0xe2, 0xa7, 0x0d, 0x34, 0xa1, 0xd8, 0x7b, 0x18, 0x6c, 0x4f, 0x5d, 0xc6,
|
||||
0x2e, 0xf3, 0xce, 0xa8, 0xb6, 0xf8, 0xe4, 0x59, 0x0b, 0x9a, 0x25, 0xec, 0x0a, 0x86, 0xd5, 0xbc,
|
||||
0xb1, 0x17, 0x87, 0xc6, 0xaa, 0x67, 0x73, 0xd2, 0x78, 0x6e, 0x46, 0xb8, 0x34, 0x67, 0x0a, 0xe1,
|
||||
0xea, 0xe8, 0x29, 0x84, 0xeb, 0xb3, 0x6f, 0x49, 0x8f, 0xb0, 0xf4, 0xcc, 0x0b, 0xe1, 0xc6, 0x24,
|
||||
0x99, 0xf0, 0xf6, 0x8d, 0x2c, 0xf9, 0x78, 0xfe, 0x75, 0x30, 0xa7, 0x89, 0x7d, 0x65, 0x3e, 0x9b,
|
||||
0x1e, 0xcd, 0xed, 0x77, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x30, 0xbd, 0x59, 0x5b, 0xca, 0x05,
|
||||
0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./user;user";
|
||||
package user;
|
||||
|
||||
message CommonResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
}
|
||||
message DeleteUsersResp{
|
||||
CommonResp commonResp = 1;
|
||||
repeated string failedUidList = 2;
|
||||
}
|
||||
message DeleteUsersReq{
|
||||
repeated string deleteUidList = 2;
|
||||
string token = 3;
|
||||
string OperationID = 4;
|
||||
}
|
||||
message GetAllUsersUidReq{
|
||||
string token = 2;
|
||||
string operationID = 3;
|
||||
|
||||
}
|
||||
message GetAllUsersUidResp{
|
||||
CommonResp commonResp = 1;
|
||||
repeated string uidList = 2;
|
||||
|
||||
}
|
||||
message GetUserInfoReq{
|
||||
repeated string userIDList = 1;
|
||||
string token = 2;
|
||||
string OperationID = 3;
|
||||
}
|
||||
message GetUserInfoResp{
|
||||
int32 errorCode = 1;
|
||||
string errorMsg = 2;
|
||||
repeated UserInfo Data = 3;
|
||||
}
|
||||
message UserInfo{
|
||||
string uid = 1;
|
||||
string name = 2;
|
||||
string icon = 3;
|
||||
int32 gender = 4;
|
||||
string mobile = 5;
|
||||
string birth = 6;
|
||||
string email = 7;
|
||||
string ex = 8;
|
||||
}
|
||||
|
||||
|
||||
message LogoutReq{
|
||||
string OperationID = 1;
|
||||
string token = 2;
|
||||
}
|
||||
|
||||
message UpdateUserInfoReq{
|
||||
string icon = 1;
|
||||
string name = 2;
|
||||
int32 gender = 3;
|
||||
string mobile = 4;
|
||||
string birth = 5;
|
||||
string email = 6;
|
||||
string ex = 7;
|
||||
string token = 8;
|
||||
string OperationID = 9;
|
||||
string Uid = 10;
|
||||
}
|
||||
|
||||
service user {
|
||||
rpc getUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
||||
rpc UpdateUserInfo(UpdateUserInfoReq) returns(CommonResp);
|
||||
rpc DeleteUsers(DeleteUsersReq)returns(DeleteUsersResp);
|
||||
rpc GetAllUsersUid(GetAllUsersUidReq)returns(GetAllUsersUidResp);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func CorsHandler() gin.HandlerFunc {
|
||||
return func(context *gin.Context) {
|
||||
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
context.Header("Access-Control-Allow-Methods", "*")
|
||||
context.Header("Access-Control-Allow-Headers", "*")
|
||||
context.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified,Pragma,FooBar") // 跨域关键设置 让浏览器可以解析
|
||||
context.Header("Access-Control-Max-Age", "172800") // 缓存请求信息 单位为秒
|
||||
context.Header("Access-Control-Allow-Credentials", "false") // 跨域请求是否需要带cookie信息 默认设置为true
|
||||
context.Header("content-type", "application/json") // 设置返回格式是json
|
||||
//Release all option pre-requests
|
||||
if context.Request.Method == http.MethodOptions {
|
||||
context.JSON(http.StatusOK, "Options Request!")
|
||||
}
|
||||
context.Next()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package utils
|
||||
|
||||
import "os"
|
||||
|
||||
// Determine whether the given path is a folder
|
||||
func IsDir(path string) bool {
|
||||
s, err := os.Stat(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return s.IsDir()
|
||||
}
|
||||
|
||||
// Determine whether the given path is a file
|
||||
func IsFile(path string) bool {
|
||||
return !IsDir(path)
|
||||
}
|
||||
|
||||
// Create a directory
|
||||
func MkDir(path string) error {
|
||||
return os.MkdirAll(path, os.ModePerm)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"net"
|
||||
)
|
||||
|
||||
var ServerIP = ""
|
||||
|
||||
func init() {
|
||||
//fixme In the configuration file, ip takes precedence, if not, get the valid network card ip of the machine
|
||||
if config.Config.ServerIP != "" {
|
||||
ServerIP = config.Config.ServerIP
|
||||
return
|
||||
}
|
||||
|
||||
// see https://gist.github.com/jniltinho/9787946#gistcomment-3019898
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
||||
ServerIP = localAddr.IP.String()
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/nfnt/resize"
|
||||
"golang.org/x/image/bmp"
|
||||
"image"
|
||||
"image/gif"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GenSmallImage(src, dst string) error {
|
||||
fIn, _ := os.Open(src)
|
||||
defer fIn.Close()
|
||||
|
||||
fOut, _ := os.Create(dst)
|
||||
defer fOut.Close()
|
||||
|
||||
if err := scale(fIn, fOut, 0, 0, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func scale(in io.Reader, out io.Writer, width, height, quality int) error {
|
||||
origin, fm, err := image.Decode(in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if width == 0 || height == 0 {
|
||||
width = origin.Bounds().Max.X / 2
|
||||
height = origin.Bounds().Max.Y / 2
|
||||
}
|
||||
if quality == 0 {
|
||||
quality = 25
|
||||
}
|
||||
canvas := resize.Thumbnail(uint(width), uint(height), origin, resize.Lanczos3)
|
||||
|
||||
switch fm {
|
||||
case "jpeg":
|
||||
return jpeg.Encode(out, canvas, &jpeg.Options{quality})
|
||||
case "png":
|
||||
return png.Encode(out, canvas)
|
||||
case "gif":
|
||||
return gif.Encode(out, canvas, &gif.Options{})
|
||||
case "bmp":
|
||||
return bmp.Encode(out, canvas)
|
||||
default:
|
||||
return errors.New("ERROR FORMAT")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/db"
|
||||
"errors"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
TokenExpired = errors.New("token is timed out, please log in again")
|
||||
TokenInvalid = errors.New("token has been invalidated")
|
||||
TokenNotValidYet = errors.New("token not active yet")
|
||||
TokenMalformed = errors.New("that's not even a token")
|
||||
TokenUnknown = errors.New("couldn't handle this token")
|
||||
)
|
||||
|
||||
type Claims struct {
|
||||
UID string
|
||||
Platform string //login platform
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
func BuildClaims(uid, platform string, ttl int64) Claims {
|
||||
now := time.Now()
|
||||
return Claims{
|
||||
UID: uid,
|
||||
Platform: platform,
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), //Expiration time
|
||||
IssuedAt: jwt.NewNumericDate(now), //Issuing time
|
||||
NotBefore: jwt.NewNumericDate(now), //Begin Effective time
|
||||
}}
|
||||
}
|
||||
|
||||
func CreateToken(userID string, platform int32) (string, int64, error) {
|
||||
claims := BuildClaims(userID, PlatformIDToName(platform), config.Config.TokenPolicy.AccessExpire)
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret))
|
||||
|
||||
return tokenString, claims.ExpiresAt.Time.Unix(), err
|
||||
}
|
||||
|
||||
func secret() jwt.Keyfunc {
|
||||
return func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(config.Config.TokenPolicy.AccessSecret), nil
|
||||
}
|
||||
}
|
||||
|
||||
func getClaimFromToken(tokensString string) (*Claims, error) {
|
||||
token, err := jwt.ParseWithClaims(tokensString, &Claims{}, secret())
|
||||
if err != nil {
|
||||
if ve, ok := err.(*jwt.ValidationError); ok {
|
||||
if ve.Errors&jwt.ValidationErrorMalformed != 0 {
|
||||
return nil, TokenMalformed
|
||||
} else if ve.Errors&jwt.ValidationErrorExpired != 0 {
|
||||
return nil, TokenExpired
|
||||
} else if ve.Errors&jwt.ValidationErrorNotValidYet != 0 {
|
||||
return nil, TokenNotValidYet
|
||||
} else {
|
||||
return nil, TokenUnknown
|
||||
}
|
||||
}
|
||||
}
|
||||
if claims, ok := token.Claims.(*Claims); ok && token.Valid {
|
||||
return claims, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func ParseToken(tokensString string) (claims *Claims, err error) {
|
||||
claims, err = getClaimFromToken(tokensString)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 1.check userid and platform class 0 not exists and 1 exists
|
||||
existsInterface, err := db.DB.ExistsUserIDAndPlatform(claims.UID, Platform2class[claims.Platform])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
exists := existsInterface.(int64)
|
||||
//get config multi login policy
|
||||
if config.Config.MultiLoginPolicy.OnlyOneTerminalAccess {
|
||||
//OnlyOneTerminalAccess policy need to check all terminal
|
||||
//When only one end is allowed to log in, there is a situation that needs to be paid attention to. After PC login,
|
||||
//mobile login should check two platform times. One of them is less than the redis storage time, which is the invalid token.
|
||||
platform := "PC"
|
||||
if Platform2class[claims.Platform] == "PC" {
|
||||
platform = "Mobile"
|
||||
}
|
||||
|
||||
existsInterface, err = db.DB.ExistsUserIDAndPlatform(claims.UID, platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
exists = existsInterface.(int64)
|
||||
if exists == 1 {
|
||||
res, err := MakeTheTokenInvalid(claims, platform)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res {
|
||||
return nil, TokenInvalid
|
||||
}
|
||||
}
|
||||
}
|
||||
// config.Config.MultiLoginPolicy.MobileAndPCTerminalAccessButOtherTerminalKickEachOther == true
|
||||
// or PC/Mobile validate success
|
||||
// final check
|
||||
if exists == 1 {
|
||||
res, err := MakeTheTokenInvalid(claims, Platform2class[claims.Platform])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if res {
|
||||
return nil, TokenInvalid
|
||||
}
|
||||
}
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
func MakeTheTokenInvalid(currentClaims *Claims, platformClass string) (bool, error) {
|
||||
storedRedisTokenInterface, err := db.DB.GetPlatformToken(currentClaims.UID, platformClass)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
storedRedisPlatformClaims, err := ParseRedisInterfaceToken(storedRedisTokenInterface)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
//if issue time less than redis token then make this token invalid
|
||||
if currentClaims.IssuedAt.Time.Unix() < storedRedisPlatformClaims.IssuedAt.Time.Unix() {
|
||||
return true, TokenInvalid
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
|
||||
return getClaimFromToken(string(redisToken.([]uint8)))
|
||||
}
|
||||
|
||||
//Validation token, false means failure, true means successful verification
|
||||
func VerifyToken(token, uid string) bool {
|
||||
claims, err := ParseToken(token)
|
||||
if err != nil || claims.UID != uid {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Map struct {
|
||||
sync.RWMutex
|
||||
m map[interface{}]interface{}
|
||||
}
|
||||
|
||||
func (m *Map) init() {
|
||||
if m.m == nil {
|
||||
m.m = make(map[interface{}]interface{})
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map) UnsafeGet(key interface{}) interface{} {
|
||||
if m.m == nil {
|
||||
return nil
|
||||
} else {
|
||||
return m.m[key]
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map) Get(key interface{}) interface{} {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return m.UnsafeGet(key)
|
||||
}
|
||||
|
||||
func (m *Map) UnsafeSet(key interface{}, value interface{}) {
|
||||
m.init()
|
||||
m.m[key] = value
|
||||
}
|
||||
|
||||
func (m *Map) Set(key interface{}, value interface{}) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.UnsafeSet(key, value)
|
||||
}
|
||||
|
||||
func (m *Map) TestAndSet(key interface{}, value interface{}) interface{} {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
m.init()
|
||||
|
||||
if v, ok := m.m[key]; ok {
|
||||
return v
|
||||
} else {
|
||||
m.m[key] = value
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map) UnsafeDel(key interface{}) {
|
||||
m.init()
|
||||
delete(m.m, key)
|
||||
}
|
||||
|
||||
func (m *Map) Del(key interface{}) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.UnsafeDel(key)
|
||||
}
|
||||
|
||||
func (m *Map) UnsafeLen() int {
|
||||
if m.m == nil {
|
||||
return 0
|
||||
} else {
|
||||
return len(m.m)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map) Len() int {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return m.UnsafeLen()
|
||||
}
|
||||
|
||||
func (m *Map) UnsafeRange(f func(interface{}, interface{})) {
|
||||
if m.m == nil {
|
||||
return
|
||||
}
|
||||
for k, v := range m.m {
|
||||
f(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Map) RLockRange(f func(interface{}, interface{})) {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
m.UnsafeRange(f)
|
||||
}
|
||||
|
||||
func (m *Map) LockRange(f func(interface{}, interface{})) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.UnsafeRange(f)
|
||||
}
|
||||
|
||||
func MapToJsonString(param map[string]interface{}) string {
|
||||
dataType, _ := json.Marshal(param)
|
||||
dataString := string(dataType)
|
||||
return dataString
|
||||
}
|
||||
func MapIntToJsonString(param map[string]int32) string {
|
||||
dataType, _ := json.Marshal(param)
|
||||
dataString := string(dataType)
|
||||
return dataString
|
||||
}
|
||||
func JsonStringToMap(str string) (tempMap map[string]interface{}) {
|
||||
_ = json.Unmarshal([]byte(str), &tempMap)
|
||||
return tempMap
|
||||
}
|
||||
func GetSwitchFromOptions(Options map[string]interface{}, key string) (result bool) {
|
||||
if flag, ok := Options[key]; !ok || flag == 1 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func Md5(s string) string {
|
||||
h := md5.New()
|
||||
h.Write([]byte(s))
|
||||
cipher := h.Sum(nil)
|
||||
return hex.EncodeToString(cipher)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package utils
|
||||
|
||||
// fixme 1<--->IOS 2<--->Android 3<--->Windows
|
||||
//fixme 4<--->OSX 5<--->Web 6<--->MiniWeb 7<--->Linux
|
||||
|
||||
const (
|
||||
//Platform ID
|
||||
IOSPlatformID = 1
|
||||
AndroidPlatformID = 2
|
||||
WindowsPlatformID = 3
|
||||
OSXPlatformID = 4
|
||||
WebPlatformID = 5
|
||||
MiniWebPlatformID = 6
|
||||
LinuxPlatformID = 7
|
||||
|
||||
//Platform string match to Platform ID
|
||||
IOSPlatformStr = "IOS"
|
||||
AndroidPlatformStr = "Android"
|
||||
WindowsPlatformStr = "Windows"
|
||||
OSXPlatformStr = "OSX"
|
||||
WebPlatformStr = "Web"
|
||||
MiniWebPlatformStr = "MiniWeb"
|
||||
LinuxPlatformStr = "Linux"
|
||||
|
||||
//terminal types
|
||||
TerminalPC = "PC"
|
||||
TerminalMobile = "Mobile"
|
||||
)
|
||||
|
||||
var PlatformID2Name = map[int32]string{
|
||||
IOSPlatformID: IOSPlatformStr,
|
||||
AndroidPlatformID: AndroidPlatformStr,
|
||||
WindowsPlatformID: WindowsPlatformStr,
|
||||
OSXPlatformID: OSXPlatformStr,
|
||||
WebPlatformID: WebPlatformStr,
|
||||
MiniWebPlatformID: MiniWebPlatformStr,
|
||||
LinuxPlatformID: LinuxPlatformStr,
|
||||
}
|
||||
var PlatformName2ID = map[string]int32{
|
||||
IOSPlatformStr: IOSPlatformID,
|
||||
AndroidPlatformStr: AndroidPlatformID,
|
||||
WindowsPlatformStr: WindowsPlatformID,
|
||||
OSXPlatformStr: OSXPlatformID,
|
||||
WebPlatformStr: WebPlatformID,
|
||||
MiniWebPlatformStr: MiniWebPlatformID,
|
||||
LinuxPlatformStr: LinuxPlatformID,
|
||||
}
|
||||
var Platform2class = map[string]string{
|
||||
IOSPlatformStr: TerminalMobile,
|
||||
AndroidPlatformStr: TerminalMobile,
|
||||
MiniWebPlatformStr: TerminalMobile,
|
||||
WindowsPlatformStr: TerminalPC,
|
||||
OSXPlatformStr: TerminalPC,
|
||||
WebPlatformStr: TerminalPC,
|
||||
LinuxPlatformStr: TerminalPC,
|
||||
}
|
||||
|
||||
func PlatformIDToName(num int32) string {
|
||||
return PlatformID2Name[num]
|
||||
}
|
||||
func PlatformNameToID(name string) int32 {
|
||||
return PlatformName2ID[name]
|
||||
}
|
||||
func PlatformNameToClass(name string) string {
|
||||
return Platform2class[name]
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/4/8 15:09).
|
||||
*/
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func IntToString(i int) string {
|
||||
return strconv.FormatInt(int64(i), 10)
|
||||
}
|
||||
|
||||
func StringToInt(i string) int {
|
||||
j, _ := strconv.Atoi(i)
|
||||
return j
|
||||
}
|
||||
func StringToInt64(i string) int64 {
|
||||
j, _ := strconv.ParseInt(i, 10, 64)
|
||||
return j
|
||||
}
|
||||
|
||||
//judge a string whether in the string list
|
||||
func IsContain(target string, List []string) bool {
|
||||
|
||||
for _, element := range List {
|
||||
|
||||
if target == element {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
func InterfaceArrayToStringArray(data []interface{}) (i []string) {
|
||||
for _, param := range data {
|
||||
i = append(i, param.(string))
|
||||
}
|
||||
return i
|
||||
}
|
||||
func StructToJsonString(param interface{}) string {
|
||||
dataType, _ := json.Marshal(param)
|
||||
dataString := string(dataType)
|
||||
return dataString
|
||||
}
|
||||
|
||||
//The incoming parameter must be a pointer
|
||||
func JsonStringToStruct(s string, args interface{}) error {
|
||||
err := json.Unmarshal([]byte(s), args)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetMsgID(sendID string) string {
|
||||
t := int64ToString(GetCurrentTimestampByNano())
|
||||
return Md5(t + sendID + int64ToString(rand.Int63n(GetCurrentTimestampByNano())))
|
||||
}
|
||||
func int64ToString(i int64) string {
|
||||
return strconv.FormatInt(i, 10)
|
||||
}
|
||||
func Int64ToString(i int64) string {
|
||||
return strconv.FormatInt(i, 10)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('tuoyun,www.tuoyun.net').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/2/22 11:52).
|
||||
*/
|
||||
package utils
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
TimeOffset = 8 * 3600 //8 hour offset
|
||||
HalfOffset = 12 * 3600 //Half-day hourly offset
|
||||
)
|
||||
|
||||
//Get the current timestamp by Second
|
||||
func GetCurrentTimestampBySecond() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
//Convert timestamp to time.Time type
|
||||
func UnixSecondToTime(second int64) time.Time {
|
||||
return time.Unix(second, 0)
|
||||
}
|
||||
|
||||
//Convert nano timestamp to time.Time type
|
||||
func UnixNanoSecondToTime(nanoSecond int64) time.Time {
|
||||
return time.Unix(0, nanoSecond)
|
||||
}
|
||||
|
||||
//Get the current timestamp by Nano
|
||||
func GetCurrentTimestampByNano() int64 {
|
||||
return time.Now().UnixNano()
|
||||
}
|
||||
|
||||
//Get the current timestamp by Mill
|
||||
func GetCurrentTimestampByMill() int64 {
|
||||
return time.Now().UnixNano() / 1e6
|
||||
}
|
||||
|
||||
//Get the timestamp at 0 o'clock of the day
|
||||
func GetCurDayZeroTimestamp() int64 {
|
||||
timeStr := time.Now().Format("2006-01-02")
|
||||
t, _ := time.Parse("2006-01-02", timeStr)
|
||||
return t.Unix() - TimeOffset
|
||||
}
|
||||
|
||||
//Get the timestamp at 12 o'clock on the day
|
||||
func GetCurDayHalfTimestamp() int64 {
|
||||
return GetCurDayZeroTimestamp() + HalfOffset
|
||||
|
||||
}
|
||||
|
||||
//Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
|
||||
func GetCurDayZeroTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp(), 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
|
||||
//Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
|
||||
func GetCurDayHalfTimeFormat() string {
|
||||
return time.Unix(GetCurDayZeroTimestamp()+HalfOffset, 0).Format("2006-01-02_15-04-05")
|
||||
}
|
||||
func GetTimeStampByFormat(datetime string) string {
|
||||
timeLayout := "2006-01-02 15:04:05"
|
||||
loc, _ := time.LoadLocation("Local")
|
||||
tmp, _ := time.ParseInLocation(timeLayout, datetime, loc)
|
||||
timestamp := tmp.Unix()
|
||||
return strconv.FormatInt(timestamp, 10)
|
||||
}
|
||||
|
||||
func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64 {
|
||||
tm, _ := time.Parse(timeFormat, timeSrc)
|
||||
return tm.Unix()
|
||||
}
|
||||
Reference in New Issue
Block a user