Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
work_service
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
work_service
Commits
0e036896
Commit
0e036896
authored
Mar 17, 2021
by
cq990612
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码结构
parent
34b9ba79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
21 deletions
+36
-21
BASE_RESP_CODE_ENUM.java
...wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
+1
-0
WorkUserServiceImpl.java
...n/java/cn/wisenergy/service/impl/WorkUserServiceImpl.java
+19
-21
UserRoleLevelUtils.java
...n/java/cn/wisenergy/service/utils/UserRoleLevelUtils.java
+16
-0
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/exception/BASE_RESP_CODE_ENUM.java
View file @
0e036896
...
...
@@ -84,6 +84,7 @@ public enum BASE_RESP_CODE_ENUM {
CHOOSEATLEASTONEROLE
(
"667"
,
"至少保留一个角色"
),
DOWNLOAD_ERROR
(
"668"
,
"下载出错"
),
PLEASE_CANCELTHE_MANAGEMENTROLE
(
"669"
,
"注销账号,请取消管理角色"
),
ATLEASTONEADMINISTRATORISREQUIRED
(
"670"
,
"至少需要一个系统管理员!"
),
;
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/impl/WorkUserServiceImpl.java
View file @
0e036896
...
...
@@ -264,32 +264,30 @@ public class WorkUserServiceImpl implements WorkUserService {
}
}
//判断当前是否已经有部门经理和中心管理
for
(
Integer
roleId
:
roleIds
)
{
// 设置部门经理
if
(
2
==
roleId
)
{
if
(
0
==
DeptUpdateIndex
&&
null
!=
workDept
.
getDeptManagerId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
DEPARTMENT_MANAGER_ALREADY_EXISTS
);
if
(
status
!=
1
)
{
for
(
Integer
roleId
:
roleIds
)
{
// 设置部门经理
if
(
2
==
roleId
)
{
if
(
0
==
DeptUpdateIndex
&&
null
!=
workDept
.
getDeptManagerId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
DEPARTMENT_MANAGER_ALREADY_EXISTS
);
}
workDept
.
setDeptManagerId
(
userId
);
workDeptService
.
updateById
(
workDept
);
}
workDept
.
setDeptManagerId
(
userId
);
workDeptService
.
updateById
(
workDept
);
}
// 设置中心管理员
if
(
3
==
roleId
)
{
if
(
0
==
centreUpdateIndex
&&
null
!=
centre
.
getCentreManagerId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
CENTERMANAGERALREADYEXISTS
);
// 设置中心管理员
if
(
3
==
roleId
)
{
if
(
0
==
centreUpdateIndex
&&
null
!=
centre
.
getCentreManagerId
())
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
CENTERMANAGERALREADYEXISTS
);
}
centre
.
setCentreManagerId
(
userId
);
workCentreService
.
updateById
(
centre
);
}
centre
.
setCentreManagerId
(
userId
);
workCentreService
.
updateById
(
centre
);
}
}
if
(
null
!=
status
&&
status
==
0
&&
!
CollectionUtils
.
isEmpty
(
roleIds
))
{
if
(
roleIds
.
size
()
==
1
&&
roleIds
.
get
(
0
).
equals
(
0
))
{
}
else
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
PLEASE_CANCELTHE_MANAGEMENTROLE
);
int
roleCountByRoleId
=
UserRoleLevelUtils
.
getRoleCountByRoleId
(
4
,
userId
);
if
(
roleCountByRoleId
==
0
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
ATLEASTONEADMINISTRATORISREQUIRED
);
}
}
workUserRoleMapper
.
insertBatch
(
userId
,
roleIds
);
return
true
;
}
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/utils/UserRoleLevelUtils.java
View file @
0e036896
...
...
@@ -8,6 +8,7 @@ import cn.wisenergy.mapper.WorkRoleMapper;
import
cn.wisenergy.mapper.WorkUserRoleMapper
;
import
cn.wisenergy.model.app.WorkLevel
;
import
cn.wisenergy.model.app.WorkRole
;
import
cn.wisenergy.model.app.WorkUser
;
import
cn.wisenergy.model.dto.UserRoleLevelDto
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -199,5 +200,20 @@ public class UserRoleLevelUtils {
return
ranks
;
}
public
static
int
getRoleCountByRoleId
(
Integer
roleId
,
Integer
userId
)
{
if
(
null
==
roleId
)
{
throw
new
BaseCustomException
(
BASE_RESP_CODE_ENUM
.
INPUT_PARAM_IS_NULL
);
}
List
<
WorkUser
>
users
=
utils
.
workUserRoleMapper
.
getUserRoleDeptDtoByRoleId
(
roleId
);
int
i
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
users
))
{
for
(
WorkUser
user
:
users
)
{
if
(!
user
.
getId
().
equals
(
userId
))
{
i
++;
}
}
}
return
i
;
}
}
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