diff --git a/README.md b/README.md new file mode 100644 index 0000000..b161df1 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# gb28181-docking-platform-mocking + +gb28181 协议 对接平台 (设备模拟) +gb28181-docking-platform-mocking + +### 项目依赖 +如果项目依赖无法拉取 请尝试将 maven 配置中 +mirror.id maven-default-http-blocker 部分改为 +```xml + + maven-default-http-blocker + + + !* + Pseudo repository to mirror external repositories initially using HTTP. + http://0.0.0.0/ + true + +``` +### 项目打包 +#### 打包 为 jar +```shell +mvn clean package +``` +打包后jar在 gb28181-mocking-orm/target/starter.jar + +#### 打包 为 docker 镜像 +一键脚本(纯docker环境打包 + 编译) +``` +chmod +x ./package-docker.sh +./package-docker.sh +``` +打包后的 docker镜像文件位于 项目根目录 gb28181-docking-platform-mocking.image + +##### 测试运行 +```shell +docker run --name gb28181-mocking --rm \ + -v `pwd`/application.yml:/opt/gb28181-docking-platform/application.yml \ + skcks.cn/gb28181-docking-platform-mocking:0.0.1-SNAPSHOT +``` + +### 打包到本地私仓 +```shell +mvn deploy -DaltDeploymentRepository=amleixun-mvn-reop::default::file:H:/Repository/skcks.cn/gb28181-docking-platform-mvn-repo +``` +git push 推送即可 diff --git a/gb28181-mocking-orm/.gitignore b/gb28181-mocking-orm/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/gb28181-mocking-orm/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/gb28181-mocking-orm/pom.xml b/gb28181-mocking-orm/pom.xml new file mode 100644 index 0000000..7a88c0d --- /dev/null +++ b/gb28181-mocking-orm/pom.xml @@ -0,0 +1,132 @@ + + + 4.0.0 + + cn.skcks.docking + gb28181-mocking + 0.0.1-SNAPSHOT + + + cn.skcks.docking.gb28181 + gb28181-mocking-orm + + + 17 + 17 + UTF-8 + + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + 3.0.2 + test + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + org.mybatis.dynamic-sql + mybatis-dynamic-sql + + + + org.springframework.boot + spring-boot-starter + + + + com.mysql + mysql-connector-j + + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.junit.jupiter + junit-jupiter-api + test + + + + + + + src/main/java + + **/** + + + + src/main/resources + + **/** + + + + + + + src/test/resources + + **/** + + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + org.mybatis.generator + mybatis-generator-maven-plugin + ${mybatis-generator-maven-plugin.version} + + + src/main/resources/config/generatorConfig.xml + true + true + + + + Generate MyBatis Artifacts + + generate + + + + + + com.mysql + mysql-connector-j + ${mysql.version} + + + + + + diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java new file mode 100644 index 0000000..3682a1c --- /dev/null +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceDynamicSqlSupport.java @@ -0,0 +1,43 @@ +package cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.mapper; + +import jakarta.annotation.Generated; +import java.sql.JDBCType; +import org.mybatis.dynamic.sql.AliasableSqlTable; +import org.mybatis.dynamic.sql.SqlColumn; + +public final class MockingDeviceDynamicSqlSupport { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + public static final MockingDevice mockingDevice = new MockingDevice(); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id") + public static final SqlColumn id = mockingDevice.id; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code") + public static final SqlColumn deviceCode = mockingDevice.deviceCode; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name") + public static final SqlColumn name = mockingDevice.name; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address") + public static final SqlColumn address = mockingDevice.address; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id") + public static final SqlColumn gbDeviceId = mockingDevice.gbDeviceId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + public static final class MockingDevice extends AliasableSqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn deviceCode = column("device_code", JDBCType.VARCHAR); + + public final SqlColumn name = column("name", JDBCType.VARCHAR); + + public final SqlColumn address = column("address", JDBCType.VARCHAR); + + public final SqlColumn gbDeviceId = column("gb_device_id", JDBCType.VARBINARY); + + public MockingDevice() { + super("mocking_device", MockingDevice::new); + } + } +} \ No newline at end of file diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java new file mode 100644 index 0000000..e053fff --- /dev/null +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/mapper/MockingDeviceMapper.java @@ -0,0 +1,169 @@ +package cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.mapper; + +import static cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.mapper.MockingDeviceDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; + +import cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model.MockingDevice; +import jakarta.annotation.Generated; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.ResultMap; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.type.JdbcType; +import org.mybatis.dynamic.sql.BasicColumn; +import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter; +import org.mybatis.dynamic.sql.select.CountDSLCompleter; +import org.mybatis.dynamic.sql.select.SelectDSLCompleter; +import org.mybatis.dynamic.sql.select.render.SelectStatementProvider; +import org.mybatis.dynamic.sql.update.UpdateDSL; +import org.mybatis.dynamic.sql.update.UpdateDSLCompleter; +import org.mybatis.dynamic.sql.update.UpdateModel; +import org.mybatis.dynamic.sql.util.SqlProviderAdapter; +import org.mybatis.dynamic.sql.util.mybatis3.CommonCountMapper; +import org.mybatis.dynamic.sql.util.mybatis3.CommonDeleteMapper; +import org.mybatis.dynamic.sql.util.mybatis3.CommonInsertMapper; +import org.mybatis.dynamic.sql.util.mybatis3.CommonUpdateMapper; +import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils; + +@Mapper +public interface MockingDeviceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper, CommonUpdateMapper { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + BasicColumn[] selectList = BasicColumn.columnList(id, deviceCode, name, address, gbDeviceId); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + @SelectProvider(type=SqlProviderAdapter.class, method="select") + @Results(id="MockingDeviceResult", value = { + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="device_code", property="deviceCode", jdbcType=JdbcType.VARCHAR), + @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR), + @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR), + @Result(column="gb_device_id", property="gbDeviceId", jdbcType=JdbcType.VARBINARY) + }) + List selectMany(SelectStatementProvider selectStatement); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + @SelectProvider(type=SqlProviderAdapter.class, method="select") + @ResultMap("MockingDeviceResult") + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int insert(MockingDevice row) { + return MyBatis3Utils.insert(this::insert, row, mockingDevice, c -> + c.map(id).toProperty("id") + .map(deviceCode).toProperty("deviceCode") + .map(name).toProperty("name") + .map(address).toProperty("address") + .map(gbDeviceId).toProperty("gbDeviceId") + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int insertMultiple(Collection records) { + return MyBatis3Utils.insertMultiple(this::insertMultiple, records, mockingDevice, c -> + c.map(id).toProperty("id") + .map(deviceCode).toProperty("deviceCode") + .map(name).toProperty("name") + .map(address).toProperty("address") + .map(gbDeviceId).toProperty("gbDeviceId") + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int insertSelective(MockingDevice row) { + return MyBatis3Utils.insert(this::insert, row, mockingDevice, c -> + c.map(id).toPropertyWhenPresent("id", row::getId) + .map(deviceCode).toPropertyWhenPresent("deviceCode", row::getDeviceCode) + .map(name).toPropertyWhenPresent("name", row::getName) + .map(address).toPropertyWhenPresent("address", row::getAddress) + .map(gbDeviceId).toPropertyWhenPresent("gbDeviceId", row::getGbDeviceId) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, mockingDevice, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + static UpdateDSL updateAllColumns(MockingDevice row, UpdateDSL dsl) { + return dsl.set(id).equalTo(row::getId) + .set(deviceCode).equalTo(row::getDeviceCode) + .set(name).equalTo(row::getName) + .set(address).equalTo(row::getAddress) + .set(gbDeviceId).equalTo(row::getGbDeviceId); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + static UpdateDSL updateSelectiveColumns(MockingDevice row, UpdateDSL dsl) { + return dsl.set(id).equalToWhenPresent(row::getId) + .set(deviceCode).equalToWhenPresent(row::getDeviceCode) + .set(name).equalToWhenPresent(row::getName) + .set(address).equalToWhenPresent(row::getAddress) + .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int updateByPrimaryKey(MockingDevice row) { + return update(c -> + c.set(deviceCode).equalTo(row::getDeviceCode) + .set(name).equalTo(row::getName) + .set(address).equalTo(row::getAddress) + .set(gbDeviceId).equalTo(row::getGbDeviceId) + .where(id, isEqualTo(row::getId)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device") + default int updateByPrimaryKeySelective(MockingDevice row) { + return update(c -> + c.set(deviceCode).equalToWhenPresent(row::getDeviceCode) + .set(name).equalToWhenPresent(row::getName) + .set(address).equalToWhenPresent(row::getAddress) + .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId) + .where(id, isEqualTo(row::getId)) + ); + } +} \ No newline at end of file diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java new file mode 100644 index 0000000..177f114 --- /dev/null +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/dynamic/model/MockingDevice.java @@ -0,0 +1,75 @@ +package cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model; + +import jakarta.annotation.Generated; + +/** + * + * This class was generated by MyBatis Generator. + * This class corresponds to the database table mocking_device + */ +public class MockingDevice { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id") + private Long id; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code") + private String deviceCode; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name") + private String name; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address") + private String address; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id") + private byte[] gbDeviceId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id") + public Long getId() { + return id; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code") + public String getDeviceCode() { + return deviceCode; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code") + public void setDeviceCode(String deviceCode) { + this.deviceCode = deviceCode == null ? null : deviceCode.trim(); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name") + public String getName() { + return name; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name") + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address") + public String getAddress() { + return address; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address") + public void setAddress(String address) { + this.address = address == null ? null : address.trim(); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id") + public byte[] getGbDeviceId() { + return gbDeviceId; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id") + public void setGbDeviceId(byte[] gbDeviceId) { + this.gbDeviceId = gbDeviceId; + } +} \ No newline at end of file diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.java b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.java new file mode 100644 index 0000000..489a3e0 --- /dev/null +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.java @@ -0,0 +1,9 @@ +package cn.skcks.docking.gb28181.mocking.orm.mybatis.operation; + +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OperateTableMapper { + // int createNewTable(@Param("tableName")String tableName); + void createDeviceTable(); +} diff --git a/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.xml b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.xml new file mode 100644 index 0000000..11b0879 --- /dev/null +++ b/gb28181-mocking-orm/src/main/java/cn/skcks/docking/gb28181/mocking/orm/mybatis/operation/OperateTableMapper.xml @@ -0,0 +1,18 @@ + + + + + + CREATE TABLE `mocking_device` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `device_code` varchar(50) NOT NULL, + `gb_device_id` varbinary(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `address` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `device_code` (`device_code`), + UNIQUE KEY `gb_device_id` (`gb_device_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + + diff --git a/gb28181-mocking-orm/src/main/resources/config/generatorConfig.xml b/gb28181-mocking-orm/src/main/resources/config/generatorConfig.xml new file mode 100644 index 0000000..266883c --- /dev/null +++ b/gb28181-mocking-orm/src/main/resources/config/generatorConfig.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+
diff --git a/starter/Dockerfile b/gb28181-mocking-starter/Dockerfile similarity index 100% rename from starter/Dockerfile rename to gb28181-mocking-starter/Dockerfile diff --git a/starter/pom.xml b/gb28181-mocking-starter/pom.xml similarity index 100% rename from starter/pom.xml rename to gb28181-mocking-starter/pom.xml diff --git a/starter/src/main/java/cn/skcks/docking/gb28181/mocking/Gb28181MockingStarter.java b/gb28181-mocking-starter/src/main/java/cn/skcks/docking/gb28181/mocking/Gb28181MockingStarter.java similarity index 100% rename from starter/src/main/java/cn/skcks/docking/gb28181/mocking/Gb28181MockingStarter.java rename to gb28181-mocking-starter/src/main/java/cn/skcks/docking/gb28181/mocking/Gb28181MockingStarter.java diff --git a/pom.xml b/pom.xml index 7f95c79..a08846c 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,8 @@ gb28181-docking-platform-mocking GB28181 Docking Platform - starter + gb28181-mocking-starter + gb28181-mocking-orm @@ -209,6 +210,8 @@ Generate MyBatis Artifacts + + deploy generate