添加 mocking_device 表
调整模块路径 更新 README.md
This commit is contained in:
parent
13fd868b7b
commit
baa6ad755a
46
README.md
Normal file
46
README.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# gb28181-docking-platform-mocking
|
||||||
|
|
||||||
|
gb28181 协议 对接平台 (设备模拟)
|
||||||
|
gb28181-docking-platform-mocking
|
||||||
|
|
||||||
|
### 项目依赖
|
||||||
|
如果项目依赖无法拉取 请尝试将 maven 配置中
|
||||||
|
mirror.id maven-default-http-blocker 部分改为
|
||||||
|
```xml
|
||||||
|
<mirror>
|
||||||
|
<id>maven-default-http-blocker</id>
|
||||||
|
<!--<mirrorOf>external:http:*</mirrorOf>-->
|
||||||
|
<!--放行 http 协议下载 -->
|
||||||
|
<mirrorOf>!*</mirrorOf>
|
||||||
|
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
|
||||||
|
<url>http://0.0.0.0/</url>
|
||||||
|
<blocked>true</blocked>
|
||||||
|
</mirror>
|
||||||
|
```
|
||||||
|
### 项目打包
|
||||||
|
#### 打包 为 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 推送即可
|
38
gb28181-mocking-orm/.gitignore
vendored
Normal file
38
gb28181-mocking-orm/.gitignore
vendored
Normal file
@ -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
|
132
gb28181-mocking-orm/pom.xml
Normal file
132
gb28181-mocking-orm/pom.xml
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.skcks.docking</groupId>
|
||||||
|
<artifactId>gb28181-mocking</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||||
|
<artifactId>gb28181-mocking-orm</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot -starter -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter-test</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Mybatis-DynamicSQL-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.dynamic-sql</groupId>
|
||||||
|
<artifactId>mybatis-dynamic-sql</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**/**</include>
|
||||||
|
</includes>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.mybatis.generator</groupId>
|
||||||
|
<artifactId>mybatis-generator-maven-plugin</artifactId>
|
||||||
|
<version>${mybatis-generator-maven-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<!--配置文件的位置-->
|
||||||
|
<configurationFile>src/main/resources/config/generatorConfig.xml</configurationFile>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<overwrite>true</overwrite>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>Generate MyBatis Artifacts</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>${mysql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -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<Long> id = mockingDevice.id;
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.device_code")
|
||||||
|
public static final SqlColumn<String> deviceCode = mockingDevice.deviceCode;
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.name")
|
||||||
|
public static final SqlColumn<String> name = mockingDevice.name;
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.address")
|
||||||
|
public static final SqlColumn<String> address = mockingDevice.address;
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: mocking_device.gb_device_id")
|
||||||
|
public static final SqlColumn<byte[]> gbDeviceId = mockingDevice.gbDeviceId;
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||||
|
public static final class MockingDevice extends AliasableSqlTable<MockingDevice> {
|
||||||
|
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<String> deviceCode = column("device_code", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> name = column("name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> address = column("address", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<byte[]> gbDeviceId = column("gb_device_id", JDBCType.VARBINARY);
|
||||||
|
|
||||||
|
public MockingDevice() {
|
||||||
|
super("mocking_device", MockingDevice::new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<MockingDevice>, 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<MockingDevice> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: mocking_device")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@ResultMap("MockingDeviceResult")
|
||||||
|
Optional<MockingDevice> 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<MockingDevice> 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<MockingDevice> 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<MockingDevice> 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<MockingDevice> 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<MockingDevice> 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<UpdateModel> updateAllColumns(MockingDevice row, UpdateDSL<UpdateModel> 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<UpdateModel> updateSelectiveColumns(MockingDevice row, UpdateDSL<UpdateModel> 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))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="cn.skcks.docking.gb28181.orm.mybatis.operation.OperateTableMapper">
|
||||||
|
<update id="createDeviceTable">
|
||||||
|
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;
|
||||||
|
</update>
|
||||||
|
</mapper>
|
@ -0,0 +1,132 @@
|
|||||||
|
<!DOCTYPE generatorConfiguration
|
||||||
|
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
|
||||||
|
<!-- 配置生成器 -->
|
||||||
|
<generatorConfiguration>
|
||||||
|
<!-- 可以用于加载配置项或者配置文件,在整个配置文件中就可以使用${propertyKey}的方式来引用配置项
|
||||||
|
resource:配置资源加载地址,使用resource,MBG从classpath开始找,比如com/myproject/generatorConfig.properties
|
||||||
|
url:配置资源加载地质,使用URL的方式,比如file:///C:/myfolder/generatorConfig.properties.
|
||||||
|
注意,两个属性只能选址一个;
|
||||||
|
|
||||||
|
另外,如果使用了mybatis-generator-maven-plugin,那么在pom.xml中定义的properties都可以直接在generatorConfig.xml中使用
|
||||||
|
<properties resource="" url="" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- 在MBG工作的时候,需要额外加载的依赖包
|
||||||
|
location属性指明加载jar/zip包的全路径
|
||||||
|
<classPathEntry location="/Program Files/IBM/SQLLIB/java/db2java.zip" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
context:生成一组对象的环境
|
||||||
|
id:必选,上下文id,用于在生成错误时提示
|
||||||
|
defaultModelType:指定生成对象的样式
|
||||||
|
1,conditional:类似hierarchical;
|
||||||
|
2,flat:所有内容(主键,blob)等全部生成在一个对象中;
|
||||||
|
3,hierarchical:主键生成一个XXKey对象(key class),Blob等单独生成一个对象,其他简单属性在一个对象中(record class)
|
||||||
|
targetRuntime:
|
||||||
|
1,MyBatis3:默认的值,生成基于MyBatis3.x以上版本的内容,包括XXXBySample;
|
||||||
|
2,MyBatis3Simple:类似MyBatis3,只是不生成XXXBySample;
|
||||||
|
introspectedColumnImpl:类全限定名,用于扩展MBG
|
||||||
|
-->
|
||||||
|
<context id="dynamic-mysql" defaultModelType="hierarchical" targetRuntime="MyBatis3DynamicSql" >
|
||||||
|
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;
|
||||||
|
一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖
|
||||||
|
-->
|
||||||
|
<property name="autoDelimitKeywords" value="false"/>
|
||||||
|
<!-- 生成的Java文件的编码 -->
|
||||||
|
<property name="javaFileEncoding" value="UTF-8"/>
|
||||||
|
<!-- 格式化java代码 -->
|
||||||
|
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
|
||||||
|
<!-- 格式化XML代码 -->
|
||||||
|
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
|
||||||
|
|
||||||
|
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
|
||||||
|
<property name="beginningDelimiter" value="`"/>
|
||||||
|
<property name="endingDelimiter" value="`"/>
|
||||||
|
|
||||||
|
<commentGenerator>
|
||||||
|
<!--自动生成的文件中 注释不包含时间-->
|
||||||
|
<property name="suppressDate" value="true"/>
|
||||||
|
<!--添加数据库中字段/列的注释-->
|
||||||
|
<property name="addRemarkComments" value="true"/>
|
||||||
|
</commentGenerator>
|
||||||
|
|
||||||
|
<!-- 必须要有的,使用这个配置链接数据库
|
||||||
|
@TODO:是否可以扩展
|
||||||
|
-->
|
||||||
|
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://10.10.10.200:3306/gb28181_docking_platform" userId="root" password="12341234">
|
||||||
|
<!-- 这里面可以设置property属性,每一个property属性都设置到配置的Driver上 -->
|
||||||
|
|
||||||
|
<!-- Mysql8 驱动 api会查出其他库同名的表 故需要添加此配置-->
|
||||||
|
<property name="nullCatalogMeansCurrent" value="true"/>
|
||||||
|
</jdbcConnection>
|
||||||
|
|
||||||
|
<!-- java类型处理器
|
||||||
|
用于处理DB中的类型到Java中的类型,默认使用JavaTypeResolverDefaultImpl;
|
||||||
|
注意一点,默认会先尝试使用Integer,Long,Short等来对应DECIMAL和 NUMERIC数据类型;
|
||||||
|
-->
|
||||||
|
<javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
|
||||||
|
<!--
|
||||||
|
true:使用BigDecimal对应DECIMAL和 NUMERIC数据类型
|
||||||
|
false:默认,
|
||||||
|
scale>0;length>18:使用BigDecimal;
|
||||||
|
scale=0;length[10,18]:使用Long;
|
||||||
|
scale=0;length[5,9]:使用Integer;
|
||||||
|
scale=0;length<5:使用Short;
|
||||||
|
-->
|
||||||
|
<property name="forceBigDecimals" value="false"/>
|
||||||
|
</javaTypeResolver>
|
||||||
|
<!-- java模型创建器,是必须要的元素
|
||||||
|
负责:1,key类(见context的defaultModelType);2,java类;3,查询类
|
||||||
|
targetPackage:生成的类要放的包,真实的包受enableSubPackages属性控制;
|
||||||
|
targetProject:目标项目,指定一个存在的目录下,生成的内容会放到指定目录中,如果目录不存在,MBG不会自动建目录
|
||||||
|
-->
|
||||||
|
<javaModelGenerator targetPackage="cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.model" targetProject="src/main/java">
|
||||||
|
<property name="constructorBased" value="false"/>
|
||||||
|
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||||
|
<property name="enableSubPackages" value="true"/>
|
||||||
|
<property name="immutable" value="false"/>
|
||||||
|
<!-- 设置一个根对象,
|
||||||
|
如果设置了这个根对象,那么生成的keyClass或者recordClass会继承这个类;在Table的rootClass属性中可以覆盖该选项
|
||||||
|
注意:如果在key class或者record class中有root class相同的属性,MBG就不会重新生成这些属性了,包括:
|
||||||
|
1,属性名相同,类型相同,有相同的getter/setter方法;
|
||||||
|
-->
|
||||||
|
<!--<property name="rootClass" value="cn.skcks.docking.gb28181.orm.mybatis.domain.BaseDomain"/>-->
|
||||||
|
<!-- 设置是否在getter方法中,对String类型字段调用trim()方法 -->
|
||||||
|
<property name="trimStrings" value="true"/>
|
||||||
|
</javaModelGenerator>
|
||||||
|
<sqlMapGenerator targetPackage="cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.mapper" targetProject="src/main/resources">
|
||||||
|
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||||
|
<property name="enableSubPackages" value="true"/>
|
||||||
|
</sqlMapGenerator>
|
||||||
|
<javaClientGenerator targetPackage="cn.skcks.docking.gb28181.mocking.orm.mybatis.dynamic.mapper" type="ANNOTATEDMAPPER" targetProject="src/main/java">
|
||||||
|
<!-- 在targetPackage的基础上,根据数据库的schema再生成一层package,最终生成的类放在这个package下,默认为false -->
|
||||||
|
<property name="enableSubPackages" value="true"/>
|
||||||
|
</javaClientGenerator>
|
||||||
|
|
||||||
|
<table tableName="mocking_%">
|
||||||
|
<!-- 参考 javaModelGenerator 的 constructorBased属性-->
|
||||||
|
<property name="constructorBased" value="false"/>
|
||||||
|
<!-- 默认为false,如果设置为true,在生成的SQL中,table名字不会加上catalog或schema; -->
|
||||||
|
<property name="ignoreQualifiersAtRuntime" value="false"/>
|
||||||
|
<!-- 参考 javaModelGenerator 的 immutable 属性 -->
|
||||||
|
<property name="immutable" value="false"/>
|
||||||
|
<!-- 指定是否只生成domain类,如果设置为true,只生成domain类,如果还配置了sqlMapGenerator,那么在mapper XML文件中,只生成resultMap元素 -->
|
||||||
|
<property name="modelOnly" value="false"/>
|
||||||
|
<property name="useActualColumnNames" value="false"/>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- <table tableName="weather" domainObjectName="weather.DynamicWeather">-->
|
||||||
|
<!-- <!– 参考 javaModelGenerator 的 constructorBased属性–>-->
|
||||||
|
<!-- <property name="constructorBased" value="false"/>-->
|
||||||
|
<!-- <!– 默认为false,如果设置为true,在生成的SQL中,table名字不会加上catalog或schema; –>-->
|
||||||
|
<!-- <property name="ignoreQualifiersAtRuntime" value="false"/>-->
|
||||||
|
<!-- <!– 参考 javaModelGenerator 的 immutable 属性 –>-->
|
||||||
|
<!-- <property name="immutable" value="false"/>-->
|
||||||
|
<!-- <!– 指定是否只生成domain类,如果设置为true,只生成domain类,如果还配置了sqlMapGenerator,那么在mapper XML文件中,只生成resultMap元素 –>-->
|
||||||
|
<!-- <property name="modelOnly" value="false"/>-->
|
||||||
|
<!-- <property name="useActualColumnNames" value="false"/>-->
|
||||||
|
<!-- </table>-->
|
||||||
|
</context>
|
||||||
|
</generatorConfiguration>
|
5
pom.xml
5
pom.xml
@ -15,7 +15,8 @@
|
|||||||
<name>gb28181-docking-platform-mocking</name>
|
<name>gb28181-docking-platform-mocking</name>
|
||||||
<description>GB28181 Docking Platform</description>
|
<description>GB28181 Docking Platform</description>
|
||||||
<modules>
|
<modules>
|
||||||
<module>starter</module>
|
<module>gb28181-mocking-starter</module>
|
||||||
|
<module>gb28181-mocking-orm</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@ -209,6 +210,8 @@
|
|||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>Generate MyBatis Artifacts</id>
|
<id>Generate MyBatis Artifacts</id>
|
||||||
|
<!--打包时不自动执行-->
|
||||||
|
<phase>deploy</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>generate</goal>
|
<goal>generate</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
Loading…
Reference in New Issue
Block a user