[新增功能](master): 数据导入模块相关的代码编写

1. 使用策略模式和工厂模式对多种方式的数据模式进行编写
master
土豆兄弟 2 years ago
parent 163ed45b69
commit 6d20e7dd55

@ -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

@ -5,8 +5,7 @@ package com.baiye.core.constant;
*
* @author ruoyi
*/
public final class HttpStatus
{
public final class HttpStatus {
/**
*
*/

@ -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">
<parent>
<artifactId>cdp-entrance</artifactId>
<artifactId>by-cdp</artifactId>
<groupId>com.baiye</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api-entrance</artifactId>
<artifactId>cdp-customer</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>

@ -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

@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>file-entrance</artifactId>
<artifactId>cdp-entrance-api</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>

@ -9,11 +9,24 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>database-entrance</artifactId>
<artifactId>cdp-entrance-service</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.baiye</groupId>
<artifactId>cdp-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

@ -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);
}
}

@ -0,0 +1,10 @@
package com.baiye.service;
/**
*
*
* @author q
* @date 2022/05/18
*/
public interface AsyncDataUploadService {
}

@ -0,0 +1,19 @@
package com.baiye.service;
/**
*
*
* @author q
* @date 2022/05/18
*/
public interface SyncDataUploadService {
/**
* fixme ,,
*
*/
@Deprecated
boolean demoUploadData();
}

@ -0,0 +1,28 @@
package com.baiye.service.factory;
/**
* enumbean
*
* @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";
}

@ -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<String, IEntranceStrategy> entranceStrategyMap) {
this.entranceStrategyMap = entranceStrategyMap;
}
public Map<String, IEntranceStrategy> 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;
}
}

@ -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 {
}

@ -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;
}
}

@ -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() {
}
}

@ -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() {
}
}

@ -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() {
}
}

@ -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() {
}
}

@ -0,0 +1,16 @@
package com.baiye.service.strategy;
/**
*
*
* @author q
* @date 2022/05/18
*/
public interface IEntranceStrategy {
/**
*
*/
void doEntrance();
}

@ -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

@ -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

@ -12,9 +12,8 @@
<artifactId>cdp-entrance</artifactId>
<packaging>pom</packaging>
<modules>
<module>api-entrance</module>
<module>database-entrance</module>
<module>file-entrance</module>
<module>cdp-entrance-api</module>
<module>cdp-entrance-service</module>
</modules>
<properties>
@ -22,4 +21,6 @@
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>

@ -19,6 +19,7 @@
<module>cdp-retrieval</module>
<module>cdp-entrance</module>
<module>cdp-tag-center</module>
<module>cdp-customer</module>
</modules>

Loading…
Cancel
Save