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
04e1c964
Commit
04e1c964
authored
Sep 24, 2020
by
陶光胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' into 'master'
Developer See merge request
!3
parents
5c21fe8b
5e1339ac
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
113 additions
and
27 deletions
+113
-27
Constants.java
src/main/java/com/gic/message/constant/Constants.java
+7
-0
TestMapper.java
src/main/java/com/gic/message/dao/mapper/TestMapper.java
+7
-1
TabCity.java
src/main/java/com/gic/message/entity/TabCity.java
+7
-0
MessageHandler.java
src/main/java/com/gic/message/service/MessageHandler.java
+16
-1
KafkaMessageServiceImpl.java
...com/gic/message/service/impl/KafkaMessageServiceImpl.java
+7
-2
MessageHandlerInit.java
...java/com/gic/message/service/impl/MessageHandlerInit.java
+7
-0
StoreCustomMessageHandler.java
...m/gic/message/service/impl/StoreCustomMessageHandler.java
+13
-3
StoreIndexRefreshHandler.java
...om/gic/message/service/impl/StoreIndexRefreshHandler.java
+8
-2
StoreInfoMessageHandler.java
...com/gic/message/service/impl/StoreInfoMessageHandler.java
+15
-9
StoreMessageHandler.java
...ava/com/gic/message/service/impl/StoreMessageHandler.java
+19
-8
ListToMapUtil.java
src/main/java/com/gic/message/utils/ListToMapUtil.java
+7
-1
No files found.
src/main/java/com/gic/message/constant/Constants.java
View file @
04e1c964
package
com
.
gic
.
message
.
constant
;
/**
*
* @ClassName: Constants
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
class
Constants
{
public
static
final
String
INSERT
=
"INSERT"
;
public
static
final
String
UPDATE
=
"UPDATE"
;
...
...
src/main/java/com/gic/message/dao/mapper/TestMapper.java
View file @
04e1c964
package
com
.
gic
.
message
.
dao
.
mapper
;
/**
*
* @ClassName: TestMapper
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
class
TestMapper
{
}
src/main/java/com/gic/message/entity/TabCity.java
View file @
04e1c964
...
...
@@ -5,6 +5,13 @@ import java.util.Date;
/**
* tab_city
*/
/**
*
* @ClassName: TabCity
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
class
TabCity
{
/**
* 城市id
...
...
src/main/java/com/gic/message/service/MessageHandler.java
View file @
04e1c964
...
...
@@ -2,7 +2,22 @@ package com.gic.message.service;
import
com.gic.binlog.base.entity.GicRecord
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
/**
*
* @ClassName: MessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
interface
MessageHandler
{
/**
* handler
* @Title: handler
* @Description:
* @author zhiwj
* @param consumerRecord
* @return void
* @throws
*/
void
handler
(
ConsumerRecord
<
String
,
GicRecord
>
consumerRecord
);
}
src/main/java/com/gic/message/service/impl/KafkaMessageServiceImpl.java
View file @
04e1c964
package
com
.
gic
.
message
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.binlog.base.entity.GicRecord
;
import
com.gic.message.service.MessageHandler
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
...
...
@@ -8,7 +7,13 @@ import org.apache.logging.log4j.LogManager;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.kafka.listener.MessageListener
;
/**
*
* @ClassName: KafkaMessageServiceImpl
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
class
KafkaMessageServiceImpl
implements
MessageListener
<
String
,
GicRecord
>
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
KafkaMessageServiceImpl
.
class
);
@Autowired
...
...
src/main/java/com/gic/message/service/impl/MessageHandlerInit.java
View file @
04e1c964
...
...
@@ -8,6 +8,13 @@ import javax.annotation.PostConstruct;
import
java.util.HashMap
;
import
java.util.Map
;
/**
*
* @ClassName: MessageHandlerInit
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public
class
MessageHandlerInit
{
@Autowired
...
...
src/main/java/com/gic/message/service/impl/StoreCustomMessageHandler.java
View file @
04e1c964
...
...
@@ -25,9 +25,19 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @ClassName: StoreCustomMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public
class
StoreCustomMessageHandler
implements
MessageHandler
{
private
static
final
String
OLD_VALUE
=
"old_value"
;
private
static
final
String
NEW_VALUE
=
"new_value"
;
@Autowired
private
StoreApiService
storeApiService
;
@Autowired
...
...
@@ -55,7 +65,7 @@ public class StoreCustomMessageHandler implements MessageHandler {
enterpriseId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_enterprise_id"
).
getValue
());
storeFieldId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_store_field_id"
).
getValue
());
storeInfoId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_store_info_id"
).
getValue
());
if
(!
fieldMap
.
get
(
"old_value"
).
getValue
().
equals
(
fieldMap
.
get
(
"new_value"
).
getValue
())){
if
(!
fieldMap
.
get
(
OLD_VALUE
).
getValue
().
equals
(
fieldMap
.
get
(
NEW_VALUE
).
getValue
())){
this
.
dealCustomChange
(
enterpriseId
,
storeFieldId
,
storeInfoId
,
fieldMap
);
}
}
...
...
@@ -91,7 +101,7 @@ public class StoreCustomMessageHandler implements MessageHandler {
}
StoreWidgetDTO
storeWidgetDTO
=
storeWidget
.
getResult
();
if
(
storeWidgetDTO
!=
null
){
if
(
AuthModeEnum
.
YES
.
getCode
()
==
storeWidgetDTO
.
getAuthMode
(
)){
if
(
AuthModeEnum
.
YES
.
getCode
()
.
equals
(
storeWidgetDTO
.
getAuthMode
()
)){
StoreSearchDTO
storeSearchDTO
=
new
StoreSearchDTO
();
storeSearchDTO
.
setStoreInfoIds
(
String
.
valueOf
(
storeInfoId
));
storeSearchDTO
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
...
...
src/main/java/com/gic/message/service/impl/StoreIndexRefreshHandler.java
View file @
04e1c964
...
...
@@ -6,7 +6,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.TimeUnit
;
/**
*
* @ClassName: StoreIndexRefreshHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public
class
StoreIndexRefreshHandler
{
@Autowired
...
...
@@ -17,7 +23,7 @@ public class StoreIndexRefreshHandler {
Object
cache
=
RedisUtil
.
getCache
(
key
);
if
(
cache
==
null
){
this
.
storeApiService
.
addStoreToIndex
(
enterpriseId
,
storeId
);
RedisUtil
.
setCache
(
key
,
storeId
,
1
l
,
TimeUnit
.
SECONDS
);
RedisUtil
.
setCache
(
key
,
storeId
,
1
L
,
TimeUnit
.
SECONDS
);
}
}
}
src/main/java/com/gic/message/service/impl/StoreInfoMessageHandler.java
View file @
04e1c964
...
...
@@ -25,7 +25,13 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @ClassName: StoreInfoMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
@Component
public
class
StoreInfoMessageHandler
implements
MessageHandler
{
@Autowired
...
...
@@ -57,7 +63,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
for
(
StoreDTO
storeDTO
:
listStore
){
if
(
storeDTO
.
getOwnType
()
==
StoreOwnTypeEnum
.
OWNER
.
getCode
()){
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_status"
).
getValue
())
==
1
&&
Integer
.
valueOf
(
fieldMap
.
get
(
"new_status"
).
getValue
())
==
0
){
this
.
storeApiService
.
deleteStoreFromE
S
(
storeDTO
.
getEnterpriseId
(),
storeDTO
.
getStoreId
());
this
.
storeApiService
.
deleteStoreFromE
s
(
storeDTO
.
getEnterpriseId
(),
storeDTO
.
getStoreId
());
}
else
{
this
.
storeIndexRefreshHandler
.
refreshStoreIndex
(
storeDTO
.
getEnterpriseId
(),
storeDTO
.
getStoreId
());
}
...
...
@@ -76,7 +82,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
ServiceResponse
<
List
<
StoreDTO
>>
listStoreResponse
=
this
.
storeApiService
.
listStoreByStoreInfoId
(
storeInfoId
);
List
<
StoreDTO
>
listStore
=
listStoreResponse
.
getResult
();
for
(
StoreDTO
storeDTO
:
listStore
){
this
.
storeApiService
.
deleteStoreFromE
S
(
storeDTO
.
getEnterpriseId
(),
storeDTO
.
getStoreId
());
this
.
storeApiService
.
deleteStoreFromE
s
(
storeDTO
.
getEnterpriseId
(),
storeDTO
.
getStoreId
());
}
}
}
...
...
@@ -91,7 +97,7 @@ public class StoreInfoMessageHandler implements MessageHandler {
}
StoreWidgetDTO
storeWidgetDTO
=
storeWidget
.
getResult
();
if
(
storeWidgetDTO
!=
null
){
if
(
AuthModeEnum
.
YES
.
getCode
()
==
storeWidgetDTO
.
getAuthMode
(
)){
if
(
AuthModeEnum
.
YES
.
getCode
()
.
equals
(
storeWidgetDTO
.
getAuthMode
()
)){
StoreSearchDTO
storeSearchDTO
=
new
StoreSearchDTO
();
storeSearchDTO
.
setStoreInfoIds
(
String
.
valueOf
(
storeInfoId
));
storeSearchDTO
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
...
...
@@ -109,11 +115,11 @@ public class StoreInfoMessageHandler implements MessageHandler {
}
else
{
this
.
storeAuthorizationApiService
.
cancelStore
(
storeInfoId
,
dto
.
getUnionEnterpriseId
());
}
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_region_id"
).
getValue
())
!=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_region_id"
).
getValue
(
))){
StoreSearchDTO
storeSearchD
TO
1
=
new
StoreSearchDTO
();
storeSearchD
TO
1
.
setRegionId
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_region_id"
).
getValue
()));
storeSearchD
TO
1
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
storeSearchD
TO
1
.
setEnterpriseId
(
enterpriseId
);
if
(
!
Integer
.
valueOf
(
fieldMap
.
get
(
"old_region_id"
).
getValue
()).
equals
(
Integer
.
valueOf
(
fieldMap
.
get
(
"new_region_id"
).
getValue
()
))){
StoreSearchDTO
storeSearchD
to
1
=
new
StoreSearchDTO
();
storeSearchD
to
1
.
setRegionId
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_region_id"
).
getValue
()));
storeSearchD
to
1
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
storeSearchD
to
1
.
setEnterpriseId
(
enterpriseId
);
ServiceResponse
<
Page
<
StoreDTO
>>
response1
=
this
.
storeApiService
.
listStore
(
storeSearchDTO
,
1
,
1
);
if
(
CollectionUtils
.
isEmpty
(
response1
.
getResult
().
getResult
())){
this
.
storeRegionApiService
.
unAuthorizeRegion
(
dto
.
getUnionEnterpriseId
(),
Integer
.
valueOf
(
fieldMap
.
get
(
"old_region_id"
).
getValue
()));
...
...
src/main/java/com/gic/message/service/impl/StoreMessageHandler.java
View file @
04e1c964
...
...
@@ -3,7 +3,6 @@ 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
;
...
...
@@ -25,9 +24,21 @@ import org.springframework.stereotype.Component;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @ClassName: StoreMessageHandler
* @Description:
* @author zhiwj
* @date 2020-09-10 15:12
*/
@Component
public
class
StoreMessageHandler
implements
MessageHandler
{
public
static
final
String
OLD_STATUS
=
"old_status"
;
public
static
final
String
NEW_STATUS
=
"new_status"
;
public
static
final
String
NEW_OWN_TYPE
=
"new_own_type"
;
public
static
final
Integer
NEW_STATUS_VALUE
=
2
;
@Autowired
private
StoreApiService
storeApiService
;
@Autowired
...
...
@@ -58,14 +69,14 @@ public class StoreMessageHandler implements MessageHandler {
enterpriseId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_enterprise_id"
).
getValue
());
storeId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_store_id"
).
getValue
());
storeInfoId
=
Integer
.
valueOf
(
fieldMap
.
get
(
"new_store_info_id"
).
getValue
());
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_status"
).
getValue
())
==
1
&&
Integer
.
valueOf
(
fieldMap
.
get
(
"new_status"
).
getValue
())
==
0
)
{
//删除
this
.
storeApiService
.
deleteStoreFromE
S
(
enterpriseId
,
storeId
);
}
else
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
"old_status"
).
getValue
())
==
1
&&
Integer
.
valueOf
(
fieldMap
.
get
(
"new_status"
).
getValue
())
==
2
){
//下线
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
OLD_STATUS
).
getValue
())
==
1
&&
Integer
.
valueOf
(
fieldMap
.
get
(
NEW_STATUS
).
getValue
())
==
0
)
{
//删除
this
.
storeApiService
.
deleteStoreFromE
s
(
enterpriseId
,
storeId
);
}
else
if
(
Integer
.
valueOf
(
fieldMap
.
get
(
OLD_STATUS
).
getValue
())
==
1
&&
Integer
.
valueOf
(
fieldMap
.
get
(
NEW_STATUS
).
getValue
()).
equals
(
NEW_STATUS_VALUE
)
){
//下线
//todo 通知会员组(积分成本转移)
}
else
{
this
.
storeIndexRefreshHandler
.
refreshStoreIndex
(
enterpriseId
,
storeId
);
}
if
(
StoreOwnTypeEnum
.
OWNER
.
getCode
()
==
Integer
.
valueOf
(
fieldMap
.
get
(
"new_own_type"
).
getValue
()))
{
if
(
StoreOwnTypeEnum
.
OWNER
.
getCode
()
==
Integer
.
valueOf
(
fieldMap
.
get
(
NEW_OWN_TYPE
).
getValue
()))
{
this
.
dealStoreChange
(
enterpriseId
,
storeId
,
storeInfoId
,
GicRecordType
.
UPDATE
.
value
());
}
}
...
...
@@ -73,7 +84,7 @@ public class StoreMessageHandler implements MessageHandler {
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
.
storeApiService
.
deleteStoreFromE
S
(
enterpriseId
,
storeId
);
this
.
storeApiService
.
deleteStoreFromE
s
(
enterpriseId
,
storeId
);
Integer
ownType
=
Integer
.
valueOf
(
fieldMap
.
get
(
"own_type"
).
getValue
());
if
(
ownType
==
StoreOwnTypeEnum
.
OWNER
.
getCode
()){
this
.
dealStoreChange
(
enterpriseId
,
storeId
,
storeInfoId
,
GicRecordType
.
DELETE
.
value
());
...
...
@@ -91,7 +102,7 @@ public class StoreMessageHandler implements MessageHandler {
}
StoreWidgetDTO
storeWidgetDTO
=
storeWidget
.
getResult
();
if
(
storeWidgetDTO
!=
null
){
if
(
AuthModeEnum
.
YES
.
getCode
()
==
storeWidgetDTO
.
getAuthMode
(
)){
if
(
AuthModeEnum
.
YES
.
getCode
()
.
equals
(
storeWidgetDTO
.
getAuthMode
()
)){
StoreSearchDTO
storeSearchDTO
=
new
StoreSearchDTO
();
storeSearchDTO
.
setStoreIds
(
String
.
valueOf
(
storeId
));
storeSearchDTO
.
setSearchJson
(
storeWidgetDTO
.
getSearchParam
());
...
...
src/main/java/com/gic/message/utils/ListToMapUtil.java
View file @
04e1c964
...
...
@@ -8,7 +8,13 @@ import org.apache.kafka.clients.consumer.ConsumerRecord;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
*
* @ClassName: ListToMapUtil
* @Description:
* @author zhiwj
* @date 2020-09-10 15:10
*/
public
class
ListToMapUtil
{
public
static
Map
<
String
,
GicField
>
listToMap
(
ConsumerRecord
<
String
,
GicRecord
>
consumerRecord
){
GicRecord
value
=
consumerRecord
.
value
();
...
...
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