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
7e799c55
Commit
7e799c55
authored
Apr 01, 2019
by
季圣华
Browse files
!43 baozh:修改角色功能权限的同时,同步应用权限。
Merge pull request !43 from joecfan/pullrequest
parents
1a8b4d89
f2244a3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
erp_web/pages/manage/role.html
View file @
7e799c55
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
<td>
<td>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-search"
id=
"searchBtn"
>
查询
</a>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-search"
id=
"searchBtn"
>
查询
</a>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-redo"
id=
"searchResetBtn"
>
重置
</a>
<a
href=
"javascript:void(0)"
class=
"easyui-linkbutton"
iconCls=
"icon-redo"
id=
"searchResetBtn"
>
重置
</a>
<a
id=
"btnSetApp"
class=
'easyui-linkbutton iframe iframe_LargeForm'
href=
'#'
title=
'分配应用'
>
分配应用
</a>
<!--
<a id="btnSetApp" class='easyui-linkbutton iframe iframe_LargeForm' href='#' title='分配应用'>分配应用</a>
-->
<a
id=
"btnSetFunctions"
class=
'easyui-linkbutton iframe iframe_LargeForm'
href=
'#'
title=
'分配功能'
>
分配功能
</a>
<a
id=
"btnSetFunctions"
class=
'easyui-linkbutton iframe iframe_LargeForm'
href=
'#'
title=
'分配功能'
>
分配功能
</a>
<a
id=
"btnSetPushBtn"
class=
'easyui-linkbutton iframe iframe_LargeForm'
href=
'#'
title=
'分配按钮'
>
分配按钮
</a>
<a
id=
"btnSetPushBtn"
class=
'easyui-linkbutton iframe iframe_LargeForm'
href=
'#'
title=
'分配按钮'
>
分配按钮
</a>
</td>
</td>
...
...
src/main/java/com/jsh/erp/constants/BusinessConstants.java
View file @
7e799c55
...
@@ -197,6 +197,8 @@ public class BusinessConstants {
...
@@ -197,6 +197,8 @@ public class BusinessConstants {
public
static
final
String
LOG_MODULE_NAME_ORGANIZATION
=
"机构"
;
public
static
final
String
LOG_MODULE_NAME_ORGANIZATION
=
"机构"
;
public
static
final
String
LOG_INTERFACE_NAME_ORGANIZATION
=
"organization"
;
public
static
final
String
LOG_INTERFACE_NAME_ORGANIZATION
=
"organization"
;
public
static
final
String
TYPE_NAME_ROLE_APP
=
"RoleAPP"
;
...
...
src/main/java/com/jsh/erp/service/app/AppService.java
View file @
7e799c55
...
@@ -5,10 +5,12 @@ import com.jsh.erp.constants.BusinessConstants;
...
@@ -5,10 +5,12 @@ import com.jsh.erp.constants.BusinessConstants;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.datasource.entities.AppExample
;
import
com.jsh.erp.datasource.entities.AppExample
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.mappers.AppMapper
;
import
com.jsh.erp.datasource.mappers.AppMapper
;
import
com.jsh.erp.datasource.mappers.AppMapperEx
;
import
com.jsh.erp.datasource.mappers.AppMapperEx
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.utils.StringUtil
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -35,6 +37,9 @@ public class AppService {
...
@@ -35,6 +37,9 @@ public class AppService {
@Resource
@Resource
private
LogService
logService
;
private
LogService
logService
;
@Resource
private
UserBusinessService
userBusinessService
;
public
List
<
App
>
findDock
(){
public
List
<
App
>
findDock
(){
AppExample
example
=
new
AppExample
();
AppExample
example
=
new
AppExample
();
example
.
createCriteria
().
andZlEqualTo
(
"dock"
).
andEnabledEqualTo
(
true
);
example
.
createCriteria
().
andZlEqualTo
(
"dock"
).
andEnabledEqualTo
(
true
);
...
@@ -126,4 +131,39 @@ public class AppService {
...
@@ -126,4 +131,39 @@ public class AppService {
String
[]
idArray
=
ids
.
split
(
","
);
String
[]
idArray
=
ids
.
split
(
","
);
return
appMapperEx
.
batchDeleteAppByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
return
appMapperEx
.
batchDeleteAppByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
}
public
List
<
App
>
findAppByUserId
(
String
userId
)
{
List
<
UserBusiness
>
roleList
=
userBusinessService
.
findRoleByUserId
(
userId
);
String
roles
=
null
;
if
(
roleList
!=
null
&&
roleList
.
size
()>
0
&&
roleList
.
get
(
0
)!=
null
){
roles
=
roleList
.
get
(
0
).
getValue
();
}
if
(
roles
!=
null
)
{
roles
=
roles
.
replaceAll
(
"\\]\\["
,
","
).
replaceAll
(
"\\]"
,
""
).
replaceAll
(
"\\["
,
""
);
//转为逗号隔开的
}
List
<
UserBusiness
>
appList
=
userBusinessService
.
findAppByRoles
(
roles
);
String
apps
=
null
;
if
(
appList
!=
null
&&
appList
.
size
()>
0
&&
appList
.
get
(
0
)!=
null
){
apps
=
appList
.
get
(
0
).
getValue
();
}
if
(
apps
!=
null
)
{
apps
=
apps
.
replaceAll
(
"\\]\\["
,
","
).
replaceAll
(
"\\]"
,
""
).
replaceAll
(
"\\["
,
""
);
//转为逗号隔开的
}
List
<
App
>
deskList
=
findAppInIds
(
apps
,
"desk"
);
return
deskList
;
}
/**
* 通过number列表查询app list
* @param numberList
* @return
*/
public
List
<
App
>
findAppByNumber
(
List
<
String
>
numberList
)
{
AppExample
example
=
new
AppExample
();
example
.
createCriteria
().
andEnabledEqualTo
(
true
).
andNumberIn
(
numberList
);
return
appMapper
.
selectByExample
(
example
);
}
}
}
src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java
View file @
7e799c55
...
@@ -2,10 +2,15 @@ package com.jsh.erp.service.userBusiness;
...
@@ -2,10 +2,15 @@ package com.jsh.erp.service.userBusiness;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.App
;
import
com.jsh.erp.datasource.entities.Functions
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.service.CommonQueryManager
;
import
com.jsh.erp.service.app.AppService
;
import
com.jsh.erp.service.functions.FunctionsService
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapperEx
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapperEx
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.service.user.UserService
;
import
com.jsh.erp.service.user.UserService
;
...
@@ -14,13 +19,17 @@ import org.slf4j.Logger;
...
@@ -14,13 +19,17 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
@Service
@Service
public
class
UserBusinessService
{
public
class
UserBusinessService
{
...
@@ -35,6 +44,15 @@ public class UserBusinessService {
...
@@ -35,6 +44,15 @@ public class UserBusinessService {
@Resource
@Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
private
FunctionsService
functionsService
;
@Resource
private
AppService
appService
;
@Resource
private
CommonQueryManager
configResourceManager
;
public
UserBusiness
getUserBusiness
(
long
id
)
{
public
UserBusiness
getUserBusiness
(
long
id
)
{
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
}
}
...
@@ -54,7 +72,14 @@ public class UserBusinessService {
...
@@ -54,7 +72,14 @@ public class UserBusinessService {
public
int
updateUserBusiness
(
String
beanJson
,
Long
id
)
{
public
int
updateUserBusiness
(
String
beanJson
,
Long
id
)
{
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
userBusiness
.
setId
(
id
);
userBusiness
.
setId
(
id
);
return
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
int
updates
=
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
// 更新应用权限
if
(
updates
>
0
)
{
updates
=
updateAppValue
(
BusinessConstants
.
TYPE_NAME_ROLE_APP
,
userBusiness
.
getKeyid
(),
userBusiness
.
getValue
());
}
return
updates
;
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
...
@@ -143,4 +168,52 @@ public class UserBusinessService {
...
@@ -143,4 +168,52 @@ public class UserBusinessService {
String
[]
idArray
=
ids
.
split
(
","
);
String
[]
idArray
=
ids
.
split
(
","
);
return
userBusinessMapperEx
.
batchDeleteUserBusinessByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
return
userBusinessMapperEx
.
batchDeleteUserBusinessByIds
(
new
Date
(),
userInfo
==
null
?
null
:
userInfo
.
getId
(),
idArray
);
}
}
/**
* 通过功能(RoleFunctions)权限更新应用(RoleApp)权限
* @param type
* @param keyId
* @param functionIds
* @return
*/
public
int
updateAppValue
(
String
type
,
String
keyId
,
String
functionIds
)
{
int
updates
=
0
;
functionIds
=
functionIds
.
replaceAll
(
"\\]\\["
,
","
).
replaceAll
(
"\\["
,
""
).
replaceAll
(
"\\]"
,
""
);
List
<
Functions
>
functionsList
=
functionsService
.
findByIds
(
functionIds
);
if
(!
CollectionUtils
.
isEmpty
(
functionsList
))
{
Set
<
String
>
appNumbers
=
new
HashSet
<>();
String
appNumber
;
for
(
Functions
functions
:
functionsList
)
{
appNumber
=
functions
.
getNumber
().
substring
(
0
,
2
);
appNumbers
.
add
(
appNumber
);
}
List
<
String
>
appNumberList
=
new
ArrayList
<>(
appNumbers
);
List
<
App
>
appList
=
appService
.
findAppByNumber
(
appNumberList
);
StringBuilder
appIdSb
=
new
StringBuilder
();
if
(!
CollectionUtils
.
isEmpty
(
appList
))
{
for
(
App
app
:
appList
)
{
appIdSb
.
append
(
"["
+
app
.
getId
()
+
"]"
);
}
List
<
UserBusiness
>
userBusinessList
=
getBasicData
(
keyId
,
type
);
if
(
userBusinessList
.
size
()
>
0
)
{
UserBusiness
userBusiness
=
userBusinessList
.
get
(
0
);
userBusiness
.
setValue
(
appIdSb
.
toString
());
updates
=
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
}
}
}
return
updates
;
}
}
}
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