Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
face4a4e
Commit
face4a4e
authored
Mar 02, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
雪花id生成调整
parent
837f1616
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
11 deletions
+3
-11
core/src/main/java/com/wecloud/im/service/impl/ImClientLoginServiceImpl.java
+2
-1
core/src/main/java/com/wecloud/utils/SnowflakeUtil.java
+1
-10
No files found.
core/src/main/java/com/wecloud/im/service/impl/ImClientLoginServiceImpl.java
View file @
face4a4e
...
...
@@ -12,6 +12,7 @@ import com.wecloud.im.service.ImApplicationService;
import
com.wecloud.im.service.ImClientLoginService
;
import
com.wecloud.im.service.ImClientService
;
import
com.wecloud.im.vo.TokenVo
;
import
com.wecloud.utils.SnowflakeUtil
;
import
io.geekidea.springbootplus.config.properties.JwtProperties
;
import
io.geekidea.springbootplus.framework.common.api.ApiCode
;
import
io.geekidea.springbootplus.framework.common.api.ApiResult
;
...
...
@@ -91,7 +92,7 @@ public class ImClientLoginServiceImpl implements ImClientLoginService {
if
(
imClient
==
null
)
{
log
.
info
(
"client不存在,先走注册流程"
);
imClient
=
new
ImClient
();
imClient
.
setId
(
new
Snowflake
(
1L
,
1L
).
nex
tId
());
imClient
.
setId
(
SnowflakeUtil
.
ge
tId
());
imClient
.
setFkAppid
(
imApplication
.
getId
());
imClient
.
setClientId
(
imTokenVerify
.
getClientId
());
imClientService
.
save
(
imClient
);
...
...
core/src/main/java/com/wecloud/utils/SnowflakeUtil.java
View file @
face4a4e
...
...
@@ -33,7 +33,7 @@ public class SnowflakeUtil {
if
(
SNOWFLAKE
==
null
)
{
synchronized
(
SnowflakeUtil
.
class
)
{
if
(
SNOWFLAKE
==
null
)
{
SNOWFLAKE
=
new
Snowflake
(
SnowflakeUtil
.
getWorkId
(),
SnowflakeUtil
.
getDataCenterId
()
);
SNOWFLAKE
=
new
Snowflake
(
SnowflakeUtil
.
getWorkId
(),
1L
);
}
}
}
...
...
@@ -59,13 +59,4 @@ public class SnowflakeUtil {
}
}
private
static
Long
getDataCenterId
(){
int
[]
ints
=
StringUtils
.
toCodePoints
(
SystemUtils
.
getHostName
());
int
sums
=
0
;
for
(
int
i:
ints
)
{
sums
+=
i
;
}
return
(
long
)(
sums
%
32
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment