Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-platform
Commits
26c85420
Commit
26c85420
authored
8 months ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加菜单资源配置
parent
2a223ab3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
26 deletions
+73
-26
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/ResourceService.java
...als/xhx/base/system/resource/service/ResourceService.java
+5
-0
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+26
-1
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/web/ResourceController.java
...tals/xhx/base/system/resource/web/ResourceController.java
+2
-20
bill-manager/src/main/java/com/mortals/xhx/base/system/role/web/RoleAuthController.java
.../mortals/xhx/base/system/role/web/RoleAuthController.java
+40
-5
No files found.
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/ResourceService.java
View file @
26c85420
...
...
@@ -16,6 +16,7 @@ import com.mortals.framework.service.ICRUDService;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
...
...
@@ -49,4 +50,8 @@ public interface ResourceService extends ICRUDService<ResourceEntity,Long> {
Rest
<
String
>
refreshResourceUrl
(
String
packageName
,
Context
context
);
Map
<
String
,
List
<
ResourceEntity
>>
group
(
Long
roleId
,
Context
context
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
26c85420
...
...
@@ -23,6 +23,7 @@ import com.mortals.xhx.base.system.resource.service.ResourceService;
import
com.mortals.xhx.base.system.role.model.RoleAuthEntity
;
import
com.mortals.xhx.base.system.role.model.RoleAuthQuery
;
import
com.mortals.xhx.base.system.role.service.RoleAuthService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.utils.ControllerScanUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -68,7 +69,7 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
continue
;
}
urls
.
add
(
url
);
// url = url.replaceAll(",", ",");
// url = url.replaceAll(",", ",");
}
return
urls
;
}
...
...
@@ -128,6 +129,30 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
return
Rest
.
ok
();
}
@Override
public
Map
<
String
,
List
<
ResourceEntity
>>
group
(
Long
roleId
,
Context
context
)
{
if
(!
ObjectUtils
.
isEmpty
(
roleId
))
{
List
<
RoleAuthEntity
>
roleAuthEntities
=
roleAuthService
.
find
(
new
RoleAuthQuery
().
roleId
(
roleId
));
Set
<
Long
>
collect
=
roleAuthEntities
.
stream
()
.
filter
(
f
->
f
.
getMenuId
()
==
null
)
.
map
(
m
->
m
.
getResourceId
())
.
collect
(
Collectors
.
toSet
());
Map
<
String
,
List
<
ResourceEntity
>>
group
=
this
.
find
(
new
ResourceQuery
(),
context
).
stream
()
.
map
(
m
->
{
if
(
collect
.
contains
(
m
.
getId
()))
{
m
.
setChecked
(
YesNoEnum
.
YES
.
getValue
());
}
return
m
;
})
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getGroupName
()));
return
group
;
}
Map
<
String
,
List
<
ResourceEntity
>>
group
=
this
.
find
(
new
ResourceQuery
(),
context
).
stream
()
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getGroupName
()));
return
group
;
}
private
void
saveUpdateResourceEntity
(
Context
context
,
Map
<
String
,
List
<
ResourceEntity
>>
localResourceMap
,
ResourceEntity
resourceEntity
)
{
//查找 本地是否已经存在了
List
<
ResourceEntity
>
tempResourceList
=
localResourceMap
.
getOrDefault
(
resourceEntity
.
getUrl
(),
new
ArrayList
<>());
...
...
This diff is collapsed.
Click to expand it.
bill-manager/src/main/java/com/mortals/xhx/base/system/resource/web/ResourceController.java
View file @
26c85420
...
...
@@ -101,26 +101,8 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
"查询"
+
this
.
getModuleDesc
()
+
"子节点"
;
try
{
if
(!
ObjectUtils
.
isEmpty
(
query
.
getRoleId
()))
{
List
<
RoleAuthEntity
>
roleAuthEntities
=
roleAuthService
.
find
(
new
RoleAuthQuery
().
roleId
(
query
.
getRoleId
()));
Set
<
Long
>
collect
=
roleAuthEntities
.
stream
()
.
filter
(
f
->
f
.
getMenuId
()
==
null
)
.
map
(
m
->
m
.
getResourceId
())
.
collect
(
Collectors
.
toSet
());
Map
<
String
,
List
<
ResourceEntity
>>
group
=
this
.
service
.
find
(
new
ResourceQuery
(),
getContext
()).
stream
()
.
map
(
m
->
{
if
(
collect
.
contains
(
m
.
getId
()))
{
m
.
setChecked
(
YesNoEnum
.
YES
.
getValue
());
}
return
m
;
})
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getGroupName
()));
model
.
put
(
KEY_RESULT_DATA
,
group
);
}
else
{
Map
<
String
,
List
<
ResourceEntity
>>
group
=
this
.
service
.
find
(
new
ResourceQuery
(),
getContext
()).
stream
()
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getGroupName
()));
model
.
put
(
KEY_RESULT_DATA
,
group
);
}
Map
<
String
,
List
<
ResourceEntity
>>
group
=
this
.
service
.
group
(
query
.
getRoleId
(),
getContext
());
model
.
put
(
KEY_RESULT_DATA
,
group
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_DATA
,
model
);
recordSysLog
(
request
,
busiDesc
+
"【成功】"
);
...
...
This diff is collapsed.
Click to expand it.
bill-manager/src/main/java/com/mortals/xhx/base/system/role/web/RoleAuthController.java
View file @
26c85420
...
...
@@ -3,15 +3,23 @@ package com.mortals.xhx.base.system.role.web;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.resource.model.ResourceEntity
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.role.model.RoleAuthEntity
;
import
com.mortals.xhx.base.system.role.model.RoleAuthQuery
;
import
com.mortals.xhx.base.system.role.service.RoleAuthService
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 角色资源权限
*
...
...
@@ -23,6 +31,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"role/auth"
)
public
class
RoleAuthController
extends
BaseCRUDJsonBodyMappingController
<
RoleAuthService
,
RoleAuthEntity
,
Long
>
{
@Autowired
private
ResourceService
resourceService
;
public
RoleAuthController
()
{
super
.
setModuleDesc
(
"角色资源权限"
);
}
...
...
@@ -33,7 +44,7 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
@PostMapping
(
value
=
"distributionSource"
)
public
String
distributionSource
(
@RequestBody
RoleAuthQuery
query
)
{
try
{
service
.
doDistributionSource
(
query
,
this
.
getContext
());
service
.
doDistributionSource
(
query
,
this
.
getContext
());
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
...
...
@@ -52,7 +63,7 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
@PostMapping
(
value
=
"distributionMenu"
)
public
String
distributionMenu
(
@RequestBody
RoleAuthQuery
query
)
{
try
{
service
.
doDistributionMenu
(
query
,
this
.
getContext
());
service
.
doDistributionMenu
(
query
,
this
.
getContext
());
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
...
...
@@ -67,17 +78,18 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
/**
* 根据
橘
色编辑菜单
* 根据
角
色编辑菜单
*/
@ApiOperation
(
value
=
"根据角色编辑菜单"
)
@PostMapping
(
value
=
"editMenu"
)
public
String
editMenu
(
@RequestBody
RoleAuthQuery
query
)
{
try
{
service
.
editMenu
(
query
,
this
.
getContext
());
service
.
editMenu
(
query
,
this
.
getContext
());
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"
分配角色资源
错误"
,
e
);
log
.
error
(
"
角色编辑菜单
错误"
,
e
);
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
...
...
@@ -85,4 +97,27 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
}
}
/**
* 根据角色编辑资源
*/
@ApiOperation
(
value
=
"根据角色编辑资源"
)
@PostMapping
(
value
=
"editResource"
)
public
String
editResource
(
@RequestBody
RoleAuthQuery
query
)
{
JSONObject
ret
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
try
{
Map
<
String
,
List
<
ResourceEntity
>>
group
=
resourceService
.
group
(
query
.
getRoleId
(),
getContext
());
model
.
put
(
KEY_RESULT_DATA
,
group
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_DATA
,
model
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"角色编辑资源错误"
,
e
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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