Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
7c328d51
Commit
7c328d51
authored
Dec 22, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
埋点
parent
daea2d91
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
329 additions
and
10 deletions
+329
-10
pom.xml
pom.xml
+61
-9
InnerController.java
...tgroup/xyqb/controller/internal/user/InnerController.java
+4
-0
UserCenterController.java
...controller/internal/user/center/UserCenterController.java
+7
-1
UserExtController.java
...qb/controller/middleoffice/userext/UserExtController.java
+7
-0
UserDetailUpdateEventListener.java
.../quantgroup/xyqb/event/UserDetailUpdateEventListener.java
+60
-0
UserExtInfoSaveEvent.java
...n/java/cn/quantgroup/xyqb/event/UserExtInfoSaveEvent.java
+29
-0
UserExtInfoSaveEventListener.java
...n/quantgroup/xyqb/event/UserExtInfoSaveEventListener.java
+70
-0
KinesisProducerClientFactory.java
...risk/uereventcollecting/KinesisProducerClientFactory.java
+37
-0
UserEventCollectingUtil.java
...xyqb/risk/uereventcollecting/UserEventCollectingUtil.java
+54
-0
No files found.
pom.xml
View file @
7c328d51
...
...
@@ -27,19 +27,19 @@
<dependencies>
<!-- swagger2 start -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
RELEASE
</version>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
RELEASE
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-core
</artifactId>
<version>
RELEASE
</version>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-core
</artifactId>
<version>
RELEASE
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
RELEASE
</version>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
RELEASE
</version>
</dependency>
<!-- swagger2 end -->
<dependency>
...
...
@@ -340,6 +340,58 @@
<artifactId>
qiniu-java-sdk
</artifactId>
<version>
7.2.27
</version>
</dependency>
<!-- 大数据用户行为采集 http://confluence.quantgroup.cn/pages/viewpage.action?pageId=34818640 -->
<dependency>
<groupId>
cn.qg.ec.data-stream-sdk
</groupId>
<artifactId>
data-stream-sdk
</artifactId>
<version>
1.0.5-SNAPSHOT
</version>
<exclusions>
<exclusion>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
<!--<exclusion>-->
<!--<groupId>commons-io</groupId>-->
<!--<artifactId>commons-io</artifactId>-->
<!--</exclusion>-->
<exclusion>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
</exclusion>
<exclusion>
<groupId>
commons-logging
</groupId>
<artifactId>
commons-logging
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
</exclusion>
<exclusion>
<groupId>
joda-time
</groupId>
<artifactId>
joda-time
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/InnerController.java
View file @
7c328d51
...
...
@@ -23,6 +23,8 @@ import cn.quantgroup.xyqb.entity.UserExtInfo;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.event.DisableActiveEvent
;
import
cn.quantgroup.xyqb.event.UserDetailUpdateEvent
;
import
cn.quantgroup.xyqb.event.UserExtInfoSaveEvent
;
import
cn.quantgroup.xyqb.exception.UserNotExistException
;
import
cn.quantgroup.xyqb.model.AddressRet
;
import
cn.quantgroup.xyqb.model.ContactInfo
;
...
...
@@ -644,6 +646,8 @@ public class InnerController implements IBaseController {
info
.
setMarryStatus
(
cn
.
quantgroup
.
user
.
enums
.
MaritalStatus
.
valueOf
(
maritalStatus
.
name
()));
}
info
=
userExtInfoService
.
save
(
info
);
applicationEventPublisher
.
publishEvent
(
new
UserExtInfoSaveEvent
(
this
,
info
));
return
JsonResult
.
buildSuccessResult
(
null
,
UserExtInfoRet
.
getUserExtInfoRet
(
info
));
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/center/UserCenterController.java
View file @
7c328d51
...
...
@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.entity.User;
import
cn.quantgroup.xyqb.entity.UserAttached
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.event.UserExtInfoSaveEvent
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.IAddressService
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
...
...
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -59,7 +61,8 @@ public class UserCenterController {
private
IAddressService
addressService
;
@Autowired
private
IUserService
userService
;
@Autowired
private
ApplicationEventPublisher
applicationEventPublisher
;
@GetMapping
(
"/attach"
)
public
JsonResult
queryUserAttach
(
Long
userId
)
{
...
...
@@ -396,6 +399,9 @@ public class UserCenterController {
}
userExtInfo
=
userExtInfoService
.
save
(
userExtInfo
);
applicationEventPublisher
.
publishEvent
(
new
UserExtInfoSaveEvent
(
this
,
userExtInfo
));
return
JsonResult
.
buildSuccessResult
(
null
,
userExtInfo
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/userext/UserExtController.java
View file @
7c328d51
...
...
@@ -6,6 +6,7 @@ import cn.quantgroup.xyqb.controller.middleoffice.userext.req.UserExtReq;
import
cn.quantgroup.xyqb.entity.Address
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.event.UserExtInfoSaveEvent
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.IAddressService
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
...
...
@@ -13,6 +14,8 @@ import cn.quantgroup.xyqb.service.user.IUserDetailService;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PutMapping
;
...
...
@@ -47,6 +50,9 @@ public class UserExtController {
@Resource
private
IUserService
userService
;
@Resource
private
ApplicationEventPublisher
applicationEventPublisher
;
//todo 保存失败的各种场景。
@PutMapping
(
"/{userId}"
)
public
JsonResult
ext
(
@PathVariable
Long
userId
,
@RequestBody
UserExtReq
userExtReq
)
{
...
...
@@ -81,6 +87,7 @@ public class UserExtController {
}
}
userExtInfoService
.
save
(
userExtReq
.
getExtInfo
());
applicationEventPublisher
.
publishEvent
(
new
UserExtInfoSaveEvent
(
this
,
userExtReq
.
getExtInfo
()));
}
return
JsonResult
.
buildSuccessResult
();
}
...
...
src/main/java/cn/quantgroup/xyqb/event/UserDetailUpdateEventListener.java
0 → 100644
View file @
7c328d51
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.qg.ec.model.base.BusinessEventBaseInfo
;
import
cn.qg.ec.model.user.UserBaseInfoEvent
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.risk.uereventcollecting.UserEventCollectingUtil
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
/**
* @author :dongjianhua
* @date :Created in 2020/12/22 16:21
* @description:用变更身份证号的时候发送给大数据
* @modified By:
* @version:
*/
@Slf4j
@Component
public
class
UserDetailUpdateEventListener
implements
ApplicationListener
<
UserDetailUpdateEvent
>
{
@Autowired
private
IUserService
userService
;
@Override
public
void
onApplicationEvent
(
UserDetailUpdateEvent
userDetailUpdateEvent
)
{
UserDetail
userDetail
=
userDetailUpdateEvent
.
getUserDetail
();
log
.
info
(
"用户实名认证事件监听,userDetail:{}"
,
userDetail
);
if
(
null
==
userDetail
)
{
log
.
error
(
"来了个假的?????"
);
return
;
}
if
(
null
==
userDetail
.
getIdNo
()){
log
.
warn
(
"实名认证没有身份证号?userId:{}"
,
userDetail
.
getUserId
());
return
;
}
UserBaseInfoEvent
.
UserBaseInfoEventBuilder
builder
=
UserBaseInfoEvent
.
builder
();
builder
.
maskIdNo
(
userDetail
.
getIdNo
());
User
user
=
userService
.
findById
(
userDetail
.
getUserId
());
if
(
null
==
user
)
{
log
.
error
(
"用户竟然不存在userDetail:{}"
,
userDetail
);
return
;
}
BusinessEventBaseInfo
.
BusinessEventBaseInfoBuilder
baseInfoBuilder
=
BusinessEventBaseInfo
.
builder
();
baseInfoBuilder
.
userUuid
(
user
.
getUuid
());
builder
.
businessEventBaseInfo
(
baseInfoBuilder
.
build
());
UserEventCollectingUtil
.
addEvent
(
builder
.
build
());
log
.
info
(
"用户实名认证事件监听结束userId:{}"
,
userDetail
.
getUserId
());
}
}
src/main/java/cn/quantgroup/xyqb/event/UserExtInfoSaveEvent.java
0 → 100644
View file @
7c328d51
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
lombok.Getter
;
import
org.springframework.context.ApplicationEvent
;
/**
* @author :dongjianhua
* @date :Created in 2020/12/22 11:42
* @description:用户扩展信息事件监听
* @modified By:
* @version:
*/
@Getter
public
class
UserExtInfoSaveEvent
extends
ApplicationEvent
{
private
UserExtInfo
userExtInfo
;
public
UserExtInfoSaveEvent
(
Object
source
)
{
super
(
source
);
}
public
UserExtInfoSaveEvent
(
Object
source
,
UserExtInfo
extInfo
)
{
super
(
source
);
userExtInfo
=
extInfo
;
}
}
src/main/java/cn/quantgroup/xyqb/event/UserExtInfoSaveEventListener.java
0 → 100644
View file @
7c328d51
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.qg.ec.model.base.BusinessEventBaseInfo
;
import
cn.qg.ec.model.user.UserBaseInfoEvent
;
import
cn.quantgroup.user.enums.EducationEnum
;
import
cn.quantgroup.user.enums.IncomeRangeEnum
;
import
cn.quantgroup.user.enums.MaritalStatus
;
import
cn.quantgroup.user.enums.OccupationEnum
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.risk.uereventcollecting.UserEventCollectingUtil
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
/**
* @author :dongjianhua
* @date :Created in 2020/12/22 14:25
* @description:监听
* @modified By:
* @version:
*/
@Slf4j
@Component
public
class
UserExtInfoSaveEventListener
implements
ApplicationListener
<
UserExtInfoSaveEvent
>
{
@Autowired
private
IUserService
userService
;
@Override
public
void
onApplicationEvent
(
UserExtInfoSaveEvent
userExtInfoSaveEvent
)
{
UserExtInfo
userExtInfo
=
userExtInfoSaveEvent
.
getUserExtInfo
();
log
.
info
(
"用户开始保存扩展信息userExtInfo:{}"
,
userExtInfo
);
EducationEnum
educationEnum
=
userExtInfo
.
getEducationEnum
();
IncomeRangeEnum
incomeRangeEnum
=
userExtInfo
.
getIncomeRangeEnum
();
MaritalStatus
marryStatus
=
userExtInfo
.
getMarryStatus
();
OccupationEnum
occupationEnum
=
userExtInfo
.
getOccupationEnum
();
UserBaseInfoEvent
.
UserBaseInfoEventBuilder
builder
=
UserBaseInfoEvent
.
builder
();
builder
.
subEventType
(
UserBaseInfoEvent
.
SubEventType
.
user_occupation
);
if
(
null
!=
educationEnum
)
{
builder
.
education
(
String
.
valueOf
(
educationEnum
.
ordinal
()));
}
if
(
null
!=
incomeRangeEnum
)
{
builder
.
income
(
String
.
valueOf
(
incomeRangeEnum
.
ordinal
()));
}
if
(
null
!=
marryStatus
)
{
builder
.
maritalStatus
(
String
.
valueOf
(
marryStatus
.
ordinal
()));
}
if
(
null
!=
occupationEnum
)
{
builder
.
occupation
(
String
.
valueOf
(
occupationEnum
.
ordinal
()));
}
BusinessEventBaseInfo
.
BusinessEventBaseInfoBuilder
baseInfoBuilder
=
BusinessEventBaseInfo
.
builder
();
User
user
=
userService
.
findById
(
userExtInfo
.
getUserId
());
if
(
null
==
user
)
{
log
.
error
(
"没找到用户,应该不存在这种情况"
);
}
baseInfoBuilder
.
userId
(
user
.
getUuid
());
builder
.
businessEventBaseInfo
(
baseInfoBuilder
.
build
());
UserEventCollectingUtil
.
addEvent
(
builder
.
build
());
}
}
src/main/java/cn/quantgroup/xyqb/risk/uereventcollecting/KinesisProducerClientFactory.java
0 → 100644
View file @
7c328d51
package
cn
.
quantgroup
.
xyqb
.
risk
.
uereventcollecting
;
import
cn.qg.ec.kinesis.EnvironmentConfig
;
import
cn.qg.ec.kinesis.KinesisProducerClient
;
import
cn.quantgroup.tech.util.TechEnvironment
;
/**
* @author :dongjianhua
* @date :Created in 2020/12/21 16:15
* @description:client获取
* @modified By:
* @version:
*/
public
class
KinesisProducerClientFactory
{
private
KinesisProducerClientFactory
()
{
}
private
static
KinesisProducerClient
client
;
public
static
KinesisProducerClient
getClient
()
{
if
(
null
==
client
)
{
synchronized
(
KinesisProducerClient
.
class
)
{
if
(
null
==
client
)
{
client
=
new
KinesisProducerClient
(
getConfig
());
}
}
}
return
client
;
}
private
static
EnvironmentConfig
getConfig
()
{
if
(!
TechEnvironment
.
isPro
())
{
return
EnvironmentConfig
.
DEV
;
}
return
EnvironmentConfig
.
PROD
;
}
}
src/main/java/cn/quantgroup/xyqb/risk/uereventcollecting/UserEventCollectingUtil.java
0 → 100644
View file @
7c328d51
package
cn
.
quantgroup
.
xyqb
.
risk
.
uereventcollecting
;
import
cn.qg.ec.kinesis.KinesisProducerClient
;
import
cn.qg.ec.model.base.EventInfo
;
import
com.alibaba.fastjson.JSON
;
import
com.amazonaws.services.kinesis.producer.UserRecordResult
;
import
com.google.common.util.concurrent.FutureCallback
;
import
com.google.common.util.concurrent.Futures
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
lombok.extern.slf4j.Slf4j
;
import
javax.annotation.Nullable
;
import
java.io.UnsupportedEncodingException
;
/**
* @author :dongjianhua
* @date :Created in 2020/12/21 16:01
* @description:用户事件采集工具类
* @modified By:
* @version: http://confluence.quantgroup.cn/pages/viewpage.action?pageId=34820403
*/
@Slf4j
public
class
UserEventCollectingUtil
{
private
static
final
MyCallBack
CALL_BACK
=
new
MyCallBack
();
public
static
void
addEvent
(
EventInfo
eventInfo
)
{
KinesisProducerClient
client
=
KinesisProducerClientFactory
.
getClient
();
try
{
ListenableFuture
<
UserRecordResult
>
future
=
client
.
SendRecord
(
eventInfo
);
Futures
.
addCallback
(
future
,
CALL_BACK
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"发送事件异常UnsupportedEncodingException:{}"
,
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"发送事件未知异常e"
,
e
);
}
}
@Slf4j
public
static
class
MyCallBack
<
UserRecordResult
>
implements
FutureCallback
<
UserRecordResult
>
{
@Override
public
void
onSuccess
(
@Nullable
UserRecordResult
userRecordResult
)
{
log
.
info
(
"发送事件成功 o:{}"
,
JSON
.
toJSONString
(
userRecordResult
));
}
@Override
public
void
onFailure
(
Throwable
throwable
)
{
log
.
error
(
"发送事件失败"
,
throwable
);
}
}
}
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