diff --git a/.gitignore b/.gitignore index dced3d9..e42f183 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ target/ *.iml # log -logs/ \ No newline at end of file +logs/ + +.DS_Store +~/ \ No newline at end of file diff --git a/connectors/grafana-plugin/README.md b/connectors/grafana-plugin/README.md index 4c52aa1..ce4f07b 100644 --- a/connectors/grafana-plugin/README.md +++ b/connectors/grafana-plugin/README.md @@ -26,7 +26,7 @@ Grafana is an open source volume metrics monitoring and visualization tool, whic We developed the Grafana-Plugin for IoTDB, using the IoTDB REST service to present time series data and providing many visualization methods for time series data. -Iotdb grafana plugin supports grafana version 9.3.0 and above +IoTDB grafana plugin supports grafana version 9.3.0 and above ### How to use Grafana-Plugin diff --git a/distributions/pom.xml b/distributions/pom.xml index a4f59d2..92e5be4 100644 --- a/distributions/pom.xml +++ b/distributions/pom.xml @@ -81,6 +81,8 @@ src/assembly/spark-connector.xml src/assembly/flink-sql-connector.xml + src/assembly/mybatis-generator-plugin.xml + src/assembly/iotdb-spring-boot-starter.xml apache-iotdb-${project.version} diff --git a/distributions/src/assembly/iotdb-spring-boot-starter.xml b/distributions/src/assembly/iotdb-spring-boot-starter.xml new file mode 100644 index 0000000..266a498 --- /dev/null +++ b/distributions/src/assembly/iotdb-spring-boot-starter.xml @@ -0,0 +1,41 @@ + + + + spring-boot-starter-bin + + dir + zip + + apache-iotdb-${project.version}-spring-boot-starter-bin + + + ${maven.multiModuleProjectDirectory}/iotdb-spring-boot-starter/target/ + ${file.separator} + + iotdb-spring-boot-starter-*.jar + + + + + common-files.xml + + diff --git a/distributions/src/assembly/mybatis-generator-plugin.xml b/distributions/src/assembly/mybatis-generator-plugin.xml new file mode 100644 index 0000000..271c084 --- /dev/null +++ b/distributions/src/assembly/mybatis-generator-plugin.xml @@ -0,0 +1,41 @@ + + + + mybatis-generator-plugin-bin + + dir + zip + + apache-iotdb-${project.version}-mybatis-generator-plugin-bin + + + ${maven.multiModuleProjectDirectory}/mybatis-generator/target/ + ${file.separator} + + mybatis-generator-plugin-*.jar + + + + + common-files.xml + + diff --git a/examples/iotdb-spring-boot-start/pom.xml b/examples/iotdb-spring-boot-start/pom.xml new file mode 100644 index 0000000..919f52c --- /dev/null +++ b/examples/iotdb-spring-boot-start/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.4.3 + + + + org.apache.iotdb + iotdb-spring-boot-start-example + 2.0.2-SNAPHOT + iotdb-spring-boot-start + iotdb-spring-boot-start + + 17 + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.iotdb + iotdb-spring-boot-starter + 2.0.2-SNAPSHOT + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/examples/iotdb-spring-boot-start/readme.md b/examples/iotdb-spring-boot-start/readme.md new file mode 100644 index 0000000..ba43418 --- /dev/null +++ b/examples/iotdb-spring-boot-start/readme.md @@ -0,0 +1,116 @@ + +# IoTDB-Spring-Boot-Starter Demo +## Introduction + + This demo shows how to use iotdb-spring-boot-starter + +### Version usage + + IoTDB: 2.0.1-beta + iotdb-spring-boot-starter: 2.0.2-SNAPSHOT + +### 1. Install IoTDB + + please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download) + +### 2. Startup IoTDB + + please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html) + + Then we need to create a database 'wind' by cli in table model + ``` + create database wind; + use wind; + ``` + Then we need to create a database 'table' + ``` + CREATE TABLE table1 ( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status Boolean FIELD, + arrival_time TIMESTAMP FIELD + ) WITH (TTL=31536000000); + ``` + +### 3. Build Dependencies with Maven in your Project + + ``` + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.iotdb + iotdb-spring-boot-starter + 2.0.2-SNAPSHOT + + + ``` + +### 4、Use The target Bean with @Autowired + + You can use the target Bean in your Project,like: + ``` + @Autowired + private ITableSessionPool ioTDBSessionPool; + @Autowired + private SessionPool sessionPool; + + public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException { + ITableSession tableSession = ioTDBSessionPool.getSession(); + final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10"); + while (sessionDataSet.hasNext()) { + final RowRecord rowRecord = sessionDataSet.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); + } + } + + public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException { + final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases"); + while (sessionDataSetWrapper.hasNext()) { + final RowRecord rowRecord = sessionDataSetWrapper.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); + } + } + + ``` diff --git a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java new file mode 100644 index 0000000..367fe3a --- /dev/null +++ b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/IoTDBSpringBootStartApplication.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.iotdbspringbootstartexample; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class IoTDBSpringBootStartApplication { + + public static void main(String[] args) { + SpringApplication.run(IoTDBSpringBootStartApplication.class, args); + } + +} diff --git a/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java new file mode 100644 index 0000000..c9a5163 --- /dev/null +++ b/examples/iotdb-spring-boot-start/src/main/java/org/apache/iotdb/iotdbspringbootstartexample/service/IoTDBService.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.iotdbspringbootstartexample.service; + +import org.apache.iotdb.isession.ITableSession; +import org.apache.iotdb.isession.SessionDataSet; +import org.apache.iotdb.isession.pool.ISessionPool; +import org.apache.iotdb.isession.pool.ITableSessionPool; +import org.apache.iotdb.isession.pool.SessionDataSetWrapper; +import org.apache.iotdb.rpc.IoTDBConnectionException; +import org.apache.iotdb.rpc.StatementExecutionException; +import org.apache.iotdb.session.pool.SessionPool; +import org.apache.tsfile.read.common.Field; +import org.apache.tsfile.read.common.RowRecord; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class IoTDBService { + + @Autowired + private ITableSessionPool ioTDBSessionPool; + + @Autowired + private ISessionPool sessionPool; + + + public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException { + ITableSession tableSession = ioTDBSessionPool.getSession(); + final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from power_data_set limit 10"); + while (sessionDataSet.hasNext()) { + final RowRecord rowRecord = sessionDataSet.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); + } + } + + public void querySessionPool() throws IoTDBConnectionException, StatementExecutionException { + final SessionDataSetWrapper sessionDataSetWrapper = sessionPool.executeQueryStatement("show databases"); + while (sessionDataSetWrapper.hasNext()) { + final RowRecord rowRecord = sessionDataSetWrapper.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); + } + } +} diff --git a/examples/iotdb-spring-boot-start/src/main/resources/application.properties b/examples/iotdb-spring-boot-start/src/main/resources/application.properties new file mode 100644 index 0000000..98953f1 --- /dev/null +++ b/examples/iotdb-spring-boot-start/src/main/resources/application.properties @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +spring.application.name=iotdb-spring-boot-start + +iotdb.session.url=172.20.31.56:6668 +iotdb.session.password=root +iotdb.session.username=root +iotdb.session.database=wind +iotdb.session.sql-dialect=table +iotdb.session.max-size=10 \ No newline at end of file diff --git a/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java b/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java new file mode 100644 index 0000000..0e98959 --- /dev/null +++ b/examples/iotdb-spring-boot-start/src/test/java/org/apache/iotdb/iotdbspringbootstartexample/SpringBootIoTDBApplicationTests.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.iotdbspringbootstartexample; + +import org.apache.iotdb.iotdbspringbootstartexample.service.IoTDBService; +import org.apache.iotdb.rpc.IoTDBConnectionException; +import org.apache.iotdb.rpc.StatementExecutionException; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class SpringBootIoTDBApplicationTests { + + @Autowired + private IoTDBService iotdbService; + + @Test + void contextLoads() throws IoTDBConnectionException, StatementExecutionException { + iotdbService.querySessionPool(); + iotdbService.queryTableSessionPool(); + } + +} \ No newline at end of file diff --git a/examples/mybatis-generator/pom.xml b/examples/mybatis-generator/pom.xml new file mode 100644 index 0000000..83e2c72 --- /dev/null +++ b/examples/mybatis-generator/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.iotdb + iotdb-extras-parent + 2.0.2-SNAPSHOT + ../../pom.xml + + mybatis-generator-example + 2.0.2-SNAPHOT + + 21 + 21 + UTF-8 + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.4.2 + + + org.apache.iotdb + mybatis-generator-plugin + 1.3.2 + + + + true + true + src/main/resources/generatorConfig.xml + + + + + diff --git a/examples/mybatis-generator/readme.md b/examples/mybatis-generator/readme.md new file mode 100644 index 0000000..4c4e4fe --- /dev/null +++ b/examples/mybatis-generator/readme.md @@ -0,0 +1,102 @@ + +# Mybatis-Generator Demo +## Introduction + + This demo shows how to use IoTDB-Mybatis-Generator + +### Version usage + + IoTDB: 2.0.2 + mybatis-generator-plugin: 1.3.2 + +### 1. Install IoTDB + + please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download) + +### 2. Startup IoTDB + + please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html) + + Then we need to create a database 'test' by cli in table model + ``` + create database test; + use test; + ``` + Then we need to create a database 'table' + ``` + CREATE TABLE mix3 ( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status Boolean FIELD, + arrival_time TIMESTAMP FIELD + ) WITH (TTL=31536000000); + ``` + +### 3. Build Dependencies with Maven in your Project + + ``` + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.4.2 + + + org.apache.iotdb + mybatis-generator-plugin + 1.3.2 + + + + true + true + src/main/resources/generatorConfig.xml + + + + + ``` + +### 5. put The generatorConfig.xml in your project + + The location of the ` configurationFile ` configuration ` generatorConfig. xml ` file can be found in the ` src/main/resources ` template of this project for reference` Copy its content and place it in the corresponding location + +### 6. exec 'mvn mybatis-generator:generate' + + Execute the command at the location of the 'pom' in the project:` Mvn mybatis generator: generate generates corresponding Java classes and mapper files + +### 7、the target file location + + You can see the target file in your Project + ``` + org/apache/iotdb/mybatis/plugin/model/Mix.java + org/apache/iotdb/mybatis/plugin/mapper/MixMapper.java + org/apache/iotdb/mybatis/plugin/xml/MixMapper.xml + + ``` diff --git a/examples/mybatis-generator/src/main/resources/generatorConfig.xml b/examples/mybatis-generator/src/main/resources/generatorConfig.xml new file mode 100644 index 0000000..530ff4f --- /dev/null +++ b/examples/mybatis-generator/src/main/resources/generatorConfig.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/examples/mybatisplus-generator/pom.xml b/examples/mybatisplus-generator/pom.xml new file mode 100644 index 0000000..a24d947 --- /dev/null +++ b/examples/mybatisplus-generator/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + org.apache.iotdb + iotdb-extras-parent + 2.0.2-SNAPSHOT + ../../pom.xml + + org.apache.iotdb + mybatisplus-generator-example + 2.0.2-SNAPHOT + + 3.5.10 + 21 + 21 + UTF-8 + + + + com.baomidou + mybatis-plus-spring-boot3-starter + ${mybatisplus.version} + + + com.baomidou + mybatis-plus-generator + 3.5.10 + + + org.apache.velocity + velocity-engine-core + 2.0 + + + org.apache.iotdb + iotdb-jdbc + 2.0.1-beta + + + org.springframework.boot + spring-boot-starter + 3.4.3 + + + org.springframework.boot + spring-boot-starter-web + 3.4.3 + + + io.springfox + springfox-swagger2 + 3.0.0 + + + io.springfox + springfox-swagger-ui + 3.0.0 + + + org.projectlombok + lombok + 1.18.36 + + + diff --git a/examples/mybatisplus-generator/readme.md b/examples/mybatisplus-generator/readme.md new file mode 100644 index 0000000..457b93f --- /dev/null +++ b/examples/mybatisplus-generator/readme.md @@ -0,0 +1,128 @@ + +# Mybatis-Generator Demo +## Introduction + + This demo shows how to use IoTDB-Mybatis-Generator + +### Version usage + + IoTDB: 2.0.1-beta + mybatisPlus: 3.5.10 + +### 1. Install IoTDB + + please refer to [https://iotdb.apache.org/#/Download](https://iotdb.apache.org/#/Download) + +### 2. Startup IoTDB + + please refer to [Quick Start](http://iotdb.apache.org/UserGuide/Master/Get%20Started/QuickStart.html) + + Then we need to create a database 'test' by cli in table model + ``` + create database test; + use test; + ``` + Then we need to create a database 'table' + ``` + CREATE TABLE mix ( + time TIMESTAMP TIME, + region STRING TAG, + plant_id STRING TAG, + device_id STRING TAG, + model_id STRING ATTRIBUTE, + maintenance STRING ATTRIBUTE, + temperature FLOAT FIELD, + humidity FLOAT FIELD, + status Boolean FIELD, + arrival_time TIMESTAMP FIELD + ) WITH (TTL=31536000000); + ``` + +### 3. Build Dependencies with Maven in your Project + + ``` + + + com.baomidou + mybatis-plus-spring-boot3-starter + 3.5.10 + + + + com.baomidou + mybatis-plus-generator + 3.5.10 + + + + org.apache.velocity + velocity-engine-core + 2.0 + + + + org.apache.iotdb + iotdb-jdbc + 2.0.2 + + + org.springframework.boot + spring-boot-starter + 3.4.3 + + + org.springframework.boot + spring-boot-starter-web + 3.4.3 + + + io.springfox + springfox-swagger2 + 3.0.0 + + + io.springfox + springfox-swagger-ui + 3.0.0 + + + org.projectlombok + lombok + 1.18.36 + + + ``` + +### 5. Start the Main.java + +### 6、the target file location + + You can see the target file in your Project + ``` + org/apache/iotdb/controller/MixController.java + org/apache/iotdb/entity/Mix.java + org/apache/iotdb/mapper/MixMapper.xml + org/apache/iotdb/service/MixService.java + org/apache/iotdb/service/MixServiceImpl.java + org/apache/iotdb/MixMapper.xml + + ``` diff --git a/examples/mybatisplus-generator/src/main/java/org/apache/iotdb/Main.java b/examples/mybatisplus-generator/src/main/java/org/apache/iotdb/Main.java new file mode 100644 index 0000000..b8e19af --- /dev/null +++ b/examples/mybatisplus-generator/src/main/java/org/apache/iotdb/Main.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb; + +import com.baomidou.mybatisplus.generator.FastAutoGenerator; +import com.baomidou.mybatisplus.generator.config.DataSourceConfig; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.config.rules.DateType; +import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; +import org.apache.iotdb.jdbc.IoTDBDataSource; + +import java.sql.Types; +import java.util.Collections; + + +public class Main { + public static void main(String[] args) { + IoTDBDataSource dataSource = new IoTDBDataSource(); + dataSource.setUrl("jdbc:iotdb://127.0.0.1:6667/test?sql_dialect=table"); + dataSource.setUser("root"); + dataSource.setPassword("root"); + FastAutoGenerator generator = FastAutoGenerator.create(new DataSourceConfig.Builder(dataSource).driverClassName("org.apache.iotdb.jdbc.IoTDBDriver")); + generator + .globalConfig(builder -> { + builder.author("IoTDB") + .enableSwagger() + .dateType(DateType.ONLY_DATE) + .outputDir("/apache/iotdb-extras/examples/mybatisplus-generator/src/main/java/"); + }) + .packageConfig(builder -> { + builder.parent("org.apache.iotdb") + .mapper("mapper") + .pathInfo(Collections.singletonMap(OutputFile.xml, "/apache/iotdb-extras/examples/mybatisplus-generator/src/main/java/")); + }) + .dataSourceConfig(builder -> { + builder.typeConvertHandler((globalConfig, typeRegistry, metaInfo) -> { + int typeCode = metaInfo.getJdbcType().TYPE_CODE; + switch (typeCode) { + case Types.FLOAT: + return DbColumnType.FLOAT; + default: + return typeRegistry.getColumnType(metaInfo); + } + }); + }) + .strategyConfig(builder -> { + builder.addInclude("mix"); + builder.entityBuilder() + .enableLombok() + .addIgnoreColumns("create_time") + .enableFileOverride(); + builder.serviceBuilder() + .formatServiceFileName("%sService") + .formatServiceImplFileName("%sServiceImpl") + .convertServiceFileName((entityName -> entityName + "Service")) + .enableFileOverride(); + builder.controllerBuilder() + .enableRestStyle() + .enableFileOverride(); + }) + .execute(); + } +} diff --git a/examples/spark-table/README.md b/examples/spark-table/README.md index b986b66..69b50ea 100644 --- a/examples/spark-table/README.md +++ b/examples/spark-table/README.md @@ -35,7 +35,7 @@ Import the IoTDB-Table-Spark-Connector dependency in your project. ## Options | Key | Default Value | Comment | Required | |----------------|----------------|-----------------------------------------------------------------------------------------------------------|----------| -| iotdb.database | -- | The database name of Iotdb, which needs to be a database that already exists in IoTDB | true | +| iotdb.database | -- | The database name of IoTDB, which needs to be a database that already exists in IoTDB | true | | iotdb.table | -- | The table name in IoTDB needs to be a table that already exists in IoTDB | true | | iotdb.username | root | the username to access IoTDB | false | | iotdb.password | root | the password to access IoTDB | false | diff --git a/iotdb-spring-boot-starter/README.md b/iotdb-spring-boot-starter/README.md new file mode 100644 index 0000000..20860e1 --- /dev/null +++ b/iotdb-spring-boot-starter/README.md @@ -0,0 +1,63 @@ + +# iotdb-spring-boot-starter + +* After 'clone' the project, execute 'mvn clean install'. This step is not necessary as it has already been uploaded to the Maven central repository + +* Add the following configuration to the 'pom' file of the project to be generated: + +``` + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.iotdb + iotdb-spring-boot-starter + 2.0.2-SNAPSHOT + + +``` + +* Use The target Bean with @Autowired like: +```java + @Autowired + private ITableSessionPool ioTDBSessionPool; + + public void queryTableSessionPool() throws IoTDBConnectionException, StatementExecutionException { + ITableSession tableSession = ioTDBSessionPool.getSession(); + final SessionDataSet sessionDataSet = tableSession.executeQueryStatement("select * from table1 limit 10"); + while (sessionDataSet.hasNext()) { + final RowRecord rowRecord = sessionDataSet.next(); + final List fields = rowRecord.getFields(); + for (Field field : fields) { + System.out.print(field.getStringValue()); + } + System.out.println(); + } + } +``` \ No newline at end of file diff --git a/iotdb-spring-boot-starter/pom.xml b/iotdb-spring-boot-starter/pom.xml new file mode 100644 index 0000000..eb1607a --- /dev/null +++ b/iotdb-spring-boot-starter/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.4.3 + + + + org.apache.iotdb + iotdb-spring-boot-starter + 2.0.2-SNAPSHOT + + 21 + 21 + UTF-8 + 3.1.4 + + + + org.apache.iotdb + iotdb-session + 2.0.1-beta + + + org.springframework.boot + spring-boot-starter + ${spring-boot3.version} + + + org.springframework.boot + spring-boot-autoconfigure + ${spring-boot3.version} + + + org.springframework.boot + spring-boot-configuration-processor + ${spring-boot3.version} + + + diff --git a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java new file mode 100644 index 0000000..b61ee8d --- /dev/null +++ b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/config/IoTDBSessionProperties.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "iotdb.session") +public class IoTDBSessionProperties { + private String url; + private String username; + private String password; + private String database; + private String sql_dialect = "table"; + private Integer max_size = 5; + private Integer fetch_size = 1024; + private long query_timeout_in_ms = 60000L; + private boolean enable_auto_fetch = true; + private boolean use_ssl = false; + private int max_retry_count = 60; + private long wait_to_get_session_timeout_in_msit = 60000L; + private boolean enable_compression = false; + private long retry_interval_in_ms = 500L; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getDatabase() { + return database; + } + + public void setDatabase(String database) { + this.database = database; + } + + public String getSql_dialect() { + return sql_dialect; + } + + public void setSql_dialect(String sql_dialect) { + this.sql_dialect = sql_dialect; + } + + public Integer getMax_size() { + return max_size; + } + + public void setMax_size(Integer max_size) { + this.max_size = max_size; + } + + public Integer getFetch_size() { + return fetch_size; + } + + public void setFetch_size(Integer fetch_size) { + this.fetch_size = fetch_size; + } + + public Long getQuery_timeout_in_ms() { + return query_timeout_in_ms; + } + + public void setQuery_timeout_in_ms(Long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public Boolean getEnable_auto_fetch() { + return enable_auto_fetch; + } + + public void setEnable_auto_fetch(Boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } + + public Boolean getUse_ssl() { + return use_ssl; + } + + public void setUse_ssl(Boolean use_ssl) { + this.use_ssl = use_ssl; + } + + public Integer getMax_retry_count() { + return max_retry_count; + } + + public void setMax_retry_count(Integer max_retry_count) { + this.max_retry_count = max_retry_count; + } + + public void setQuery_timeout_in_ms(long query_timeout_in_ms) { + this.query_timeout_in_ms = query_timeout_in_ms; + } + + public boolean isEnable_auto_fetch() { + return enable_auto_fetch; + } + + public void setEnable_auto_fetch(boolean enable_auto_fetch) { + this.enable_auto_fetch = enable_auto_fetch; + } + + public boolean isUse_ssl() { + return use_ssl; + } + + public void setUse_ssl(boolean use_ssl) { + this.use_ssl = use_ssl; + } + + public void setMax_retry_count(int max_retry_count) { + this.max_retry_count = max_retry_count; + } + + public long getWait_to_get_session_timeout_in_msit() { + return wait_to_get_session_timeout_in_msit; + } + + public void setWait_to_get_session_timeout_in_msit(long wait_to_get_session_timeout_in_msit) { + this.wait_to_get_session_timeout_in_msit = wait_to_get_session_timeout_in_msit; + } + + public boolean isEnable_compression() { + return enable_compression; + } + + public void setEnable_compression(boolean enable_compression) { + this.enable_compression = enable_compression; + } + + public long getRetry_interval_in_ms() { + return retry_interval_in_ms; + } + + public void setRetry_interval_in_ms(long retry_interval_in_ms) { + this.retry_interval_in_ms = retry_interval_in_ms; + } +} \ No newline at end of file diff --git a/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java new file mode 100644 index 0000000..8914cdd --- /dev/null +++ b/iotdb-spring-boot-starter/src/main/java/org/apache/iotdb/session/IoTDBSessionPool.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.session; + +import org.apache.iotdb.config.IoTDBSessionProperties; +import org.apache.iotdb.isession.pool.ISessionPool; +import org.apache.iotdb.isession.pool.ITableSessionPool; +import org.apache.iotdb.session.pool.SessionPool; +import org.apache.iotdb.session.pool.TableSessionPoolBuilder; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Arrays; + +@Configuration +@ConditionalOnClass({IoTDBSessionProperties.class}) +@EnableConfigurationProperties(IoTDBSessionProperties.class) +public class IoTDBSessionPool { + + private final IoTDBSessionProperties properties; + private ITableSessionPool tableSessionPool; + private ISessionPool treeSessionPool; + + public IoTDBSessionPool(IoTDBSessionProperties properties) { + this.properties = properties; + } + + @Bean + public ITableSessionPool tableSessionPool() { + if(tableSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if(tableSessionPool == null) { + tableSessionPool = new TableSessionPoolBuilder(). + nodeUrls(Arrays.asList(properties.getUrl().split(";"))). + user(properties.getUsername()). + password(properties.getPassword()). + database(properties.getDatabase()). + maxSize(properties.getMax_size()). + fetchSize(properties.getFetch_size()). + enableAutoFetch(properties.getEnable_auto_fetch()). + useSSL(properties.getUse_ssl()). + queryTimeoutInMs(properties.getQuery_timeout_in_ms()). + maxRetryCount(properties.getMax_retry_count()). + waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()). + enableCompression(properties.isEnable_compression()). + retryIntervalInMs(properties.getRetry_interval_in_ms()). + build(); + } + } + } + return tableSessionPool; + } + + @Bean + public ISessionPool treeSessionPool() { + if(treeSessionPool == null) { + synchronized (IoTDBSessionPool.class) { + if(treeSessionPool == null) { + treeSessionPool = new SessionPool.Builder(). + nodeUrls(Arrays.asList(properties.getUrl().split(";"))). + user(properties.getUsername()). + password(properties.getPassword()). + maxSize(properties.getMax_size()). + fetchSize(properties.getFetch_size()). + enableAutoFetch(properties.getEnable_auto_fetch()). + useSSL(properties.getUse_ssl()). + queryTimeoutInMs(properties.getQuery_timeout_in_ms()). + maxRetryCount(properties.getMax_retry_count()). + waitToGetSessionTimeoutInMs(properties.getQuery_timeout_in_ms()). + enableCompression(properties.isEnable_compression()). + retryIntervalInMs(properties.getRetry_interval_in_ms()). + build(); + } + } + } + return treeSessionPool; + } +} diff --git a/iotdb-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/iotdb-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..5195201 --- /dev/null +++ b/iotdb-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +org.apache.iotdb.session.IoTDBSessionPool \ No newline at end of file diff --git a/mybatis-generator/.gitignore b/mybatis-generator/.gitignore new file mode 100644 index 0000000..90c8f11 --- /dev/null +++ b/mybatis-generator/.gitignore @@ -0,0 +1,7 @@ +target/ +.settings/ +.classpath +.project +.idea/ +*.iml +.DS_Store diff --git a/mybatis-generator/README-zh.md b/mybatis-generator/README-zh.md new file mode 100644 index 0000000..94eb875 --- /dev/null +++ b/mybatis-generator/README-zh.md @@ -0,0 +1,55 @@ + +# mybatis-generator-plugin + +* 把该项目 `clone` 下来之后,在本地执行 `mvn clean install` 或者 `mvn clean deploy` (`deploy` 需要修改 `pom` 中的 `distributionManagement`)【已经上传 `Maven` 中央仓库,所以此步骤不在需要】 + +* 在要生成的项目的 `pom` 文件中添加如下配置: + +```java + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.4.2 + + + org.apache.iotdb + mybatis-generator-plugin + 2.0.2-SNAPSHOT + + + + true + true + src/main/resources/generatorConfig.xml + + + + +``` + +* `configurationFile` 配置 `generatorConfig.xml` 文件的位置,其内容在本项目的 `src/main/resources` 有一个模板供参考,`copy` 其内容放到相应的位置 + +* 修改 `generatorConfig.xml` 中 想用的内容,主要是:`jdbcConnection`、`javaModelGenerator`、`sqlMapGenerator`、`javaClientGenerator`、`table` + +* 在项目的 `pom` 所在的地方执行命令:`mvn mybatis-generator:generate` 生成相应的 `Java` 类和 `mapper` 文件 \ No newline at end of file diff --git a/mybatis-generator/README.md b/mybatis-generator/README.md new file mode 100644 index 0000000..e8f848f --- /dev/null +++ b/mybatis-generator/README.md @@ -0,0 +1,55 @@ + + + +# iotdb-spring-boot-starter + +* After 'clone' the project, execute 'mvn clean install'. This step is not necessary as it has already been uploaded to the Maven central repository + +```java + + + + org.mybatis.generator + mybatis-generator-maven-plugin + 1.4.2 + + + org.apache.iotdb + iotdb-mybatis-generator + 2.0.2-SNAPSHOT + + + + true + true + src/main/resources/generatorConfig.xml + + + + +``` + +* The location of the ` configurationFile ` configuration ` generatorConfig. xml ` file can be found in the ` src/main/resources ` template of this project for reference` Copy its content and place it in the corresponding location + +* Modify the content you want to use in 'generatorConfig. xml', mainly by:` jdbcConnection`、`javaModelGenerator`、`sqlMapGenerator`、`javaClientGenerator`、`table` + +* Execute the command at the location of the 'pom' in the project:` Mvn mybatis generator: generate generates corresponding Java classes and mapper files \ No newline at end of file diff --git a/mybatis-generator/pom.xml b/mybatis-generator/pom.xml new file mode 100644 index 0000000..43ec0e4 --- /dev/null +++ b/mybatis-generator/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + org.apache.iotdb + iotdb-extras-parent + 2.0.2-SNAPSHOT + + org.apache.iotdb + mybatis-generator-plugin + 2.0.2-SNAPSHOT + jar + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + org.mybatis.generator + mybatis-generator-core + 1.4.2 + + + diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/BatchInsertPlugin.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/BatchInsertPlugin.java new file mode 100644 index 0000000..cb24f3c --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/BatchInsertPlugin.java @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.PluginAdapter; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.api.dom.java.Interface; +import org.mybatis.generator.api.dom.java.JavaVisibility; +import org.mybatis.generator.api.dom.java.Method; +import org.mybatis.generator.api.dom.java.Parameter; +import org.mybatis.generator.api.dom.xml.Attribute; +import org.mybatis.generator.api.dom.xml.Document; +import org.mybatis.generator.api.dom.xml.TextElement; +import org.mybatis.generator.api.dom.xml.XmlElement; + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +public class BatchInsertPlugin extends PluginAdapter { + + @Override + public boolean clientGenerated(Interface interfaze, IntrospectedTable introspectedTable) { + batchInsertMethod(interfaze, introspectedTable); + + return super.clientGenerated(interfaze, introspectedTable); + } + + @Override + public boolean sqlMapDocumentGenerated(Document document, IntrospectedTable introspectedTable) { + addBatchInsertXml(document, introspectedTable); + return super.sqlMapDocumentGenerated(document, introspectedTable); + } + + @Override + public boolean validate(List list) { + return true; + } + + private void batchInsertMethod(Interface interfaze, IntrospectedTable introspectedTable) { + Set importedTypes = new TreeSet<>(); + importedTypes.add(FullyQualifiedJavaType.getNewListInstance()); + importedTypes.add(new FullyQualifiedJavaType(introspectedTable.getBaseRecordType())); + + Method ibsmethod = new Method("batchInsert"); + ibsmethod.setVisibility(JavaVisibility.PUBLIC); + ibsmethod.setAbstract(true); + + FullyQualifiedJavaType ibsReturnType = FullyQualifiedJavaType.getIntInstance(); + + ibsmethod.setReturnType(ibsReturnType); + + ibsmethod.setName("batchInsert"); + + FullyQualifiedJavaType paramType = FullyQualifiedJavaType.getNewListInstance(); + FullyQualifiedJavaType paramListType; + paramListType = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()); + paramType.addTypeArgument(paramListType); + ibsmethod.addParameter(new Parameter(paramType, "records", "@Param(\"records\")")); + interfaze.addImportedTypes(importedTypes); + + interfaze.addMethod(ibsmethod); + } + + private void addBatchInsertXml(Document document, IntrospectedTable introspectedTable) { + List columns = introspectedTable.getAllColumns(); + String incrementField = + introspectedTable.getTableConfiguration().getProperties().getProperty("incrementField"); + if (incrementField != null) { + incrementField = incrementField.toUpperCase(); + } + + XmlElement insertBatchElement = new XmlElement("insert"); + insertBatchElement.addAttribute(new Attribute("id", "batchInsert")); + insertBatchElement.addAttribute(new Attribute("parameterType", "java.util.List")); + + StringBuilder sqlElement = new StringBuilder(); + StringBuilder javaPropertyAndDbType = new StringBuilder("("); + for (IntrospectedColumn introspectedColumn : columns) { + String columnName = introspectedColumn.getActualColumnName(); + if (!columnName.toUpperCase().equals(incrementField)) { + sqlElement.append(columnName + ",\n "); + javaPropertyAndDbType.append( + "\n #{item." + + introspectedColumn.getJavaProperty() + + ",jdbcType=" + + introspectedColumn.getJdbcTypeName() + + "},"); + } + } + + XmlElement foreachElement = new XmlElement("foreach"); + foreachElement.addAttribute(new Attribute("collection", "records")); + foreachElement.addAttribute(new Attribute("index", "index")); + foreachElement.addAttribute(new Attribute("item", "item")); + foreachElement.addAttribute(new Attribute("separator", ",")); + insertBatchElement.addElement( + new TextElement( + "insert into " + + introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime() + + " (")); + insertBatchElement.addElement( + new TextElement( + " " + sqlElement.delete(sqlElement.lastIndexOf(","), sqlElement.length()).toString())); + insertBatchElement.addElement(new TextElement(") values ")); + foreachElement.addElement( + new TextElement( + javaPropertyAndDbType + .delete(javaPropertyAndDbType.length() - 1, javaPropertyAndDbType.length()) + .append("\n )") + .toString())); + insertBatchElement.addElement(foreachElement); + + document.getRootElement().addElement(insertBatchElement); + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/LombokPlugin.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/LombokPlugin.java new file mode 100644 index 0000000..650d4ec --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/LombokPlugin.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.PluginAdapter; +import org.mybatis.generator.api.dom.java.Method; +import org.mybatis.generator.api.dom.java.TopLevelClass; + +import java.util.List; + +public class LombokPlugin extends PluginAdapter { + + @Override + public boolean validate(List list) { + return true; + } + + @Override + public boolean modelBaseRecordClassGenerated( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + topLevelClass.addImportedType("lombok.Data"); + + topLevelClass.addAnnotation("@Data"); + + return true; + } + + @Override + public boolean modelSetterMethodGenerated( + Method method, + TopLevelClass topLevelClass, + IntrospectedColumn introspectedColumn, + IntrospectedTable introspectedTable, + ModelClassType modelClassType) { + return false; + } + + @Override + public boolean modelGetterMethodGenerated( + Method method, + TopLevelClass topLevelClass, + IntrospectedColumn introspectedColumn, + IntrospectedTable introspectedTable, + ModelClassType modelClassType) { + return false; + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/SerializablePlugin.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/SerializablePlugin.java new file mode 100644 index 0000000..31767c4 --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/SerializablePlugin.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin; + +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.PluginAdapter; +import org.mybatis.generator.api.dom.java.Field; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.api.dom.java.InnerClass; +import org.mybatis.generator.api.dom.java.JavaVisibility; +import org.mybatis.generator.api.dom.java.TopLevelClass; + +import java.util.List; +import java.util.Properties; + +public class SerializablePlugin extends PluginAdapter { + + private FullyQualifiedJavaType serializable; + private FullyQualifiedJavaType gwtSerializable; + private boolean addGWTInterface; + private boolean suppressJavaInterface; + + public SerializablePlugin() { + super(); + serializable = new FullyQualifiedJavaType("java.io.Serializable"); + gwtSerializable = new FullyQualifiedJavaType("com.google.gwt.user.client.rpc.IsSerializable"); + } + + @Override + public boolean validate(List warnings) { + // this plugin is always valid + return true; + } + + @Override + public void setProperties(Properties properties) { + super.setProperties(properties); + addGWTInterface = Boolean.valueOf(properties.getProperty("addGWTInterface")); + suppressJavaInterface = Boolean.valueOf(properties.getProperty("suppressJavaInterface")); + } + + @Override + public boolean modelBaseRecordClassGenerated( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + makeSerializable(topLevelClass, introspectedTable); + return true; + } + + @Override + public boolean modelPrimaryKeyClassGenerated( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + makeSerializable(topLevelClass, introspectedTable); + return true; + } + + @Override + public boolean modelRecordWithBLOBsClassGenerated( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + makeSerializable(topLevelClass, introspectedTable); + return true; + } + + @Override + public boolean modelExampleClassGenerated( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + + makeSerializable(topLevelClass, introspectedTable); + + for (InnerClass innerClass : topLevelClass.getInnerClasses()) { + if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { + addSerialVersionUIDField(innerClass); + } else if ("Criteria".equals(innerClass.getType().getShortName())) { + addSerialVersionUIDField(innerClass); + } else if ("Criterion".equals(innerClass.getType().getShortName())) { + addSerialVersionUIDField(innerClass); + } + } + + return true; + } + + private void addSerialVersionUIDField(InnerClass innerClass) { + innerClass.addSuperInterface(serializable); + Field field = getSerialVersionUIDField(); + innerClass.addField(field); + } + + private Field getSerialVersionUIDField() { + final FullyQualifiedJavaType qualifiedJavaType = new FullyQualifiedJavaType("long"); + Field field = new Field("serialVersionUID", qualifiedJavaType); + field.setFinal(true); + field.setInitializationString("1L"); + field.setName("serialVersionUID"); + field.setStatic(true); + field.setType(qualifiedJavaType); + field.setVisibility(JavaVisibility.PRIVATE); + return field; + } + + protected void makeSerializable( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + if (addGWTInterface) { + topLevelClass.addImportedType(gwtSerializable); + topLevelClass.addSuperInterface(gwtSerializable); + } + + List fields = topLevelClass.getFields(); + if (null != fields && fields.size() > 0) { + for (Field field : fields) { + if ("serialVersionUID".equals(field.getName())) { + return; + } + } + } + + if (!suppressJavaInterface) { + topLevelClass.addImportedType(serializable); + topLevelClass.addSuperInterface(serializable); + + Field field = getSerialVersionUIDField(); + context.getCommentGenerator().addFieldComment(field, introspectedTable); + + topLevelClass.addField(field); + } + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/CNCommentGenerator.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/CNCommentGenerator.java new file mode 100644 index 0000000..3d16206 --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/CNCommentGenerator.java @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin.generator; + +import org.apache.iotdb.mybatis.plugin.util.DateUtil; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.dom.java.CompilationUnit; +import org.mybatis.generator.api.dom.java.Field; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.api.dom.java.JavaVisibility; +import org.mybatis.generator.api.dom.java.TopLevelClass; +import org.mybatis.generator.internal.DefaultCommentGenerator; +import org.mybatis.generator.internal.util.StringUtility; + +import java.util.Date; +import java.util.Properties; + +public class CNCommentGenerator extends DefaultCommentGenerator { + private Properties properties; + + @Override + public void addConfigurationProperties(Properties properties) { + super.addConfigurationProperties(properties); + this.properties = new Properties(); + this.properties.putAll(properties); + } + + @Override + public void addJavaFileComment(CompilationUnit compilationUnit) { + compilationUnit.addFileCommentLine("/**"); + + String copyright = " * Copyright From 2025. IoTDB."; + compilationUnit.addFileCommentLine(copyright); + + compilationUnit.addFileCommentLine(" * "); + compilationUnit.addFileCommentLine( + " * " + compilationUnit.getType().getShortNameWithoutTypeArguments() + ".java"); + compilationUnit.addFileCommentLine(" */"); + } + + @Override + public void addModelClassComment( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + StringBuilder sb = new StringBuilder(); + + topLevelClass.addJavaDocLine("/**"); + topLevelClass.addJavaDocLine(" *"); + + String remarks = introspectedTable.getRemarks(); + if (StringUtility.stringHasValue(remarks)) { + String[] remarkLines = remarks.split(System.getProperty("line.separator")); + for (String remarkLine : remarkLines) { + topLevelClass.addJavaDocLine(" * " + remarkLine); + } + sb.append(" * "); + } + + sb.append("table: "); + sb.append(introspectedTable.getFullyQualifiedTable()); + sb.append(" of model class"); + topLevelClass.addJavaDocLine(sb.toString()); + topLevelClass.addJavaDocLine(" *"); + + String author = "IoTDB"; + if (properties.containsKey("author")) { + author = properties.getProperty("author"); + } + + topLevelClass.addJavaDocLine(" * @author " + author); + topLevelClass.addJavaDocLine(" * @date " + DateUtil.date2Str(new Date())); + topLevelClass.addJavaDocLine(" */"); + FullyQualifiedJavaType serializable = new FullyQualifiedJavaType("java.io.Serializable"); + + topLevelClass.addImportedType(serializable); + topLevelClass.addSuperInterface(serializable); + + final FullyQualifiedJavaType qualifiedJavaType = new FullyQualifiedJavaType("long"); + Field serialVersionUID = new Field("serialVersionUID", qualifiedJavaType); + serialVersionUID.setVisibility(JavaVisibility.PRIVATE); + serialVersionUID.setStatic(true); + serialVersionUID.setFinal(true); + serialVersionUID.setName("serialVersionUID"); + serialVersionUID.setType(qualifiedJavaType); + serialVersionUID.setInitializationString("1L"); + sb = new StringBuilder(); + sb.append("/**\n "); + sb.append(" * class serial version id\n "); + sb.append(" */"); + serialVersionUID.addJavaDocLine(sb.toString()); + + topLevelClass.addField(serialVersionUID); + } + + @Override + public void addFieldComment( + Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { + StringBuffer sb = new StringBuffer(); + + sb.append("/**\n "); + sb.append(" * field: "); + sb.append(introspectedColumn.getActualColumnName()); + + String remarks = introspectedColumn.getRemarks(); + if (StringUtility.stringHasValue(remarks)) { + sb.append(","); + sb.append(remarks); + } + + sb.append("\n */"); + field.addJavaDocLine(sb.toString()); + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/SwaggerCommentGenerator.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/SwaggerCommentGenerator.java new file mode 100644 index 0000000..09a9c78 --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/SwaggerCommentGenerator.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin.generator; + +import org.apache.iotdb.mybatis.plugin.util.DateUtil; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.IntrospectedTable; +import org.mybatis.generator.api.dom.java.CompilationUnit; +import org.mybatis.generator.api.dom.java.Field; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.api.dom.java.JavaVisibility; +import org.mybatis.generator.api.dom.java.TopLevelClass; +import org.mybatis.generator.internal.DefaultCommentGenerator; +import org.mybatis.generator.internal.util.StringUtility; + +import java.util.Date; +import java.util.Properties; + +public class SwaggerCommentGenerator extends DefaultCommentGenerator { + private Properties properties; + private boolean addRemarkComments = false; + private static final String API_MODEL_FULL_CLASS_NAME = + "io.swagger.v3.oas.annotations.media.Schema"; + + @Override + public void addConfigurationProperties(Properties properties) { + super.addConfigurationProperties(properties); + this.addRemarkComments = StringUtility.isTrue(properties.getProperty("addRemarkComments")); + this.properties = new Properties(); + this.properties.putAll(properties); + } + + @Override + public void addFieldComment( + Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) { + String remarks = introspectedColumn.getRemarks(); + if (addRemarkComments && StringUtility.stringHasValue(remarks)) { + addFieldJavaDoc(field, introspectedColumn); + if (remarks.contains("\"")) { + remarks = remarks.replace("\"", "'"); + } + field.addJavaDocLine("@Schema(title = \"" + remarks + "\")"); + } + } + + private void addFieldJavaDoc(Field field, IntrospectedColumn introspectedColumn) { + + StringBuffer sb = new StringBuffer(); + sb.append("/**\n "); + sb.append(" * field: "); + sb.append(introspectedColumn.getActualColumnName()); + String remarks = introspectedColumn.getRemarks(); + if (StringUtility.stringHasValue(remarks)) { + sb.append(","); + sb.append(remarks); + } + + sb.append("\n */"); + field.addJavaDocLine(sb.toString()); + } + + @Override + public void addModelClassComment( + TopLevelClass topLevelClass, IntrospectedTable introspectedTable) { + StringBuilder sb = new StringBuilder(); + + topLevelClass.addJavaDocLine("/**"); + topLevelClass.addJavaDocLine(" *"); + + String remarks = introspectedTable.getRemarks(); + if (StringUtility.stringHasValue(remarks)) { + String[] remarkLines = remarks.split(System.getProperty("line.separator")); + for (String remarkLine : remarkLines) { + topLevelClass.addJavaDocLine(" * " + remarkLine); + } + sb.append(" * "); + } + + sb.append("table: "); + sb.append(introspectedTable.getFullyQualifiedTable()); + sb.append(" of model class"); + topLevelClass.addJavaDocLine(sb.toString()); + topLevelClass.addJavaDocLine(" *"); + + String author = "IoTDB"; + if (properties.containsKey("author")) { + author = properties.getProperty("author"); + } + + topLevelClass.addJavaDocLine(" * @author " + author); + topLevelClass.addJavaDocLine(" * @date " + DateUtil.date2Str(new Date())); + topLevelClass.addJavaDocLine(" */"); + FullyQualifiedJavaType serializable = new FullyQualifiedJavaType("java.io.Serializable"); + + topLevelClass.addImportedType(serializable); + topLevelClass.addSuperInterface(serializable); + + final FullyQualifiedJavaType fullyQualifiedJavaType = new FullyQualifiedJavaType("long"); + Field serialVersionUID = new Field("serialVersionUID", fullyQualifiedJavaType); + serialVersionUID.setVisibility(JavaVisibility.PRIVATE); + serialVersionUID.setStatic(true); + serialVersionUID.setFinal(true); + serialVersionUID.setName("serialVersionUID"); + serialVersionUID.setType(fullyQualifiedJavaType); + serialVersionUID.setInitializationString("1L"); + sb = new StringBuilder(); + sb.append("/**\n "); + sb.append(" * class serial version id\n "); + sb.append(" */"); + serialVersionUID.addJavaDocLine(sb.toString()); + + topLevelClass.addField(serialVersionUID); + topLevelClass.addImportedType(API_MODEL_FULL_CLASS_NAME); + topLevelClass.addAnnotation( + "@Schema(title = \"" + + introspectedTable.getFullyQualifiedTable() + + "\", description = \"" + + remarks + + "\")"); + } + + @Override + public void addJavaFileComment(CompilationUnit compilationUnit) { + compilationUnit.addFileCommentLine("/**"); + + String copyright = " * Copyright From 2025, IoTDB."; + compilationUnit.addFileCommentLine(copyright); + + compilationUnit.addFileCommentLine(" * "); + compilationUnit.addFileCommentLine( + " * " + compilationUnit.getType().getShortNameWithoutTypeArguments() + ".java"); + compilationUnit.addFileCommentLine(" */"); + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/IoTDBJavaTypeResolver.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/IoTDBJavaTypeResolver.java new file mode 100644 index 0000000..3aefc81 --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/IoTDBJavaTypeResolver.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin.generator.resolver; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; +import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl; + +import java.sql.Types; +import java.util.HashMap; +import java.util.Map; + +public class IoTDBJavaTypeResolver extends JavaTypeResolverDefaultImpl { + protected Map typeExtMap; + + public IoTDBJavaTypeResolver() { + super(); + typeExtMap = new HashMap<>(); + initTypeSet(); + } + + @Override + public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) { + + for (String jdbcType : typeExtMap.keySet()) { + + String value = properties.getProperty(jdbcType); + + if (hasText(value)) { + typeMap.put( + typeExtMap.get(jdbcType), + new JdbcTypeInformation( + jdbcType.substring(jdbcType.indexOf(".") + 1), new FullyQualifiedJavaType(value))); + } + } + + return super.calculateJavaType(introspectedColumn); + } + + private void initTypeSet() { + typeExtMap.put("jdbcType.ARRAY", Types.ARRAY); + typeExtMap.put("jdbcType.BIGINT", Types.BIGINT); + typeExtMap.put("jdbcType.BINARY", Types.BINARY); + typeExtMap.put("jdbcType.BIT", Types.BIT); + typeExtMap.put("jdbcType.BLOB", Types.BLOB); + typeExtMap.put("jdbcType.BOOLEAN", Types.BOOLEAN); + typeExtMap.put("jdbcType.CHAR", Types.CHAR); + typeExtMap.put("jdbcType.CLOB", Types.CLOB); + typeExtMap.put("jdbcType.DATALINK", Types.DATALINK); + typeExtMap.put("jdbcType.DATE", Types.DATE); + typeExtMap.put("jdbcType.DECIMAL", Types.DECIMAL); + typeExtMap.put("jdbcType.DISTINCT", Types.DISTINCT); + typeExtMap.put("jdbcType.DOUBLE", Types.DOUBLE); + typeExtMap.put("jdbcType.FLOAT", Types.FLOAT); + typeExtMap.put("jdbcType.INTEGER", Types.INTEGER); + typeExtMap.put("jdbcType.JAVA_OBJECT", Types.JAVA_OBJECT); + typeExtMap.put("jdbcType.LONGNVARCHAR", Types.LONGNVARCHAR); + typeExtMap.put("jdbcType.LONGVARBINARY", Types.LONGVARBINARY); + typeExtMap.put("jdbcType.LONGVARCHAR", Types.LONGVARCHAR); + typeExtMap.put("jdbcType.NCHAR", Types.NCHAR); + typeExtMap.put("jdbcType.NCLOB", Types.NCLOB); + typeExtMap.put("jdbcType.NVARCHAR", Types.NVARCHAR); + typeExtMap.put("jdbcType.NULL", Types.NULL); + typeExtMap.put("jdbcType.NUMERIC", Types.NUMERIC); + typeExtMap.put("jdbcType.OTHER", Types.OTHER); + typeExtMap.put("jdbcType.REAL", Types.REAL); + typeExtMap.put("jdbcType.REF", Types.REF); + typeExtMap.put("jdbcType.SMALLINT", Types.SMALLINT); + typeExtMap.put("jdbcType.STRUCT", Types.STRUCT); + typeExtMap.put("jdbcType.TIME", Types.TIME); + typeExtMap.put("jdbcType.TIMESTAMP", Types.TIMESTAMP); + typeExtMap.put("jdbcType.TINYINT", Types.TINYINT); + typeExtMap.put("jdbcType.VARBINARY", Types.VARBINARY); + typeExtMap.put("jdbcType.VARCHAR", Types.VARCHAR); + } + + public static boolean hasText(String text) { + if (text != null && text.trim().length() > 0) { + return true; + } + return false; + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/JavaTypeResolverSelfImpl.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/JavaTypeResolverSelfImpl.java new file mode 100644 index 0000000..ed841ff --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/generator/resolver/JavaTypeResolverSelfImpl.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin.generator.resolver; + +import org.mybatis.generator.api.IntrospectedColumn; +import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl; + +import java.sql.Types; + +public class JavaTypeResolverSelfImpl extends JavaTypeResolverDefaultImpl { + + @Override + public String calculateJdbcTypeName(IntrospectedColumn introspectedColumn) { + String answer; + JdbcTypeInformation jdbcTypeInformation = typeMap.get(introspectedColumn.getJdbcType()); + + if (jdbcTypeInformation == null) { + switch (introspectedColumn.getJdbcType()) { + case Types.DECIMAL: + answer = "DECIMAL"; + break; + case Types.NUMERIC: + answer = "NUMERIC"; + break; + case Types.DATE: + answer = "TIMESTAMP"; + break; + default: + answer = null; + break; + } + } else { + if ("DATE".equals(jdbcTypeInformation.getJdbcTypeName())) { + answer = "TIMESTAMP"; + } else { + answer = jdbcTypeInformation.getJdbcTypeName(); + } + } + + return answer; + } +} diff --git a/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/util/DateUtil.java b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/util/DateUtil.java new file mode 100644 index 0000000..327a919 --- /dev/null +++ b/mybatis-generator/src/main/java/org/apache/iotdb/mybatis/plugin/util/DateUtil.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.iotdb.mybatis.plugin.util; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class DateUtil { + + public static String date2Str(Date date) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.format(date); + } +} diff --git a/mybatis-generator/src/main/resources/generatorConfig.xml b/mybatis-generator/src/main/resources/generatorConfig.xml new file mode 100644 index 0000000..67d17f1 --- /dev/null +++ b/mybatis-generator/src/main/resources/generatorConfig.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/pom.xml b/pom.xml index 4423708..e19571c 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ distributions examples iotdb-collector + mybatis-generator