Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c1809f63
authored
Oct 09, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:用户登陆鉴权,组织机构关联处理
1 parent
435f8a44
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
8 deletions
project-interface/src/main/java/com/dituhui/pea/enums/StatusCodeEnum.java
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfo.java
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
project-user/src/main/java/com/dituhui/pea/user/entity/UserOrgEntity.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/enums/StatusCodeEnum.java
View file @
c1809f6
...
...
@@ -102,6 +102,11 @@ public enum StatusCodeEnum {
*/
RESOURCE_ALREADY_EXISTS_ROLE
(
"017"
,
"角色中已存在该资源,不能重复添加"
,
false
),
/**
* 用户状态异常或已被禁用
*/
USER_ISBAN_OR_ERROR
(
"018"
,
"用户状态异常或已被禁用"
,
false
),
GIS_EXISTS
(
"001"
,
"已存在"
,
false
),
GIS_NOT_EXISTS
(
"002"
,
"不存在"
,
false
),
...
...
project-interface/src/main/java/com/dituhui/pea/pojo/UserInfo.java
View file @
c1809f6
...
...
@@ -86,7 +86,7 @@ public class UserInfo {
/**
* 组织ids
*/
private
List
<
Integer
>
orgIds
;
private
List
<
String
>
orgIds
;
/**
* 组织级别 0:大区 1:分部 2:站点
*/
...
...
project-interface/src/main/java/com/dituhui/pea/pojo/user/OrgInfo.java
View file @
c1809f6
...
...
@@ -10,7 +10,7 @@ public class OrgInfo implements Serializable {
/**
* 机构id
*/
private
Integer
id
;
private
String
id
;
/**
* 机构名称
...
...
project-user/src/main/java/com/dituhui/pea/user/entity/UserOrgEntity.java
View file @
c1809f6
...
...
@@ -20,7 +20,7 @@ public class UserOrgEntity {
private
String
userId
;
@Column
(
name
=
"org_id"
,
nullable
=
false
)
private
Integer
orgId
;
private
String
orgId
;
/**
* 组织级别 0:大区 1:分部 2:站点
...
...
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
c1809f6
...
...
@@ -102,7 +102,13 @@ public class UserService {
public
Result
<
UserLoginDTO
>
userLogin
(
String
account
,
String
password
)
{
UserEntity
user
=
userDao
.
findByAccountAndPassword
(
account
,
SecureUtil
.
md5
(
password
));
log
.
info
(
"{}/{} login"
,
account
,
password
);
if
(
null
!=
user
)
{
if
(
null
==
user
)
{
return
Result
.
failure
(
"鉴权失败"
);
}
//判断用户禁用/异常情况
if
(
user
.
getBan
()
==
1
||
user
.
getStatus
()
==
0
)
{
Result
.
failed
(
StatusCodeEnum
.
USER_ISBAN_OR_ERROR
,
null
);
}
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
// 生成token
String
token
=
IdUtil
.
simpleUUID
();
...
...
@@ -110,9 +116,6 @@ public class UserService {
long
timestamp
=
System
.
currentTimeMillis
()
+
LIVE_TIME_MILLIS
;
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
token
,
gson
.
toJson
(
userDTO
),
timestamp
/
1000
);
return
Result
.
success
(
userDTO
);
}
else
{
return
Result
.
failure
(
"鉴权失败"
);
}
}
private
UserLoginDTO
convertToUserLoginDTO
(
UserEntity
user
)
{
...
...
@@ -482,7 +485,7 @@ public class UserService {
//处理用户机构关联信息
if
(
CollectionUtils
.
isNotEmpty
(
userInfo
.
getOrgIds
())
&&
null
!=
userInfo
.
getOrgIds
())
{
userOrgDao
.
deleteByUserId
(
userInfo
.
getId
());
for
(
Integer
orgId
:
userInfo
.
getOrgIds
())
{
for
(
String
orgId
:
userInfo
.
getOrgIds
())
{
UserOrgEntity
userOrgEntity
=
new
UserOrgEntity
();
userOrgEntity
.
setUserId
(
userInfo
.
getId
());
userOrgEntity
.
setOrgId
(
orgId
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment