Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
b35243f2
Commit
b35243f2
authored
Apr 25, 2021
by
季圣华
Browse files
限制演示用户和配置不被删除
parent
dc7d15c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
b35243f2
...
...
@@ -68,8 +68,14 @@ public class ExceptionConstants {
public
static
final
int
USER_OVER_LIMIT_FAILED_CODE
=
500004
;
public
static
final
String
USER_OVER_LIMIT_FAILED_MSG
=
"用户录入数量超出限制,请联系管理员"
;
//此用户名限制使用
public
static
final
int
USER_NAME_LIMIT_USE_CODE
=
50000
4
;
public
static
final
int
USER_NAME_LIMIT_USE_CODE
=
50000
5
;
public
static
final
String
USER_NAME_LIMIT_USE_MSG
=
"此用户名限制使用"
;
//演示用户不允许删除
public
static
final
int
USER_LIMIT_DELETE_CODE
=
500006
;
public
static
final
String
USER_LIMIT_DELETE_MSG
=
"抱歉,演示用户不允许删除"
;
//演示用户不允许修改
public
static
final
int
USER_LIMIT_UPDATE_CODE
=
500007
;
public
static
final
String
USER_LIMIT_UPDATE_MSG
=
"抱歉,演示用户不允许修改"
;
/**
* 角色信息
...
...
jshERP-boot/src/main/java/com/jsh/erp/controller/ResourceController.java
View file @
b35243f2
...
...
@@ -103,6 +103,8 @@ public class ResourceController {
int
delete
=
configResourceManager
.
delete
(
apiName
,
id
,
request
);
if
(
delete
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
else
if
(
delete
==
-
1
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
TEST_USER
.
name
,
ErpInfo
.
TEST_USER
.
code
);
}
else
{
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
}
...
...
@@ -115,6 +117,8 @@ public class ResourceController {
int
delete
=
configResourceManager
.
deleteBatch
(
apiName
,
ids
,
request
);
if
(
delete
>
0
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
OK
.
name
,
ErpInfo
.
OK
.
code
);
}
else
if
(
delete
==
-
1
)
{
return
returnJson
(
objectMap
,
ErpInfo
.
TEST_USER
.
name
,
ErpInfo
.
TEST_USER
.
code
);
}
else
{
return
returnJson
(
objectMap
,
ErpInfo
.
ERROR
.
name
,
ErpInfo
.
ERROR
.
code
);
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java
View file @
b35243f2
...
...
@@ -40,6 +40,8 @@ public class SystemConfigService {
@Resource
private
LogService
logService
;
private
static
final
String
TEST_USER
=
"jsh"
;
public
SystemConfig
getSystemConfig
(
long
id
)
throws
Exception
{
SystemConfig
result
=
null
;
try
{
...
...
@@ -136,7 +138,11 @@ public class SystemConfigService {
String
[]
idArray
=
ids
.
split
(
","
);
int
result
=
0
;
try
{
result
=
systemConfigMapperEx
.
batchDeleteSystemConfigByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
if
(
userService
.
checkIsTestUser
())
{
result
=-
1
;
}
else
{
result
=
systemConfigMapperEx
.
batchDeleteSystemConfigByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
}
catch
(
Exception
e
){
JshException
.
writeFail
(
logger
,
e
);
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/user/UserService.java
View file @
b35243f2
...
...
@@ -257,6 +257,12 @@ public class UserService {
sb
.
append
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
);
List
<
User
>
list
=
getUserListByIds
(
ids
);
for
(
User
user:
list
){
if
(
user
.
getLoginName
().
equals
(
TEST_USER
)){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,ids:[{}]"
,
ExceptionConstants
.
USER_LIMIT_DELETE_CODE
,
ExceptionConstants
.
USER_LIMIT_DELETE_MSG
,
ids
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_LIMIT_DELETE_CODE
,
ExceptionConstants
.
USER_LIMIT_DELETE_MSG
);
}
sb
.
append
(
"["
).
append
(
user
.
getLoginName
()).
append
(
"]"
);
}
logService
.
insertLog
(
"用户"
,
sb
.
toString
(),
...
...
@@ -531,6 +537,12 @@ public class UserService {
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_NAME_LIMIT_USE_CODE
,
ExceptionConstants
.
USER_NAME_LIMIT_USE_MSG
);
}
else
{
if
(
ue
.
getLoginName
().
equals
(
TEST_USER
)){
logger
.
error
(
"异常码[{}],异常提示[{}],参数,obj:[{}]"
,
ExceptionConstants
.
USER_LIMIT_UPDATE_CODE
,
ExceptionConstants
.
USER_LIMIT_UPDATE_MSG
,
TEST_USER
);
throw
new
BusinessRunTimeException
(
ExceptionConstants
.
USER_LIMIT_UPDATE_CODE
,
ExceptionConstants
.
USER_LIMIT_UPDATE_MSG
);
}
logService
.
insertLog
(
"用户"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
ue
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
...
...
Write
Preview
Supports
Markdown
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