Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jz-dmp-service
Project
Project
Details
Activity
Releases
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
姚本章
jz-dmp-service
Commits
2fe69a17
Commit
2fe69a17
authored
Jan 15, 2021
by
sml
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码提交
parent
b8dc5470
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
12 deletions
+100
-12
CustomUserService.java
...ain/java/com/jz/common/interceptor/CustomUserService.java
+10
-2
SecurityInitializer.java
src/main/java/com/jz/dmp/config/SecurityInitializer.java
+1
-1
DmpPermissionController.java
...z/dmp/modules/controller/sys/DmpPermissionController.java
+4
-3
DmpMember.java
src/main/java/com/jz/dmp/modules/model/DmpMember.java
+5
-0
DmpPermissionService.java
.../com/jz/dmp/modules/service/sys/DmpPermissionService.java
+14
-0
DmpMemberServiceImpl.java
...jz/dmp/modules/service/sys/impl/DmpMemberServiceImpl.java
+7
-2
DmpPermissionServiceImpl.java
...mp/modules/service/sys/impl/DmpPermissionServiceImpl.java
+53
-0
DmpPermissionMapper.xml
src/main/resources/mapper/sys/DmpPermissionMapper.xml
+6
-4
No files found.
src/main/java/com/jz/common/interceptor/CustomUserService.java
View file @
2fe69a17
...
...
@@ -11,6 +11,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.dmp.modules.model.DmpMember
;
import
com.jz.dmp.modules.model.DmpPermission
;
import
com.jz.dmp.modules.model.DmpRole
;
...
...
@@ -32,6 +33,9 @@ public class CustomUserService implements UserDetailsService {
@Autowired
DmpPermissionService
dmpPermissionService
;
/**
*
*/
@Override
public
UserDetails
loadUserByUsername
(
String
userName
)
{
DmpMember
user
=
null
;
...
...
@@ -59,10 +63,14 @@ public class CustomUserService implements UserDetailsService {
//设置用户资源
List
<
DmpPermission
>
permissions
=
new
ArrayList
<
DmpPermission
>();
if
(!
CollectionUtils
.
isEmpty
(
memberPermissions
))
{
permissions
.
addAll
(
memberPermissions
);
String
jsonStr
=
JSONObject
.
toJSONString
(
memberPermissions
);
List
<
DmpPermission
>
list
=
JSONObject
.
parseArray
(
jsonStr
,
DmpPermission
.
class
);
permissions
.
addAll
(
list
);
}
if
(!
CollectionUtils
.
isEmpty
(
memberProjPermissions
))
{
permissions
.
addAll
(
memberProjPermissions
);
String
jsonStr
=
JSONObject
.
toJSONString
(
memberProjPermissions
);
List
<
DmpPermission
>
list
=
JSONObject
.
parseArray
(
jsonStr
,
DmpPermission
.
class
);
permissions
.
addAll
(
list
);
}
user
.
setPermissionList
(
permissions
);
...
...
src/main/java/com/jz/dmp/config/SecurityInitializer.java
View file @
2fe69a17
...
...
@@ -3,7 +3,7 @@ package com.jz.dmp.config;
import
org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer
;
import
org.springframework.stereotype.Component
;
@Component
//
@Component
public
class
SecurityInitializer
extends
AbstractSecurityWebApplicationInitializer
{
public
SecurityInitializer
()
{
...
...
src/main/java/com/jz/dmp/modules/controller/sys/DmpPermissionController.java
View file @
2fe69a17
...
...
@@ -2,6 +2,7 @@ package com.jz.dmp.modules.controller.sys;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -166,11 +167,11 @@ public class DmpPermissionController {
@ApiImplicitParam
(
name
=
"parentCode"
,
value
=
"父资源编码"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"请求类型:0:用户项目下资源;1:用户系统级别资源"
)
})
public
BaseBeanResponse
<
DmpPermissionDto
>
findListByParentCode
(
@RequestParam
(
name
=
"parentCode"
,
required
=
true
)
String
parentCode
,
@RequestParam
(
name
=
"type"
,
required
=
true
)
String
type
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
DmpPermissionDto
>
baseBeanResponse
=
new
BaseBeanResponse
<
DmpPermissionDto
>();
public
BaseBeanResponse
<
Map
<
String
,
Object
>
>
findListByParentCode
(
@RequestParam
(
name
=
"parentCode"
,
required
=
true
)
String
parentCode
,
@RequestParam
(
name
=
"type"
,
required
=
true
)
String
type
,
HttpServletRequest
httpRequest
){
BaseBeanResponse
<
Map
<
String
,
Object
>>
baseBeanResponse
=
new
BaseBeanResponse
<
Map
<
String
,
Object
>
>();
try
{
baseBeanResponse
=
dmpPermissionService
.
find
List
ByParentCode
(
parentCode
,
type
,
httpRequest
);
baseBeanResponse
=
dmpPermissionService
.
find
UserAndPremission
ByParentCode
(
parentCode
,
type
,
httpRequest
);
}
catch
(
Exception
e
)
{
baseBeanResponse
.
setMessage
(
"查询失败"
);
baseBeanResponse
.
setCode
(
StatuConstant
.
FAILURE_CODE
);
...
...
src/main/java/com/jz/dmp/modules/model/DmpMember.java
View file @
2fe69a17
...
...
@@ -19,6 +19,11 @@ import com.fasterxml.jackson.annotation.JsonFormat;
*/
@ApiModel
(
value
=
"用户表"
,
description
=
"用户表"
)
public
class
DmpMember
implements
UserDetails
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
7755162995496909499L
;
/**
* 用户ID
*/
...
...
src/main/java/com/jz/dmp/modules/service/sys/DmpPermissionService.java
View file @
2fe69a17
package
com
.
jz
.
dmp
.
modules
.
service
.
sys
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -102,5 +103,18 @@ public interface DmpPermissionService {
*/
public
BaseBeanResponse
<
DmpPermissionDto
>
findListByParentCode
(
String
parentCode
,
String
type
,
HttpServletRequest
httpRequest
)
throws
Exception
;
/**
* @Title: findUserAndPremissionByParentCode
* @Description: TODO(根据父编码)
* @param @param parentCode
* @param @param httpRequest
* @param @return
* @param @throws Exception 参数
* @return BaseBeanResponse<DmpPermissionDto> 返回类型
* @throws
*/
public
BaseBeanResponse
<
Map
<
String
,
Object
>>
findUserAndPremissionByParentCode
(
String
parentCode
,
String
type
,
HttpServletRequest
httpRequest
)
throws
Exception
;
}
src/main/java/com/jz/dmp/modules/service/sys/impl/DmpMemberServiceImpl.java
View file @
2fe69a17
...
...
@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.jz.common.bean.BaseBeanResponse
;
...
...
@@ -469,10 +470,14 @@ public class DmpMemberServiceImpl extends BaseService implements DmpMemberServic
List
<
DmpPermission
>
permissions
=
new
ArrayList
<
DmpPermission
>();
if
(!
CollectionUtils
.
isEmpty
(
memberProjPermissions
))
{
permissions
.
addAll
(
memberProjPermissions
);
String
jsonStr
=
JSONObject
.
toJSONString
(
memberProjPermissions
);
List
<
DmpPermission
>
list
=
JSONObject
.
parseArray
(
jsonStr
,
DmpPermission
.
class
);
permissions
.
addAll
(
list
);
}
if
(!
CollectionUtils
.
isEmpty
(
member
.
getMemberPermissionList
()))
{
permissions
.
addAll
(
member
.
getMemberPermissionList
());
String
jsonStr
=
JSONObject
.
toJSONString
(
member
.
getMemberPermissionList
());
List
<
DmpPermission
>
list
=
JSONObject
.
parseArray
(
jsonStr
,
DmpPermission
.
class
);
permissions
.
addAll
(
list
);
}
member
.
setPermissionList
(
permissions
);
...
...
src/main/java/com/jz/dmp/modules/service/sys/impl/DmpPermissionServiceImpl.java
View file @
2fe69a17
...
...
@@ -392,4 +392,57 @@ public class DmpPermissionServiceImpl extends BaseService implements DmpPermissi
return
baseBeanResponse
;
}
/**
*获取父资源编码下当前用户项目所有资源
*/
@Override
public
BaseBeanResponse
<
Map
<
String
,
Object
>>
findUserAndPremissionByParentCode
(
String
parentCode
,
String
type
,
HttpServletRequest
httpRequest
)
throws
Exception
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<
String
,
Object
>();
BaseBeanResponse
<
Map
<
String
,
Object
>>
baseBeanResponse
=
new
BaseBeanResponse
<>();
//获取当前用户拥有的项目角色
DmpMember
currentUser
=
SessionUtils
.
getSecurityUser
();
if
(
currentUser
==
null
)
{
baseBeanResponse
.
setCode
(
StatuConstant
.
CODE_NOT_SIGNED
);
baseBeanResponse
.
setMessage
(
"用户未登录!"
);
return
baseBeanResponse
;
}
resultMap
.
put
(
"user"
,
currentUser
);
List
<
DmpPermission
>
dmpPermissions
=
new
ArrayList
<
DmpPermission
>();
if
(
"0"
.
equals
(
type
))
{
dmpPermissions
=
dmpPermissionMapper
.
findByRoles
(
currentUser
.
getMemberProjectRoleList
());
}
else
if
(
"1"
.
equals
(
type
))
{
dmpPermissions
=
dmpPermissionMapper
.
findByRoles
(
currentUser
.
getMemberRoleList
());
}
else
{
List
<
DmpPermission
>
list1
=
dmpPermissionMapper
.
findByRoles
(
currentUser
.
getMemberProjectRoleList
());
List
<
DmpPermission
>
list2
=
dmpPermissionMapper
.
findByRoles
(
currentUser
.
getMemberRoleList
());
List
<
DmpPermission
>
permissions
=
new
ArrayList
<
DmpPermission
>();
if
(!
CollectionUtils
.
isEmpty
(
list1
))
{
permissions
.
addAll
(
list1
);
}
if
(!
CollectionUtils
.
isEmpty
(
list2
))
{
permissions
.
addAll
(
list2
);
}
dmpPermissions
=
permissions
;
}
//整理资源为树形结构
List
<
DmpPermission
>
permissions
=
permissionArrangeTree
(
parentCode
,
dmpPermissions
);
List
<
DmpPermissionDto
>
list
=
MyDmpPermissionConverter
.
INSTANCE
().
domain2dto
(
permissions
);
resultMap
.
put
(
"permissions"
,
list
);
baseBeanResponse
.
setCode
(
StatuConstant
.
CODE_SUCCESS
);
baseBeanResponse
.
setMessage
(
"查询成功"
);
baseBeanResponse
.
setData
(
resultMap
);
return
baseBeanResponse
;
}
}
src/main/resources/mapper/sys/DmpPermissionMapper.xml
View file @
2fe69a17
...
...
@@ -39,6 +39,7 @@
<include
refid=
"Base_Column_List"
/>
from dmp_permission
where permission_id = #{permissionId,jdbcType=INTEGER}
AND data_status='1'
</select>
<!-- 根据主键删除资源表 -->
...
...
@@ -304,6 +305,7 @@
<include
refid=
"BaseDto_Column_List"
/>
from dmp_permission
where permission_id = #{permissionId,jdbcType=INTEGER}
AND data_status='1'
</select>
<!-- 根据角色获取所有资源 -->
...
...
@@ -314,16 +316,16 @@
permission.create_user_id, permission.create_time, permission.update_user_id, permission.update_time
from dmp_permission permission
left join dmp_role_permission rolePermission on permission.permission_id=rolePermission.permission_id
where
where
permission.data_status='1'
<choose>
<when
test=
"dmpRoles.size>0"
>
rolePermission.role_id in
AND
rolePermission.role_id in
<foreach
collection=
"dmpRoles"
item=
"item"
index=
"index"
open=
"("
separator =
","
close=
")"
>
#{item.roleId,jdbcType=INTEGER}
</foreach>
</when>
<otherwise>
1
<![CDATA[ <> ]]>
1
AND
1
<![CDATA[ <> ]]>
1
</otherwise>
</choose>
</select>
...
...
@@ -333,7 +335,7 @@
SELECT
<include
refid=
"BaseDto_Column_List"
/>
FROM dmp_permission
WHERE permission_url IS NOT NULL
WHERE permission_url IS NOT NULL
AND data_status='1'
</select>
</mapper>
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