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
87d6f60e
Commit
87d6f60e
authored
Feb 24, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资源组变更通知业务方
parent
04dd7173
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
6 deletions
+123
-6
ResourceGroupApiService.java
...in/java/com/gic/auth/service/ResourceGroupApiService.java
+11
-0
ResourceGroupApiServiceImpl.java
.../auth/service/outer/impl/ResourceGroupApiServiceImpl.java
+112
-6
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/service/ResourceGroupApiService.java
View file @
87d6f60e
...
...
@@ -33,6 +33,17 @@ public interface ResourceGroupApiService {
ServiceResponse
<
String
>
editResourceGroup
(
ResourceGroupDTO
resourceGroup
);
/**
* 授权给联合商户的通知 syncResourceAuthChangeMQ
* @param ownEnterpriseId 自有商户ID
* @param unionEnterpriseId 联合商户ID
* @param newResourceGroup
* @param oldResourceGroup
* @return
*/
ServiceResponse
<
Void
>
syncResourceAuthChangeMQ
(
Integer
ownEnterpriseId
,
Integer
unionEnterpriseId
,
ResourceGroupDTO
newResourceGroup
,
ResourceGroupDTO
oldResourceGroup
);
/**
* 分页查询
* @param name 资源组名称
* @param enterpriseId
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/ResourceGroupApiServiceImpl.java
View file @
87d6f60e
package
com
.
gic
.
auth
.
service
.
outer
.
impl
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.auth.constant.ResourceHoldEnum
;
import
com.gic.auth.dto.*
;
import
com.gic.auth.entity.TabSysUser
;
import
com.gic.auth.service.*
;
import
com.gic.auth.utils.resourcegroup.ResourceGroupUtils
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.enterprise.dto.union.UnionEnterpriseAuthDTO
;
import
com.gic.enterprise.dto.union.UnionEnterpriseAuthResNoticeDTO
;
import
com.gic.enterprise.dto.union.UserResourceChangeInfoDTO
;
import
com.gic.enterprise.exception.CommonException
;
import
com.gic.enterprise.response.EnterpriseServiceResponse
;
import
com.gic.enterprise.service.UnionEnterpriseAuthApiService
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.store.service.StoreWidgetApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -75,18 +78,95 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
}
//是否联合授权,如果是
if
(
unionEnterpriseAuthApiService
.
hasUnionEnterpriseAuth
(
resourceGroup
.
getResourceGroupId
()).
getResult
())
{
UnionEnterpriseAuthDTO
unionEnterpriseAuthDTO
=
unionEnterpriseAuthApiService
.
getUnionEnterpriseAuthByResourceGroupId
(
resourceGroup
.
getResourceGroupId
()).
getResult
();
if
(
unionEnterpriseAuthDTO
!=
null
)
{
ServiceResponse
authCodeResult
=
authCodeApiService
.
validateAuthCode
(
resourceGroup
.
getAuthCodeId
(),
resourceGroup
.
getAuthCode
());
if
(!
authCodeResult
.
isSuccess
())
{
return
authCodeResult
;
}
ResourceGroupDTO
oldResourceGroup
=
EntityUtil
.
changeEntityNew
(
ResourceGroupDTO
.
class
,
checkExistResourceGroup
(
resourceGroup
.
getResourceGroupId
()));
//通知业务方数据同步联合调整
syncResourceAuthChangeMQ
(
unionEnterpriseAuthDTO
.
getOwnEnterpriseId
(),
unionEnterpriseAuthDTO
.
getUnionEnterpriseId
(),
resourceGroup
,
oldResourceGroup
);
}
//todo starrynight 通知业务方数据同步联合调整
resourceGroupService
.
editResourceGroup
(
resourceGroup
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Void
>
syncResourceAuthChangeMQ
(
Integer
ownEnterpriseId
,
Integer
unionEnterpriseId
,
ResourceGroupDTO
newResourceGroup
,
ResourceGroupDTO
oldResourceGroup
)
{
UnionEnterpriseAuthResNoticeDTO
unionEnterpriseAuthResNoticeDTO
=
new
UnionEnterpriseAuthResNoticeDTO
();
unionEnterpriseAuthResNoticeDTO
.
setGoodsResourceId
(
newResourceGroup
.
getGoodsResourceId
());
unionEnterpriseAuthResNoticeDTO
.
setStoreResource
(
newResourceGroup
.
getStoreResource
());
unionEnterpriseAuthResNoticeDTO
.
setOwnEnterpriseId
(
ownEnterpriseId
);
unionEnterpriseAuthResNoticeDTO
.
setUnionEnterpriseId
(
unionEnterpriseId
);
List
<
UserResourceChangeInfoDTO
>
userResourceInfoList
=
new
ArrayList
<>();
Map
<
Integer
,
List
<
Long
>>
oldUserAreaMap
=
dealUserResourceData
(
oldResourceGroup
);
if
(
newResourceGroup
.
getCustomUser
()
==
1
)
{
Map
<
Integer
,
List
<
Long
>>
newUserAreaMap
=
dealUserResourceData
(
newResourceGroup
);
newUserAreaMap
.
entrySet
().
forEach
(
e
->
{
List
<
Long
>
oldAreaList
=
oldUserAreaMap
.
get
(
e
.
getKey
());
UserResourceChangeInfoDTO
userResourceChangeInfoDTO
=
new
UserResourceChangeInfoDTO
();
userResourceChangeInfoDTO
.
setType
(
e
.
getKey
());
if
(
oldAreaList
==
null
)
{
userResourceChangeInfoDTO
.
setAddList
(
e
.
getValue
());
}
else
{
List
<
Long
>
newAreaList
=
e
.
getValue
();
List
<
Long
>
addList
=
new
ArrayList
<>();
List
<
Long
>
deleteList
=
new
ArrayList
<>();
for
(
Long
newArea
:
newAreaList
)
{
if
(!
oldAreaList
.
contains
(
newArea
))
{
//如果新的数据在旧的数据里面不存在了,则说明增加了域
addList
.
add
(
newArea
);
}
}
for
(
Long
oldArea
:
oldAreaList
)
{
if
(!
newAreaList
.
contains
(
oldArea
))
{
//如果旧的数据在新的数据里面不存在,则说明被删除了域
deleteList
.
add
(
oldArea
);
}
}
userResourceChangeInfoDTO
.
setAddList
(
addList
);
userResourceChangeInfoDTO
.
setDeleteList
(
deleteList
);
}
userResourceInfoList
.
add
(
userResourceChangeInfoDTO
);
});
}
else
{
oldUserAreaMap
.
entrySet
().
forEach
(
e
->
{
UserResourceChangeInfoDTO
userResourceChangeInfoDTO
=
new
UserResourceChangeInfoDTO
();
userResourceChangeInfoDTO
.
setType
(
e
.
getKey
());
userResourceChangeInfoDTO
.
setDeleteList
(
e
.
getValue
());
userResourceInfoList
.
add
(
userResourceChangeInfoDTO
);
});
}
unionEnterpriseAuthResNoticeDTO
.
setUserResourceInfoList
(
userResourceInfoList
);
GicMQClient
client
=
GICMQClientUtil
.
getClientInstance
();
Map
<
String
,
Object
>
params
=
new
HashMap
<>(
4
);
params
.
put
(
"unionEnterpriseAuthResNoticeDTO"
,
unionEnterpriseAuthResNoticeDTO
);
try
{
client
.
sendMessage
(
"syncResourceAuthChangeMQ"
,
JSONObject
.
toJSONString
(
params
));
}
catch
(
Exception
e
)
{
logger
.
warn
(
"联合商户资源授权路由:{}"
,
e
.
getMessage
(),
e
);
}
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
Page
<
ResourceGroupDTO
>>
pageResourceGroup
(
String
name
,
Integer
enterpriseId
,
Integer
pageNum
,
Integer
pageSize
)
{
com
.
github
.
pagehelper
.
Page
<
TabSysResourceGroup
>
page
=
resourceGroupService
.
pageResourceGroup
(
name
,
enterpriseId
,
pageNum
,
pageSize
);
...
...
@@ -206,4 +286,30 @@ public class ResourceGroupApiServiceImpl implements ResourceGroupApiService{
}
return
record
;
}
private
Map
<
Integer
,
List
<
Long
>>
dealUserResourceData
(
ResourceGroupDTO
oldResourceGroup
)
{
//处理旧的用户域数据,用于比对区分增加/删除域数据
Map
<
Integer
,
List
<
Long
>>
oldUserAreaMap
=
new
HashMap
<>();
if
(
oldResourceGroup
!=
null
)
{
if
(
oldResourceGroup
.
getCustomUser
()
==
1
)
{
List
<
ResourceGroupCustomUserDTO
>
customUserList
=
JSON
.
parseArray
(
oldResourceGroup
.
getCustomUserData
(),
ResourceGroupCustomUserDTO
.
class
);
Map
<
Integer
,
List
<
ResourceGroupCustomUserDTO
>>
map
=
customUserList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ResourceGroupCustomUserDTO:
:
getType
));
map
.
entrySet
().
forEach
(
e
->
{
List
<
ResourceGroupCustomUserDTO
>
tempList
=
e
.
getValue
();
List
<
Long
>
areaValueList
=
new
ArrayList
<>();
for
(
ResourceGroupCustomUserDTO
temp
:
tempList
)
{
String
[]
areaValueArr
=
temp
.
getAreaValue
().
split
(
","
);
for
(
String
areaValue
:
areaValueArr
)
{
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isBlank
(
areaValue
))
{
continue
;
}
areaValueList
.
add
(
Long
.
valueOf
(
areaValue
));
}
}
oldUserAreaMap
.
put
(
e
.
getKey
(),
areaValueList
);
});
}
}
return
oldUserAreaMap
;
}
}
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