Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
Overview
Overview
Details
Activity
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
base_platform_enterprise
gic-platform-auth
Commits
19401412
Commit
19401412
authored
Mar 17, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
协作人权限接口
parent
9da5b806
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
203 additions
and
23 deletions
+203
-23
CollaboratorApiService.java
...ain/java/com/gic/auth/service/CollaboratorApiService.java
+25
-0
MenuApiService.java
...pi/src/main/java/com/gic/auth/service/MenuApiService.java
+25
-0
CollaboratorApiServiceImpl.java
...c/auth/service/outer/impl/CollaboratorApiServiceImpl.java
+43
-4
MenuApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
+78
-13
MenuController.java
...main/java/com/gic/auth/web/controller/MenuController.java
+32
-6
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/service/CollaboratorApiService.java
View file @
19401412
...
...
@@ -5,6 +5,7 @@ import com.gic.api.base.commons.ServiceResponse;
import
com.gic.auth.dto.AppDTO
;
import
com.gic.auth.dto.CollaboratorDTO
;
import
com.gic.auth.dto.CollaboratorListDTO
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.qo.CollaboratorListQO
;
import
java.util.List
;
...
...
@@ -93,6 +94,30 @@ public interface CollaboratorApiService {
ServiceResponse
<
Void
>
cancel
(
Integer
collaboratorId
);
/**
* 获取协作应用的应用菜单权限页面
* @Title: getCollaboratorMenuPage
* @Description:
* @author guojuxing
* @param enterpriseId
* @param phone
* @param appId
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>
*/
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorMenuPage
(
Integer
enterpriseId
,
String
phone
,
String
appId
);
/**
* 获取协作应用的没有权限的操作项列表
* @Title: getCollaboratorOperationItem
* @Description:
* @author guojuxing
* @param enterpriseId
* @param phone
* @param appId
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>
*/
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorOperationItem
(
Integer
enterpriseId
,
String
phone
,
String
appId
,
boolean
isSuperAdmin
);
/**
* 查询主键ID,协作人那边授权跳转,需要主键ID
* @param enterpriseId 协作商户ID
* @param phone
...
...
gic-platform-auth-api/src/main/java/com/gic/auth/service/MenuApiService.java
View file @
19401412
...
...
@@ -54,6 +54,31 @@ public interface MenuApiService {
String
versionCode
);
/**
* 获取协作应用的权限页面
* @Title: getCollaboratorAppMenuPage
* @Description:
* @author guojuxing
* @param enterpriseId
* @param menuIdList
* @param appId
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>
*/
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorAppMenuPage
(
Integer
enterpriseId
,
List
<
Integer
>
menuIdList
,
String
appId
);
/**
* 获取协作应用的没有权限的操作项列表数据
* @Title: getCollaboratorAppOperationItem
* @Description:
* @author guojuxing
* @param menuIdList 协作应用权限
* @param appId 应用ID
* @param isSuperAdmin 是否是超级管理员
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>
*/
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorAppOperationItem
(
List
<
Integer
>
menuIdList
,
String
appId
,
boolean
isSuperAdmin
);
/**
* 获取登陆用户的应用菜单(页面类型)
* @Title: getUserMenuOfApp
* @Description:
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/CollaboratorApiServiceImpl.java
View file @
19401412
...
...
@@ -5,8 +5,9 @@ import java.util.Date;
import
java.util.List
;
import
com.gic.auth.constant.AccountGroupMemberTypeEnum
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.entity.TabSysAccountGroupRel
;
import
com.gic.auth.service.
AccountGroupRelService
;
import
com.gic.auth.service.
*
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -26,9 +27,6 @@ import com.gic.auth.dto.CollaboratorListDTO;
import
com.gic.auth.entity.TabSysCollaborator
;
import
com.gic.auth.entity.TabSysCollaboratorRoleRel
;
import
com.gic.auth.qo.CollaboratorListQO
;
import
com.gic.auth.service.CollaboratorApiService
;
import
com.gic.auth.service.CollaboratorRoleRelService
;
import
com.gic.auth.service.CollaboratorService
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.PageHelperUtils
;
import
com.gic.enterprise.error.ErrorCode
;
...
...
@@ -53,6 +51,8 @@ public class CollaboratorApiServiceImpl implements CollaboratorApiService {
private
EnterpriseApiService
enterpriseApiService
;
@Autowired
private
AccountGroupRelService
accountGroupRelService
;
@Autowired
private
MenuApiService
menuApiService
;
@Override
public
ServiceResponse
<
Integer
>
save
(
CollaboratorDTO
dto
)
{
...
...
@@ -210,6 +210,45 @@ public class CollaboratorApiServiceImpl implements CollaboratorApiService {
}
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorMenuPage
(
Integer
enterpriseId
,
String
phone
,
String
appId
)
{
TabSysCollaborator
record
=
collaboratorService
.
getByPhoneAndAppId
(
enterpriseId
,
phone
,
appId
);
if
(
record
==
null
)
{
LOGGER
.
info
(
"协作人接口getIdByPhoneAndAppId入参数据:{}, {}, {}"
,
enterpriseId
,
phone
,
appId
);
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"参数有误,查无数据"
);
}
List
<
Integer
>
menuIdList
=
null
;
List
<
TabSysCollaboratorRoleRel
>
menuList
=
collaboratorRoleRelService
.
listByCollaboratorId
(
record
.
getCollaboratorId
());
if
(
CollectionUtils
.
isNotEmpty
(
menuList
))
{
menuIdList
=
new
ArrayList
<>(
menuList
.
size
());
for
(
TabSysCollaboratorRoleRel
menu
:
menuList
)
{
menuIdList
.
add
(
menu
.
getMenuId
());
}
}
return
this
.
menuApiService
.
getCollaboratorAppMenuPage
(
enterpriseId
,
menuIdList
,
appId
);
}
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorOperationItem
(
Integer
enterpriseId
,
String
phone
,
String
appId
,
boolean
isSuperAdmin
)
{
TabSysCollaborator
record
=
collaboratorService
.
getByPhoneAndAppId
(
enterpriseId
,
phone
,
appId
);
if
(
record
==
null
)
{
LOGGER
.
info
(
"协作人接口getIdByPhoneAndAppId入参数据:{}, {}, {}"
,
enterpriseId
,
phone
,
appId
);
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"参数有误,查无数据"
);
}
List
<
Integer
>
menuIdList
=
null
;
List
<
TabSysCollaboratorRoleRel
>
menuList
=
collaboratorRoleRelService
.
listByCollaboratorId
(
record
.
getCollaboratorId
());
if
(
CollectionUtils
.
isNotEmpty
(
menuList
))
{
menuIdList
=
new
ArrayList
<>(
menuList
.
size
());
for
(
TabSysCollaboratorRoleRel
menu
:
menuList
)
{
menuIdList
.
add
(
menu
.
getMenuId
());
}
}
return
menuApiService
.
getCollaboratorAppOperationItem
(
menuIdList
,
appId
,
isSuperAdmin
);
}
@Override
public
ServiceResponse
<
Integer
>
getIdByPhoneAndAppId
(
Integer
enterpriseId
,
String
phone
,
String
appId
)
{
TabSysCollaborator
record
=
collaboratorService
.
getByPhoneAndAppId
(
enterpriseId
,
phone
,
appId
);
if
(
record
==
null
)
{
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
View file @
19401412
...
...
@@ -118,6 +118,16 @@ public class MenuApiServiceImpl implements MenuApiService {
}
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorAppMenuPage
(
Integer
enterpriseId
,
List
<
Integer
>
menuIdList
,
String
appId
)
{
return
getAppMenuPage
(
enterpriseId
,
menuIdList
,
appId
);
}
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getCollaboratorAppOperationItem
(
List
<
Integer
>
menuIdList
,
String
appId
,
boolean
isSuperAdmin
)
{
return
getAppNoAuthOperationItem
(
menuIdList
,
appId
,
isSuperAdmin
);
}
@Override
public
ServiceResponse
<
List
<
MenuDTO
>>
getUserMenuOfApp
(
Integer
enterpriseId
,
Integer
userId
,
Integer
currentMenu
,
String
versionCode
)
{
return
getUserLoginMenu
(
enterpriseId
,
userId
,
currentMenu
,
false
,
versionCode
);
...
...
@@ -944,6 +954,42 @@ public class MenuApiServiceImpl implements MenuApiService {
level
=
menu
.
getLevel
()
+
1
;
}
Map
<
String
,
Object
>
resourcePage
=
getBusinessFrontRes
(
enterpriseId
);
List
<
TabSysMenu
>
tempList
=
new
ArrayList
<>();
for
(
TabSysMenu
menu
:
resultList
)
{
if
(
resourcePage
.
containsKey
(
menu
.
getMenuCode
()))
{
//如果包含了,则过滤掉
continue
;
}
tempList
.
add
(
menu
);
}
return
ServiceResponse
.
success
(
this
.
treeMenu
(
tempList
,
level
,
parentId
));
}
private
ServiceResponse
<
List
<
MenuDTO
>>
getAppMenuPage
(
Integer
enterpriseId
,
List
<
Integer
>
menuIdList
,
String
appId
)
{
//返回结果集定义声明
List
<
TabSysMenu
>
resultList
=
menuService
.
selectByIdsAndOrderBy
(
menuIdList
,
" order by sort"
);
Map
<
String
,
Object
>
resourcePage
=
getBusinessFrontRes
(
enterpriseId
);
List
<
TabSysMenu
>
tempList
=
new
ArrayList
<>();
for
(
TabSysMenu
menu
:
resultList
)
{
if
(
resourcePage
.
containsKey
(
menu
.
getMenuCode
()))
{
//如果包含了,则过滤掉
continue
;
}
tempList
.
add
(
menu
);
}
return
ServiceResponse
.
success
(
this
.
treeMenu
(
tempList
,
1
,
0
));
}
/**
* 获取商户业务前置资源配置数据
* @param enterpriseId
* @return
*/
private
Map
<
String
,
Object
>
getBusinessFrontRes
(
Integer
enterpriseId
)
{
Map
<
String
,
Object
>
resourcePage
=
new
HashMap
<>(
16
);
//过滤商品资源页面
ServiceResponse
<
List
<
EnterpriseResourceRelDTO
>>
resourceResult
=
enterpriseApiService
.
getBusinessFrontRes
(
enterpriseId
);
...
...
@@ -969,17 +1015,7 @@ public class MenuApiServiceImpl implements MenuApiService {
}
}
}
List
<
TabSysMenu
>
tempList
=
new
ArrayList
<>();
for
(
TabSysMenu
menu
:
resultList
)
{
if
(
resourcePage
.
containsKey
(
menu
.
getMenuCode
()))
{
//如果包含了,则过滤掉
continue
;
}
tempList
.
add
(
menu
);
}
return
ServiceResponse
.
success
(
this
.
treeMenu
(
tempList
,
level
,
parentId
));
return
resourcePage
;
}
/**
...
...
@@ -1005,6 +1041,19 @@ public class MenuApiServiceImpl implements MenuApiService {
//用户拥有的菜单权限
List
<
TabSysMenu
>
menuList
=
getUserMenuList
(
userId
);
List
<
MenuDTO
>
resultList
=
getNoAuthOperationItemByMenuIdList
(
menuList
,
projectCode
,
versionCode
);
//仅超管可用
if
(
tabSysUser
.
getSuperAdmin
().
intValue
()
!=
1
)
{
List
<
TabSysMenu
>
adminOnlyOperationItemList
=
menuService
.
listAdminOnlyOperationItem
();
if
(
CollectionUtils
.
isNotEmpty
(
adminOnlyOperationItemList
))
{
resultList
.
addAll
(
EntityUtil
.
changeEntityListNew
(
MenuDTO
.
class
,
adminOnlyOperationItemList
));
}
}
return
ServiceResponse
.
success
(
resultList
);
}
private
List
<
MenuDTO
>
getNoAuthOperationItemByMenuIdList
(
List
<
TabSysMenu
>
menuList
,
int
projectCode
,
String
versionCode
)
{
//获取用户拥有的权限项ID
List
<
Integer
>
authItemIdList
=
new
ArrayList
<>();
for
(
TabSysMenu
menu
:
menuList
)
{
...
...
@@ -1046,13 +1095,29 @@ public class MenuApiServiceImpl implements MenuApiService {
}
}
}
return
resultList
;
}
private
ServiceResponse
<
List
<
MenuDTO
>>
getAppNoAuthOperationItem
(
List
<
Integer
>
menuIdList
,
String
appId
,
boolean
isSuperAdmin
)
{
//用户拥有的菜单权限
List
<
TabSysMenu
>
menuList
=
menuService
.
selectByIds
(
menuIdList
);
List
<
MenuDTO
>
resultList
=
getNoAuthOperationItemByMenuIdList
(
menuList
,
MenuProjectConstants
.
APP_PROJECT_CODE
,
""
);
//仅超管可用
if
(
tabSysUser
.
getSuperAdmin
().
intValue
()
!=
1
)
{
if
(
!
isSuperAdmin
)
{
List
<
TabSysMenu
>
adminOnlyOperationItemList
=
menuService
.
listAdminOnlyOperationItem
();
if
(
CollectionUtils
.
isNotEmpty
(
adminOnlyOperationItemList
))
{
resultList
.
addAll
(
EntityUtil
.
changeEntityListNew
(
MenuDTO
.
class
,
adminOnlyOperationItemList
));
}
}
return
ServiceResponse
.
success
(
resultList
);
//过滤应用
List
<
MenuDTO
>
tempResult
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
resultList
))
{
for
(
MenuDTO
menuDTO
:
resultList
)
{
if
(
menuDTO
.
getProject
().
equals
(
appId
))
{
tempResult
.
add
(
menuDTO
);
}
}
}
return
ServiceResponse
.
success
(
tempResult
);
}
}
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/MenuController.java
View file @
19401412
...
...
@@ -3,8 +3,10 @@ package com.gic.auth.web.controller;
import
java.util.*
;
import
com.gic.api.base.commons.Page
;
import
com.gic.auth.service.CollaboratorApiService
;
import
com.gic.auth.web.vo.LogListVO
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.enterprise.utils.UserDetail
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -33,6 +35,8 @@ public class MenuController {
private
MenuApiService
menuApiService
;
@Autowired
private
MenuItemApiService
menuItemApiService
;
@Autowired
private
CollaboratorApiService
collaboratorApiService
;
/**
* 查询登录用户的gic菜单
...
...
@@ -46,8 +50,8 @@ public class MenuController {
public
RestResponse
loginUserMenu
(
Integer
currentMenu
)
{
Integer
userId
=
UserDetailUtils
.
getUserDetail
().
getUserId
();
Integer
enterpriseId
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
();
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
menuApiService
.
getUserMenuOfGic
(
enterpriseId
,
userId
,
currentMenu
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getVersionCode
());
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
menuApiService
.
getUserMenuOfGic
(
enterpriseId
,
userId
,
currentMenu
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getVersionCode
());
if
(
userMenu
.
isSuccess
())
{
return
RestResponse
.
success
(
userMenu
.
getResult
());
}
...
...
@@ -67,8 +71,31 @@ public class MenuController {
public
RestResponse
loginUserMenu
(
Integer
currentMenu
,
String
appId
)
{
Integer
userId
=
UserDetailUtils
.
getUserDetail
().
getUserId
();
Integer
enterpriseId
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
();
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
menuApiService
.
getUserMenuOfApp
(
enterpriseId
,
userId
,
currentMenu
,
appId
);
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
menuApiService
.
getUserMenuOfApp
(
enterpriseId
,
userId
,
currentMenu
,
appId
);
if
(
userMenu
.
isSuccess
())
{
return
RestResponse
.
success
(
userMenu
.
getResult
());
}
return
EnterpriseRestResponse
.
failure
(
userMenu
);
}
@RequestMapping
(
"login-collaborator-menu-of-app"
)
public
RestResponse
getCollaboratorMenu
(
String
appId
)
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
collaboratorApiService
.
getCollaboratorMenuPage
(
userDetail
.
getEnterpriseId
(),
userDetail
.
getUserInfo
().
getPhoneNumber
(),
appId
);
if
(
userMenu
.
isSuccess
())
{
return
RestResponse
.
success
(
userMenu
.
getResult
());
}
return
EnterpriseRestResponse
.
failure
(
userMenu
);
}
@RequestMapping
(
"login-collaborator-operation-item"
)
public
RestResponse
getCollaboratorOperationItem
(
String
appId
)
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
boolean
isSuperAdmin
=
userDetail
.
getUserInfo
().
getSuperAdmin
().
intValue
()
==
1
;
ServiceResponse
<
List
<
MenuDTO
>>
userMenu
=
this
.
collaboratorApiService
.
getCollaboratorOperationItem
(
userDetail
.
getEnterpriseId
(),
userDetail
.
getUserInfo
().
getPhoneNumber
(),
appId
,
isSuperAdmin
);
if
(
userMenu
.
isSuccess
())
{
return
RestResponse
.
success
(
userMenu
.
getResult
());
}
...
...
@@ -101,8 +128,7 @@ public class MenuController {
@RequestMapping
(
"login-user-operation-item-of-app"
)
public
RestResponse
loginUserOperationItemOfApp
(
String
appId
)
{
Integer
userId
=
UserDetailUtils
.
getUserDetail
().
getUserId
();
ServiceResponse
<
List
<
MenuDTO
>>
menuList
=
this
.
menuApiService
.
getNoAuthOperationItemOfApp
(
userId
,
""
);
ServiceResponse
<
List
<
MenuDTO
>>
menuList
=
this
.
menuApiService
.
getNoAuthOperationItemOfApp
(
userId
,
""
);
List
<
UserOperationItemAuthVO
>
resultList
=
new
ArrayList
<>();
if
(
menuList
.
isSuccess
())
{
List
<
MenuDTO
>
list
=
menuList
.
getResult
();
...
...
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