├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── stone ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── es │ │ │ └── stone │ │ │ └── StoneApplicationTests.java │ └── main │ │ └── java │ │ └── com │ │ └── es │ │ └── stone │ │ ├── converter │ │ ├── IdConverter.java │ │ ├── ArrayConverter.java │ │ └── LocationConverter.java │ │ ├── result │ │ ├── BaseErrorCode.java │ │ ├── BaseResult.java │ │ ├── BasePageResult.java │ │ └── ResultSupport.java │ │ ├── enums │ │ └── EsStatus.java │ │ ├── util │ │ ├── WebPager.java │ │ ├── Pager.java │ │ ├── ConvertUtil.java │ │ ├── Test.java │ │ ├── CustomizationClassLoader.java │ │ ├── MobilePager.java │ │ ├── Pagers.java │ │ └── CamelCaseUtils.java │ │ ├── constant │ │ └── EsConstant.java │ │ └── manager │ │ ├── ElasticSearchIndexManager.java │ │ ├── ElasticSearchInitClientManager.java │ │ └── ElasticSearchDumpManager.java ├── pom.xml └── mvnw.cmd ├── data-back ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── es │ │ │ └── databack │ │ │ └── DataBackApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── es │ │ │ └── databack │ │ │ ├── common │ │ │ ├── Table.java │ │ │ └── Column.java │ │ │ ├── DataBackApplication.java │ │ │ ├── util │ │ │ ├── DatabaseUtil.java │ │ │ ├── StringUtil.java │ │ │ └── FileHelper.java │ │ │ ├── configuration │ │ │ ├── Swagger2Config.java │ │ │ └── auth │ │ │ │ └── WebConfiguration.java │ │ │ ├── enums │ │ │ ├── SqlTypeEnum.java │ │ │ └── IndexTypeEnum.java │ │ │ └── controller │ │ │ └── ConstantController.java │ │ └── resources │ │ ├── templates │ │ ├── data-migration │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── es │ │ │ │ │ └── datamigration │ │ │ │ │ ├── model │ │ │ │ │ └── ${className}DO.ftl │ │ │ │ │ ├── mapper │ │ │ │ │ └── ${className}DOMapper.ftl │ │ │ │ │ ├── util │ │ │ │ │ └── Convert${className}Util.ftl │ │ │ │ │ ├── controller │ │ │ │ │ └── ${className}Controller.ftl │ │ │ │ │ └── manager │ │ │ │ │ └── ${classNameLower} │ │ │ │ │ └── ${className}ToEsManager.ftl │ │ │ │ └── resources │ │ │ │ └── com │ │ │ │ └── es │ │ │ │ └── datamigration │ │ │ │ └── mapper │ │ │ │ └── ${className}DOMapper.xml │ │ ├── data-search │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── es │ │ │ │ └── datasearch │ │ │ │ ├── service │ │ │ │ ├── ${className}Service.ftl │ │ │ │ └── impl │ │ │ │ │ └── ${className}ServiceImpl.ftl │ │ │ │ ├── param │ │ │ │ └── Query${className}SearchVO.ftl │ │ │ │ ├── controller │ │ │ │ └── ${className}Controller.ftl │ │ │ │ └── manager │ │ │ │ └── ${classNameLower} │ │ │ │ └── ${className}SearchManager.ftl │ │ └── data-dump │ │ │ └── datadump │ │ │ └── ${package} │ │ │ ├── model │ │ │ └── ${className}Model.ftl │ │ │ ├── dao │ │ │ └── ${className}Dao.ftl │ │ │ ├── service │ │ │ ├── ${className}Service.ftl │ │ │ └── impl │ │ │ │ └── ${className}ServiceImpl.ftl │ │ │ └── mapper │ │ │ └── ${className}Mapper.xml │ │ ├── application.yml │ │ └── META-INF │ │ └── spring │ │ └── application-manager.xml ├── pom.xml └── mvnw.cmd ├── data-dump ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ └── META-INF │ │ │ │ └── spring │ │ │ │ └── application-manager.xml │ │ └── java │ │ │ └── com │ │ │ └── es │ │ │ └── datadump │ │ │ ├── manager │ │ │ ├── canal │ │ │ │ ├── CanalCoreManager.java │ │ │ │ └── CanalInitClientManager.java │ │ │ └── ServiceImportManager.java │ │ │ ├── DataDumpApplication.java │ │ │ ├── run │ │ │ ├── ElasticsearchEnvInitRunner.java │ │ │ └── CanalClientRunner.java │ │ │ └── util │ │ │ └── CharSetUtil.java │ └── test │ │ └── java │ │ └── com │ │ └── es │ │ └── datadump │ │ └── DataDumpApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── data-search ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── es │ │ │ └── datasearch │ │ │ ├── service │ │ │ ├── ArticleService.java │ │ │ └── impl │ │ │ │ └── ArticleServiceImpl.java │ │ │ ├── result │ │ │ └── ResultByEsDO.java │ │ │ ├── param │ │ │ └── QueryArticleSearchVO.java │ │ │ ├── controller │ │ │ ├── TestController.java │ │ │ └── ArticleController.java │ │ │ ├── DataSearchApplication.java │ │ │ └── util │ │ │ └── ConvertDateUtil.java │ └── test │ │ └── java │ │ └── com │ │ └── es │ │ └── datasearch │ │ ├── CreateSqlTest.java │ │ └── DataSearchApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── data-migration ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.yml │ │ │ ├── config │ │ │ │ ├── mybatis-config.xml │ │ │ │ └── generator │ │ │ │ │ └── generatorConfig.xml │ │ │ ├── com │ │ │ │ └── es │ │ │ │ │ └── datamigration │ │ │ │ │ └── mapper │ │ │ │ │ └── TbArticleDOMapper.xml │ │ │ └── META-INF │ │ │ │ └── spring │ │ │ │ └── application-persistance.xml │ │ └── java │ │ │ └── com │ │ │ └── es │ │ │ └── datamigration │ │ │ ├── mapper │ │ │ └── TbArticleDOMapper.java │ │ │ ├── model │ │ │ └── TbArticleDO.java │ │ │ ├── util │ │ │ └── ConvertMapUtil.java │ │ │ ├── run │ │ │ └── ElasticSearchInitRunner.java │ │ │ ├── DataMigrationApplication.java │ │ │ ├── configuration │ │ │ ├── Swagger2Config.java │ │ │ └── auth │ │ │ │ └── WebConfiguration.java │ │ │ ├── controller │ │ │ └── ArticleController.java │ │ │ └── manager │ │ │ ├── ServiceImportManager.java │ │ │ └── article │ │ │ └── ArticleSyncToEsManager.java │ └── test │ │ └── java │ │ └── datamigration │ │ └── datamigration │ │ └── DataMigrationApplicationTests.java ├── .gitignore ├── pom.xml └── mvnw.cmd ├── .gitignore ├── db_search.sql ├── pom.xml ├── README.md ├── mvnw.cmd └── mvnw /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /stone/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/stone/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /data-back/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/data-back/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /data-dump/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/data-dump/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /data-search/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/data-search/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /data-search/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8083 3 | 4 | es: 5 | client: 6 | servers: localhost:9200 7 | -------------------------------------------------------------------------------- /data-migration/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HappyWjl/es-home/HEAD/data-migration/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /stone/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /data-dump/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /data-search/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /data-back/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /data-migration/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /data-dump/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 3 | 4 | es: 5 | client: 6 | servers: localhost:9200 7 | 8 | canal: 9 | client: 10 | servers: 127.0.0.1:11111 11 | cluser: false 12 | destination: articlesubscibe -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/manager/canal/CanalCoreManager.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.manager.canal; 2 | 3 | public class CanalCoreManager extends AbstractCanalCoreManager { 4 | 5 | public CanalCoreManager(String destination) { 6 | super(destination); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /data-migration/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8082 3 | 4 | es: 5 | client: 6 | servers: localhost:9200 7 | 8 | local: 9 | jdbc: 10 | url: jdbc:mysql://localhost:3306/db_search?autoReconnect=true&useUnicode=true&characterset=utf8mb4 11 | username: root 12 | password: root -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/service/ArticleService.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.service; 2 | 3 | import com.es.datasearch.param.QueryArticleSearchVO; 4 | import com.es.datasearch.result.ResultByEsDO; 5 | 6 | public interface ArticleService { 7 | 8 | ResultByEsDO getArticleList(QueryArticleSearchVO queryArticleSearchVO); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /stone/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /data-dump/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /data-search/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /data-migration/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /data-back/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /nbbuild/ 22 | /dist/ 23 | /nbdist/ 24 | /.nb-gradle/ 25 | /build/ 26 | 27 | ### VS Code ### 28 | .vscode/ 29 | -------------------------------------------------------------------------------- /stone/src/test/java/com/es/stone/StoneApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.es.stone; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class StoneApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-search/src/test/java/com/es/datasearch/CreateSqlTest.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch; 2 | 3 | public class CreateSqlTest { 4 | 5 | public static void main(String[] args) { 6 | String s = "('%s', '我是测试数据标题%s', '我是测试数据内容%s', '2', '22.539051', '113.952254', '2018-08-20 11:03:00', '2018-08-20 00:00:00'),"; 7 | 8 | for(int i = 31; i<1000; i++) { 9 | System.out.println(String.format(s, i, i, i)); 10 | } 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/converter/IdConverter.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.converter; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 将数据id拼接后缀 9 | * 10 | * @author Administrator 11 | */ 12 | public class IdConverter { 13 | 14 | public static void IdConverter(Map colMap, String index) { 15 | colMap.put(EsConstant.ES_KEY, colMap.get(EsConstant.ES_KEY).toString() + index); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /data-back/src/test/java/com/es/databack/DataBackApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.es.databack; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DataBackApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-dump/src/test/java/com/es/datadump/DataDumpApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DataDumpApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-search/src/test/java/com/es/datasearch/DataSearchApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DataSearchApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/converter/ArrayConverter.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.converter; 2 | 3 | public class ArrayConverter { 4 | 5 | public static int[] convertArray(String str) { 6 | char[] arr; 7 | int[] intArr = new int[str.length()]; 8 | arr = str.toCharArray(); 9 | for (int i = 0; i < str.length(); i++) { 10 | intArr[i] = arr[i] - 48;//数字0~9的ASCII码为48~57 11 | } 12 | return intArr; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /data-migration/src/test/java/datamigration/datamigration/DataMigrationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package datamigration.datamigration; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class DataMigrationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/common/Table.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.common; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class Table { 9 | 10 | private String name; 11 | private String dbName; 12 | private String tableDesc; 13 | private List columns; 14 | private List pkColumns; 15 | 16 | public String getNameUpper() { 17 | return name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/result/ResultByEsDO.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.result; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | @Data 11 | @Builder 12 | public class ResultByEsDO implements Serializable { 13 | 14 | private int pageNo; 15 | 16 | private int pageSize; 17 | 18 | private List list; 19 | 20 | private String esStatus; 21 | 22 | private int recordSize; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/DataBackApplication.java: -------------------------------------------------------------------------------- 1 | package com.es.databack; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ImportResource; 6 | 7 | @ImportResource("classpath:META-INF/spring/*.xml") 8 | @SpringBootApplication 9 | public class DataBackApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DataBackApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/common/Column.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.common; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Column { 7 | 8 | private String name; 9 | private String dbName; 10 | private String label; 11 | private String type; 12 | private String dbType; 13 | private Integer length; 14 | private Boolean nullable; 15 | private Integer decimalDigits; 16 | 17 | public String getNameUpper() { 18 | return name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/mapper/TbArticleDOMapper.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.mapper; 2 | 3 | import com.es.datamigration.model.TbArticleDO; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface TbArticleDOMapper { 9 | 10 | /** 11 | * 查询所有数据列表 12 | * @return 13 | */ 14 | List selectAll(); 15 | 16 | /** 17 | * 分页查询所有数据列表 18 | * @return 19 | */ 20 | List selectByPage(@Param("skip") int skip, @Param("limit") int limit); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/result/BaseErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.result; 2 | 3 | import java.io.Serializable; 4 | 5 | public class BaseErrorCode implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private int errorCode; 10 | private String errorMsg; 11 | 12 | public BaseErrorCode(int errorCode, String errorMsg) { 13 | this.errorCode = errorCode; 14 | this.errorMsg = errorMsg; 15 | } 16 | 17 | public int getErrorCode() { 18 | return errorCode; 19 | } 20 | 21 | public String getErrorMsg() { 22 | return errorMsg; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/model/TbArticleDO.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.model; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | 8 | @Data 9 | public class TbArticleDO implements Serializable { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | private Long id; 14 | 15 | private String title; 16 | 17 | private String content; 18 | 19 | private Integer state; 20 | 21 | private Double latitude; 22 | 23 | private Double longitude; 24 | 25 | private Date createTime; 26 | 27 | private Date updateTime; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/java/com/es/datamigration/model/${className}DO.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.model; 2 | 3 | import lombok.Data; 4 | import java.io.Serializable; 5 | /** 6 | *

Description: [${table.tableDesc}model]

7 | * Created on ${date} 8 | * @author ${author} 9 | * @version 1.0 10 | * Copyright (c) ${year} ${website} 11 | */ 12 | @Data 13 | public class ${className}DO implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | <#list table.columns as column> 17 | 18 | private ${column.type} ${column.name}; 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/enums/EsStatus.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.enums; 2 | 3 | public enum EsStatus { 4 | 5 | SUCESS("SUCESS",0), 6 | PARAM_ERROR("PARAM_ERROR",1); 7 | 8 | private String desc; 9 | private int type; 10 | 11 | private EsStatus(String desc,int type){ 12 | this.desc = desc; 13 | this.type = type; 14 | } 15 | 16 | public String getDesc() { 17 | return desc; 18 | } 19 | 20 | public int getType() { 21 | return type; 22 | } 23 | 24 | public static EsStatus getByType(int type) { 25 | for(EsStatus userType : values()) { 26 | if(userType.getType() == type) { 27 | return userType; 28 | } 29 | } 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /data-back/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8084 3 | 4 | es: 5 | client: 6 | servers: localhost:9200 7 | 8 | canal: 9 | client: 10 | servers: 127.0.0.1:11111 11 | cluser: false 12 | destination: articlesubscibe 13 | 14 | local: 15 | jdbc: 16 | driver: com.mysql.jdbc.Driver 17 | url: jdbc:mysql://localhost:3306/db_search?autoReconnect=true&useUnicode=true&characterset=utf8mb4 18 | username: root 19 | password: root 20 | 21 | #自动生成代码配置# 22 | 23 | #生成的包名 24 | basePackage: com.es. 25 | 26 | #输出路径,当输出地址为null时,文件放到固定项目目录下,否则输出到桌面指定文件夹下 27 | outRoot: 28 | 29 | #需要移除的表名前缀,使用逗号进行分隔多个前缀,可以没值 30 | #比如表名: tb_article,想将表名前缀移除,填入值: tb_ 31 | tableRemovePrefixes: 32 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-search/src/main/java/com/es/datasearch/service/${className}Service.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.service; 2 | 3 | import ${package}.param.Query${className}SearchVO; 4 | import ${package}.result.ResultByEsDO; 5 | 6 | /** 7 | * Description: [${table.tableDesc}数据ES查询] 8 | * Created on ${date} 9 | * @author ${author} 10 | * @version 1.0 11 | * Copyright (c) ${year} ${website} 12 | */ 13 | public interface ${className}Service { 14 | 15 | /** 16 | *

Discription:[${table.tableDesc}数据ES查询]

17 | * Created on ${date} 18 | * 19 | * @author:${author} 20 | */ 21 | ResultByEsDO get${className}List (Query${className}SearchVO query${className}SearchVO); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/java/com/es/datamigration/mapper/${className}DOMapper.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.mapper; 2 | 3 | import ${package}.model.${className}DO; 4 | import org.apache.ibatis.annotations.Param; 5 | import java.util.List; 6 | 7 | /** 8 | *

Description: [${table.tableDesc}dao]

9 | * Created on ${date} 10 | * @author ${author} 11 | * @version 1.0 12 | * Copyright (c) ${year} ${website} 13 | */ 14 | public interface ${className}DOMapper{ 15 | 16 | /** 17 | * 查询所有数据 18 | */ 19 | List<${className}DO> selectAll (); 20 | 21 | /** 22 | * 分页查询所有数据列表 23 | * @return 24 | */ 25 | List<${className}DO> selectByPage(@Param("skip") int skip, @Param("limit") int limit); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/service/impl/ArticleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.service.impl; 2 | 3 | import com.es.datasearch.manager.tbArticle.ArticleSearchManager; 4 | import com.es.datasearch.param.QueryArticleSearchVO; 5 | import com.es.datasearch.result.ResultByEsDO; 6 | import com.es.datasearch.service.ArticleService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | @Service 11 | public class ArticleServiceImpl implements ArticleService { 12 | 13 | @Autowired 14 | ArticleSearchManager articleSearchManager; 15 | 16 | @Override 17 | public ResultByEsDO getArticleList(QueryArticleSearchVO queryArticleSearchVO) { 18 | return articleSearchManager.queryArticleList(queryArticleSearchVO); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/result/BaseResult.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.result; 2 | 3 | /** 4 | * Created by 海浩 on 2015/3/29. 5 | */ 6 | public class BaseResult extends ResultSupport { 7 | 8 | private static final long serialVersionUID = 4999091548448313101L; 9 | 10 | protected T value; 11 | 12 | public T getValue() { 13 | return value; 14 | } 15 | 16 | public void setValue(T value) { 17 | this.value = value; 18 | } 19 | 20 | public BaseResult(T value) { 21 | this.value = value; 22 | } 23 | 24 | public BaseResult() { 25 | 26 | } 27 | 28 | public static BaseResult buildSuccessResult(U value) { 29 | BaseResult baseResult = new BaseResult(); 30 | baseResult.setSuccess(true); 31 | baseResult.setValue(value); 32 | return baseResult; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/java/com/es/datamigration/util/Convert${className}Util.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import ${package}.model.${className}DO; 7 | import com.es.stone.util.ConvertUtil; 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * Description: [${table.tableDesc}转map] 12 | * Created on ${date} 13 | * @author ${author} 14 | * @version 1.0 15 | * Copyright (c) ${year} ${website} 16 | */ 17 | @Slf4j 18 | public class Convert${className}Util { 19 | 20 | public static Map convertToMap(${className}DO ${classNameLower}DO) { 21 | try { 22 | return ConvertUtil.objectToMap(${classNameLower}DO); 23 | } catch (Exception e) { 24 | e.printStackTrace(); 25 | } 26 | return new HashMap(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/util/DatabaseUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.util; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class DatabaseUtil { 8 | 9 | /** 10 | * 获取数据库链接 11 | * @param driver 12 | * @param url 13 | * @param name 14 | * @param pwd 15 | * @return 16 | */ 17 | public static Connection getConnection(String driver, String url, String name, String pwd){ 18 | try{ 19 | Class.forName(driver); 20 | Connection conn= DriverManager.getConnection(url,name,pwd);//获取连接对象 21 | return conn; 22 | }catch(ClassNotFoundException e){ 23 | e.printStackTrace(); 24 | return null; 25 | }catch(SQLException e){ 26 | e.printStackTrace(); 27 | return null; 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/WebPager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import java.util.List; 4 | 5 | public class WebPager extends Pager { 6 | 7 | private static final long serialVersionUID = 320206316488698266L; 8 | 9 | private int currentPage; 10 | 11 | WebPager(int pageSize, int currentPage) { 12 | super(pageSize); 13 | this.currentPage = currentPage; 14 | } 15 | 16 | WebPager load(List data, int totalCount) { 17 | this.data = data; 18 | this.totalCount = totalCount; 19 | return this; 20 | } 21 | 22 | public int getTotalPage() { 23 | if (totalCount % pageSize == 0) { 24 | return totalCount / pageSize; 25 | } else { 26 | return totalCount / pageSize + 1; 27 | } 28 | } 29 | 30 | public int getCurrentPage() { 31 | return currentPage; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/converter/LocationConverter.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.converter; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | import org.springframework.util.StringUtils; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * 获取经纬度,返回经纬度字符串 10 | * 11 | * @author Administrator 12 | */ 13 | public class LocationConverter { 14 | 15 | public static void locationConverter(Map colMap) { 16 | StringBuffer sb = new StringBuffer(); 17 | if (!StringUtils.isEmpty(colMap.get(EsConstant.GEO.LATITUDE).toString()) && 18 | !StringUtils.isEmpty(colMap.get(EsConstant.GEO.LONGITUDE).toString())) { 19 | sb.append(colMap.get(EsConstant.GEO.LATITUDE).toString()) 20 | .append(',') 21 | .append(colMap.get(EsConstant.GEO.LONGITUDE).toString()); 22 | colMap.put(EsConstant.GEO.LOCATION, sb.toString()); 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/param/QueryArticleSearchVO.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.param; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 搜索传入对象 7 | */ 8 | public class QueryArticleSearchVO implements Serializable { 9 | 10 | // 每页大小 11 | public int pageSize; 12 | 13 | // 页码 14 | public int pageNo; 15 | 16 | // 关键字,模糊查询 17 | public String keyWords; 18 | 19 | // 排序规则,0:创建时间倒序;1:距离由近到远排序 20 | public int sortType; 21 | 22 | // 传入经度 23 | public double latitude; 24 | 25 | // 传入纬度 26 | public double longitude; 27 | 28 | // 文章id 29 | public long id; 30 | 31 | // 文章标题 32 | public String title; 33 | 34 | // 文章内容 35 | public String content; 36 | 37 | // 文章状态,按照状态id + “,”分隔的字符串传入 38 | public String state; 39 | 40 | // 创建开始时间 41 | public String createStartTime; 42 | 43 | // 创建结束时间 44 | public String createEndTime; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/DataDumpApplication.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.ImportResource; 9 | import org.springframework.core.annotation.Order; 10 | 11 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) 12 | @ComponentScan 13 | @ImportResource("classpath:META-INF/spring/*.xml") 14 | @Order(1) 15 | public class DataDumpApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(DataDumpApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /data-back/src/main/resources/META-INF/spring/application-manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.controller; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.io.IOException; 9 | 10 | @Slf4j 11 | @RestController 12 | @RequestMapping("/api/test") 13 | public class TestController { 14 | 15 | /** 16 | * 根据条件查询列表 17 | * @return 18 | */ 19 | @GetMapping("/test") 20 | public String test(String cmd) { 21 | try { 22 | Process ps = Runtime.getRuntime().exec(cmd); 23 | ps.waitFor(); 24 | } catch (IOException ioe) { 25 | ioe.printStackTrace(); 26 | } catch (InterruptedException e) { 27 | e.printStackTrace(); 28 | } 29 | System.out.println("程序准备重启!"); 30 | return "aaa"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/controller/ArticleController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.es.datasearch.controller; 3 | 4 | import com.es.datasearch.param.QueryArticleSearchVO; 5 | import com.es.datasearch.result.ResultByEsDO; 6 | import com.es.datasearch.service.ArticleService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | /** 12 | * 文章搜索相关 13 | * 14 | */ 15 | @Slf4j 16 | @RestController 17 | @RequestMapping("/api/article") 18 | public class ArticleController { 19 | 20 | @Autowired 21 | private ArticleService articleService; 22 | 23 | /** 24 | * 查询文章列表 25 | * @return 26 | */ 27 | @PostMapping("/getArticleList") 28 | public ResultByEsDO getArticleList(@RequestBody QueryArticleSearchVO queryArticleSearchVO) { 29 | ResultByEsDO articleList = articleService.getArticleList(queryArticleSearchVO); 30 | return articleList; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/util/ConvertMapUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.util; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.es.datamigration.model.TbArticleDO; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | @Slf4j 11 | public class ConvertMapUtil { 12 | 13 | public static Map convertToMap(TbArticleDO tbArticleDO) { 14 | Map map = new HashMap<>(); 15 | map.put("id", tbArticleDO.getId()); 16 | map.put("title", tbArticleDO.getTitle()); 17 | map.put("content", tbArticleDO.getContent()); 18 | map.put("state", tbArticleDO.getState()); 19 | map.put("latitude", tbArticleDO.getLatitude()); 20 | map.put("longitude", tbArticleDO.getLongitude()); 21 | map.put("create_time", tbArticleDO.getCreateTime()); 22 | map.put("update_time", tbArticleDO.getUpdateTime()); 23 | log.info("TbArticleDO.convertToMap:{}", JSON.toJSONString(map)); 24 | return map; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/DataSearchApplication.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch; 2 | 3 | import com.es.stone.manager.ElasticSearchDumpManager; 4 | import com.es.stone.manager.ElasticSearchInitClientManager; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | 10 | @ComponentScan(basePackages = {"com.es.datasearch"}) 11 | @SpringBootApplication 12 | public class DataSearchApplication { 13 | 14 | public static void main(String[] args) { 15 | SpringApplication.run(DataSearchApplication.class, args); 16 | } 17 | 18 | @Bean 19 | public ElasticSearchDumpManager getElasticSearchDumpManager() { 20 | return new ElasticSearchDumpManager(); 21 | } 22 | 23 | @Bean 24 | public ElasticSearchInitClientManager getElasticSearchInitClientManager() { 25 | return new ElasticSearchInitClientManager(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/run/ElasticSearchInitRunner.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.run; 2 | 3 | import com.es.stone.manager.ElasticSearchInitClientManager; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * 此处只能监听到ContextClosedEvent 11 | * 因此,考虑使用CommandLineRunner实现启动后自动执行 12 | * 13 | * @author Administrator 14 | * 15 | */ 16 | @Slf4j 17 | @Component 18 | //@Order(3) 19 | public class ElasticSearchInitRunner implements CommandLineRunner { 20 | 21 | @Autowired 22 | private ElasticSearchInitClientManager elasticSearchInitClientManager; 23 | 24 | @Override 25 | public void run(String... args) { 26 | log.info("-----------------------------ES连接池初始化------------------------------------"); 27 | elasticSearchInitClientManager.initClientPool(); 28 | log.info("-----------------------------ES连接池初始化完成------------------------------------"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-search/src/main/java/com/es/datasearch/service/impl/${className}ServiceImpl.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.service.impl; 2 | 3 | import ${package}.manager.${classNameLower}.${className}SearchManager; 4 | import ${package}.param.Query${className}SearchVO; 5 | import ${package}.result.ResultByEsDO; 6 | import ${package}.service.${className}Service; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * Description: [${table.tableDesc}服务实现] 12 | * Created on ${date} 13 | * @author ${author} 14 | * @version 1.0 15 | * Copyright (c) ${year} ${website} 16 | */ 17 | @Service("${classNameLower}Service") 18 | public class ${className}ServiceImpl implements ${className}Service { 19 | 20 | @Autowired 21 | ${className}SearchManager ${classNameLower}SearchManager; 22 | 23 | @Override 24 | public ResultByEsDO get${className}List(Query${className}SearchVO query${className}SearchVO) { 25 | return ${classNameLower}SearchManager.query${className}List(query${className}SearchVO); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/Pager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | @JsonInclude(JsonInclude.Include.NON_NULL) 9 | public abstract class Pager implements Serializable { 10 | 11 | protected int pageSize; 12 | 13 | protected List data; 14 | 15 | protected Integer totalCount; 16 | 17 | Pager() { 18 | } 19 | 20 | Pager(int pageSize) { 21 | this.pageSize = pageSize; 22 | } 23 | 24 | public int getPageSize() { 25 | return pageSize; 26 | } 27 | 28 | public Pager setPageSize(int pageSize) { 29 | this.pageSize = pageSize; 30 | return this; 31 | } 32 | 33 | public List getData() { 34 | return data; 35 | } 36 | 37 | public Pager setData(List data) { 38 | this.data = data; 39 | return this; 40 | } 41 | 42 | public Integer getTotalCount() { 43 | return totalCount; 44 | } 45 | 46 | public void setTotalCount(Integer totalCount) { 47 | this.totalCount = totalCount; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/ConvertUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import java.beans.BeanInfo; 4 | import java.beans.Introspector; 5 | import java.beans.PropertyDescriptor; 6 | import java.lang.reflect.Method; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | public class ConvertUtil { 11 | 12 | public static Map objectToMap(Object obj) throws Exception { 13 | if (obj == null) 14 | return null; 15 | 16 | Map map = new HashMap<>(); 17 | BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); 18 | PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); 19 | for (PropertyDescriptor property : propertyDescriptors) { 20 | String key = property.getName(); 21 | if (key.compareToIgnoreCase("class") == 0) { 22 | continue; 23 | } 24 | Method getter = property.getReadMethod(); 25 | Object value = getter != null ? getter.invoke(obj) : null; 26 | map.put(CamelCaseUtils.toUnderlineName(key), value); 27 | } 28 | return map; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-dump/datadump/${package}/model/${className}Model.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.model; 2 | 3 | import java.io.Serializable; 4 | /** 5 | *

Description: [${table.tableDesc}model]

6 | * Created on ${date} 7 | * @author ${author} 8 | * @version 1.0 9 | * Copyright (c) ${year} ${website} 10 | */ 11 | public class ${className}Model implements Serializable { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | <#list table.columns as column> 16 | /** 17 | * ${column.label} 18 | */ 19 | private ${column.type} ${column.name}; 20 | 21 | 22 | // setter and getter 23 | <#list table.columns as column> 24 | /** 25 | *

Discription:[${column.label}]

26 | * Created on ${date} 27 | * @return ${column.type} 28 | * @author:${author} 29 | */ 30 | public ${column.type} get${column.nameUpper}(){ 31 | return ${column.name}; 32 | } 33 | /** 34 | *

Discription:[${column.label}]

35 | * Created on ${date} 36 | * @author:${author} 37 | */ 38 | public void set${column.nameUpper}(${column.type} ${column.name}){ 39 | this.${column.name} = ${column.name}; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/resources/com/es/datamigration/mapper/${className}DOMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <#list table.columns as column> 8 | 9 | 10 | 11 | 12 | 13 | 14 | SELECT 15 | 17 | ${column.dbName}<#if column_has_next>, 18 | 19 | ]]> 20 | FROM ${table.dbName} record 21 | 22 | 23 | 24 | 27 | 28 | 29 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-search/src/main/java/com/es/datasearch/param/Query${className}SearchVO.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.param; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | *

Description: [${table.tableDesc}搜索传入对象]

7 | * Created on ${date} 8 | * @author ${author} 9 | * @version 1.0 10 | * Copyright (c) ${year} ${website} 11 | */ 12 | public class Query${className}SearchVO implements Serializable { 13 | 14 | /** 15 | * 每页大小 16 | */ 17 | public int pageSize; 18 | 19 | /** 20 | * 页码 21 | */ 22 | public int pageNo; 23 | 24 | /** 25 | * 关键字,模糊查询 26 | */ 27 | public String keyWords; 28 | 29 | /** 30 | * 排序规则,0:创建时间倒序;1:距离由近到远排序 31 | */ 32 | public int sortType; 33 | 34 | /** 35 | * 传入经度 36 | */ 37 | public double latitude; 38 | 39 | /** 40 | * 传入纬度 41 | */ 42 | public double longitude; 43 | 44 | /** 45 | * 创建开始时间 46 | */ 47 | public String createStartTime; 48 | 49 | /** 50 | * 创建结束时间 51 | */ 52 | public String createEndTime; 53 | <#list table.columns as column> 54 | 55 | /** 56 | * ${column.label} 57 | */ 58 | public ${column.type} ${column.name}; 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/java/com/es/datamigration/controller/${className}Controller.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.controller; 2 | 3 | import ${package}.manager.${classNameLower}.${className}ToEsManager; 4 | import lombok.extern.slf4j.Slf4j; 5 | import io.swagger.annotations.Api; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | *

Description: [${table.tableDesc}历史数据同步]

13 | * Created on ${date} 14 | * @author ${author} 15 | * @version 1.0 16 | * Copyright (c) ${year} ${website} 17 | */ 18 | @Api("${className} 历史数据同步 API") 19 | @Slf4j 20 | @RestController 21 | @RequestMapping("/api/${classNameLower}") 22 | public class ${className}Controller { 23 | 24 | @Autowired 25 | private ${className}ToEsManager ${classNameLower}ToEsManager; 26 | 27 | /** 28 | * 开启同步数据,将表中数据同步到ES 29 | * @return 30 | */ 31 | @GetMapping("/${classNameLower}ToEs") 32 | public String syncPlaceToEs() { 33 | return ${classNameLower}ToEsManager.syncDataControl(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /data-migration/src/main/resources/config/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /data-dump/src/main/resources/META-INF/spring/application-manager.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/Test.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import javax.tools.JavaCompiler; 4 | import javax.tools.StandardJavaFileManager; 5 | import javax.tools.ToolProvider; 6 | import java.io.File; 7 | import java.util.Arrays; 8 | 9 | public class Test { 10 | 11 | /** 12 | * 编译java文件 13 | */ 14 | public static void compilerJava(String outRoot, String namespace, File... file) throws Exception{ 15 | String classPath = outRoot + "/" + namespace; 16 | // 取得当前系统的编译器 17 | JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler(); 18 | //获取一个文件管理器 19 | StandardJavaFileManager javaFileManager = javaCompiler.getStandardFileManager(null, null, null); 20 | try { 21 | //文件管理器与文件连接起来 22 | Iterable it = javaFileManager.getJavaFileObjects(file); 23 | File dir = new File(classPath); 24 | if(!dir.exists()){ 25 | dir.mkdirs(); 26 | } 27 | //创建编译任务 28 | JavaCompiler.CompilationTask task = javaCompiler.getTask(null, javaFileManager, null, Arrays.asList("-d", classPath + "/target/classes/"), null, it); 29 | //执行编译 30 | task.call(); 31 | } catch (Exception e) { 32 | e.printStackTrace(); 33 | } finally { 34 | javaFileManager.close(); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/DataMigrationApplication.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration; 2 | 3 | import com.es.stone.manager.ElasticSearchDumpManager; 4 | import com.es.stone.manager.ElasticSearchIndexManager; 5 | import com.es.stone.manager.ElasticSearchInitClientManager; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.context.annotation.ImportResource; 11 | 12 | @ComponentScan(basePackages = {"com.es.datamigration"}) 13 | @SpringBootApplication 14 | @ImportResource("classpath:META-INF/spring/*.xml") 15 | public class DataMigrationApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(DataMigrationApplication.class, args); 19 | } 20 | 21 | @Bean 22 | public ElasticSearchDumpManager getElasticSearchDumpManager() { 23 | return new ElasticSearchDumpManager(); 24 | } 25 | 26 | @Bean 27 | public ElasticSearchInitClientManager getElasticSearchInitClientManager() { 28 | return new ElasticSearchInitClientManager(); 29 | } 30 | 31 | @Bean 32 | public ElasticSearchIndexManager getElasticSearchIndexManager() { 33 | return new ElasticSearchIndexManager(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/configuration/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.configuration; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.spi.DocumentationType; 10 | import springfox.documentation.spring.web.plugins.Docket; 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 | 13 | /** 14 | * 项目启动后,可访问下方url查看api文档,方便测试 15 | * http://localhost:8084/swagger-ui.html#/ 16 | */ 17 | @Configuration 18 | @EnableSwagger2 19 | public class Swagger2Config { 20 | 21 | @Bean 22 | public Docket createRestApi() { 23 | return new Docket(DocumentationType.SWAGGER_2) 24 | .apiInfo(apiInfo()) 25 | .select().apis(RequestHandlerSelectors.basePackage("com.es.databack")) 26 | .paths(PathSelectors.any()).build(); 27 | } 28 | 29 | private ApiInfo apiInfo() { 30 | return new ApiInfoBuilder().version("1.0").title("得码网 API").description("得码网") 31 | .termsOfServiceUrl("http://www.dema.com/the url is not create") 32 | .contact("Happy王子乐 @得码网").build(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/configuration/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.configuration; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.spi.DocumentationType; 10 | import springfox.documentation.spring.web.plugins.Docket; 11 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 12 | 13 | /** 14 | * 项目启动后,可访问下方url查看api文档,方便测试 15 | * http://localhost:8084/swagger-ui.html#/ 16 | */ 17 | @Configuration 18 | @EnableSwagger2 19 | public class Swagger2Config { 20 | 21 | @Bean 22 | public Docket createRestApi() { 23 | return new Docket(DocumentationType.SWAGGER_2) 24 | .apiInfo(apiInfo()) 25 | .select().apis(RequestHandlerSelectors.basePackage("com.es.datamigration")) 26 | .paths(PathSelectors.any()).build(); 27 | } 28 | 29 | private ApiInfo apiInfo() { 30 | return new ApiInfoBuilder().version("1.0").title("得码网 API").description("得码网") 31 | .termsOfServiceUrl("http://www.dema.com/the url is not create") 32 | .contact("Happy王子乐 @得码网").build(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/run/ElasticsearchEnvInitRunner.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.run; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | import com.es.stone.manager.ElasticSearchIndexManager; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.core.annotation.Order; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 此处只能监听到ContextClosedEvent 14 | * 因此,考虑使用CommandLineRunner实现启动后自动执行 15 | * 同步模块启动校验特殊索引配置,在此类中添加。 16 | * 17 | * @author Administrator 18 | */ 19 | @Component 20 | @Order(2) 21 | public class ElasticsearchEnvInitRunner implements CommandLineRunner { 22 | 23 | private final static Logger logger = LoggerFactory.getLogger(ElasticsearchEnvInitRunner.class); 24 | 25 | @Autowired 26 | private ElasticSearchIndexManager elasticSearchIndexManager; 27 | 28 | @Override 29 | public void run(String... args) { 30 | logger.info("-------------------------------------检查ES索引状态---------------------------------------------"); 31 | boolean flag = elasticSearchIndexManager.checkIndex(EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE);//特殊索引配置入口,可直接追加 32 | if (!flag) { 33 | System.exit(0); 34 | } 35 | logger.info("-------------------------------------ES索引状态检查完成---------------------------------------------"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/enums/SqlTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.enums; 2 | 3 | public enum SqlTypeEnum { 4 | 5 | CHAR("CHAR","String"), 6 | VARCHAR("VARCHAR","String"), 7 | LONGVARCHAR("LONGVARCHAR","String"), 8 | TINYINT("TINYINT","Integer"), 9 | TINYINT_UNSIGNED("TINYINT UNSIGNED","Integer"), 10 | NUMERIC("NUMERIC","Double"), 11 | DECIMAL("DECIMAL","java.math.BigDecimal"), 12 | BIGINT("BIGINT","Long"), 13 | BIGINT_UNSIGNED("BIGINT UNSIGNED","Long"), 14 | REAL("REAL","Double"), 15 | SMALLINT("SMALLINT","Integer"), 16 | INTEGER("INTEGER","Integer"), 17 | INTEGER_UNSIGNED("INTEGER UNSIGNED","Integer"), 18 | INT("INT","Integer"), 19 | INT_UNSIGNED("INT UNSIGNED","Integer"), 20 | DATE("DATE","java.util.Date"), 21 | TIME("TIME","java.util.Date"), 22 | DATETIME("DATETIME","java.util.Date"), 23 | TIMESTAMP("TIMESTAMP","java.util.Date"), 24 | BIT("BITD","Boolean"); 25 | 26 | private final String sqlType; 27 | private final String javaType; 28 | 29 | SqlTypeEnum(String sqlType, String javaType) { 30 | this.sqlType = sqlType; 31 | this.javaType = javaType; 32 | } 33 | 34 | public static String getJavaTypeBySqlType(String sqlType) { 35 | for(SqlTypeEnum sqlTypeEnum : values()) { 36 | if(sqlTypeEnum.sqlType.equals(sqlType)) { 37 | return sqlTypeEnum.javaType; 38 | } 39 | } 40 | return ""; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-search/src/main/java/com/es/datasearch/controller/${className}Controller.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.controller; 2 | 3 | import ${package}.param.Query${className}SearchVO; 4 | import ${package}.result.ResultByEsDO; 5 | import ${package}.service.${className}Service; 6 | import lombok.extern.slf4j.Slf4j; 7 | import io.swagger.annotations.Api; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | /** 15 | *

Description: [${table.tableDesc}搜索]

16 | * Created on ${date} 17 | * @author ${author} 18 | * @version 1.0 19 | * Copyright (c) ${year} ${website} 20 | */ 21 | @Api("${className} 搜索 API") 22 | @Slf4j 23 | @RestController 24 | @RequestMapping("/api/${classNameLower}") 25 | public class ${className}Controller { 26 | 27 | @Autowired 28 | private ${className}Service ${classNameLower}Service; 29 | 30 | /** 31 | * 根据条件查询列表 32 | * @return 33 | */ 34 | @PostMapping("/get${className}List") 35 | public ResultByEsDO get${className}List(@RequestBody Query${className}SearchVO query${className}SearchVO) { 36 | return ${classNameLower}Service.get${className}List(query${className}SearchVO); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/CustomizationClassLoader.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import java.io.FileInputStream; 4 | 5 | public class CustomizationClassLoader extends ClassLoader{ 6 | public static String classPath; 7 | static { 8 | classPath = System.getProperty("user.dir") + "/target/classes"; 9 | } 10 | @Override 11 | protected Class findClass(String name) throws ClassNotFoundException { 12 | try { 13 | name = name.replaceAll("src/main/java", "target/classes"); 14 | name = name.replaceAll("java", "class"); 15 | byte[] data = loadByte(name); 16 | 17 | name = name.replaceAll("\\.", ""); 18 | name = name.replaceAll("/", "."); 19 | 20 | String[] sArray = name.split("classes."); 21 | name = sArray[1].replaceAll("class", ""); 22 | 23 | System.out.println(name); 24 | return defineClass(name, data, 0, data.length); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | throw new ClassNotFoundException(); 28 | } 29 | } 30 | 31 | /** 32 | * 加载class文件,转换为字节数组 33 | */ 34 | private byte[] loadByte(String name) throws Exception { 35 | 36 | FileInputStream fis = new FileInputStream(name); 37 | int len = fis.available(); 38 | byte[] data = new byte[len]; 39 | fis.read(data); 40 | fis.close(); 41 | return data; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /data-migration/src/main/resources/com/es/datamigration/mapper/TbArticleDOMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id, title, content, state, latitude, longitude, create_time, update_time 17 | 18 | 19 | 24 | 25 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-dump/datadump/${package}/dao/${className}Dao.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.dao; 2 | 3 | import ${package}.model.${className}Model; 4 | import ${package}.model.Page; 5 | import java.util.List; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | /** 9 | *

Description: [${table.tableDesc}dao]

10 | * Created on ${date} 11 | * @author ${author} 12 | * @version 1.0 13 | * Copyright (c) ${year} ${website} 14 | */ 15 | public interface ${className}Dao{ 16 | 17 | /** 18 | * 分页查询固定参数 19 | */ 20 | List<${className}Model> queryPage${className}(@Param("page")Page page, @Param("entity")${className}Model entity, @Param("queryFields")List queryFields); 21 | 22 | /** 23 | * 查询固定参数 24 | */ 25 | List<${className}Model> queryList${className}(@Param("entity")${className}Model entity, @Param("queryFields")List queryFields); 26 | 27 | /** 28 | * 查询总数量 29 | */ 30 | Long queryCount${className}(@Param("entity")${className}Model entity); 31 | 32 | /** 33 | * 查询单个实体 34 | */ 35 | ${className}Model query${className}ById(@Param("id")String id, @Param("queryFields")List queryFields); 36 | 37 | /** 38 | * 新增 39 | */ 40 | int add${className}(${className}Model entity); 41 | 42 | /** 43 | * 修改 44 | */ 45 | int update${className}(${className}Model entity); 46 | 47 | /** 48 | * 批量删除 49 | */ 50 | int remove${className}ByIds(List code); 51 | 52 | /** 53 | * 删除 54 | */ 55 | int remove${className}ById(@Param("id")String id); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/manager/ServiceImportManager.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.manager; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.es.stone.constant.EsConstant; 5 | import com.es.stone.manager.ElasticSearchDumpManager; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import java.util.Map; 10 | 11 | @Slf4j 12 | public class ServiceImportManager { 13 | 14 | @Autowired 15 | private ElasticSearchDumpManager elasticSearchDumpManager; 16 | 17 | /** 18 | * 区分索引进行业务关联同步 19 | * 20 | * @param colMap 21 | * @param index 22 | * @return 23 | */ 24 | public Map getDateMap(Map colMap, String index) { 25 | if (EsConstant.EsIndexName.DB_SEARCH_TB_TS.equals(index)) { 26 | //判断是哪种特殊索引,根据需求,处理数据,再 存入/更新 到es 27 | txListInfoDump(colMap, index); 28 | } else { 29 | elasticSearchDumpManager.insertOrUpdateToEs(colMap, index); 30 | } 31 | log.debug("------------------ colMap:{}, index:{}", JSON.toJSONString(colMap), index); 32 | return colMap; 33 | } 34 | 35 | /** 36 | * 根据特殊业务表同步数据 37 | * 38 | * @param colMap 39 | * @param index 40 | */ 41 | protected void txListInfoDump(Map colMap, String index) { 42 | log.info("ServiceImportManager.txListInfoDump colMap:{}", JSON.toJSONString(colMap)); 43 | //此处可进行特殊逻辑处理,根据需求来 44 | elasticSearchDumpManager.insertOrUpdateToEs(colMap, index); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/enums/IndexTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.enums; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public enum IndexTypeEnum { 7 | 8 | GEO("geo","DOUBLE", "type=geo_point"), 9 | IK_SMART("ik_smart","VARCHAR", "type=text,fielddata=true,analyzer=ik_smart"); 10 | 11 | private final String indexType; 12 | private final String sqlType; 13 | private final String indexStr; 14 | 15 | IndexTypeEnum(String indexType, String sqlType, String indexStr) { 16 | this.indexType = indexType; 17 | this.sqlType = sqlType; 18 | this.indexStr = indexStr; 19 | } 20 | 21 | public static String getSqlTypeByIndexType(String indexType) { 22 | for(IndexTypeEnum indexTypeEnum : values()) { 23 | if(indexTypeEnum.indexType.equals(indexType)) { 24 | return indexTypeEnum.sqlType; 25 | } 26 | } 27 | return ""; 28 | } 29 | 30 | public static String getIndexStrByIndexType(String indexType) { 31 | for(IndexTypeEnum indexTypeEnum : values()) { 32 | if(indexTypeEnum.indexType.equals(indexType)) { 33 | return indexTypeEnum.indexStr; 34 | } 35 | } 36 | return ""; 37 | } 38 | 39 | public static List getIndexTypeList() { 40 | List list = new ArrayList<>(); 41 | for(IndexTypeEnum indexTypeEnum : values()) { 42 | list.add(indexTypeEnum.indexType); 43 | } 44 | return list; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /data-search/src/main/java/com/es/datasearch/util/ConvertDateUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.datasearch.util; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.text.ParseException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Locale; 9 | import java.util.Map; 10 | import java.util.TimeZone; 11 | 12 | public class ConvertDateUtil { 13 | 14 | private static SimpleDateFormat sdflocal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); 15 | private static SimpleDateFormat sdflocalsimple = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); 16 | private static SimpleDateFormat sdfutc = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 17 | 18 | static { 19 | sdflocal.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); 20 | sdfutc.setTimeZone(TimeZone.getTimeZone("UTC")); 21 | } 22 | 23 | public static Map convertDate(Map mapDTO) throws ParseException { 24 | 25 | if (StringUtils.isNotBlank(mapDTO.get(EsConstant.SqlWord.CREATE_TIME) == null ? "" : (String) mapDTO.get(EsConstant.SqlWord.CREATE_TIME))) { 26 | mapDTO.put(EsConstant.SqlWord.CREATE_TIME, sdflocal.format(sdfutc.parse((String) mapDTO.get(EsConstant.SqlWord.CREATE_TIME)))); 27 | } 28 | 29 | if (StringUtils.isNotBlank(mapDTO.get(EsConstant.SqlWord.UPDATE_TIME) == null ? "" : (String) mapDTO.get(EsConstant.SqlWord.UPDATE_TIME))) { 30 | mapDTO.put(EsConstant.SqlWord.UPDATE_TIME, sdflocal.format(sdfutc.parse((String) mapDTO.get(EsConstant.SqlWord.UPDATE_TIME)))); 31 | } 32 | return mapDTO; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/result/BasePageResult.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.result; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by 海浩 on 2015/3/29. 7 | * 8 | */ 9 | public class BasePageResult extends ResultSupport { 10 | 11 | private static final long serialVersionUID = 7378807577314788084L; 12 | 13 | protected int pageNo = 1; 14 | protected int pageSize; 15 | protected int totalCount; 16 | protected boolean hasNext; 17 | protected List list; 18 | 19 | public List getList() { 20 | return list; 21 | } 22 | 23 | public void setList(List list) { 24 | this.list = list; 25 | } 26 | 27 | public int getPageNo() { 28 | return pageNo; 29 | } 30 | 31 | public void setPageNo(int pageNo) { 32 | if (pageNo <= 0) { 33 | pageNo = 1; 34 | } 35 | this.pageNo = pageNo; 36 | } 37 | 38 | public int getPageSize() { 39 | return pageSize; 40 | } 41 | 42 | public void setPageSize(int pageSize) { 43 | if (pageSize < 0) { 44 | pageSize = 0; 45 | } 46 | this.pageSize = pageSize; 47 | } 48 | 49 | public int getStartRow() { 50 | return (pageNo - 1) * pageSize; 51 | } 52 | 53 | public int getTotalCount() { 54 | return totalCount; 55 | } 56 | 57 | public void setTotalCount(int totalCount) { 58 | this.totalCount = totalCount; 59 | } 60 | 61 | public boolean isHasNext() { 62 | return hasNext; 63 | } 64 | 65 | public void setHasNext(boolean hasNext) { 66 | this.hasNext = hasNext; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /db_search.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : 本地数据库 5 | Source Server Version : 50624 6 | Source Host : localhost:3306 7 | Source Database : db_search 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50624 11 | File Encoding : 65001 12 | 13 | Date: 2018-08-22 13:21:05 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `tb_article` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `tb_article`; 22 | CREATE TABLE `tb_article` ( 23 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id', 24 | `title` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文章标题', 25 | `content` varchar(512) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL COMMENT '文章内容', 26 | `state` int(1) unsigned NOT NULL COMMENT '文章状态(0:待审核;1:审核通过;2:审核不通过;)', 27 | `latitude` double NOT NULL COMMENT '发布文章所在位置精度', 28 | `longitude` double NOT NULL COMMENT '发布文章所在位置纬度', 29 | `create_time` datetime NOT NULL COMMENT '创建时间', 30 | `update_time` datetime NOT NULL COMMENT '更新时间', 31 | PRIMARY KEY (`id`) 32 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; 33 | 34 | -- ---------------------------- 35 | -- Records of tb_article 36 | -- ---------------------------- 37 | INSERT INTO `tb_article` VALUES ('1', '这是一条标题', '调皮的内容~', '0', '31.234219', '121.490601', '2018-08-21 03:01:00', '2018-08-17 00:00:00'); 38 | INSERT INTO `tb_article` VALUES ('2', '我比上一条标题长。', '上一条内容比我短。', '1', '39.915446', '116.403849', '2018-08-17 10:02:00', '2018-08-17 00:00:00'); 39 | INSERT INTO `tb_article` VALUES ('3', '我是老三', '老三的内容12345678', '2', '22.539051', '113.952254', '2018-08-20 11:03:00', '2018-08-20 00:00:00'); 40 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/result/ResultSupport.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.result; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by 海浩 on 2015/3/29. 7 | */ 8 | public class ResultSupport implements Serializable { 9 | 10 | private static final long serialVersionUID = -2235152751651905167L; 11 | 12 | private boolean success = true; 13 | private String errorMsg; 14 | private int errorCode; 15 | 16 | public ResultSupport() { 17 | 18 | } 19 | 20 | public ResultSupport(String errorMsg, int errorCode) { 21 | this.errorMsg = errorMsg; 22 | this.errorCode = errorCode; 23 | this.success = false; 24 | } 25 | 26 | public boolean isSuccess() { 27 | return success; 28 | } 29 | 30 | public void setSuccess(boolean success) { 31 | this.success = success; 32 | } 33 | 34 | public String getErrorMsg() { 35 | return errorMsg; 36 | } 37 | 38 | public void setErrorMsg(String errorMsg) { 39 | this.errorMsg = errorMsg; 40 | } 41 | 42 | public int getErrorCode() { 43 | return errorCode; 44 | } 45 | 46 | public void setErrorCode(int errorCode) { 47 | this.errorCode = errorCode; 48 | } 49 | 50 | public void setError(int errorCode, String errorMsg) { 51 | this.errorCode = errorCode; 52 | this.errorMsg = errorMsg; 53 | this.success = false; 54 | } 55 | 56 | public void setError(BaseErrorCode baseErrorCode) { 57 | if (baseErrorCode == null) { 58 | return; 59 | } 60 | this.errorCode = baseErrorCode.getErrorCode(); 61 | this.errorMsg = baseErrorCode.getErrorMsg(); 62 | this.success = false; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/util/CharSetUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.util; 2 | 3 | import org.apache.commons.lang.ArrayUtils; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | import java.nio.ByteBuffer; 7 | import java.nio.CharBuffer; 8 | import java.nio.charset.CharacterCodingException; 9 | import java.nio.charset.Charset; 10 | import java.nio.charset.CharsetDecoder; 11 | 12 | public class CharSetUtil { 13 | public static String bytesToString(byte[] input, String sourceCharSet,String destCharSet) throws CharacterCodingException { 14 | if(ArrayUtils.isEmpty(input)) { 15 | return StringUtils.EMPTY; 16 | } 17 | 18 | ByteBuffer buffer = ByteBuffer.allocate(input.length); 19 | 20 | buffer.put(input); 21 | buffer.flip(); 22 | 23 | Charset defCharSet = null; 24 | CharsetDecoder defCharSetDecoder = null; 25 | CharBuffer defCharSetCharBuffer = null; 26 | 27 | Charset srcCharSet = null; 28 | ByteBuffer srcByteBuffer = null; 29 | 30 | Charset desCharSet = null; 31 | CharsetDecoder desDecoder = null; 32 | CharBuffer desCharBuffer = null; 33 | 34 | defCharSet = Charset.defaultCharset(); 35 | defCharSetDecoder = defCharSet.newDecoder(); 36 | defCharSetCharBuffer = defCharSetDecoder.decode(buffer.asReadOnlyBuffer()); 37 | 38 | srcCharSet = Charset.forName(sourceCharSet); 39 | srcByteBuffer = srcCharSet.encode(defCharSetCharBuffer); 40 | 41 | 42 | desCharSet = Charset.forName(destCharSet); 43 | desDecoder = desCharSet.newDecoder(); 44 | 45 | desCharBuffer = desDecoder.decode(srcByteBuffer); 46 | 47 | return desCharBuffer.toString(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.util; 2 | 3 | public class StringUtil { 4 | 5 | public static final char UNDERLINE = '_'; 6 | 7 | /** 8 | * 驼峰格式字符串转换为下划线格式字符串 9 | * 10 | * @param param 11 | * @return 12 | */ 13 | public static String camelToUnderline(String param) { 14 | if (param == null || "".equals(param.trim())) 15 | return ""; 16 | int len = param.length(); 17 | StringBuilder sb = new StringBuilder(len); 18 | for (int i = 0; i < len; i++) { 19 | char c = param.charAt(i); 20 | if (Character.isUpperCase(c)) { 21 | sb.append(UNDERLINE); 22 | sb.append(Character.toLowerCase(c)); 23 | } else { 24 | sb.append(c); 25 | } 26 | } 27 | return sb.toString(); 28 | } 29 | 30 | /** 31 | * 下划线格式字符串转换为驼峰格式字符串 32 | * 33 | * @param param 34 | * @return 35 | */ 36 | public static String underlineToCamel(String param) { 37 | if (param == null || "".equals(param.trim())) 38 | return ""; 39 | int len = param.length(); 40 | StringBuilder sb = new StringBuilder(len); 41 | for (int i = 0; i < len; i++) { 42 | char c = param.charAt(i); 43 | if (c == UNDERLINE) { 44 | if (++i < len) { 45 | sb.append(Character.toUpperCase(param.charAt(i))); 46 | } 47 | } else { 48 | sb.append(c); 49 | } 50 | } 51 | return sb.toString(); 52 | } 53 | 54 | /** 55 | * 删除字符串中 横线 56 | * @param param 57 | * @return 58 | */ 59 | public static String replaceLine(String param) { 60 | return param.replaceAll("-",""); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/controller/ArticleController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.es.datamigration.controller; 3 | 4 | import com.es.stone.manager.ElasticSearchIndexManager; 5 | import com.es.datamigration.manager.article.ArticleSyncToEsManager; 6 | import com.es.stone.constant.EsConstant; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * 文章搜索相关 15 | * 16 | */ 17 | @Slf4j 18 | @RestController 19 | @RequestMapping("/api/article") 20 | public class ArticleController { 21 | 22 | @Autowired 23 | private ArticleSyncToEsManager articleSyncToEsManager; 24 | 25 | @Autowired 26 | private ElasticSearchIndexManager elasticSearchIndexManager; 27 | 28 | /** 29 | * 开启同步数据,将article表中数据同步到ES 30 | * @return 31 | */ 32 | @GetMapping("/articleToEs") 33 | public String syncPlaceToEs() { 34 | return articleSyncToEsManager.syncDataControl(); 35 | } 36 | 37 | /** 38 | * 检查ES索引状态 39 | * @return 40 | */ 41 | @RequestMapping("/checkIndex") 42 | public boolean createIndex() { 43 | boolean flag = Boolean.FALSE; 44 | try { 45 | log.info("-------------------------------------检查ES索引状态---------------------------------------------"); 46 | flag = elasticSearchIndexManager.checkIndex(EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE);//特殊索引配置入口,可直接追加 47 | log.info("-------------------------------------ES索引状态检查完成---------------------------------------------"); 48 | 49 | } catch (Exception e) { 50 | log.info("checkIndex is error!", e); 51 | } 52 | return flag; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /data-migration/src/main/resources/config/generator/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 19 | 21 | 23 | 24 | 27 | 28 |
29 |
30 |
-------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/constant/EsConstant.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.constant; 2 | 3 | public class EsConstant { 4 | 5 | public final static String ES_KEY = "es_key"; 6 | 7 | public final static String ID = "id"; 8 | 9 | /** 10 | * es索引属性 11 | */ 12 | public class EsIndexProperty { 13 | 14 | public final static String GENERAL_TYPE = "doc"; 15 | 16 | public final static String NUMBER_OF_SHARDS = "number_of_shards"; 17 | 18 | public final static String MAX_RESULT_WINDOW = "max_result_window"; 19 | 20 | } 21 | 22 | /** 23 | * es索引字段属性 24 | */ 25 | public class EsIndexWordProperty { 26 | 27 | public final static String IK = "type=text,fielddata=true,analyzer=ik_smart"; 28 | 29 | public final static String GEO = "type=geo_point"; 30 | 31 | } 32 | 33 | /** 34 | * es索引名称 35 | */ 36 | public class EsIndexName { 37 | 38 | public final static String DB_SEARCH_TB_ARTICLE = "db_search.tb_article"; 39 | 40 | public final static String DB_SEARCH_TB_TS = "db_search.tb_ts"; 41 | 42 | } 43 | 44 | /** 45 | * 数据库特殊字段 46 | */ 47 | public class SqlWord { 48 | 49 | public final static String TIMESTAMP = "timestamp"; 50 | 51 | public final static String DATETIME = "datetime"; 52 | 53 | public final static String DATE = "date"; 54 | 55 | public final static String TIME = "time"; 56 | 57 | public final static String BLOB = "blob"; 58 | 59 | public final static String CREATE_TIME = "create_time"; 60 | 61 | public final static String UPDATE_TIME = "update_time"; 62 | 63 | } 64 | 65 | /** 66 | * geo搜索,相关 67 | */ 68 | public class GEO { 69 | 70 | public final static String LONGITUDE = "longitude"; 71 | 72 | public final static String LATITUDE = "latitude"; 73 | 74 | public final static String LOCATION = "location"; 75 | 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | es 7 | es-home 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | es-home 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | stone 29 | data-dump 30 | data-migration 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/manager/canal/CanalInitClientManager.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.manager.canal; 2 | 3 | import com.alibaba.otter.canal.client.CanalConnector; 4 | import com.alibaba.otter.canal.client.CanalConnectors; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.beans.factory.annotation.Value; 7 | 8 | import java.net.InetSocketAddress; 9 | 10 | @Slf4j 11 | public class CanalInitClientManager { 12 | 13 | @Value("${canal.client.servers}") 14 | private String servers; 15 | 16 | @Value("${canal.client.cluser}") 17 | private boolean cluser; 18 | 19 | @Value("${canal.client.destination}") 20 | private String destination; 21 | 22 | private CanalConnector canalConnector = null; 23 | 24 | public final CanalConnector getCanalConnector() { 25 | log.info("--------------canalServer:" + servers); 26 | log.info("--------------destination:" + destination); 27 | if (cluser) { 28 | canalConnector = CanalConnectors.newClusterConnector(servers, destination, "", ""); 29 | } else { 30 | if (canalConnector == null) { 31 | if (servers != null) { 32 | InetSocketAddress inetSocketAddress = stringToAddress(servers); 33 | canalConnector = CanalConnectors.newSingleConnector(inetSocketAddress, destination, "", ""); 34 | } 35 | 36 | } 37 | } 38 | return canalConnector; 39 | } 40 | 41 | /** 42 | * 将ip:port格式装换为 InetSocketAddress对象返回 43 | * 44 | * @param server 45 | * @return 46 | */ 47 | protected InetSocketAddress stringToAddress(String server) { 48 | if (server != null) { 49 | String[] ipAndPort = server.split(":"); 50 | return new InetSocketAddress(ipAndPort[0], Integer.valueOf(ipAndPort[1])); 51 | } 52 | return null; 53 | } 54 | 55 | public String getDestination() { 56 | return destination; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/manager/ServiceImportManager.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.manager; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.es.stone.converter.LocationConverter; 5 | import com.es.stone.constant.EsConstant; 6 | import com.es.stone.manager.ElasticSearchDumpManager; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.util.Map; 12 | 13 | @Slf4j 14 | @Component 15 | public class ServiceImportManager { 16 | 17 | @Autowired 18 | private ElasticSearchDumpManager elasticSearchDumpManager; 19 | 20 | /** 21 | * 区分索引进行业务关联同步 22 | * 23 | * @param colMap 24 | * @param index 25 | * @return 26 | * @throws Exception 27 | */ 28 | public Map getDateMap(Map colMap, String index) { 29 | if (EsConstant.EsIndexName.DB_SEARCH_TB_TS.equals(index)) { 30 | //判断是哪种特殊索引,根据需求,处理数据,再 存入/更新 到es 31 | txListInfoDump(colMap, index); 32 | } else if (EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE.equals(index)) { 33 | //判断是否是article索引,根据需求,处理数据,再 存入/更新 到es 34 | articleListInfoDump(colMap, index); 35 | } else { 36 | elasticSearchDumpManager.insertOrUpdateToEs(colMap, index); 37 | } 38 | return colMap; 39 | } 40 | 41 | /** 42 | * 根据特殊业务表同步数据 43 | * 44 | * @param colMap 45 | * @param index 46 | */ 47 | protected void txListInfoDump(Map colMap, String index) { 48 | log.info("ServiceImportManager.txListInfoDump colMap:{}", JSON.toJSONString(colMap)); 49 | //此处可进行特殊逻辑处理,根据需求来 50 | elasticSearchDumpManager.insertOrUpdateToEs(colMap, index); 51 | } 52 | 53 | /** 54 | * 根据article表同步数据 55 | * 56 | * @param colMap 57 | * @param index 58 | */ 59 | protected void articleListInfoDump(Map colMap, String index) { 60 | //经纬度合并 61 | LocationConverter.locationConverter(colMap); 62 | elasticSearchDumpManager.insertOrUpdateToEs(colMap, index); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/MobilePager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import org.springframework.util.CollectionUtils; 4 | 5 | import java.util.List; 6 | import java.util.function.Function; 7 | 8 | public class MobilePager extends Pager { 9 | 10 | private static final long serialVersionUID = 4133617516309958598L; 11 | 12 | private Long nextAnchorId; 13 | 14 | private Boolean nextPage; 15 | 16 | MobilePager(int pageSize, Integer totalCount) { 17 | this.pageSize = pageSize; 18 | this.totalCount = totalCount; 19 | } 20 | 21 | /** 22 | * 这里不再对 data 排序(不知道排序规则,也可能会造成额外的性能浪费),调用方负责保证data正确的顺序 23 | * 24 | * @param data data 25 | * @param anchorIdFunc 锚点id的获取规则 26 | * @param getAnchorIdByLast 是否根据最后一个对象获取锚点id 27 | * @return pager 28 | */ 29 | MobilePager load(List data, Function anchorIdFunc, boolean getAnchorIdByLast) { 30 | this.data = data; 31 | if (CollectionUtils.isEmpty(data)) { 32 | // nextPage 为 false 了,nextAnchorId 不再需要(因为不需要再获取更多内容了) 33 | this.nextPage = false; 34 | return this; 35 | } 36 | 37 | this.nextPage = data.size() == this.pageSize; 38 | if (!this.nextPage) { 39 | // nextPage 为 false 了,nextAnchorId 不再需要(因为不需要再获取更多内容了) 40 | return this; 41 | } 42 | 43 | T anchorItem; 44 | if (getAnchorIdByLast) { 45 | anchorItem = data.get(data.size() - 1); 46 | } else { 47 | anchorItem = data.get(0); 48 | } 49 | this.nextAnchorId = anchorIdFunc.apply(anchorItem); 50 | 51 | return this; 52 | } 53 | 54 | public Long getNextAnchorId() { 55 | return nextAnchorId; 56 | } 57 | 58 | public MobilePager setNextAnchorId(Long nextAnchorId) { 59 | this.nextAnchorId = nextAnchorId; 60 | return this; 61 | } 62 | 63 | public Boolean getNextPage() { 64 | return nextPage; 65 | } 66 | 67 | public MobilePager setNextPage(Boolean nextPage) { 68 | this.nextPage = nextPage; 69 | return this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/manager/article/ArticleSyncToEsManager.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.manager.article; 2 | 3 | import com.es.datamigration.manager.ServiceImportManager; 4 | import com.es.datamigration.mapper.TbArticleDOMapper; 5 | import com.es.datamigration.model.TbArticleDO; 6 | import com.es.datamigration.util.ConvertMapUtil; 7 | import com.es.stone.constant.EsConstant; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | @Slf4j 17 | @Component 18 | public class ArticleSyncToEsManager { 19 | 20 | private Integer page = 0; 21 | private Integer pageSize = 10000; 22 | 23 | @Autowired 24 | private ServiceImportManager serviceImportManager; 25 | 26 | @Autowired 27 | private TbArticleDOMapper tbArticleDOMapper; 28 | 29 | /** 30 | * 同步数据到ES主控方法 31 | */ 32 | public String syncDataControl() { 33 | 34 | //全部查询,数据量如果过大,容易内存溢出,所以改为自动分页查询 35 | // List articleDOList = tbArticleDOMapper.selectAll(); 36 | 37 | List articleDOResultList = new ArrayList<>(); 38 | List articleDOList; 39 | while (true) { 40 | articleDOList= tbArticleDOMapper.selectByPage(page, pageSize); 41 | articleDOResultList.addAll(articleDOList); 42 | page ++; 43 | if (articleDOList.size() < pageSize) { 44 | break; 45 | } 46 | } 47 | 48 | for (TbArticleDO tbArticleDO : articleDOResultList) { 49 | Map colMap = ConvertMapUtil.convertToMap(tbArticleDO); 50 | colMap.put(EsConstant.ES_KEY, colMap.get(EsConstant.ID).toString()); 51 | try { 52 | serviceImportManager.getDateMap(colMap, EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE); 53 | } catch (Exception e) { 54 | log.error("同步数据异常,ID: {} , e: {}", tbArticleDO.getId(), e); 55 | } 56 | } 57 | return "success"; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/configuration/auth/WebConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.configuration.auth;// 2 | //package com.learn.api.configuration.auth; 3 | // 4 | //import org.springframework.beans.factory.annotation.Autowired; 5 | //import org.springframework.beans.factory.annotation.Value; 6 | //import org.springframework.context.annotation.Configuration; 7 | //import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | //import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | //import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | //import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | //import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 12 | // 13 | //@Configuration 14 | //@EnableWebSecurity 15 | //@EnableGlobalMethodSecurity(prePostEnabled = true) 16 | //public class WebConfiguration extends WebSecurityConfigurerAdapter { 17 | // 18 | // @Value("${login.learn.basicAuthName}") 19 | // String authUserName; 20 | // 21 | // @Value("${login.learn.basicAuthPass}") 22 | // String authPassword; 23 | // 24 | // @Autowired 25 | // public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 26 | // authenticationManagerBuilder 27 | // .inMemoryAuthentication().withUser(authUserName).password(authPassword).roles("BASIC"); 28 | // } 29 | // 30 | // /** 31 | // * http.authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN") 32 | // * .antMatchers("/**").hasRole("USER").and().formLogin(); 33 | // * 34 | // * 控制swagger访问权限,下方注释打开,即需要账号密码登录,账号密码可查看配置文件 35 | // */ 36 | // @Override 37 | // protected void configure(HttpSecurity http) throws Exception { 38 | // http.authorizeRequests() 39 | // .antMatchers("/admin/**").hasRole("ADMIN") 40 | // .antMatchers("/learn/swagger**").permitAll() 41 | // .antMatchers("/**") 42 | //// .hasRole("BASIC") 43 | //// .and() 44 | //// .formLogin(); 45 | // .permitAll(); 46 | // } 47 | // 48 | //} 49 | -------------------------------------------------------------------------------- /data-migration/src/main/java/com/es/datamigration/configuration/auth/WebConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.es.datamigration.configuration.auth;// 2 | //package com.learn.api.configuration.auth; 3 | // 4 | //import org.springframework.beans.factory.annotation.Autowired; 5 | //import org.springframework.beans.factory.annotation.Value; 6 | //import org.springframework.context.annotation.Configuration; 7 | //import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | //import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | //import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | //import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | //import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 12 | // 13 | //@Configuration 14 | //@EnableWebSecurity 15 | //@EnableGlobalMethodSecurity(prePostEnabled = true) 16 | //public class WebConfiguration extends WebSecurityConfigurerAdapter { 17 | // 18 | // @Value("${login.learn.basicAuthName}") 19 | // String authUserName; 20 | // 21 | // @Value("${login.learn.basicAuthPass}") 22 | // String authPassword; 23 | // 24 | // @Autowired 25 | // public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 26 | // authenticationManagerBuilder 27 | // .inMemoryAuthentication().withUser(authUserName).password(authPassword).roles("BASIC"); 28 | // } 29 | // 30 | // /** 31 | // * http.authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN") 32 | // * .antMatchers("/**").hasRole("USER").and().formLogin(); 33 | // * 34 | // * 控制swagger访问权限,下方注释打开,即需要账号密码登录,账号密码可查看配置文件 35 | // */ 36 | // @Override 37 | // protected void configure(HttpSecurity http) throws Exception { 38 | // http.authorizeRequests() 39 | // .antMatchers("/admin/**").hasRole("ADMIN") 40 | // .antMatchers("/learn/swagger**").permitAll() 41 | // .antMatchers("/**") 42 | //// .hasRole("BASIC") 43 | //// .and() 44 | //// .formLogin(); 45 | // .permitAll(); 46 | // } 47 | // 48 | //} 49 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/Pagers.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | import org.springframework.util.Assert; 4 | 5 | import java.util.Collections; 6 | import java.util.List; 7 | import java.util.function.Function; 8 | 9 | public final class Pagers { 10 | 11 | private Pagers() { 12 | } 13 | 14 | public static WebPager buildWebPager( 15 | List data, int pageSize, int currentPage, int totalCount) { 16 | return new WebPager(pageSize, currentPage).load(data, totalCount); 17 | } 18 | 19 | public static WebPager emptyWebPager(int pageSize, int currentPage, int totalCount) { 20 | return buildWebPager(Collections.emptyList(), pageSize, currentPage, totalCount); 21 | } 22 | 23 | public static MobilePager buildMobilePager( 24 | List data, Function anchorIdFunc, int pageSize, boolean getAnchorIdByLast) { 25 | return buildMobilePager(data, anchorIdFunc, pageSize, null, getAnchorIdByLast); 26 | } 27 | 28 | public static MobilePager buildMobilePager( 29 | List data, Function anchorIdFunc, int pageSize, Integer totalCount, boolean getAnchorIdByLast) { 30 | return new MobilePager(pageSize, totalCount).load(data, anchorIdFunc, getAnchorIdByLast); 31 | } 32 | 33 | public static MobilePager emptyMobilePager() { 34 | return buildMobilePager(Collections.emptyList(), null, 0, false); 35 | } 36 | 37 | public static List subList(List data, int pageSize, int page) { 38 | int start = pageSize * (page - 1); 39 | if (start > data.size()) { 40 | return Collections.emptyList(); 41 | } 42 | int end = pageSize * page; 43 | if (end > data.size()) { 44 | end = data.size(); 45 | } 46 | return data.subList(start, end); 47 | } 48 | 49 | public static long validCursorId(long cursorId) { 50 | return cursorId < 0 ? 0 : cursorId; 51 | } 52 | 53 | public static int validPage(int page) { 54 | return page < 1 ? 1 : page; 55 | } 56 | 57 | public static int validPageSize(int pageSize) { 58 | Assert.isTrue(pageSize <= 200, "页数查询太多"); 59 | return pageSize < 1 ? 20 : pageSize; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /data-dump/src/main/java/com/es/datadump/run/CanalClientRunner.java: -------------------------------------------------------------------------------- 1 | package com.es.datadump.run; 2 | 3 | import com.alibaba.otter.canal.client.CanalConnector; 4 | import com.es.datadump.manager.canal.CanalCoreManager; 5 | import com.es.datadump.manager.canal.CanalInitClientManager; 6 | import com.es.datadump.manager.ServiceImportManager; 7 | import com.es.stone.manager.ElasticSearchDumpManager; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.CommandLineRunner; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * 此处只能监听到ContextClosedEvent 15 | * 因此,考虑使用CommandLineRunner实现启动后自动执行 16 | * 17 | * @author Administrator 18 | */ 19 | @Slf4j 20 | @Component 21 | //@Order(3) 22 | public class CanalClientRunner implements CommandLineRunner { 23 | 24 | @Autowired 25 | private CanalInitClientManager canalInitClientManager; 26 | 27 | @Autowired 28 | private ElasticSearchDumpManager elasticSearchDumpManager; 29 | 30 | @Autowired 31 | private ServiceImportManager serviceImportManager; 32 | 33 | @Override 34 | public void run(String... args) { 35 | log.info("-------------------------------------canal服务启动----------------------------------------------"); 36 | // 根据ip,直接创建链接,无HA的功能 37 | CanalConnector canalConnector = canalInitClientManager.getCanalConnector(); 38 | 39 | final CanalCoreManager canalManager = new CanalCoreManager(canalInitClientManager.getDestination()); 40 | canalManager.setCanalConnector(canalConnector); 41 | canalManager.setElasticSearchDumpManager(elasticSearchDumpManager); 42 | canalManager.setServiceImportManager(serviceImportManager); 43 | canalManager.start(); 44 | Runtime.getRuntime().addShutdownHook(new Thread() { 45 | 46 | public void run() { 47 | try { 48 | log.info("## stop the canal client"); 49 | canalManager.stop(); 50 | } catch (Throwable e) { 51 | log.warn("##something goes wrong when stopping canal:", e); 52 | } finally { 53 | log.info("## canal client is down."); 54 | } 55 | } 56 | 57 | }); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-migration/src/main/java/com/es/datamigration/manager/${classNameLower}/${className}ToEsManager.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.manager.${classNameLower}; 2 | 3 | import ${package}.manager.ServiceImportManager; 4 | import ${package}.mapper.${className}DOMapper; 5 | import ${package}.model.${className}DO; 6 | import ${package}.util.Convert${className}Util; 7 | import com.es.stone.constant.EsConstant; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * Description: [${table.tableDesc}同步数据到ES] 18 | * Created on ${date} 19 | * @author ${author} 20 | * @version 1.0 21 | * Copyright (c) ${year} ${website} 22 | */ 23 | @Slf4j 24 | @Component 25 | public class ${className}ToEsManager { 26 | 27 | private Integer page = 0; 28 | private Integer pageSize = 10000; 29 | 30 | @Autowired 31 | private ServiceImportManager serviceImportManager; 32 | 33 | @Autowired 34 | private ${className}DOMapper ${classNameLower}DOMapper; 35 | 36 | /** 37 | * 同步数据到ES主控方法 38 | */ 39 | public String syncDataControl() { 40 | 41 | //全部查询,数据量如果过大,容易内存溢出,所以改为自动分页查询 42 | // List<${className}DO> ${classNameLower}DOList = ${classNameLower}DOMapper.selectAll(); 43 | 44 | List<${className}DO> ${classNameLower}DOResultList = new ArrayList<>(); 45 | List<${className}DO> ${classNameLower}DOList; 46 | while (true) { 47 | ${classNameLower}DOList= ${classNameLower}DOMapper.selectByPage(page, pageSize); 48 | ${classNameLower}DOResultList.addAll(${classNameLower}DOList); 49 | page ++; 50 | if (${classNameLower}DOList.size() < pageSize) { 51 | break; 52 | } 53 | } 54 | 55 | for (${className}DO ${classNameLower}DO : ${classNameLower}DOResultList) { 56 | Map colMap = Convert${className}Util.convertToMap(${classNameLower}DO); 57 | colMap.put(EsConstant.ES_KEY, colMap.get(EsConstant.ID).toString()); 58 | try { 59 | serviceImportManager.getDateMap(colMap, "${dbName}." + "${tableName}"); 60 | } catch (Exception e) { 61 | log.error("同步数据异常,ID: {} , e: {}", ${classNameLower}DO.getId(), e); 62 | } 63 | } 64 | return "success"; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/util/FileHelper.java: -------------------------------------------------------------------------------- 1 | package com.es.databack.util; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.regex.Matcher; 9 | import java.util.regex.Pattern; 10 | 11 | public class FileHelper { 12 | 13 | /** 14 | * 根据路径搜索所有文件 15 | * @param file 16 | * @return 17 | */ 18 | public static List findAllFile(File file) { 19 | List files = new ArrayList(); 20 | if (file.listFiles().length > 0) { 21 | for (File f : file.listFiles()) { 22 | if (f.isFile()) { 23 | String fileName = f.getName(); 24 | String suffix = fileName.substring(fileName.lastIndexOf(".") + 1); 25 | if (!fileName.equals("DataSearchApplication.java") && (suffix.equals("ftl") || suffix.equals("java") || suffix.equals("xml"))) { 26 | files.add(f); 27 | } else if (!fileName.equals("DataSearchApplication.class") && suffix.equals("class")) { 28 | files.add(f); 29 | } 30 | } else { 31 | files.addAll(findAllFile(f)); 32 | } 33 | } 34 | } 35 | 36 | return files; 37 | } 38 | 39 | /** 40 | * 生成文件 41 | * @param fileName 42 | * @throws IOException 43 | */ 44 | public static File makeFile(String fileName) throws IOException { 45 | File f = new File(fileName); 46 | if (!f.exists()) { 47 | f.getParentFile().mkdirs(); 48 | f.createNewFile(); 49 | } 50 | return f; 51 | } 52 | 53 | /** 54 | * 转换java文件头部文案 55 | * @param dir 56 | * @param params 57 | * @return 58 | */ 59 | public static String genFileDir(String dir, Map params) { 60 | String input = dir; 61 | Pattern p = Pattern.compile("\\$\\{([^}]*)\\}*"); 62 | Matcher m = p.matcher(input); 63 | while (m.find()) { 64 | String name = m.group(1); 65 | String value = String.valueOf(params.get(name)); 66 | input = input.replace(m.group(), value); 67 | } 68 | return input; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /data-migration/src/main/resources/META-INF/spring/application-persistance.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/util/CamelCaseUtils.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.util; 2 | 3 | public class CamelCaseUtils { 4 | 5 | /** 6 | * 下划线转驼峰 7 | * @param str 8 | * @return 9 | */ 10 | public static String toUnderlineName(String str) { 11 | if (str == null || "".equals(str.trim())) { 12 | return ""; 13 | } else { 14 | StringBuilder sb = new StringBuilder(); 15 | boolean upperCase = false; 16 | for (int i = 0; i < str.length(); i++) { 17 | char c = str.charAt(i); 18 | boolean nextUpperCase = true; 19 | if (i < (str.length() - 1)) { 20 | nextUpperCase = Character.isUpperCase(str.charAt(i + 1)); 21 | } 22 | if ((i >= 0) && Character.isUpperCase(c)) { 23 | if (!upperCase || !nextUpperCase) { 24 | if (i > 0) 25 | sb.append("_"); 26 | } 27 | upperCase = true; 28 | } else { 29 | upperCase = false; 30 | } 31 | sb.append(Character.toLowerCase(c)); 32 | } 33 | return sb.toString(); 34 | } 35 | } 36 | 37 | /** 38 | * 驼峰转下划线 39 | * @param str 40 | * @return 41 | */ 42 | public static String toCamelCase(String str) { 43 | if (str == null || "".equals(str.trim())) { 44 | return null; 45 | } else { 46 | str = str.toLowerCase(); 47 | StringBuilder sb = new StringBuilder(str.length()); 48 | boolean upperCase = false; 49 | for (int i = 0; i < str.length(); i++) { 50 | char c = str.charAt(i); 51 | if (c == '_') { 52 | if (i == 0) { 53 | sb.append(c); 54 | } else { 55 | upperCase = true; 56 | } 57 | } else if (upperCase) { 58 | sb.append(Character.toUpperCase(c)); 59 | upperCase = false; 60 | } else { 61 | sb.append(c); 62 | } 63 | } 64 | return sb.toString(); 65 | } 66 | } 67 | 68 | public static void main(String[] args) { 69 | System.out.println(CamelCaseUtils.toUnderlineName("ISOCertifiedStaff")); 70 | System.out.println(CamelCaseUtils.toUnderlineName("CertifiedStaff")); 71 | System.out.println(CamelCaseUtils.toUnderlineName("UserID")); 72 | System.out.println(CamelCaseUtils.toCamelCase("iso_certified_staff")); 73 | System.out.println(CamelCaseUtils.toCamelCase("certified_staff_")); 74 | System.out.println(CamelCaseUtils.toCamelCase("_i_s_o_certified_staff")); 75 | System.out.println(CamelCaseUtils.toUnderlineName("updateTime")); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /data-back/src/main/java/com/es/databack/controller/ConstantController.java: -------------------------------------------------------------------------------- 1 | 2 | package com.es.databack.controller; 3 | 4 | import com.es.databack.enums.IndexTypeEnum; 5 | import com.es.stone.result.BaseResult; 6 | import io.swagger.annotations.Api; 7 | import io.swagger.annotations.ApiOperation; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import java.sql.*; 15 | import java.util.*; 16 | 17 | /** 18 | * 配置相关 19 | */ 20 | @Api("配置API") 21 | @Slf4j 22 | @RestController 23 | @RequestMapping("/api/config/admin") 24 | public class ConstantController { 25 | 26 | @Value("${local.jdbc.url}") 27 | private String url; 28 | 29 | @Value("${local.jdbc.username}") 30 | private String username; 31 | 32 | @Value("${local.jdbc.password}") 33 | private String password; 34 | 35 | /** 36 | * 获取数据库名称 37 | * 38 | * @return 39 | */ 40 | @ApiOperation(value = "获取数据库名称") 41 | @GetMapping("/database") 42 | public BaseResult database() { 43 | try { 44 | //检查数据库连接 45 | Connection connection = DriverManager.getConnection(url, username, password); 46 | DatabaseMetaData dbMetaData = connection.getMetaData(); 47 | ResultSet rs = dbMetaData.getCatalogs(); 48 | connection.close(); 49 | while (rs.next()) { 50 | String name = rs.getString("TABLE_CAT"); 51 | return BaseResult.buildSuccessResult(name); 52 | } 53 | } catch (SQLException e) { 54 | e.printStackTrace(); 55 | } 56 | return BaseResult.buildSuccessResult(""); 57 | } 58 | 59 | /** 60 | * 获取数据库表名列表 61 | * 62 | * @return 63 | */ 64 | @ApiOperation(value = "获取数据库表名列表") 65 | @GetMapping("/table") 66 | public BaseResult table() { 67 | List list = new ArrayList<>(); 68 | try { 69 | //检查数据库连接 70 | Connection connection = DriverManager.getConnection(url, username, password); 71 | DatabaseMetaData dbMetaData = connection.getMetaData(); 72 | ResultSet rs = dbMetaData.getTables(null, null, null,new String[] { "TABLE" }); 73 | while (rs.next()) { 74 | list.add(rs.getString("TABLE_NAME")); 75 | } 76 | connection.close(); 77 | } catch (SQLException e) { 78 | e.printStackTrace(); 79 | } 80 | return BaseResult.buildSuccessResult(list); 81 | } 82 | 83 | /** 84 | * 获取索引类型列表 85 | * 86 | * @return 87 | */ 88 | @ApiOperation(value = "获取索引类型列表") 89 | @GetMapping("/index") 90 | public BaseResult index() { 91 | return BaseResult.buildSuccessResult(IndexTypeEnum.getIndexTypeList()); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-dump/datadump/${package}/service/${className}Service.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.service; 2 | 3 | import java.util.List; 4 | 5 | import ${package}.model.Page; 6 | import ${package}.model.${className}Model; 7 | 8 | /** 9 | * Description: [${table.tableDesc}服务] 10 | * Created on ${date} 11 | * @author ${author} 12 | * @version 1.0 13 | * Copyright (c) ${year} ${website} 14 | */ 15 | public interface ${className}Service { 16 | 17 | /** 18 | *

Discription:[${table.tableDesc}数据分页查询]

19 | * Created on ${date} 20 | * @param pager ${table.tableDesc}数据分页条件 21 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 22 | * @param queryFields ${table.tableDesc}数据查询字段集合 23 | * @return List<${className}Model>分页数据 24 | * 25 | * @author:${author} 26 | */ 27 | public List<${className}Model> queryPage${className}(Page page, ${className}Model ${classNameLower}Model, String queryFields); 28 | 29 | /** 30 | *

Discription:[${table.tableDesc}数据不分页查询]

31 | * Created on ${date} 32 | * @param pager ${table.tableDesc}数据分页条件 33 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 34 | * @param queryFields ${table.tableDesc}数据查询字段集合 35 | * @return List<${className}Model>分页数据 36 | * 37 | * @author:${author} 38 | */ 39 | public List<${className}Model> queryList${className}(${className}Model ${classNameLower}Model, String queryFields); 40 | 41 | /** 42 | *

Discription:[${table.tableDesc}数据查询总条数]

43 | * Created on ${date} 44 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 45 | * @return 查询条数 46 | * @author:${author} 47 | */ 48 | public Long queryCount${className}(${className}Model ${classNameLower}Model); 49 | 50 | /** 51 | *

Discription:[根据id查询${table.tableDesc}数据]

52 | * Created on ${date} 53 | * @param id ${table.tableDesc}数据id 54 | * @return ${className}Model 单条数据 55 | * @author:${author} 56 | */ 57 | public ${className}Model query${className}ById(String id); 58 | 59 | /** 60 | *

Discription:[${table.tableDesc}数据新增]

61 | * Created on ${date} 62 | * @param ${classNameLower}Model ${table.tableDesc}数据 63 | * @return String 添加成功的id 64 | * @author:${author} 65 | */ 66 | public int save(${className}Model ${classNameLower}Model); 67 | 68 | /** 69 | *

Discription:[${table.tableDesc}数据编辑]

70 | * Created on ${date} 71 | * @param ${classNameLower}Model ${table.tableDesc}数据 72 | * @return 成功条数 73 | * @author:${author} 74 | */ 75 | public int edit(${className}Model ${classNameLower}Model); 76 | 77 | /** 78 | *

Discription:[${table.tableDesc}数据删除]

79 | * Created on ${date} 80 | * @param id ${table.tableDesc}数据id 81 | * @return 成功条数 82 | * @author:${author} 83 | */ 84 | public int remove${className}ById(String id); 85 | 86 | /** 87 | *

Discription:[${table.tableDesc}数据批量删除]

88 | * Created on ${date} 89 | * @param ids ${table.tableDesc}数据id的集合 90 | * @return 成功条数 91 | * @author:${author} 92 | */ 93 | public int remove${className}ByIds(String ids); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/manager/ElasticSearchIndexManager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.manager; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.elasticsearch.action.admin.indices.alias.Alias; 6 | import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; 7 | import org.elasticsearch.common.settings.Settings; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | @Slf4j 14 | public class ElasticSearchIndexManager { 15 | 16 | @Autowired 17 | private ElasticSearchDumpManager elasticSearchDumpManager; 18 | 19 | /** 20 | * db_search.tb_article创建逻辑 21 | * 22 | * @param index 23 | * @return 24 | */ 25 | protected CreateIndexRequest convertTbArticle(String index) { 26 | CreateIndexRequest createIndexRequest = new CreateIndexRequest(); 27 | createIndexRequest.index(index + "_v1");//同步模块创建的索引,默认版本都为v1,同步时,使用别名进行同步 28 | createIndexRequest.alias(new Alias(index));//创建别名 29 | createIndexRequest.settings(Settings.builder().put(EsConstant.EsIndexProperty.NUMBER_OF_SHARDS, 7)//设置分片数 30 | .put(EsConstant.EsIndexProperty.MAX_RESULT_WINDOW, 100000));//设置查询条数上限 31 | createIndexRequest.mapping(EsConstant.EsIndexProperty.GENERAL_TYPE, 32 | "title", EsConstant.EsIndexWordProperty.IK,//设置 title 分词 33 | "content", EsConstant.EsIndexWordProperty.IK, //设置 content 分词 34 | "location", EsConstant.EsIndexWordProperty.GEO);//设置 location 经纬度字段,用于距离排序 35 | return createIndexRequest; 36 | } 37 | 38 | /** 39 | * 检查索引情况并根据情况创建索引 40 | * 41 | * @param index 42 | * @return 43 | */ 44 | public boolean checkIndex(String... index) { 45 | boolean flag = true; 46 | if (index != null) { 47 | List indexList = Arrays.asList(index); 48 | try { 49 | for (String idx : indexList) {//需特殊处理的索引列表 50 | if (!elasticSearchDumpManager.isExistsIndex(idx)) {//先判断索引是否存在,若不存在,则继续判断是什么索引 51 | CreateIndexRequest createIndexRequest = null; 52 | if (EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE.equals(idx)) {//针对特殊索引配置初始化逻辑 53 | createIndexRequest = convertTbArticle(EsConstant.EsIndexName.DB_SEARCH_TB_ARTICLE);//设置索引初始化mapper 54 | } 55 | //设置完成mapper后进行判断 56 | if (createIndexRequest != null) {//mapper非空则创建索引 57 | flag = elasticSearchDumpManager.createIndex(createIndexRequest);//根据mapper创建索引 58 | if (!flag) {//若创建失败,则程序终止 59 | log.error("索引" + idx + "创建失败!"); 60 | return flag; 61 | } 62 | } 63 | } 64 | } 65 | } catch (Exception e) { 66 | flag = false;//出现异常false 67 | log.error("索引检查失败,程序退出!", e); 68 | } 69 | } 70 | return flag; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /stone/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | stone 7 | stone 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | stone 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | 41 | org.elasticsearch.client 42 | elasticsearch-rest-high-level-client 43 | 6.3.0 44 | 45 | 46 | org.elasticsearch 47 | elasticsearch 48 | 6.3.0 49 | 50 | 51 | 52 | 53 | 54 | org.projectlombok 55 | lombok 56 | 1.18.4 57 | 58 | 59 | 60 | 61 | 62 | io.springfox 63 | springfox-swagger-ui 64 | 2.2.2 65 | 66 | 67 | io.springfox 68 | springfox-swagger2 69 | 2.2.2 70 | 71 | 72 | 73 | 74 | com.fasterxml.jackson.core 75 | jackson-annotations 76 | 2.9.0 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # es-home 2 | 企业级搜索系统案例(已经非常精简),基于前公司项目搭建。 3 | 4 | 项目讲解地址:https://blog.csdn.net/u012888052/article/details/81876152 5 | 6 | 作者:Happy王子乐 7 | QQ:820155406 8 | WX:Happy-wjl 9 | 10 | 承接各种软件兼职,包括且不限于:项目外包、面试指导、简历修改、模拟大厂面试、讲解知识点、大厂内推等 11 | 12 | 13 | ## 说明 14 | 15 | > 基于SpringBoot+MyBatis的搜索系统,包括 同步历史数据、准实时同步数据、条件搜索数据、智能生成代码 四个模块 16 | 17 | > 如果该项目对您有帮助,您可以点右上角 "Star" 支持一下 谢谢! 18 | 19 | > 或者您可以 "follow" 一下,该项目将持续更新,不断完善功能。 20 | 21 | > 项目交流人QQ:[820155406] 22 | 23 | > 项目讲解地址:https://blog.csdn.net/u012888052/article/details/81876152 24 | 25 | ## 前言 26 | 27 | `es-home`项目致力于打造一个完整的,智能的,简洁的搜索系统,采用现阶段流行技术实现。 28 | 29 | ## 项目介绍 30 | 31 | `es-home`项目是一套搜索系统,包括 **同步历史数据、准实时同步数据、条件搜索数据、智能生成代码** 四个模块。 32 | 采用JAVA语言,并结合elasticsearch、canal、MySQL实现数据搜索、同步数据。 33 | 34 | ### 项目演示 35 | 36 | > 相关截图 37 | 38 | 39 | 40 | ### 组织结构 41 | 42 | ``` lua 43 | es-home 44 | ├── data-back -- 智能生成同步代码、搜索代码,功能尚未完善。 45 | ├── data-dump -- 准实时同步变动数据,MySQL -> ES 46 | ├── data-migration -- 批量同步历史数据 47 | ├── data-search -- 提供对外搜索接口 48 | └── stone -- 以上模块公共代码 49 | 50 | es-home-web 智能生成各模块代码,vue操作页面 51 | 52 | ``` 53 | 54 | 55 | ## es-home-web 初版原型图 56 | https://www.processon.com/view/link/5caef9a4e4b0a13c9ddb8e5d 57 | 58 | ## 目前data-back已实现功能 59 | 1. 生成data-migration项目代码 60 | 2. 生成data-search项目代码 61 | 62 | 63 | ### 技术选型 64 | 65 | #### 后端技术 66 | 67 | 技术 | 说明 | 官网 68 | ----|----|---- 69 | Spring Boot | 容器+MVC框架 | [https://spring.io/projects/spring-boot](https://spring.io/projects/spring-boot) 70 | MyBatis | ORM框架 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html) 71 | MyBatisGenerator | 数据层代码生成 | [http://www.mybatis.org/generator/index.html](http://www.mybatis.org/generator/index.html) 72 | Swagger-UI | 文档生产工具 | [https://github.com/swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui) 73 | Elasticsearch | 搜索引擎 | [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch) 74 | Lombok | 简化对象封装工具 | [https://github.com/rzwitserloot/lombok](https://github.com/rzwitserloot/lombok) 75 | 76 | #### 前端技术 77 | 78 | 技术 | 说明 | 官网 79 | ----|----|---- 80 | Vue | 前端框架 | [https://vuejs.org/](https://vuejs.org/) 81 | Vue-router | 路由框架 | [https://router.vuejs.org/](https://router.vuejs.org/) 82 | Vuex | 全局状态管理框架 | [https://vuex.vuejs.org/](https://vuex.vuejs.org/) 83 | Element | 前端UI框架 | [https://element.eleme.io/](https://element.eleme.io/) 84 | Axios | 前端HTTP框架 | [https://github.com/axios/axios](https://github.com/axios/axios) 85 | 86 | ## 环境搭建 87 | 88 | ### 开发工具 89 | 90 | 工具 | 说明 | 官网 91 | ----|----|---- 92 | IDEA | 开发IDE | https://www.jetbrains.com/idea/download 93 | Navicat | 数据库连接工具 | http://www.formysql.com/xiazai.html 94 | 95 | ### 开发环境 96 | 97 | 工具 | 版本号 | 下载 98 | ----|----|---- 99 | JDK | 1.8 | https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 100 | Mysql | 5.7 | https://www.mysql.com/ 101 | Elasticsearch | 6.3.0 | https://www.elastic.co/downloads 102 | Canal | | https://github.com/alibaba/canal/releases 103 | ### 搭建步骤 104 | 105 | > 本地环境搭建 106 | 107 | - 本地安装开发环境中的所有工具并启动,具体参考博客:https://blog.csdn.net/u012888052/article/details/81876152 108 | 109 | ### 个人网站:http://www.demxy.com/ 110 | ### 个人公众号:得码网 111 | 112 | -------------------------------------------------------------------------------- /data-search/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.es 7 | data-search 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | data-search 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | com.alibaba 46 | fastjson 47 | 1.2.4 48 | 49 | 50 | 51 | org.apache.commons 52 | commons-lang3 53 | 54 | 55 | 56 | 57 | stone 58 | stone 59 | 0.0.1-SNAPSHOT 60 | 61 | 62 | 63 | 64 | 65 | org.elasticsearch.client 66 | elasticsearch-rest-high-level-client 67 | 6.3.0 68 | 69 | 70 | org.elasticsearch.client 71 | elasticsearch-rest-client 72 | 6.3.0 73 | 74 | 75 | org.elasticsearch 76 | elasticsearch 77 | 6.3.0 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /data-dump/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | data-dump 7 | data-dump 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | data-dump 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-test 36 | test 37 | 38 | 39 | 40 | org.apache.commons 41 | commons-lang3 42 | 3.3.1 43 | 44 | 45 | 46 | 47 | stone 48 | stone 49 | 0.0.1-SNAPSHOT 50 | 51 | 52 | 53 | 54 | 55 | org.elasticsearch.client 56 | elasticsearch-rest-high-level-client 57 | 6.3.0 58 | 59 | 60 | org.elasticsearch.client 61 | elasticsearch-rest-client 62 | 6.3.0 63 | 64 | 65 | org.elasticsearch 66 | elasticsearch 67 | 6.3.0 68 | 69 | 70 | 71 | 72 | com.alibaba.otter 73 | canal.client 74 | 1.0.25 75 | 76 | 77 | com.alibaba.otter 78 | canal.protocol 79 | 1.0.25 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | org.springframework.boot 89 | spring-boot-maven-plugin 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /data-back/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.3.RELEASE 9 | 10 | 11 | com.es 12 | data-back 13 | 0.0.1-SNAPSHOT 14 | data-back 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-test 35 | test 36 | 37 | 38 | 39 | com.alibaba 40 | fastjson 41 | 1.2.4 42 | 43 | 44 | 45 | org.apache.commons 46 | commons-lang3 47 | 48 | 49 | 50 | 51 | org.springframework 52 | spring-jdbc 53 | 4.3.2.RELEASE 54 | 55 | 56 | 57 | mysql 58 | mysql-connector-java 59 | 5.1.45 60 | 61 | 62 | 63 | 64 | 65 | stone 66 | stone 67 | 0.0.1-SNAPSHOT 68 | 69 | 70 | 71 | 72 | 73 | org.elasticsearch.client 74 | elasticsearch-rest-high-level-client 75 | 6.3.0 76 | 77 | 78 | org.elasticsearch.client 79 | elasticsearch-rest-client 80 | 6.3.0 81 | 82 | 83 | org.elasticsearch 84 | elasticsearch 85 | 6.3.0 86 | 87 | 88 | 89 | 90 | com.alibaba.otter 91 | canal.client 92 | 1.0.25 93 | 94 | 95 | com.alibaba.otter 96 | canal.protocol 97 | 1.0.25 98 | 99 | 100 | 101 | 102 | 103 | org.freemarker 104 | freemarker 105 | 2.3.28 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | org.springframework.boot 115 | spring-boot-maven-plugin 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/manager/ElasticSearchInitClientManager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.manager; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.http.HttpHost; 5 | import org.elasticsearch.client.RestClient; 6 | import org.elasticsearch.client.RestHighLevelClient; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | import java.util.concurrent.BlockingQueue; 13 | import java.util.concurrent.LinkedBlockingQueue; 14 | 15 | @Slf4j 16 | @Configuration 17 | public class ElasticSearchInitClientManager { 18 | 19 | private final static int poolSize = 50; 20 | private static volatile int idleconnect; 21 | private static BlockingQueue pool = null; 22 | 23 | @Value("${es.client.servers}") 24 | private String servers; 25 | private RestHighLevelClient client = null; 26 | 27 | public final RestHighLevelClient getElasticClient() { 28 | if (client == null) { 29 | HttpHost[] httpHosts = serverToHttpHost(servers); 30 | if (httpHosts != null) { 31 | try { 32 | client = new RestHighLevelClient(RestClient.builder(httpHosts)); 33 | } catch (Exception e) { 34 | log.error("创建es客户端对象异常:", e); 35 | } 36 | } 37 | } 38 | return client; 39 | } 40 | 41 | protected HttpHost[] serverToHttpHost(String servers) { 42 | String[] arrServer = servers.split(","); 43 | List hostList = new ArrayList<>(); 44 | HttpHost[] hostArr = null; 45 | if (arrServer.length < 1) { 46 | log.error("ES服务器配置不正确,请检查!"); 47 | return null; 48 | } 49 | for (String server : arrServer) { 50 | String[] ipAndPort = server.split(":"); 51 | if (ipAndPort.length == 2) { 52 | try { 53 | hostList.add(new HttpHost(ipAndPort[0], Integer.valueOf(ipAndPort[1]), "http")); 54 | } catch (Exception e) { 55 | log.error("ES服务器地址配置不正确!", e); 56 | return null; 57 | } 58 | } else { 59 | log.error("ES服务器配置的ip与port不正确。错误值:" + ipAndPort.toString()); 60 | return null; 61 | } 62 | } 63 | if (!hostList.isEmpty()) { 64 | hostArr = new HttpHost[hostList.size()]; 65 | return hostList.toArray(hostArr); 66 | } 67 | return null; 68 | } 69 | 70 | /** 71 | * 初始化ES连接池 72 | * 连接池有上限,若连接池满,则阻塞等待占用的线程释放ES客户端连接。 73 | * 一旦连接被释放,池中存在空闲客户端,即可继续被消费。 74 | */ 75 | public synchronized void initClientPool() { 76 | if (pool != null) { 77 | return; 78 | } 79 | HttpHost[] httpHosts = serverToHttpHost(servers); 80 | pool = new LinkedBlockingQueue<>(poolSize); 81 | for (int i = 0; i < poolSize; i++) { 82 | try { 83 | pool.put(new RestHighLevelClient(RestClient.builder(httpHosts))); 84 | } catch (InterruptedException e) { 85 | log.error("同步服务初始化ES连接池失败,退出!", e); 86 | System.exit(0); 87 | } 88 | } 89 | } 90 | 91 | /** 92 | * 从线程池中获取ES客户端 93 | * 94 | * @return 95 | */ 96 | public RestHighLevelClient getClientFromPool() { 97 | if (pool == null) { 98 | initClientPool(); 99 | } 100 | try { 101 | return this.pool.take(); 102 | } catch (InterruptedException e) { 103 | log.error("从线程池中获取客户端异常!", e); 104 | } finally { 105 | this.idleconnect = this.pool.size(); 106 | } 107 | return null; 108 | } 109 | 110 | public void disConnect(RestHighLevelClient client) { 111 | try { 112 | this.pool.put(client); 113 | this.idleconnect = this.pool.size(); 114 | } catch (InterruptedException e) { 115 | log.error("同步服务断开连接异常!", e); 116 | } 117 | } 118 | 119 | public String getServers() { 120 | return servers; 121 | } 122 | 123 | public void setServers(String servers) { 124 | this.servers = servers; 125 | } 126 | 127 | public static int getIdleconnect() { 128 | return idleconnect; 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-dump/datadump/${package}/mapper/${className}Mapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | <#list table.columns as column> 9 | 10 | 11 | 12 | 13 | 14 | 15 | select count(1) from ${table.dbName} record 16 | 17 | 18 | 19 | 20 | limit ${ r"#{page.pageOffset} , #{page.pageSize}"} 21 | 22 | 23 | 24 | 25 | SELECT 26 | 27 | 28 | 29 | ${ r"${fi},"} 30 | 31 | 32 | 33 | 34 | 36 | ${column.dbName}<#if column_has_next>, 37 | 38 | ]]> 39 | 40 | FROM ${table.dbName} record 41 | 42 | 43 | 44 | 45 | 46 | <#list table.columns as column> 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | order by createtime desc 57 | 58 | 59 | 60 | 69 | 70 | 71 | 76 | 77 | 78 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | <#list table.columns as column> 94 | ${column.dbName}, 95 | 96 | 97 | 98 | 99 | 100 | 101 | <#list table.columns as column> 102 | ${ r"#{" + column.name + r"}" }, 103 | 104 | 105 | 106 | 107 | 108 | 109 | insert into ${table.dbName}( 110 | 111 | )values( 112 | 113 | ) 114 | 115 | 116 | 117 | 118 | update ${table.dbName} record 119 | 120 | <#list table.columns as column> 121 | <#if column.name != '${modelId}' > 122 | 123 | record.${column.dbName} = ${ r"#{" + column.name + r"}" }<#if column_has_next>, 124 | 125 | 126 | 127 | 128 | where ${primaryKey} = ${r'#{'+"${modelId}"+r'}'} 129 | 130 | 131 | 132 | 133 | delete from ${table.dbName} 134 | where ${primaryKey} in 135 | 136 | ${r"#{code}"} 137 | 138 | 139 | 140 | 141 | delete from ${table.dbName} 142 | 143 | where ${primaryKey} = ${r"#{id}"} 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /data-migration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | data-migration 7 | data-migration 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | data-migration 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.0.4.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-web 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | 45 | com.alibaba 46 | fastjson 47 | 1.2.4 48 | 49 | 50 | 51 | org.apache.commons 52 | commons-lang3 53 | 54 | 55 | 56 | 57 | org.springframework 58 | spring-jdbc 59 | 4.3.2.RELEASE 60 | 61 | 62 | 63 | mysql 64 | mysql-connector-java 65 | 5.1.45 66 | 67 | 68 | 69 | com.alibaba.druid 70 | druid-wrapper 71 | 0.2.9 72 | 73 | 74 | 75 | org.mybatis 76 | mybatis 77 | 3.2.8 78 | 79 | 80 | 81 | org.mybatis 82 | mybatis-spring 83 | 1.2.2 84 | 85 | 86 | 87 | 88 | stone 89 | stone 90 | 0.0.1-SNAPSHOT 91 | 92 | 93 | 94 | 95 | 96 | org.elasticsearch.client 97 | elasticsearch-rest-high-level-client 98 | 6.3.0 99 | 100 | 101 | org.elasticsearch.client 102 | elasticsearch-rest-client 103 | 6.3.0 104 | 105 | 106 | org.elasticsearch 107 | elasticsearch 108 | 6.3.0 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | org.springframework.boot 118 | spring-boot-maven-plugin 119 | 120 | 121 | 122 | org.mybatis.generator 123 | mybatis-generator-maven-plugin 124 | 1.3.2 125 | 126 | src/main/resources/config/generator/generatorConfig.xml 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /data-back/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if (mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if (mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if (!outputFile.getParentFile().exists()) { 87 | if (!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /stone/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /data-dump/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /data-migration/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /data-search/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /stone/src/main/java/com/es/stone/manager/ElasticSearchDumpManager.java: -------------------------------------------------------------------------------- 1 | package com.es.stone.manager; 2 | 3 | import com.es.stone.constant.EsConstant; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; 6 | import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; 7 | import org.elasticsearch.action.admin.indices.get.GetIndexRequest; 8 | import org.elasticsearch.action.bulk.BulkRequest; 9 | import org.elasticsearch.action.delete.DeleteRequest; 10 | import org.elasticsearch.action.index.IndexRequest; 11 | import org.elasticsearch.action.update.UpdateRequest; 12 | import org.elasticsearch.client.RestHighLevelClient; 13 | import org.elasticsearch.common.xcontent.XContentType; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | 16 | import java.io.IOException; 17 | import java.util.Map; 18 | 19 | @Slf4j 20 | public class ElasticSearchDumpManager { 21 | 22 | @Autowired 23 | private ElasticSearchInitClientManager elasticSearchInitClientManager; 24 | 25 | /** 26 | * 排序组装es的id,兼容联合主键 27 | * 28 | * @param keyMap 29 | * @return 30 | */ 31 | public String esKeyString(Map keyMap) { 32 | StringBuffer sb = new StringBuffer(); 33 | for (Map.Entry tmpMap : keyMap.entrySet()) { 34 | sb.append(tmpMap.getValue()); 35 | } 36 | return sb.toString(); 37 | } 38 | 39 | /** 40 | * 同步删除ES数据方法 41 | * 42 | * @param colMap 43 | * @param index 44 | */ 45 | public void deleteRecordToEs(Map colMap, String index) { 46 | String esKey = (String) colMap.get(EsConstant.ES_KEY); 47 | DeleteRequest request = new DeleteRequest(index, EsConstant.EsIndexProperty.GENERAL_TYPE, esKey); 48 | try { 49 | elasticSearchInitClientManager.getElasticClient().delete(request); 50 | } catch (Exception e) { 51 | log.error("ES删除数据失败:" + esKey, e); 52 | } 53 | } 54 | 55 | /** 56 | * 同步插入或更新ES数据方法 57 | * 58 | * @param colMap 59 | * @param index 60 | */ 61 | public void insertOrUpdateToEs(Map colMap, String index) { 62 | insertOrUpdateToEsWithType(colMap, index, EsConstant.EsIndexProperty.GENERAL_TYPE, 0); 63 | } 64 | 65 | /** 66 | * 同步插入或更新ES数据方法 67 | * 68 | * @param colMap 69 | * @param index 70 | */ 71 | public void insertOrUpdateToEsWithType(Map colMap, String index, String type, int tryCount) { 72 | String esKey = (String) colMap.get(EsConstant.ES_KEY); 73 | UpdateRequest request = new UpdateRequest(index, type, esKey); 74 | //移除主键值 75 | colMap.remove(EsConstant.ES_KEY); 76 | request.doc(colMap); 77 | request.upsert(colMap); 78 | RestHighLevelClient client = elasticSearchInitClientManager.getClientFromPool(); 79 | try { 80 | client.update(request); 81 | } catch (Exception e) { 82 | log.error("数据同步es异常,重试次数:,{}, esKey:{}, colMap:{}", tryCount, esKey, colMap, e); 83 | if (tryCount < 3) { 84 | tryCount++; 85 | colMap.put(EsConstant.ES_KEY, esKey); 86 | insertOrUpdateToEsWithType(colMap, index, type, tryCount); 87 | } 88 | } finally { 89 | elasticSearchInitClientManager.disConnect(client); 90 | } 91 | } 92 | 93 | /** 94 | * 同步插入或更新ES数据方法 95 | * 96 | * @param index 97 | * @param type 98 | * @param json 99 | * @param key 100 | */ 101 | public void insertOrUpdateToEsWithTypeUseJson(String index, String type, String json, String key) { 102 | IndexRequest request = new IndexRequest(index, type, key); 103 | request.source(json, XContentType.JSON); 104 | try { 105 | elasticSearchInitClientManager.getElasticClient().index(request); 106 | } catch (Exception e) { 107 | log.error("数据同步es异常:" + key, e); 108 | } 109 | } 110 | 111 | /** 112 | * 批量提交json到es 113 | * 114 | * @param map 115 | * @param index 116 | */ 117 | public void insertOrUpdateToEsbatch(Map map, String index) { 118 | //批量同步约战约球人员表 119 | BulkRequest request = new BulkRequest(); 120 | for (Map.Entry entry : map.entrySet()) { 121 | request.add(new IndexRequest(index, index, entry.getKey()).source(entry.getValue(), XContentType.JSON)); 122 | } 123 | try { 124 | elasticSearchInitClientManager.getElasticClient().bulk(request); 125 | } catch (IOException e) { 126 | log.error("数据同步es异常 insertOrUpdateToEs:" + index, e); 127 | } 128 | } 129 | 130 | /** 131 | * 根据配置创建索引,通用方法 132 | * 133 | * @param createRequest 134 | * @return 135 | * @throws Exception 136 | */ 137 | public boolean createIndex(CreateIndexRequest createRequest) throws Exception { 138 | CreateIndexResponse response = elasticSearchInitClientManager.getElasticClient().indices().create(createRequest); 139 | return response.isAcknowledged(); 140 | } 141 | 142 | /** 143 | * 判断索引是否存在,通用方法 144 | * 145 | * @param index 146 | * @return 147 | * @throws Exception 148 | */ 149 | public boolean isExistsIndex(String... index) throws Exception { 150 | GetIndexRequest request = new GetIndexRequest(); 151 | request.indices(index); 152 | return elasticSearchInitClientManager.getElasticClient().indices().exists(request); 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-search/src/main/java/com/es/datasearch/manager/${classNameLower}/${className}SearchManager.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.manager.${classNameLower}; 2 | 3 | 4 | import com.alibaba.fastjson.JSON; 5 | import ${package}.param.Query${className}SearchVO; 6 | import ${package}.result.ResultByEsDO; 7 | import ${package}.util.ConvertDateUtil; 8 | import com.es.stone.constant.EsConstant; 9 | import com.es.stone.enums.EsStatus; 10 | import com.es.stone.manager.ElasticSearchInitClientManager; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.elasticsearch.action.search.*; 13 | import org.elasticsearch.client.RestHighLevelClient; 14 | import org.elasticsearch.common.geo.GeoPoint; 15 | import org.elasticsearch.common.unit.Fuzziness; 16 | import org.elasticsearch.index.query.BoolQueryBuilder; 17 | import org.elasticsearch.index.query.Operator; 18 | import org.elasticsearch.index.query.QueryBuilders; 19 | import org.elasticsearch.search.SearchHit; 20 | import org.elasticsearch.search.SearchHits; 21 | import org.elasticsearch.search.builder.SearchSourceBuilder; 22 | import org.elasticsearch.search.sort.FieldSortBuilder; 23 | import org.elasticsearch.search.sort.GeoDistanceSortBuilder; 24 | import org.elasticsearch.search.sort.SortOrder; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.stereotype.Component; 27 | import org.springframework.util.StringUtils; 28 | 29 | import java.util.ArrayList; 30 | import java.util.List; 31 | import java.util.Map; 32 | 33 | import static org.elasticsearch.index.query.QueryBuilders.termQuery; 34 | 35 | /** 36 | * Description: [${table.tableDesc}从ES查询数据] 37 | * Created on ${date} 38 | * @author ${author} 39 | * @version 1.0 40 | * Copyright (c) ${year} ${website} 41 | */ 42 | @Slf4j 43 | @Component 44 | public class ${className}SearchManager { 45 | 46 | @Autowired 47 | private ElasticSearchInitClientManager elasticSearchInitClientManager; 48 | 49 | /** 50 | * ${className}列表信息列表查询 51 | * 52 | * @param query${className}SearchVO 53 | * @return 54 | */ 55 | public ResultByEsDO query${className}List(Query${className}SearchVO query${className}SearchVO) { 56 | log.info("${className}SearchManager.query${className}List.query${className}SearchVO:{}", JSON.toJSONString(query${className}SearchVO)); 57 | 58 | ResultByEsDO resultByEsDO = ResultByEsDO.builder().build(); 59 | List ${classNameLower}List = new ArrayList<>();//存放文章列表信息 60 | // 限制最多查询50条 61 | if (query${className}SearchVO.pageSize < 1 || query${className}SearchVO.pageSize > 50) { 62 | resultByEsDO.builder() 63 | .recordSize(0) 64 | .esStatus(EsStatus.PARAM_ERROR.getDesc()) 65 | .build(); 66 | return resultByEsDO; 67 | } 68 | RestHighLevelClient client = elasticSearchInitClientManager.getElasticClient(); 69 | SearchRequest searchRequest = new SearchRequest("${dbName}.${tableName}"); 70 | searchRequest.types(EsConstant.EsIndexProperty.GENERAL_TYPE); 71 | 72 | SearchSourceBuilder searchSourceBuilder = builder${className}SquareCondition(query${className}SearchVO);//组装查询条件 73 | 74 | searchRequest.source(searchSourceBuilder); 75 | //查询条件组装完成------------------------------------------------------------------------------------------------- 76 | try { 77 | SearchResponse rsp = client.search(searchRequest);//开始查询 78 | SearchHits hits = rsp.getHits(); 79 | 80 | for (SearchHit hit : hits) { 81 | Map recordMap = hit.getSourceAsMap(); 82 | ConvertDateUtil.convertDate(recordMap); 83 | ${classNameLower}List.add(recordMap); 84 | } 85 | } catch (Exception e) { 86 | log.error("query${className}List search from tbArticle error!" + searchRequest.toString(), e); 87 | } 88 | return resultByEsDO.builder() 89 | .recordSize(${classNameLower}List.size()) 90 | .list(${classNameLower}List) 91 | .pageNo(query${className}SearchVO.pageNo) 92 | .pageSize(query${className}SearchVO.pageSize) 93 | .esStatus(EsStatus.SUCESS.getDesc()) 94 | .build(); 95 | 96 | } 97 | 98 | /** 99 | * 组装${className}查询逻辑 100 | * 101 | * @param query${className}SearchVO 102 | * @return 103 | */ 104 | protected static SearchSourceBuilder builder${className}SquareCondition(Query${className}SearchVO query${className}SearchVO) { 105 | //组装查询条件----------------------------------------------------------------------------- 106 | SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); 107 | if (query${className}SearchVO.pageNo > 0) { 108 | int from = (query${className}SearchVO.pageNo - 1) * query${className}SearchVO.pageSize; 109 | int size = query${className}SearchVO.pageSize; 110 | searchSourceBuilder.from(from);//设置分页 111 | searchSourceBuilder.size(size); 112 | } 113 | 114 | BoolQueryBuilder bq = QueryBuilders.boolQuery(); 115 | 116 | if (!StringUtils.isEmpty(query${className}SearchVO.keyWords)) { 117 | //设置是否关键字查询条件,并增加了ik分词器,字段的分词器也需要在建索引时进行设置 118 | bq.must(QueryBuilders.multiMatchQuery(query${className}SearchVO.keyWords, "title", "content").analyzer("ik_smart").operator(Operator.AND).fuzziness(Fuzziness.AUTO)); 119 | } 120 | if (queryTbUserSearchVO.id != null && query${className}SearchVO.id > 0) { 121 | //设置是否主键id查询条件 122 | bq.must(termQuery("id", query${className}SearchVO.id)); 123 | } 124 | if (query${className}SearchVO.createStartTime != null) { 125 | bq.filter(QueryBuilders.rangeQuery("create_time").format("yyyy-MM-dd").gte(query${className}SearchVO.createStartTime).timeZone("Asia/Shanghai")); 126 | } 127 | if (query${className}SearchVO.createEndTime != null) { 128 | bq.filter(QueryBuilders.rangeQuery("create_time").format("yyyy-MM-dd").lte(query${className}SearchVO.createEndTime).timeZone("Asia/Shanghai")); 129 | } 130 | searchSourceBuilder.query(bq); 131 | 132 | if (query${className}SearchVO.sortType == 1) { 133 | //当排序规则传入为1时,按照距离正序排序 134 | searchSourceBuilder.sort(new GeoDistanceSortBuilder("location", 135 | new GeoPoint().parseFromLatLon(query${className}SearchVO.latitude + "," + query${className}SearchVO.longitude)) 136 | .order(SortOrder.ASC)); 137 | } else if (query${className}SearchVO.sortType == 0) { 138 | //当排序规则传入为0时,按照时间倒序排序 139 | searchSourceBuilder.sort(new FieldSortBuilder("create_time").order(SortOrder.DESC)); 140 | } 141 | 142 | return searchSourceBuilder; 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /data-back/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /data-back/src/main/resources/templates/data-dump/datadump/${package}/service/impl/${className}ServiceImpl.ftl: -------------------------------------------------------------------------------- 1 | package ${package}.service.impl; 2 | 3 | import java.util.List; 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | 7 | import javax.annotation.Resource; 8 | import org.springframework.stereotype.Service; 9 | import ${package}.model.Page; 10 | import ${package}.dao.${className}Dao; 11 | import ${package}.model.${className}Model; 12 | import ${package}.service.${className}Service; 13 | import com.lxmall.mainframe.utils.ParamValidateUtils; 14 | 15 | /** 16 | * Description: [${table.tableDesc}服务实现] 17 | * Created on ${date} 18 | * @author ${author} 19 | * @version 1.0 20 | * Copyright (c) ${year} ${website} 21 | */ 22 | @Service("${classNameLower}Service") 23 | public class ${className}ServiceImpl implements ${className}Service { 24 | 25 | /** 26 | *

Discription:[${table.tableDesc}dao]

27 | */ 28 | @Resource 29 | private ${className}Dao ${classNameLower}Dao; 30 | 31 | /** 32 | *

Discription:[${table.tableDesc}数据分页查询]

33 | * Created on ${date} 34 | * @param pager ${table.tableDesc}数据分页条件 35 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 36 | * @param queryFields ${table.tableDesc}数据查询字段 37 | * @return List<${className}Model>分页数据 38 | * 39 | * @author:${author} 40 | */ 41 | public List<${className}Model> queryPage${className}(Page page,${className}Model ${classNameLower}Model, 42 | String queryFields){ 43 | 44 | List<${className}Model> list${className} = new ArrayList<${className}Model>(); 45 | try{ 46 | //判断参数是否为空 47 | if(ParamValidateUtils.isEmpty(page)){ 48 | return null; 49 | }else{ 50 | List lis = new ArrayList(); 51 | if(ParamValidateUtils.isEmpty(queryFields)){ 52 | lis = null; 53 | }else{ 54 | lis = Arrays.asList(queryFields.split(",")); 55 | } 56 | list${className} = this.${classNameLower}Dao.queryPage${className}(page,${classNameLower}Model,lis); 57 | } 58 | }catch(Exception e){ 59 | throw new RuntimeException(e); 60 | } 61 | return list${className}; 62 | } 63 | 64 | /** 65 | *

Discription:[${table.tableDesc}数据不分页查询]

66 | * Created on ${date} 67 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 68 | * @param queryFields ${table.tableDesc}数据查询字段 69 | * @return List<${className}Model>数据 70 | * 71 | * @author:${author} 72 | */ 73 | public List<${className}Model> queryList${className}(${className}Model ${classNameLower}Model,String queryFields){ 74 | List<${className}Model> list${className} = new ArrayList<${className}Model>(); 75 | try{ 76 | List lis = new ArrayList(); 77 | if(ParamValidateUtils.isEmpty(queryFields)){ 78 | lis = null; 79 | }else{ 80 | lis = Arrays.asList(queryFields.split(",")); 81 | } 82 | list${className} = this.${classNameLower}Dao.queryList${className}(${classNameLower}Model,lis); 83 | }catch(Exception e){ 84 | throw new RuntimeException(e); 85 | } 86 | return list${className}; 87 | } 88 | 89 | /** 90 | *

Discription:[${table.tableDesc}数据查询总条数]

91 | * Created on ${date} 92 | * @param ${classNameLower}Model ${table.tableDesc}数据查询条件 93 | * @return 查询条数 94 | * @author:${author} 95 | */ 96 | public Long queryCount${className}(${className}Model ${classNameLower}Model){ 97 | 98 | Long count = (long)0; 99 | try{ 100 | count = this.${classNameLower}Dao.queryCount${className}(${classNameLower}Model); 101 | }catch(Exception e){ 102 | throw new RuntimeException(e); 103 | } 104 | return count; 105 | } 106 | 107 | /** 108 | *

Discription:[根据id查询${table.tableDesc}数据]

109 | * Created on ${date} 110 | * @param id ${table.tableDesc}数据id 111 | * @return ${className}Model 单条数据 112 | * @author:${author} 113 | */ 114 | public ${className}Model query${className}ById(String id){ 115 | 116 | ${className}Model model = new ${className}Model(); 117 | try{ 118 | if(ParamValidateUtils.isEmpty(id)){ 119 | return null; 120 | }else{ 121 | model = this.${classNameLower}Dao.query${className}ById(id,null); 122 | } 123 | }catch(Exception e){ 124 | throw new RuntimeException(e); 125 | } 126 | return model; 127 | } 128 | 129 | /** 130 | *

Discription:[${table.tableDesc}数据新增]

131 | * Created on ${date} 132 | * @param ${classNameLower}Model ${table.tableDesc}数据 133 | * @return String 添加成功的id 134 | 135 | * @author:${author} 136 | */ 137 | public int save(${className}Model ${classNameLower}Model){ 138 | int count = 0; 139 | try{ 140 | if(ParamValidateUtils.isEmpty(${classNameLower}Model)){ 141 | return 0; 142 | }else{ 143 | count = this.${classNameLower}Dao.add${className}(${classNameLower}Model); 144 | } 145 | 146 | }catch(Exception e){ 147 | throw new RuntimeException(e); 148 | } 149 | return count; 150 | } 151 | 152 | /** 153 | *

Discription:[${table.tableDesc}数据编辑]

154 | * Created on ${date} 155 | * @param ${classNameLower}Model ${table.tableDesc}数据 156 | * @return 成功条数 157 | * 158 | * @author:${author} 159 | */ 160 | public int edit(${className}Model ${classNameLower}Model){ 161 | Integer count = 0; 162 | try{ 163 | if(ParamValidateUtils.isEmpty(${classNameLower}Model) || ParamValidateUtils.isEmpty(${classNameLower}Model.get${modelIdFirstUpper}())){ 164 | return 0; 165 | }else{ 166 | count = this.${classNameLower}Dao.update${className}(${classNameLower}Model); 167 | } 168 | }catch(Exception e){ 169 | throw new RuntimeException(e); 170 | } 171 | return count; 172 | } 173 | 174 | /** 175 | *

Discription:[${table.tableDesc}数据删除]

176 | * Created on ${date} 177 | * @param id ${table.tableDesc}数据id 178 | * @return 成功条数 179 | * 180 | * @author:${author} 181 | */ 182 | public int remove${className}ById(String id){ 183 | Integer count = 0; 184 | try{ 185 | if(ParamValidateUtils.isEmpty(id)){ 186 | return 0; 187 | }else{ 188 | count = this.${classNameLower}Dao.remove${className}ById(id); 189 | } 190 | }catch(Exception e){ 191 | throw new RuntimeException(e); 192 | } 193 | return count; 194 | } 195 | 196 | /** 197 | *

Discription:[${table.tableDesc}数据批量删除]

198 | * Created on ${date} 199 | * @param ids ${table.tableDesc}数据id的集合 200 | * @return 成功条数 201 | * 202 | * @author:${author} 203 | */ 204 | public int remove${className}ByIds(String ids){ 205 | Integer count = 0; 206 | try{ 207 | if(ParamValidateUtils.isEmpty(ids)){ 208 | return 0; 209 | }else{ 210 | List lis = Arrays.asList(ids.split(",")); 211 | count = this.${classNameLower}Dao.remove${className}ByIds(lis); 212 | } 213 | }catch(Exception e){ 214 | throw new RuntimeException(e); 215 | } 216 | return count; 217 | } 218 | 219 | } 220 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | --------------------------------------------------------------------------------