From 6d20e7dd55a147367decfd5093f46d6aa5dd1be4 Mon Sep 17 00:00:00 2001
From: qyx <565485304@qq.com>
Date: Wed, 18 May 2022 20:46:28 +0800
Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](master):?=
=?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5=E6=A8=A1=E5=9D=97?=
=?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=9A=84=E4=BB=A3=E7=A0=81=E7=BC=96=E5=86=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. 使用策略模式和工厂模式对多种方式的数据模式进行编写
---
README.md | 8 ++--
.../com/baiye/core/constant/HttpStatus.java | 3 +-
.../api-entrance => cdp-customer}/pom.xml | 4 +-
cdp-entrance/api-entrance/.gitignore | 21 ---------
.../pom.xml | 2 +-
.../pom.xml | 15 ++++++-
.../com/baiye/CdpEntranceApplication.java | 17 +++++++
.../baiye/service/AsyncDataUploadService.java | 10 +++++
.../baiye/service/SyncDataUploadService.java | 19 ++++++++
.../EntranceKeyAndBeanNameConstants.java | 28 ++++++++++++
.../factory/EntranceStrategyFactory.java | 38 ++++++++++++++++
.../impl/AsyncDataUploadServiceImpl.java | 16 +++++++
.../service/impl/DataUploadServiceImpl.java | 44 +++++++++++++++++++
.../service/strategy/ApiEntranceStrategy.java | 18 ++++++++
.../strategy/DatabaseEntranceStrategy.java | 18 ++++++++
.../strategy/EmptyEntranceStrategy.java | 18 ++++++++
.../strategy/FileEntranceStrategy.java | 19 ++++++++
.../service/strategy/IEntranceStrategy.java | 16 +++++++
cdp-entrance/database-entrance/.gitignore | 21 ---------
cdp-entrance/file-entrance/.gitignore | 21 ---------
cdp-entrance/pom.xml | 7 +--
pom.xml | 1 +
22 files changed, 289 insertions(+), 75 deletions(-)
rename {cdp-entrance/api-entrance => cdp-customer}/pom.xml (85%)
delete mode 100644 cdp-entrance/api-entrance/.gitignore
rename cdp-entrance/{file-entrance => cdp-entrance-api}/pom.xml (91%)
rename cdp-entrance/{database-entrance => cdp-entrance-service}/pom.xml (57%)
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/CdpEntranceApplication.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/AsyncDataUploadService.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/SyncDataUploadService.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceKeyAndBeanNameConstants.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceStrategyFactory.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/AsyncDataUploadServiceImpl.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/DataUploadServiceImpl.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/ApiEntranceStrategy.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/DatabaseEntranceStrategy.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/EmptyEntranceStrategy.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/FileEntranceStrategy.java
create mode 100644 cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/IEntranceStrategy.java
delete mode 100644 cdp-entrance/database-entrance/.gitignore
delete mode 100644 cdp-entrance/file-entrance/.gitignore
diff --git a/README.md b/README.md
index 825752f..9223784 100644
--- a/README.md
+++ b/README.md
@@ -20,11 +20,13 @@
cdp-retrieval
- dy-retrieval-content 抖音内容检索
cdp-entrance 数据入口层
- - api-entrance API数据入口
- - database-entrance 数据库数据入口
- - file-entrance 文件数据入口
+ - 开放三方平台的API数据对接入口
+ - 开放三方平台的数据库数据同步解决方案,使用API来进行包装
+ - 开放三方平台的文件上传数据入口
cdp-tag-center 标签中心
(标签中心这个后面做多个服务来进行支撑)
+ cdp-customer 客户模块[业务模块]
+
## 内部服务结构
xxx
diff --git a/cdp-common/cdp-common-core/src/main/java/com/baiye/core/constant/HttpStatus.java b/cdp-common/cdp-common-core/src/main/java/com/baiye/core/constant/HttpStatus.java
index add01e6..ff20bb5 100644
--- a/cdp-common/cdp-common-core/src/main/java/com/baiye/core/constant/HttpStatus.java
+++ b/cdp-common/cdp-common-core/src/main/java/com/baiye/core/constant/HttpStatus.java
@@ -5,8 +5,7 @@ package com.baiye.core.constant;
*
* @author ruoyi
*/
-public final class HttpStatus
-{
+public final class HttpStatus {
/**
* 操作成功
*/
diff --git a/cdp-entrance/api-entrance/pom.xml b/cdp-customer/pom.xml
similarity index 85%
rename from cdp-entrance/api-entrance/pom.xml
rename to cdp-customer/pom.xml
index d9b9ced..0d9632b 100644
--- a/cdp-entrance/api-entrance/pom.xml
+++ b/cdp-customer/pom.xml
@@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- cdp-entrance
+ by-cdp
com.baiye
1.0-SNAPSHOT
4.0.0
- api-entrance
+ cdp-customer
8
diff --git a/cdp-entrance/api-entrance/.gitignore b/cdp-entrance/api-entrance/.gitignore
deleted file mode 100644
index 8ae32f5..0000000
--- a/cdp-entrance/api-entrance/.gitignore
+++ /dev/null
@@ -1,21 +0,0 @@
-### Maven template
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-# https://github.com/takari/maven-wrapper#usage-without-binary-jar
-.mvn/wrapper/maven-wrapper.jar
-
-### Example user template template
-### Example user template
-
-# IntelliJ project files
-.idea
-*.iml
-out
-gen
diff --git a/cdp-entrance/file-entrance/pom.xml b/cdp-entrance/cdp-entrance-api/pom.xml
similarity index 91%
rename from cdp-entrance/file-entrance/pom.xml
rename to cdp-entrance/cdp-entrance-api/pom.xml
index 30d3439..962f048 100644
--- a/cdp-entrance/file-entrance/pom.xml
+++ b/cdp-entrance/cdp-entrance-api/pom.xml
@@ -9,7 +9,7 @@
4.0.0
- file-entrance
+ cdp-entrance-api
8
diff --git a/cdp-entrance/database-entrance/pom.xml b/cdp-entrance/cdp-entrance-service/pom.xml
similarity index 57%
rename from cdp-entrance/database-entrance/pom.xml
rename to cdp-entrance/cdp-entrance-service/pom.xml
index a2a3662..0be9c43 100644
--- a/cdp-entrance/database-entrance/pom.xml
+++ b/cdp-entrance/cdp-entrance-service/pom.xml
@@ -9,11 +9,24 @@
4.0.0
- database-entrance
+ cdp-entrance-service
8
8
+
+
+ com.baiye
+ cdp-common
+ 1.0-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
\ No newline at end of file
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/CdpEntranceApplication.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/CdpEntranceApplication.java
new file mode 100644
index 0000000..59279bb
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/CdpEntranceApplication.java
@@ -0,0 +1,17 @@
+package com.baiye;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * cdp数据入口入口 应用程序
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@SpringBootApplication
+public class CdpEntranceApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(CdpEntranceApplication.class, args);
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/AsyncDataUploadService.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/AsyncDataUploadService.java
new file mode 100644
index 0000000..f6c772f
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/AsyncDataUploadService.java
@@ -0,0 +1,10 @@
+package com.baiye.service;
+
+/**
+ * 异步数据上传服务
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+public interface AsyncDataUploadService {
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/SyncDataUploadService.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/SyncDataUploadService.java
new file mode 100644
index 0000000..4ffdd56
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/SyncDataUploadService.java
@@ -0,0 +1,19 @@
+package com.baiye.service;
+
+/**
+ * 同步数据上传服务
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+public interface SyncDataUploadService {
+
+ /**
+ * fixme 这个是测试的,用于来示例调用方式,在写这个的时候进行参考再编写实际的代码
+ *
+ */
+ @Deprecated
+ boolean demoUploadData();
+
+
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceKeyAndBeanNameConstants.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceKeyAndBeanNameConstants.java
new file mode 100644
index 0000000..0fbaf79
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceKeyAndBeanNameConstants.java
@@ -0,0 +1,28 @@
+package com.baiye.service.factory;
+
+/**
+ * enum入口键和bean名称
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+public class EntranceKeyAndBeanNameConstants {
+
+ /**
+ * api入口的关键
+ */
+ public static final String API_ENTRANCE_KEY = "API-ENTRANCE";
+ /**
+ * db入口的关键
+ */
+ public static final String DB_ENTRANCE_KEY = "DB-ENTRANCE";
+ /**
+ * 入口文件的关键
+ */
+ public static final String FILE_ENTRANCE_KEY = "FILE-ENTRANCE";
+ /**
+ * 空的关键入口
+ */
+ public static final String EMPTY_ENTRANCE_KEY = "EMPTY-ENTRANCE";
+
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceStrategyFactory.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceStrategyFactory.java
new file mode 100644
index 0000000..5f6a526
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/factory/EntranceStrategyFactory.java
@@ -0,0 +1,38 @@
+package com.baiye.service.factory;
+
+import cn.hutool.core.util.StrUtil;
+import com.baiye.service.strategy.*;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * 入口策略工厂
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Component
+public class EntranceStrategyFactory {
+
+ private EntranceStrategyFactory(Map entranceStrategyMap) {
+ this.entranceStrategyMap = entranceStrategyMap;
+ }
+
+ public Map entranceStrategyMap;
+
+ /**
+ * 获取入口策略
+ *
+ * @param entranceKey 人口策略
+ * @return 具体策略的实现
+ */
+ public IEntranceStrategy getEntranceStrategy(String entranceKey) {
+
+ IEntranceStrategy entranceStrategy = entranceStrategyMap.get(entranceKey);
+
+ return StrUtil.isBlank(entranceKey) ? entranceStrategyMap.get(EntranceKeyAndBeanNameConstants.EMPTY_ENTRANCE_KEY) : entranceStrategy;
+ }
+
+
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/AsyncDataUploadServiceImpl.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/AsyncDataUploadServiceImpl.java
new file mode 100644
index 0000000..7b75813
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/AsyncDataUploadServiceImpl.java
@@ -0,0 +1,16 @@
+package com.baiye.service.impl;
+
+import com.baiye.service.AsyncDataUploadService;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.stereotype.Service;
+
+/**
+ * 异步数据上传服务
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Service
+@EnableAsync
+public class AsyncDataUploadServiceImpl implements AsyncDataUploadService {
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/DataUploadServiceImpl.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/DataUploadServiceImpl.java
new file mode 100644
index 0000000..3673ca4
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/impl/DataUploadServiceImpl.java
@@ -0,0 +1,44 @@
+package com.baiye.service.impl;
+
+import com.baiye.service.SyncDataUploadService;
+import com.baiye.service.factory.EntranceKeyAndBeanNameConstants;
+import com.baiye.service.factory.EntranceStrategyFactory;
+import com.baiye.service.strategy.IEntranceStrategy;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.security.spec.ECField;
+
+/**
+ * 同步数据上传服务impl
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Service
+public class DataUploadServiceImpl implements SyncDataUploadService {
+
+
+ @Autowired
+ private EntranceStrategyFactory entranceStrategyFactory;
+
+ /**
+ * 上线后进行删除
+ *
+ * @return 上传成功或者失败的标识
+ */
+ @Override
+ @Deprecated
+ public boolean demoUploadData() {
+ // 选择上传方式 空的
+ IEntranceStrategy entranceStrategy = entranceStrategyFactory.getEntranceStrategy("");
+ entranceStrategy.doEntrance();
+
+
+ // 选择其他上传方式
+ IEntranceStrategy entranceStrategy1 = entranceStrategyFactory.getEntranceStrategy(EntranceKeyAndBeanNameConstants.API_ENTRANCE_KEY);
+ entranceStrategy1.doEntrance();
+
+ return false;
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/ApiEntranceStrategy.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/ApiEntranceStrategy.java
new file mode 100644
index 0000000..1e157e7
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/ApiEntranceStrategy.java
@@ -0,0 +1,18 @@
+package com.baiye.service.strategy;
+
+import com.baiye.service.factory.EntranceKeyAndBeanNameConstants;
+import org.springframework.stereotype.Component;
+
+/**
+ * 通用api入口策略
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Component(value = EntranceKeyAndBeanNameConstants.API_ENTRANCE_KEY)
+public class ApiEntranceStrategy implements IEntranceStrategy{
+ @Override
+ public void doEntrance() {
+
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/DatabaseEntranceStrategy.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/DatabaseEntranceStrategy.java
new file mode 100644
index 0000000..4f44be7
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/DatabaseEntranceStrategy.java
@@ -0,0 +1,18 @@
+package com.baiye.service.strategy;
+
+import com.baiye.service.factory.EntranceKeyAndBeanNameConstants;
+import org.springframework.stereotype.Component;
+
+/**
+ * 通用数据库入口策略
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Component(value = EntranceKeyAndBeanNameConstants.DB_ENTRANCE_KEY)
+public class DatabaseEntranceStrategy implements IEntranceStrategy{
+ @Override
+ public void doEntrance() {
+
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/EmptyEntranceStrategy.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/EmptyEntranceStrategy.java
new file mode 100644
index 0000000..7b58225
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/EmptyEntranceStrategy.java
@@ -0,0 +1,18 @@
+package com.baiye.service.strategy;
+
+import com.baiye.service.factory.EntranceKeyAndBeanNameConstants;
+import org.springframework.stereotype.Component;
+
+/**
+ * 空入口策略
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Component(value = EntranceKeyAndBeanNameConstants.EMPTY_ENTRANCE_KEY)
+public class EmptyEntranceStrategy implements IEntranceStrategy{
+ @Override
+ public void doEntrance() {
+
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/FileEntranceStrategy.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/FileEntranceStrategy.java
new file mode 100644
index 0000000..ff0da3d
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/FileEntranceStrategy.java
@@ -0,0 +1,19 @@
+package com.baiye.service.strategy;
+
+import com.baiye.service.factory.EntranceKeyAndBeanNameConstants;
+import org.springframework.stereotype.Component;
+
+/**
+ * 通用文件入口策略
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+@Component(value = EntranceKeyAndBeanNameConstants.FILE_ENTRANCE_KEY)
+public class FileEntranceStrategy implements IEntranceStrategy{
+
+ @Override
+ public void doEntrance() {
+
+ }
+}
diff --git a/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/IEntranceStrategy.java b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/IEntranceStrategy.java
new file mode 100644
index 0000000..f3a74f6
--- /dev/null
+++ b/cdp-entrance/cdp-entrance-service/src/main/java/com/baiye/service/strategy/IEntranceStrategy.java
@@ -0,0 +1,16 @@
+package com.baiye.service.strategy;
+
+/**
+ * 上传方式策略模式接口
+ *
+ * @author q
+ * @date 2022/05/18
+ */
+public interface IEntranceStrategy {
+
+ /**
+ * 进行上传操作
+ */
+ void doEntrance();
+
+}
diff --git a/cdp-entrance/database-entrance/.gitignore b/cdp-entrance/database-entrance/.gitignore
deleted file mode 100644
index 8ae32f5..0000000
--- a/cdp-entrance/database-entrance/.gitignore
+++ /dev/null
@@ -1,21 +0,0 @@
-### Maven template
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-# https://github.com/takari/maven-wrapper#usage-without-binary-jar
-.mvn/wrapper/maven-wrapper.jar
-
-### Example user template template
-### Example user template
-
-# IntelliJ project files
-.idea
-*.iml
-out
-gen
diff --git a/cdp-entrance/file-entrance/.gitignore b/cdp-entrance/file-entrance/.gitignore
deleted file mode 100644
index 8ae32f5..0000000
--- a/cdp-entrance/file-entrance/.gitignore
+++ /dev/null
@@ -1,21 +0,0 @@
-### Maven template
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-# https://github.com/takari/maven-wrapper#usage-without-binary-jar
-.mvn/wrapper/maven-wrapper.jar
-
-### Example user template template
-### Example user template
-
-# IntelliJ project files
-.idea
-*.iml
-out
-gen
diff --git a/cdp-entrance/pom.xml b/cdp-entrance/pom.xml
index b4a7f50..28f6213 100644
--- a/cdp-entrance/pom.xml
+++ b/cdp-entrance/pom.xml
@@ -12,9 +12,8 @@
cdp-entrance
pom
- api-entrance
- database-entrance
- file-entrance
+ cdp-entrance-api
+ cdp-entrance-service
@@ -22,4 +21,6 @@
8
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ddc6a7f..bd63c5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,7 @@
cdp-retrieval
cdp-entrance
cdp-tag-center
+ cdp-customer