新增 wvp_proxy_device 表

添加 feign wvp deviceChannels 接口调用
WvpProxyOrmInitService + WvpProxyOperateTableMapper 自动建库建表
This commit is contained in:
shikong 2023-09-05 14:38:49 +08:00
parent aa5e2da7af
commit 0988f1dae8
15 changed files with 691 additions and 6 deletions

View 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-wvp-proxy</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gb28181-wvp-proxy-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>

View File

@ -0,0 +1,48 @@
package cn.skcks.docking.gb28181.wvp.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 WvpProxyDeviceDynamicSqlSupport {
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
public static final WvpProxyDevice wvpProxyDevice = new WvpProxyDevice();
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.id")
public static final SqlColumn<Long> id = wvpProxyDevice.id;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.device_code")
public static final SqlColumn<String> deviceCode = wvpProxyDevice.deviceCode;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_id")
public static final SqlColumn<String> gbDeviceId = wvpProxyDevice.gbDeviceId;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_channel_id")
public static final SqlColumn<String> gbDeviceChannelId = wvpProxyDevice.gbDeviceChannelId;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.name")
public static final SqlColumn<String> name = wvpProxyDevice.name;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.address")
public static final SqlColumn<String> address = wvpProxyDevice.address;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
public static final class WvpProxyDevice extends AliasableSqlTable<WvpProxyDevice> {
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
public final SqlColumn<String> deviceCode = column("device_code", JDBCType.VARCHAR);
public final SqlColumn<String> gbDeviceId = column("gb_device_id", JDBCType.VARCHAR);
public final SqlColumn<String> gbDeviceChannelId = column("gb_device_channel_id", JDBCType.VARCHAR);
public final SqlColumn<String> name = column("name", JDBCType.VARCHAR);
public final SqlColumn<String> address = column("address", JDBCType.VARCHAR);
public WvpProxyDevice() {
super("wvp_proxy_device", WvpProxyDevice::new);
}
}
}

View File

