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
909af32e
Commit
909af32e
authored
Apr 28, 2021
by
季圣华
Browse files
增加分配按钮的功能
parent
8d9a0557
Changes
3
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java
View file @
909af32e
...
...
@@ -20,7 +20,9 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author ji-sheng-hua jshERP
...
...
@@ -186,32 +188,52 @@ public class FunctionController {
/**
* 根据id列表查找功能信息
* @param
functions
Id
s
* @param
role
Id
* @param request
* @return
*/
@GetMapping
(
value
=
"/findById
s
"
)
public
BaseResponseInfo
findByIds
(
@RequestParam
(
"
functions
Id
s
"
)
String
functions
Id
s
,
@GetMapping
(
value
=
"/find
RoleFunctions
ById"
)
public
BaseResponseInfo
findByIds
(
@RequestParam
(
"
role
Id"
)
Long
role
Id
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
List
<
Function
>
dataList
=
functionService
.
findByIds
(
functionsIds
);
JSONObject
outer
=
new
JSONObject
();
outer
.
put
(
"total"
,
dataList
.
size
());
//存放数据json数组
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
Function
function
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"id"
,
function
.
getId
());
item
.
put
(
"name"
,
function
.
getName
());
item
.
put
(
"pushBtn"
,
function
.
getPushBtn
());
dataArray
.
add
(
item
);
List
<
UserBusiness
>
list
=
userBusinessService
.
getBasicData
(
roleId
.
toString
(),
"RoleFunctions"
);
if
(
null
!=
list
&&
list
.
size
()>
0
)
{
//按钮
Map
<
Long
,
String
>
btnMap
=
new
HashMap
<>();
String
btnStr
=
list
.
get
(
0
).
getBtnStr
();
if
(
StringUtil
.
isNotEmpty
(
btnStr
))
{
JSONArray
btnArr
=
JSONArray
.
parseArray
(
btnStr
);
for
(
Object
obj:
btnArr
)
{
JSONObject
btnObj
=
JSONObject
.
parseObject
(
obj
.
toString
());
if
(
btnObj
.
get
(
"funId"
)!=
null
&&
btnObj
.
get
(
"btnStr"
)!=
null
)
{
btnMap
.
put
(
btnObj
.
getLong
(
"funId"
),
btnObj
.
getString
(
"btnStr"
));
}
}
}
//菜单
String
funIds
=
list
.
get
(
0
).
getValue
();
funIds
=
funIds
.
substring
(
1
,
funIds
.
length
()
-
1
);
funIds
=
funIds
.
replace
(
"]["
,
","
);
List
<
Function
>
dataList
=
functionService
.
findByIds
(
funIds
);
JSONObject
outer
=
new
JSONObject
();
outer
.
put
(
"total"
,
dataList
.
size
());
//存放数据json数组
JSONArray
dataArray
=
new
JSONArray
();
if
(
null
!=
dataList
)
{
for
(
Function
function
:
dataList
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"id"
,
function
.
getId
());
item
.
put
(
"name"
,
function
.
getName
());
item
.
put
(
"pushBtn"
,
function
.
getPushBtn
());
item
.
put
(
"btnStr"
,
btnMap
.
get
(
function
.
getId
()));
dataArray
.
add
(
item
);
}
}
outer
.
put
(
"rows"
,
dataArray
);
res
.
code
=
200
;
res
.
data
=
outer
;
}
outer
.
put
(
"rows"
,
dataArray
);
res
.
code
=
200
;
res
.
data
=
outer
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
res
.
code
=
500
;
...
...
jshERP-boot/src/main/java/com/jsh/erp/controller/UserBusinessController.java
View file @
909af32e
...
...
@@ -8,6 +8,7 @@ import com.jsh.erp.service.user.UserService;
import
com.jsh.erp.service.userBusiness.UserBusinessService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
com.jsh.erp.utils.ErpInfo
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -68,18 +69,20 @@ public class UserBusinessController {
/**
* 更新角色的按钮权限
* @param userBusinessId
* @param btnStr
* @param jsonObject
* @param request
* @return
*/
@PostMapping
(
value
=
"/updateBtnStr"
)
public
BaseResponseInfo
updateBtnStr
(
@RequestParam
(
value
=
"userBusinessId"
,
required
=
false
)
Long
userBusinessId
,
@RequestParam
(
value
=
"btnStr"
,
required
=
false
)
String
btnStr
,
HttpServletRequest
request
)
throws
Exception
{
public
BaseResponseInfo
updateBtnStr
(
@RequestBody
JSONObject
jsonObject
,
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
int
back
=
userBusinessService
.
updateBtnStr
(
userBusinessId
,
btnStr
);
String
roleId
=
jsonObject
.
getString
(
"roleId"
);
String
btnStr
=
jsonObject
.
getString
(
"btnStr"
);
String
keyId
=
roleId
;
String
type
=
"RoleFunctions"
;
int
back
=
userBusinessService
.
updateBtnStr
(
keyId
,
type
,
btnStr
);
if
(
back
>
0
)
{
res
.
code
=
200
;
res
.
data
=
"成功"
;
...
...
@@ -87,7 +90,7 @@ public class UserBusinessController {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"
查询
权限失败"
;
res
.
data
=
"
更新
权限失败"
;
}
return
res
;
}
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java
View file @
909af32e
...
...
@@ -179,14 +179,14 @@ public class UserBusinessService {
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
throws
Exception
{
public
int
updateBtnStr
(
String
keyId
,
String
type
,
String
btnStr
)
throws
Exception
{
logService
.
insertLog
(
"关联关系"
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
userBusinessId
).
toString
(),
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
type
).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
UserBusiness
userBusiness
=
new
UserBusiness
();
userBusiness
.
setBtnStr
(
btnStr
);
UserBusinessExample
example
=
new
UserBusinessExample
();
example
.
createCriteria
().
andIdEqualTo
(
userBusinessId
);
example
.
createCriteria
().
and
Key
IdEqualTo
(
keyId
).
andTypeEqualTo
(
type
);
int
result
=
0
;
try
{
result
=
userBusinessMapper
.
updateByExampleSelective
(
userBusiness
,
example
);
...
...
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