Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-cdp-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bdcb861a
authored
Sep 21, 2023
by
ThomasAdv
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
数据上报接口代码审查与增加注释
1 parent
1a17bba5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
7 deletions
platform-cdp-api/src/main/java/cn/com/glsx/cdp/api/UserCenterFeignClient.java
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/ModelConstants.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/api/UserApiController.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/enums/OneIdBelongEnum.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdMappingService.java
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdService.java
platform-cdp/src/main/resources/mapper/CustomerSopJourneyMapper.xml
platform-cdp-api/src/main/java/cn/com/glsx/cdp/api/UserCenterFeignClient.java
View file @
bdcb861
...
@@ -42,7 +42,7 @@ public interface UserCenterFeignClient {
...
@@ -42,7 +42,7 @@ public interface UserCenterFeignClient {
* 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略
* 注意: @RequestParam("xx") 注解一定要写,而且属性名xx不能省略
*/
*/
@GetMapping
(
"/echo"
)
@GetMapping
(
"/echo"
)
String
echo
(
@RequestParam
String
message
);
String
echo
(
@RequestParam
(
"message"
)
String
message
);
@GetMapping
(
value
=
"/info/{id}"
)
@GetMapping
(
value
=
"/info/{id}"
)
UserDTO
info
(
@PathVariable
(
"id"
)
Long
id
);
UserDTO
info
(
@PathVariable
(
"id"
)
Long
id
);
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/common/constant/ModelConstants.java
0 → 100644
View file @
bdcb861
package
cn
.
com
.
glsx
.
cdp
.
common
.
constant
;
public
class
ModelConstants
{
public
final
static
String
CUSTOMER_MODEL_NAME
=
"cdp_customer"
;
public
final
static
String
CAR_MODEL_NAME
=
"cdp_car"
;
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/api/UserApiController.java
View file @
bdcb861
...
@@ -37,7 +37,7 @@ public class UserApiController implements UserCenterFeignClient {
...
@@ -37,7 +37,7 @@ public class UserApiController implements UserCenterFeignClient {
@Operation
(
summary
=
"FeignClient调用"
)
@Operation
(
summary
=
"FeignClient调用"
)
@Override
@Override
@GetMapping
(
"/echo"
)
@GetMapping
(
"/echo"
)
public
String
echo
(
@RequestParam
String
message
)
{
public
String
echo
(
@RequestParam
(
"message"
)
String
message
)
{
String
echo
=
echoCenterFeignClient
.
echo
(
message
);
String
echo
=
echoCenterFeignClient
.
echo
(
message
);
return
echo
;
return
echo
;
}
}
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/enums/OneIdBelongEnum.java
View file @
bdcb861
package
cn
.
com
.
glsx
.
cdp
.
modules
.
enums
;
package
cn
.
com
.
glsx
.
cdp
.
modules
.
enums
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
enum
OneIdBelongEnum
{
public
enum
OneIdBelongEnum
{
CUSTOMER
((
byte
)
1
,
"oneId"
,
"客户"
),
CUSTOMER
((
byte
)
1
,
"oneId"
,
"
cdp_customer"
,
"
客户"
),
CAR
((
byte
)
2
,
"carId"
,
"车"
);
CAR
((
byte
)
2
,
"carId"
,
"
cdp_car"
,
"
车"
);
private
final
Byte
value
;
private
final
Byte
value
;
private
final
String
oneIdFieldName
;
private
final
String
oneIdFieldName
;
private
final
String
modelName
;
private
final
String
displayText
;
private
final
String
displayText
;
OneIdBelongEnum
(
Byte
value
,
String
oneIdFieldName
,
String
displayText
){
OneIdBelongEnum
(
Byte
value
,
String
oneIdFieldName
,
String
modelName
,
String
displayText
){
this
.
value
=
value
;
this
.
value
=
value
;
this
.
oneIdFieldName
=
oneIdFieldName
;
this
.
oneIdFieldName
=
oneIdFieldName
;
this
.
modelName
=
modelName
;
this
.
displayText
=
displayText
;
this
.
displayText
=
displayText
;
}
}
...
@@ -22,6 +30,10 @@ public enum OneIdBelongEnum {
...
@@ -22,6 +30,10 @@ public enum OneIdBelongEnum {
return
oneIdFieldName
;
return
oneIdFieldName
;
}
}
public
String
getModelName
()
{
return
modelName
;
}
public
String
getDisplayText
()
{
public
String
getDisplayText
()
{
return
displayText
;
return
displayText
;
}
}
...
@@ -36,4 +48,19 @@ public enum OneIdBelongEnum {
...
@@ -36,4 +48,19 @@ public enum OneIdBelongEnum {
}
}
return
null
;
return
null
;
}
}
public
static
List
<
String
>
getModelNames
(){
return
Arrays
.
stream
(
OneIdBelongEnum
.
values
()).
map
(
OneIdBelongEnum:
:
getModelName
).
collect
(
Collectors
.
toList
());
}
public
static
OneIdBelongEnum
getByModelName
(
String
modelName
){
if
(
StringUtils
.
isNotBlank
(
modelName
))
{
for
(
OneIdBelongEnum
oneIdBelongEnum
:
OneIdBelongEnum
.
values
())
{
if
(
oneIdBelongEnum
.
getModelName
().
equals
(
modelName
))
{
return
oneIdBelongEnum
;
}
}
}
return
null
;
}
}
}
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/queue/DataReportRabbitMQConsumer.java
View file @
bdcb861
This diff is collapsed.
Click to expand it.
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdMappingService.java
View file @
bdcb861
...
@@ -44,7 +44,10 @@ public class OneIdMappingService {
...
@@ -44,7 +44,10 @@ public class OneIdMappingService {
return
null
;
return
null
;
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
void
saveOneIdMapping
(
String
oneId
,
OneIdFieldConfigDTO
oneIdFieldConfigDTO
){
public
void
saveOneIdMapping
(
String
oneId
,
OneIdFieldConfigDTO
oneIdFieldConfigDTO
){
log
.
info
(
"saveOneIdMapping, oneId:{}, oneIdFieldConfigDTO:{}"
,
oneId
,
oneIdFieldConfigDTO
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
,
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getOrgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getOrgId() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getOrgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getOrgId() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getBusinessType() not be null"
);
RpcAssert
.
assertNotNull
(
oneIdFieldConfigDTO
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"oneIdFieldConfigDTO.getBusinessType() not be null"
);
...
...
platform-cdp/src/main/java/cn/com/glsx/cdp/modules/service/OneIdService.java
View file @
bdcb861
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -28,6 +29,9 @@ public class OneIdService {
...
@@ -28,6 +29,9 @@ public class OneIdService {
private
OneIdMappingService
oneIdMappingService
;
private
OneIdMappingService
oneIdMappingService
;
@Autowired
@Autowired
private
OneIdFieldConfigService
oneIdFieldConfigService
;
private
OneIdFieldConfigService
oneIdFieldConfigService
;
@Lazy
@Autowired
private
OneIdService
thiz
;
/**
/**
...
@@ -38,7 +42,9 @@ public class OneIdService {
...
@@ -38,7 +42,9 @@ public class OneIdService {
* @author caiym
* @author caiym
* @date 2023年09月21日 16:07:51
* @date 2023年09月21日 16:07:51
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
String
findOrCreateOneId
(
FindOrCreateOneIdParam
param
){
public
String
findOrCreateOneId
(
FindOrCreateOneIdParam
param
){
log
.
info
(
"findOrCreateOneId, param:{}"
,
param
);
RpcAssert
.
assertNotNull
(
param
,
DefaultErrorEnum
.
DATA_NULL
,
"param not be null"
);
RpcAssert
.
assertNotNull
(
param
,
DefaultErrorEnum
.
DATA_NULL
,
"param not be null"
);
RpcAssert
.
assertNotNull
(
param
.
getOrgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"param.getOrgId() not be null"
);
RpcAssert
.
assertNotNull
(
param
.
getOrgId
(),
DefaultErrorEnum
.
DATA_NULL
,
"param.getOrgId() not be null"
);
RpcAssert
.
assertNotNull
(
param
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"param.getBusinessType() not be null"
);
RpcAssert
.
assertNotNull
(
param
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"param.getBusinessType() not be null"
);
...
@@ -48,7 +54,7 @@ public class OneIdService {
...
@@ -48,7 +54,7 @@ public class OneIdService {
String
finalOneId
=
null
;
String
finalOneId
=
null
;
if
(
CollectionUtils
.
isNotEmpty
(
readyMatchOneIdFieldConfigs
))
{
if
(
CollectionUtils
.
isNotEmpty
(
readyMatchOneIdFieldConfigs
))
{
for
(
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
:
readyMatchOneIdFieldConfigs
)
{
for
(
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
:
readyMatchOneIdFieldConfigs
)
{
finalOneId
=
findOrCreateOneId
(
finalOneId
,
readyMatchOneIdFieldConfig
);
finalOneId
=
thiz
.
findOrCreateOneId
(
finalOneId
,
readyMatchOneIdFieldConfig
);
}
}
}
else
{
}
else
{
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"none match oneId field config, param: "
+
JSONObject
.
toJSONString
(
param
));
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
"none match oneId field config, param: "
+
JSONObject
.
toJSONString
(
param
));
...
@@ -66,11 +72,14 @@ public class OneIdService {
...
@@ -66,11 +72,14 @@ public class OneIdService {
* @author caiym
* @author caiym
* @date 2023年09月21日 16:53:44
* @date 2023年09月21日 16:53:44
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
String
findOrCreateOneId
(
String
finalOneId
,
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
){
public
String
findOrCreateOneId
(
String
finalOneId
,
OneIdFieldConfigDTO
readyMatchOneIdFieldConfig
){
log
.
info
(
"findOrCreateOneId,finalOneId:{},fieldName:{}"
,
readyMatchOneIdFieldConfig
.
getFieldName
());
OneIdMappingDTO
oneIdMapping
=
oneIdMappingService
.
getOneIdMapping
(
readyMatchOneIdFieldConfig
.
getOrgId
(),
OneIdMappingDTO
oneIdMapping
=
oneIdMappingService
.
getOneIdMapping
(
readyMatchOneIdFieldConfig
.
getOrgId
(),
readyMatchOneIdFieldConfig
.
getBusinessType
(),
readyMatchOneIdFieldConfig
.
getFieldName
());
readyMatchOneIdFieldConfig
.
getBusinessType
(),
readyMatchOneIdFieldConfig
.
getFieldName
());
if
(
oneIdMapping
==
null
)
{
if
(
oneIdMapping
==
null
)
{
if
(
StringUtils
.
isBlank
(
finalOneId
))
{
if
(
StringUtils
.
isBlank
(
finalOneId
))
{
log
.
info
(
"generate new oneId,fieldName:{}"
,
readyMatchOneIdFieldConfig
.
getFieldName
());
//TODO 雪花算法
//TODO 雪花算法
finalOneId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
finalOneId
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
}
}
...
...
platform-cdp/src/main/resources/mapper/CustomerSopJourneyMapper.xml
View file @
bdcb861
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
<result
column=
"del_flag"
jdbcType=
"INTEGER"
property=
"delFlag"
/>
<result
column=
"del_flag"
jdbcType=
"INTEGER"
property=
"delFlag"
/>
</resultMap>
</resultMap>
<resultMap
id=
"BOResultMap"
type=
"cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO"
>
<resultMap
id=
"BOResultMap"
type=
"cn.com.glsx.cdp.modules.model.CustomerSopJourneyBO"
extends=
"BaseResultMap"
>
<association
property=
"customer"
javaType=
"cn.com.glsx.cdp.modules.model.CustomerBO"
>
<association
property=
"customer"
javaType=
"cn.com.glsx.cdp.modules.model.CustomerBO"
>
<result
column=
"org_id"
jdbcType=
"VARCHAR"
property=
"orgId"
/>
<result
column=
"org_id"
jdbcType=
"VARCHAR"
property=
"orgId"
/>
<result
column=
"one_id"
jdbcType=
"VARCHAR"
property=
"oneId"
/>
<result
column=
"one_id"
jdbcType=
"VARCHAR"
property=
"oneId"
/>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment