Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-message
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-message
Commits
e9e0d550
Commit
e9e0d550
authored
Sep 29, 2019
by
陶光胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
0245cc52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
5 deletions
+27
-5
StoreMessageHandler.java
...ava/com/gic/message/service/impl/StoreMessageHandler.java
+26
-5
dubbo-gic-platform-message.xml
src/main/resources/dubbo-gic-platform-message.xml
+1
-0
No files found.
src/main/java/com/gic/message/service/impl/StoreMessageHandler.java
View file @
e9e0d550
package
com
.
gic
.
message
.
service
.
impl
;
import
com.gic.api.base.commons.Page
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.constant.AuthModeEnum
;
import
com.gic.auth.dto.UnionEnterpriseDTO
;
import
com.gic.auth.dto.UnionEnterpriseResourceDTO
;
import
com.gic.auth.service.UnionEnterpriseApiService
;
import
com.gic.binlog.base.entity.GicField
;
import
com.gic.binlog.base.entity.GicRecord
;
...
...
@@ -9,9 +12,11 @@ import com.gic.binlog.base.entity.enums.GicRecordType;
import
com.gic.message.service.MessageHandler
;
import
com.gic.message.utils.ListToMapUtil
;
import
com.gic.store.constant.StoreOwnTypeEnum
;
import
com.gic.store.dto.StoreDTO
;
import
com.gic.store.dto.StoreSearchDTO
;
import
com.gic.store.dto.StoreWidgetDTO
;
import
com.gic.store.service.StoreApiService
;
import
com.gic.store.service.StoreAuthorizationApiService
;
import
com.gic.store.service.StoreWidgetApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
...
...
@@ -31,28 +36,44 @@ public class StoreMessageHandler implements MessageHandler {
private
StoreWidgetApiService
storeWidgetApiService
;
@Autowired
private
UnionEnterpriseApiService
unionEnterpriseApiService
;
@Autowired
private
StoreAuthorizationApiService
storeAuthorizationApiService
;
@Override
public
void
handler
(
ConsumerRecord
<
String
,
GicRecord
>
consumerRecord
){
GicRecord
value
=
consumerRecord
.
value
();
Map
<
String
,
GicField
>
fieldMap
=
ListToMapUtil
.
listToMap
(
consumerRecord
);
Integer
enterpriseId
=
0
,
storeId
=
0
;
Integer
enterpriseId
=
0
,
storeId
=
0
,
storeInfoId
;
if
(
GicRecordType
.
INSERT
.
value
()
==
value
.
getRecordType
().
value
()){
enterpriseId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"enterprise_id"
).
getValue
());
storeId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"store_id"
).
getValue
());
storeInfoId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"store_info_id"
).
getValue
());
this
.
storeIndexRefreshHandler
.
refreshStoreIndex
(
enterpriseId
,
storeId
);
Integer
ownType
=
Integer
.
valueOf
(
fieldMap
.
get
(
"own_type"
).
getValue
());
if
(
ownType
==
StoreOwnTypeEnum
.
OWNER
.
getCode
()){
ServiceResponse
<
List
<
Long
>>
resourceResponse
=
this
.
unionEnterpriseApiService
.
listStoreResourceByEnterpriseId
(
enterpriseId
);
ServiceResponse
<
List
<
UnionEnterpriseResourceDTO
>>
resourceResponse
=
this
.
unionEnterpriseApiService
.
listStoreResourceByEnterpriseId
(
enterpriseId
);
if
(
CollectionUtils
.
isNotEmpty
(
resourceResponse
.
getResult
())){
for
(
Long
resourceId
:
resourceResponse
.
getResult
()){
ServiceResponse
<
StoreWidgetDTO
>
storeWidget
=
this
.
storeWidgetApiService
.
getStoreWidget
(
resourceId
.
intValue
());
for
(
UnionEnterpriseResourceDTO
dto
:
resourceResponse
.
getResult
()){
ServiceResponse
<
StoreWidgetDTO
>
storeWidget
=
this
.
storeWidgetApiService
.
getStoreWidget
(
dto
.
getResource
()
.
intValue
());
if
(
storeWidget
.
isSuccess
()){
StoreWidgetDTO
storeWidgetDTO
=
storeWidget
.
getResult
();
if
(
storeWidgetDTO
!=
null
){
if
(
AuthModeEnum
.
YES
.
getCode
()
==
storeWidgetDTO
.
getAuthMode
()){
StoreSearchDTO
storeSearchDTO
=
new
StoreSearchDTO
();
storeSearchDTO
.
setStoreInfoIds
(
""
);
storeSearchDTO
.
setStoreIds
(
String
.
valueOf
(
storeId
));
storeSearchDTO
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
storeSearchDTO
.
setEnterpriseId
(
enterpriseId
);
ServiceResponse
<
Page
<
StoreDTO
>>
response
=
this
.
storeApiService
.
listStore
(
storeSearchDTO
,
1
,
1
);
if
(
response
.
isSuccess
()){
if
(
CollectionUtils
.
isNotEmpty
(
response
.
getResult
().
getResult
())){
StoreDTO
storeDTO
=
new
StoreDTO
();
storeDTO
.
setStoreInfoId
(
storeInfoId
);
storeDTO
.
setEnterpriseId
(
enterpriseId
);
storeDTO
.
setFromEnterpriseId
(
dto
.
getUnionEnterpriseId
());
this
.
storeAuthorizationApiService
.
saveStore
(
storeDTO
);
//this.storeIndexRefreshHandler.refreshStoreIndex(dto.getUnionEnterpriseId(), storeId);
}
}
}
}
}
...
...
src/main/resources/dubbo-gic-platform-message.xml
View file @
e9e0d550
...
...
@@ -22,4 +22,5 @@
<dubbo:reference
interface=
"com.gic.store.service.StoreApiService"
id=
"storeApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.auth.service.UnionEnterpriseApiService"
id=
"unionEnterpriseApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.store.service.StoreWidgetApiService"
id=
"storeWidgetApiService"
timeout=
"6000"
/>
<dubbo:reference
interface=
"com.gic.store.service.StoreAuthorizationApiService"
id=
"storeAuthorizationApiService"
timeout=
"6000"
/>
</beans>
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