Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhaominxu
Open-IM-Server
提交
7f227084
O
Open-IM-Server
项目概览
zhaominxu
/
Open-IM-Server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Open-IM-Server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7f227084
编写于
11月 05, 2021
作者:
X
Xan
提交者:
GitHub
11月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:uid generator & rm incompatible gopkg (#34)
上级
0cc641d1
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
60 addition
and
385 deletion
+60
-385
.gitignore
.gitignore
+6
-0
go.mod
go.mod
+6
-13
go.sum
go.sum
+0
-371
src/common/db/mysql_model/im_mysql_model/model_struct.go
src/common/db/mysql_model/im_mysql_model/model_struct.go
+1
-1
src/rpc/auth/auth/user_register.go
src/rpc/auth/auth/user_register.go
+4
-0
src/utils/id.go
src/utils/id.go
+28
-0
src/utils/id_test.go
src/utils/id_test.go
+15
-0
未找到文件。
.gitignore
浏览文件 @
7f227084
...
...
@@ -2,3 +2,9 @@
components
logs
out-test
# for unit test
src/utils/config
# gosum
go.sum
go.mod
浏览文件 @
7f227084
...
...
@@ -3,21 +3,16 @@ module Open_IM
go 1.15
require (
github.com/Shopify/sarama
v1.19.0
github.com/Shopify/toxiproxy
v2.1.4+incompatible // indirect
github.com/Shopify/sarama
v1.30.0
github.com/antonfisher/nested-logrus-formatter
v1.3.0
github.com/bwmarrin/snowflake
v0.3.0
github.com/coreos/go-semver
v0.3.0 // indirect
github.com/dustin/go-humanize
v1.0.0 // indirect
github.com/eapache/go-resiliency
v1.2.0 // indirect
github.com/eapache/go-xerial-snappy
v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue
v1.1.0 // indirect
github.com/frankban/quicktest
v1.11.3 // indirect
github.com/garyburd/redigo
v1.6.2
github.com/gin-gonic/gin
v1.7.0
github.com/go-playground/validator/v10
v10.4.1
github.com/golang-jwt/jwt/v4
v4.1.0
// indirect
github.com/golang-jwt/jwt/v4
v4.1.0
github.com/golang/protobuf
v1.5.2
github.com/golang/snappy
v0.0.3 // indirect
github.com/gorilla/websocket
v1.4.2
github.com/jinzhu/gorm
v1.9.16
github.com/jonboulle/clockwork
v0.2.2 // indirect
...
...
@@ -28,20 +23,18 @@ require (
github.com/mitchellh/mapstructure
v1.4.1
github.com/nfnt/resize
v0.0.0-20180221191011-83c6a9932646
github.com/olivere/elastic/v7
v7.0.23
github.com/pierrec/lz4
v2.6.0+incompatible // indirect
github.com/rcrowley/go-metrics
v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rifflock/lfshook
v0.0.0-20180920164130-b9218ef580f5
github.com/sirupsen/logrus
v1.
6.0
github.com/sirupsen/logrus
v1.
8.1
github.com/stretchr/testify
v1.7.0
github.com/tencentyun/qcloud-cos-sts-sdk
v0.0.0-20210325043845-84a0811633ca
github.com/tmc/grpc-websocket-proxy
v0.0.0-20190109142713-0ad062ec5ee5 // indirect
go.etcd.io/etcd
v0.0.0-20200402134248-51bdeb39e698
golang.org/x/image
v0.0.0-20210220032944-ac19c3e999fb
golang.org/x/net
v0.0.0-202
01110031124-69a78807bb2b
golang.org/x/net
v0.0.0-202
10917221730-978cfadd31cf
golang.org/x/tools
v0.0.0-20210106214847-113979e3529a // indirect
google.golang.org/grpc
v1.33.2
gopkg.in/mgo.v2
v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/yaml.v3
v3.0.0-202
00313102051-9f266ea9e77c
gopkg.in/yaml.v3
v3.0.0-202
10107192922-496545a6307b
sigs.k8s.io/yaml
v1.2.0 // indirect
)
...
...
go.sum
已删除
100644 → 0
浏览文件 @
0cc641d1
此差异已折叠。
点击以展开。
src/common/db/mysql_model/im_mysql_model/model_struct.go
浏览文件 @
7f227084
...
...
@@ -3,7 +3,7 @@ package im_mysql_model
import
"time"
type
User
struct
{
UID
string
`gorm:"column:uid"`
UID
string
`gorm:"column:uid
;primaryKey;
"`
Name
string
`gorm:"column:name"`
Icon
string
`gorm:"column:icon"`
Gender
int32
`gorm:"column:gender"`
...
...
src/rpc/auth/auth/user_register.go
浏览文件 @
7f227084
...
...
@@ -4,12 +4,16 @@ import (
"Open_IM/src/common/db/mysql_model/im_mysql_model"
"Open_IM/src/common/log"
pbAuth
"Open_IM/src/proto/auth"
"Open_IM/src/utils"
"context"
)
func
(
rpc
*
rpcAuth
)
UserRegister
(
_
context
.
Context
,
pb
*
pbAuth
.
UserRegisterReq
)
(
*
pbAuth
.
UserRegisterResp
,
error
)
{
log
.
Info
(
""
,
""
,
"rpc user_register start, [data: %s]"
,
pb
.
String
())
if
len
(
pb
.
UID
)
==
0
{
pb
.
UID
=
utils
.
GenID
()
}
if
err
:=
im_mysql_model
.
UserRegister
(
pb
);
err
!=
nil
{
log
.
Error
(
""
,
""
,
"rpc user_register error, [data: %s] [err: %s]"
,
pb
.
String
(),
err
.
Error
())
return
&
pbAuth
.
UserRegisterResp
{
Success
:
false
},
err
...
...
src/utils/id.go
0 → 100644
浏览文件 @
7f227084
package
utils
import
(
"github.com/bwmarrin/snowflake"
)
func
init
()
{
var
err
error
idGenerator
,
err
=
snowflake
.
NewNode
(
getNodeNum
())
if
err
!=
nil
{
panic
(
err
)
}
}
func
getNodeNum
()
int64
{
return
1
}
var
idGenerator
*
snowflake
.
Node
func
GenID
()
string
{
return
idGenerator
.
Generate
()
.
String
()
}
func
GenIDs
(
count
int
)
[]
string
{
//impl
return
[]
string
{}
}
src/utils/id_test.go
0 → 100644
浏览文件 @
7f227084
package
utils
import
"testing"
func
TestGenID
(
t
*
testing
.
T
)
{
m
:=
map
[
string
]
struct
{}{}
for
i
:=
0
;
i
<
2000
;
i
++
{
got
:=
GenID
()
if
_
,
ok
:=
m
[
got
];
!
ok
{
m
[
got
]
=
struct
{}{}
}
else
{
t
.
Error
(
"id generate error"
,
got
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录