@ -0,0 +1,176 @@
package cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.mapper;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
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 WvpProxyDeviceMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper<WvpProxyDevice>, CommonUpdateMapper {
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
BasicColumn[] selectList = BasicColumn.columnList(WvpProxyDeviceDynamicSqlSupport.id, WvpProxyDeviceDynamicSqlSupport.deviceCode, WvpProxyDeviceDynamicSqlSupport.gbDeviceId, WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId, WvpProxyDeviceDynamicSqlSupport.name, WvpProxyDeviceDynamicSqlSupport.address);
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
@SelectProvider(type=SqlProviderAdapter.class, method="select")
@Results(id="WvpProxyDeviceResult", value = {
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="device_code", property="deviceCode", jdbcType=JdbcType.VARCHAR),
@Result(column="gb_device_id", property="gbDeviceId", jdbcType=JdbcType.VARCHAR),
@Result(column="gb_device_channel_id", property="gbDeviceChannelId", jdbcType=JdbcType.VARCHAR),
@Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
@Result(column="address", property="address", jdbcType=JdbcType.VARCHAR)
})
List<WvpProxyDevice> selectMany(SelectStatementProvider selectStatement);
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
@SelectProvider(type=SqlProviderAdapter.class, method="select")
@ResultMap("WvpProxyDeviceResult")
Optional<WvpProxyDevice> selectOne(SelectStatementProvider selectStatement);
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default long count(CountDSLCompleter completer) {
return MyBatis3Utils.countFrom(this::count, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int delete(DeleteDSLCompleter completer) {
return MyBatis3Utils.deleteFrom(this::delete, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int deleteByPrimaryKey(Long id_) {
return delete(c ->
c.where(WvpProxyDeviceDynamicSqlSupport.id, isEqualTo(id_))
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int insert(WvpProxyDevice row) {
return MyBatis3Utils.insert(this::insert, row, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, c ->
c.map(WvpProxyDeviceDynamicSqlSupport.id).toProperty("id")
.map(WvpProxyDeviceDynamicSqlSupport.deviceCode).toProperty("deviceCode")
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).toProperty("gbDeviceId")
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).toProperty("gbDeviceChannelId")
.map(WvpProxyDeviceDynamicSqlSupport.name).toProperty("name")
.map(WvpProxyDeviceDynamicSqlSupport.address).toProperty("address")
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int insertMultiple(Collection<WvpProxyDevice> records) {
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, c ->
c.map(WvpProxyDeviceDynamicSqlSupport.id).toProperty("id")
.map(WvpProxyDeviceDynamicSqlSupport.deviceCode).toProperty("deviceCode")
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).toProperty("gbDeviceId")
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).toProperty("gbDeviceChannelId")
.map(WvpProxyDeviceDynamicSqlSupport.name).toProperty("name")
.map(WvpProxyDeviceDynamicSqlSupport.address).toProperty("address")
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int insertSelective(WvpProxyDevice row) {
return MyBatis3Utils.insert(this::insert, row, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, c ->
c.map(WvpProxyDeviceDynamicSqlSupport.id).toPropertyWhenPresent("id", row::getId)
.map(WvpProxyDeviceDynamicSqlSupport.deviceCode).toPropertyWhenPresent("deviceCode", row::getDeviceCode)
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).toPropertyWhenPresent("gbDeviceId", row::getGbDeviceId)
.map(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).toPropertyWhenPresent("gbDeviceChannelId", row::getGbDeviceChannelId)
.map(WvpProxyDeviceDynamicSqlSupport.name).toPropertyWhenPresent("name", row::getName)
.map(WvpProxyDeviceDynamicSqlSupport.address).toPropertyWhenPresent("address", row::getAddress)
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default Optional<WvpProxyDevice> selectOne(SelectDSLCompleter completer) {
return MyBatis3Utils.selectOne(this::selectOne, selectList, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default List<WvpProxyDevice> select(SelectDSLCompleter completer) {
return MyBatis3Utils.selectList(this::selectMany, selectList, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default List<WvpProxyDevice> selectDistinct(SelectDSLCompleter completer) {
return MyBatis3Utils.selectDistinct(this::selectMany, selectList, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default Optional<WvpProxyDevice> selectByPrimaryKey(Long id_) {
return selectOne(c ->
c.where(WvpProxyDeviceDynamicSqlSupport.id, isEqualTo(id_))
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int update(UpdateDSLCompleter completer) {
return MyBatis3Utils.update(this::update, WvpProxyDeviceDynamicSqlSupport.wvpProxyDevice, completer);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
static UpdateDSL<UpdateModel> updateAllColumns(WvpProxyDevice row, UpdateDSL<UpdateModel> dsl) {
return dsl.set(WvpProxyDeviceDynamicSqlSupport.id).equalTo(row::getId)
.set(WvpProxyDeviceDynamicSqlSupport.deviceCode).equalTo(row::getDeviceCode)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).equalTo(row::getGbDeviceId)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).equalTo(row::getGbDeviceChannelId)
.set(WvpProxyDeviceDynamicSqlSupport.name).equalTo(row::getName)
.set(WvpProxyDeviceDynamicSqlSupport.address).equalTo(row::getAddress);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
static UpdateDSL<UpdateModel> updateSelectiveColumns(WvpProxyDevice row, UpdateDSL<UpdateModel> dsl) {
return dsl.set(WvpProxyDeviceDynamicSqlSupport.id).equalToWhenPresent(row::getId)
.set(WvpProxyDeviceDynamicSqlSupport.deviceCode).equalToWhenPresent(row::getDeviceCode)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId)
.set(WvpProxyDeviceDynamicSqlSupport.name).equalToWhenPresent(row::getName)
.set(WvpProxyDeviceDynamicSqlSupport.address).equalToWhenPresent(row::getAddress);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int updateByPrimaryKey(WvpProxyDevice row) {
return update(c ->
c.set(WvpProxyDeviceDynamicSqlSupport.deviceCode).equalTo(row::getDeviceCode)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).equalTo(row::getGbDeviceId)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).equalTo(row::getGbDeviceChannelId)
.set(WvpProxyDeviceDynamicSqlSupport.name).equalTo(row::getName)
.set(WvpProxyDeviceDynamicSqlSupport.address).equalTo(row::getAddress)
.where(WvpProxyDeviceDynamicSqlSupport.id, isEqualTo(row::getId))
);
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: wvp_proxy_device")
default int updateByPrimaryKeySelective(WvpProxyDevice row) {
return update(c ->
c.set(WvpProxyDeviceDynamicSqlSupport.deviceCode).equalToWhenPresent(row::getDeviceCode)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceId).equalToWhenPresent(row::getGbDeviceId)
.set(WvpProxyDeviceDynamicSqlSupport.gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId)
.set(WvpProxyDeviceDynamicSqlSupport.name).equalToWhenPresent(row::getName)
.set(WvpProxyDeviceDynamicSqlSupport.address).equalToWhenPresent(row::getAddress)
.where(WvpProxyDeviceDynamicSqlSupport.id, isEqualTo(row::getId))
);
}
}

View File

@ -0,0 +1,88 @@
package cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model;
import jakarta.annotation.Generated;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table wvp_proxy_device
*/
public class WvpProxyDevice {
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.id")
private Long id;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.device_code")
private String deviceCode;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_id")
private String gbDeviceId;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_channel_id")
private String gbDeviceChannelId;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.name")
private String name;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.address")
private String address;
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.id")
public Long getId() {
return id;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.id")
public void setId(Long id) {
this.id = id;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.device_code")
public String getDeviceCode() {
return deviceCode;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_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: wvp_proxy_device.gb_device_id")
public String getGbDeviceId() {
return gbDeviceId;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_id")
public void setGbDeviceId(String gbDeviceId) {
this.gbDeviceId = gbDeviceId == null ? null : gbDeviceId.trim();
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_channel_id")
public String getGbDeviceChannelId() {
return gbDeviceChannelId;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.gb_device_channel_id")
public void setGbDeviceChannelId(String gbDeviceChannelId) {
this.gbDeviceChannelId = gbDeviceChannelId == null ? null : gbDeviceChannelId.trim();
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.name")
public String getName() {
return name;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.name")
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.address")
public String getAddress() {
return address;
}
@Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: wvp_proxy_device.address")
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
}

View File

@ -0,0 +1,9 @@
package cn.skcks.docking.gb28181.wvp.orm.mybatis.operation;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WvpProxyOperateTableMapper {
// int createNewTable(@Param("tableName")String tableName);
void createDeviceTable();
}

View File

@ -0,0 +1,23 @@
<?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.wvp.orm.mybatis.operation.WvpProxyOperateTableMapper">
<update id="createDeviceTable">
CREATE TABLE IF NOT EXISTS `wvp_proxy_device`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`device_code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`gb_device_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`gb_device_channel_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `gb_device_id` (`gb_device_id`),
UNIQUE KEY `device_code` (`device_code`),
UNIQUE KEY `gb_device_id_2` (`gb_device_id`, `gb_device_channel_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;
</update>
</mapper>

View File

@ -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配置资源加载地址使用resourceMBG从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:指定生成对象的样式
1conditional类似hierarchical
2flat所有内容主键blob等全部生成在一个对象中
3hierarchical主键生成一个XXKey对象(key class)Blob等单独生成一个对象其他简单属性在一个对象中(record class)
targetRuntime:
1MyBatis3默认的值生成基于MyBatis3.x以上版本的内容包括XXXBySample
2MyBatis3Simple类似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
注意一点默认会先尝试使用IntegerLongShort等来对应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模型创建器是必须要的元素
负责1key类见context的defaultModelType2java类3查询类
targetPackage生成的类要放的包真实的包受enableSubPackages属性控制
targetProject目标项目指定一个存在的目录下生成的内容会放到指定目录中如果目录不存在MBG不会自动建目录
-->
<javaModelGenerator targetPackage="cn.skcks.docking.gb28181.wvp.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.wvp.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.wvp.orm.mybatis.dynamic.mapper" type="ANNOTATEDMAPPER" targetProject="src/main/java">
<!-- 在targetPackage的基础上根据数据库的schema再生成一层package最终生成的类放在这个package下默认为false -->
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="wvp_proxy_%">
<!-- 参考 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">-->
<!-- &lt;!&ndash; 参考 javaModelGenerator 的 constructorBased属性&ndash;&gt;-->
<!-- <property name="constructorBased" value="false"/>-->
<!-- &lt;!&ndash; 默认为false如果设置为true在生成的SQL中table名字不会加上catalog或schema &ndash;&gt;-->
<!-- <property name="ignoreQualifiersAtRuntime" value="false"/>-->
<!-- &lt;!&ndash; 参考 javaModelGenerator 的 immutable 属性 &ndash;&gt;-->
<!-- <property name="immutable" value="false"/>-->
<!-- &lt;!&ndash; 指定是否只生成domain类如果设置为true只生成domain类如果还配置了sqlMapGenerator那么在mapper XML文件中只生成resultMap元素 &ndash;&gt;-->
<!-- <property name="modelOnly" value="false"/>-->
<!-- <property name="useActualColumnNames" value="false"/>-->
<!-- </table>-->
</context>
</generatorConfiguration>

View File

@ -18,6 +18,12 @@
</properties>
<dependencies>
<dependency>
<groupId>cn.skcks.docking</groupId>
<artifactId>gb28181-wvp-proxy-orm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.skcks.docking.gb28181</groupId>
<artifactId>common</artifactId>

View File

@ -0,0 +1,28 @@
package cn.skcks.docking.gb28181.wvp.orm;
import cn.skcks.docking.gb28181.wvp.orm.mybatis.operation.WvpProxyOperateTableMapper;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@Order(0)
@RequiredArgsConstructor
@MapperScans({
@MapperScan("cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic"),
@MapperScan("cn.skcks.docking.gb28181.wvp.orm.mybatis.operation"),
})
public class WvpProxyOrmInitService {
private final WvpProxyOperateTableMapper mapper;
@PostConstruct
public void init(){
log.info("[orm] 自动建表");
mapper.createDeviceTable();
}
}

View File

@ -1,5 +1,5 @@
proxy:
wvp:
url: http://192.168.3.12:18978
url: http://192.168.3.13:18978
user: admin
passwd: admin

View File

@ -3,11 +3,10 @@ package cn.skcks.docking.gb28181.wvp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableFeignClients
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@SpringBootApplication
public class WvpProxyTestApplication {
public static void main(String[] args) {
SpringApplication.run(WvpProxyTestApplication.class, args);

View File

@ -42,7 +42,7 @@ public class WvpProxyTest {
log.info("{}", loginResp);
String token = loginResp.getData().getAccessToken();
String deviceId = "44050100001180000001";
String deviceId = "44050100002000000001";
GetDeviceTreeReq getDeviceTreeReq = GetDeviceTreeReq.builder().build();
JsonResponse<GetDeviceTreeResp> deviceTreeResp = wvpProxyClient.getDeviceTree(token, deviceId, getDeviceTreeReq);
log.info("{}", deviceTreeResp);
@ -50,5 +50,9 @@ public class WvpProxyTest {
GetDeviceChannelsReq getDeviceChannelsReq = GetDeviceChannelsReq.builder().build();
JsonResponse<GetDeviceChannelsResp> getDeviceChannelsResp = wvpProxyClient.getDeviceChannels(token, deviceId, getDeviceChannelsReq);
log.info("{}", getDeviceChannelsResp);
getDeviceChannelsResp.getData().getList().forEach(item -> {
log.info("{}", item);
});
}
}

View File

@ -2,7 +2,6 @@ package cn.skcks.docking.gb28181.wvp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
@ -10,7 +9,7 @@ import org.springframework.context.annotation.ComponentScan;
"cn.skcks.docking.gb28181.media",
"cn.skcks.docking.gb28181.wvp.proxy"
})
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@SpringBootApplication
@ComponentScan(basePackages = {
"cn.skcks.docking.gb28181.annotation",
"cn.skcks.docking.gb28181.common",

View File

@ -0,0 +1,40 @@
server:
port: 18186
project:
version: @project.version@
spring:
data:
redis:
# [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
# host: 192.168.1.241
host: 192.168.1.241
# [必须修改] 端口号
port: 6379
# [可选] 数据库 DB
database: 15
# [可选] 访问密码,若你的redis服务器没有设置密码就不需要用密码去连接
password:
# [可选] 超时时间
timeout: 10000
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: 123456a
url: jdbc:mysql://192.168.1.241:3306/gb28181_docking_platform?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
media:
ip: 192.168.3.12
url: 'http://192.168.3.12:5081'
# url: 'http://10.10.10.200:12580/anything/'
id: amrWMKmbKqoBjRQ9
# secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333
proxy:
wvp:
url: http://192.168.3.13:18978
user: admin
passwd: admin

View File

@ -18,6 +18,7 @@
<module>gb28181-wvp-proxy-service</module>
<module>gb28181-wvp-proxy-api</module>
<module>gb28181-wvp-proxy-starter</module>
<module>gb28181-wvp-proxy-orm</module>
</modules>
<properties>