parent
163ed45b69
commit
6d20e7dd55
@ -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
|
@ -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;
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue