Commit bdcb861a by ThomasAdv

数据上报接口代码审查与增加注释

1 parent 1a17bba5
...@@ -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);
......
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";
}
...@@ -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;
} }
......
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;
}
} }
...@@ -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");
......
...@@ -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("-", "");
} }
......
...@@ -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" />
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!