From 7dec62b229004b448ceac53156f6462147269ab5 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Mon, 2 Oct 2023 16:38:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20docking=5Fdevice=5Fchannel?= =?UTF-8?q?=20=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/orm/DockingOrmInitService.java | 1 + .../docking/device/DockingDeviceService.java | 2 + .../mapper/DockingDeviceChannelMapper.java | 98 ++++++++++ .../basic/model/DockingDeviceChannel.java | 173 ++++++++++++++++++ ...DockingDeviceChannelDynamicSqlSupport.java | 43 +++++ .../mapper/DockingDeviceChannelMapper.java | 169 +++++++++++++++++ .../dynamic/model/DockingDeviceChannel.java | 75 ++++++++ .../mybatis/operation/OperateTableMapper.java | 2 + .../mybatis/operation/OperateTableMapper.xml | 13 ++ .../main/resources/config/generatorConfig.xml | 2 +- .../orm/mybatis/GenerateSchemaTest.java | 1 + 11 files changed, 578 insertions(+), 1 deletion(-) create mode 100644 orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/mapper/DockingDeviceChannelMapper.java create mode 100644 orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/model/DockingDeviceChannel.java create mode 100644 orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelDynamicSqlSupport.java create mode 100644 orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelMapper.java create mode 100644 orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/model/DockingDeviceChannel.java diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/orm/DockingOrmInitService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/orm/DockingOrmInitService.java index 32693f3..6a3e9e2 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/orm/DockingOrmInitService.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/orm/DockingOrmInitService.java @@ -24,5 +24,6 @@ public class DockingOrmInitService { public void init() { log.info("[orm] 自动建表"); mapper.createDeviceTable(); + mapper.createDeviceChannelTable(); } } diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/docking/device/DockingDeviceService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/docking/device/DockingDeviceService.java index f49f911..a18cfcb 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/docking/device/DockingDeviceService.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/docking/device/DockingDeviceService.java @@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.mybatis.dynamic.sql.SqlBuilder; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.sip.message.Response; @@ -48,6 +49,7 @@ public class DockingDeviceService { return onlineCacheService.isOnline(deviceId); } + @Transactional public void online(DockingDevice device, Response response) { String deviceId = device.getDeviceId(); log.info("[设备上线] deviceId => {}, {}://{}:{}", deviceId, device.getTransport(), device.getIp(), device.getPort()); diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/mapper/DockingDeviceChannelMapper.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/mapper/DockingDeviceChannelMapper.java new file mode 100644 index 0000000..8a79aad --- /dev/null +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/mapper/DockingDeviceChannelMapper.java @@ -0,0 +1,98 @@ +package cn.skcks.docking.gb28181.orm.mybatis.basic.mapper; + +import cn.skcks.docking.gb28181.orm.mybatis.basic.model.DockingDeviceChannel; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.type.JdbcType; + +public interface DockingDeviceChannelMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table docking_device_channel + * + * @mbg.generated + */ + @Delete({ + "delete from docking_device_channel", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table docking_device_channel + * + * @mbg.generated + */ + @Insert({ + "insert into docking_device_channel (id, gb_device_id, ", + "gb_device_channel_id, name, ", + "address)", + "values (#{id,jdbcType=BIGINT}, #{gbDeviceId,jdbcType=VARCHAR}, ", + "#{gbDeviceChannelId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ", + "#{address,jdbcType=VARCHAR})" + }) + int insert(DockingDeviceChannel row); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table docking_device_channel + * + * @mbg.generated + */ + @Select({ + "select", + "id, gb_device_id, gb_device_channel_id, name, address", + "from docking_device_channel", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @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) + }) + DockingDeviceChannel selectByPrimaryKey(Long id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table docking_device_channel + * + * @mbg.generated + */ + @Select({ + "select", + "id, gb_device_id, gb_device_channel_id, name, address", + "from docking_device_channel" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @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 selectAll(); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table docking_device_channel + * + * @mbg.generated + */ + @Update({ + "update docking_device_channel", + "set gb_device_id = #{gbDeviceId,jdbcType=VARCHAR},", + "gb_device_channel_id = #{gbDeviceChannelId,jdbcType=VARCHAR},", + "name = #{name,jdbcType=VARCHAR},", + "address = #{address,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(DockingDeviceChannel row); +} \ No newline at end of file diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/model/DockingDeviceChannel.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/model/DockingDeviceChannel.java new file mode 100644 index 0000000..d127474 --- /dev/null +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/basic/model/DockingDeviceChannel.java @@ -0,0 +1,173 @@ +package cn.skcks.docking.gb28181.orm.mybatis.basic.model; + +/** + * + * This class was generated by MyBatis Generator. + * This class corresponds to the database table docking_device_channel + */ +public class DockingDeviceChannel { + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column docking_device_channel.id + * + * @mbg.generated + */ + private Long id; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column docking_device_channel.gb_device_id + * + * @mbg.generated + */ + private String gbDeviceId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column docking_device_channel.gb_device_channel_id + * + * @mbg.generated + */ + private String gbDeviceChannelId; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column docking_device_channel.name + * + * @mbg.generated + */ + private String name; + + /** + * + * This field was generated by MyBatis Generator. + * This field corresponds to the database column docking_device_channel.address + * + * @mbg.generated + */ + private String address; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column docking_device_channel.id + * + * @return the value of docking_device_channel.id + * + * @mbg.generated + */ + public Long getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column docking_device_channel.id + * + * @param id the value for docking_device_channel.id + * + * @mbg.generated + */ + public void setId(Long id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column docking_device_channel.gb_device_id + * + * @return the value of docking_device_channel.gb_device_id + * + * @mbg.generated + */ + public String getGbDeviceId() { + return gbDeviceId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column docking_device_channel.gb_device_id + * + * @param gbDeviceId the value for docking_device_channel.gb_device_id + * + * @mbg.generated + */ + public void setGbDeviceId(String gbDeviceId) { + this.gbDeviceId = gbDeviceId == null ? null : gbDeviceId.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column docking_device_channel.gb_device_channel_id + * + * @return the value of docking_device_channel.gb_device_channel_id + * + * @mbg.generated + */ + public String getGbDeviceChannelId() { + return gbDeviceChannelId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column docking_device_channel.gb_device_channel_id + * + * @param gbDeviceChannelId the value for docking_device_channel.gb_device_channel_id + * + * @mbg.generated + */ + public void setGbDeviceChannelId(String gbDeviceChannelId) { + this.gbDeviceChannelId = gbDeviceChannelId == null ? null : gbDeviceChannelId.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column docking_device_channel.name + * + * @return the value of docking_device_channel.name + * + * @mbg.generated + */ + public String getName() { + return name; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column docking_device_channel.name + * + * @param name the value for docking_device_channel.name + * + * @mbg.generated + */ + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column docking_device_channel.address + * + * @return the value of docking_device_channel.address + * + * @mbg.generated + */ + public String getAddress() { + return address; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column docking_device_channel.address + * + * @param address the value for docking_device_channel.address + * + * @mbg.generated + */ + public void setAddress(String address) { + this.address = address == null ? null : address.trim(); + } +} \ No newline at end of file diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelDynamicSqlSupport.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelDynamicSqlSupport.java new file mode 100644 index 0000000..ec4cc6a --- /dev/null +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelDynamicSqlSupport.java @@ -0,0 +1,43 @@ +package cn.skcks.docking.gb28181.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 DockingDeviceChannelDynamicSqlSupport { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + public static final DockingDeviceChannel dockingDeviceChannel = new DockingDeviceChannel(); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.id") + public static final SqlColumn id = dockingDeviceChannel.id; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.gb_device_id") + public static final SqlColumn gbDeviceId = dockingDeviceChannel.gbDeviceId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.gb_device_channel_id") + public static final SqlColumn gbDeviceChannelId = dockingDeviceChannel.gbDeviceChannelId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.name") + public static final SqlColumn name = dockingDeviceChannel.name; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.address") + public static final SqlColumn address = dockingDeviceChannel.address; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + public static final class DockingDeviceChannel extends AliasableSqlTable { + public final SqlColumn id = column("id", JDBCType.BIGINT); + + public final SqlColumn gbDeviceId = column("gb_device_id", JDBCType.VARCHAR); + + public final SqlColumn gbDeviceChannelId = column("gb_device_channel_id", JDBCType.VARCHAR); + + public final SqlColumn name = column("name", JDBCType.VARCHAR); + + public final SqlColumn address = column("address", JDBCType.VARCHAR); + + public DockingDeviceChannel() { + super("docking_device_channel", DockingDeviceChannel::new); + } + } +} \ No newline at end of file diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelMapper.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelMapper.java new file mode 100644 index 0000000..f9db2b0 --- /dev/null +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/mapper/DockingDeviceChannelMapper.java @@ -0,0 +1,169 @@ +package cn.skcks.docking.gb28181.orm.mybatis.dynamic.mapper; + +import static cn.skcks.docking.gb28181.orm.mybatis.dynamic.mapper.DockingDeviceChannelDynamicSqlSupport.*; +import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo; + +import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDeviceChannel; +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 DockingDeviceChannelMapper extends CommonCountMapper, CommonDeleteMapper, CommonInsertMapper, CommonUpdateMapper { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + BasicColumn[] selectList = BasicColumn.columnList(id, gbDeviceId, gbDeviceChannelId, name, address); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + @SelectProvider(type=SqlProviderAdapter.class, method="select") + @Results(id="DockingDeviceChannelResult", value = { + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @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 selectMany(SelectStatementProvider selectStatement); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + @SelectProvider(type=SqlProviderAdapter.class, method="select") + @ResultMap("DockingDeviceChannelResult") + Optional selectOne(SelectStatementProvider selectStatement); + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default long count(CountDSLCompleter completer) { + return MyBatis3Utils.countFrom(this::count, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int delete(DeleteDSLCompleter completer) { + return MyBatis3Utils.deleteFrom(this::delete, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int deleteByPrimaryKey(Long id_) { + return delete(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int insert(DockingDeviceChannel row) { + return MyBatis3Utils.insert(this::insert, row, dockingDeviceChannel, c -> + c.map(id).toProperty("id") + .map(gbDeviceId).toProperty("gbDeviceId") + .map(gbDeviceChannelId).toProperty("gbDeviceChannelId") + .map(name).toProperty("name") + .map(address).toProperty("address") + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int insertMultiple(Collection records) { + return MyBatis3Utils.insertMultiple(this::insertMultiple, records, dockingDeviceChannel, c -> + c.map(id).toProperty("id") + .map(gbDeviceId).toProperty("gbDeviceId") + .map(gbDeviceChannelId).toProperty("gbDeviceChannelId") + .map(name).toProperty("name") + .map(address).toProperty("address") + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int insertSelective(DockingDeviceChannel row) { + return MyBatis3Utils.insert(this::insert, row, dockingDeviceChannel, c -> + c.map(id).toPropertyWhenPresent("id", row::getId) + .map(gbDeviceId).toPropertyWhenPresent("gbDeviceId", row::getGbDeviceId) + .map(gbDeviceChannelId).toPropertyWhenPresent("gbDeviceChannelId", row::getGbDeviceChannelId) + .map(name).toPropertyWhenPresent("name", row::getName) + .map(address).toPropertyWhenPresent("address", row::getAddress) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default Optional selectOne(SelectDSLCompleter completer) { + return MyBatis3Utils.selectOne(this::selectOne, selectList, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default List select(SelectDSLCompleter completer) { + return MyBatis3Utils.selectList(this::selectMany, selectList, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default List selectDistinct(SelectDSLCompleter completer) { + return MyBatis3Utils.selectDistinct(this::selectMany, selectList, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default Optional selectByPrimaryKey(Long id_) { + return selectOne(c -> + c.where(id, isEqualTo(id_)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int update(UpdateDSLCompleter completer) { + return MyBatis3Utils.update(this::update, dockingDeviceChannel, completer); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + static UpdateDSL updateAllColumns(DockingDeviceChannel row, UpdateDSL dsl) { + return dsl.set(id).equalTo(row::getId) + .set(gbDeviceId).equalTo(row::getGbDeviceId) + .set(gbDeviceChannelId).equalTo(row::getGbDeviceChannelId) + .set(name).equalTo(row::getName) + .set(address).equalTo(row::getAddress); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + static UpdateDSL updateSelectiveColumns(DockingDeviceChannel row, UpdateDSL dsl) { + return dsl.set(id).equalToWhenPresent(row::getId) + .set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId) + .set(gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId) + .set(name).equalToWhenPresent(row::getName) + .set(address).equalToWhenPresent(row::getAddress); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int updateByPrimaryKey(DockingDeviceChannel row) { + return update(c -> + c.set(gbDeviceId).equalTo(row::getGbDeviceId) + .set(gbDeviceChannelId).equalTo(row::getGbDeviceChannelId) + .set(name).equalTo(row::getName) + .set(address).equalTo(row::getAddress) + .where(id, isEqualTo(row::getId)) + ); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: docking_device_channel") + default int updateByPrimaryKeySelective(DockingDeviceChannel row) { + return update(c -> + c.set(gbDeviceId).equalToWhenPresent(row::getGbDeviceId) + .set(gbDeviceChannelId).equalToWhenPresent(row::getGbDeviceChannelId) + .set(name).equalToWhenPresent(row::getName) + .set(address).equalToWhenPresent(row::getAddress) + .where(id, isEqualTo(row::getId)) + ); + } +} \ No newline at end of file diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/model/DockingDeviceChannel.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/model/DockingDeviceChannel.java new file mode 100644 index 0000000..7cddef4 --- /dev/null +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/dynamic/model/DockingDeviceChannel.java @@ -0,0 +1,75 @@ +package cn.skcks.docking.gb28181.orm.mybatis.dynamic.model; + +import jakarta.annotation.Generated; + +/** + * + * This class was generated by MyBatis Generator. + * This class corresponds to the database table docking_device_channel + */ +public class DockingDeviceChannel { + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.id") + private Long id; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.gb_device_id") + private String gbDeviceId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.gb_device_channel_id") + private String gbDeviceChannelId; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.name") + private String name; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.address") + private String address; + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.id") + public Long getId() { + return id; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.id") + public void setId(Long id) { + this.id = id; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.gb_device_id") + public String getGbDeviceId() { + return gbDeviceId; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.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: docking_device_channel.gb_device_channel_id") + public String getGbDeviceChannelId() { + return gbDeviceChannelId; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.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: docking_device_channel.name") + public String getName() { + return name; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.name") + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.address") + public String getAddress() { + return address; + } + + @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source field: docking_device_channel.address") + public void setAddress(String address) { + this.address = address == null ? null : address.trim(); + } +} \ No newline at end of file diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.java b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.java index 8bf6c8a..42ab8b8 100644 --- a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.java +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.java @@ -6,4 +6,6 @@ import org.apache.ibatis.annotations.Mapper; public interface OperateTableMapper { // int createNewTable(@Param("tableName")String tableName); void createDeviceTable(); + + void createDeviceChannelTable(); } diff --git a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.xml b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.xml index 4de5c76..a1835f5 100644 --- a/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.xml +++ b/orm/src/main/java/cn/skcks/docking/gb28181/orm/mybatis/operation/OperateTableMapper.xml @@ -43,4 +43,17 @@ UNIQUE KEY `uk_device_device` (`device_id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + + + CREATE TABLE IF NOT EXISTS `docking_device_channel` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `gb_device_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `gb_device_channel_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `gb_device_id_2` (`gb_device_id`,`gb_device_channel_id`) USING BTREE, + KEY `gb_device_id` (`gb_device_id`) + ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + diff --git a/orm/src/main/resources/config/generatorConfig.xml b/orm/src/main/resources/config/generatorConfig.xml index 19f3f64..f2870ec 100644 --- a/orm/src/main/resources/config/generatorConfig.xml +++ b/orm/src/main/resources/config/generatorConfig.xml @@ -178,7 +178,7 @@ 注意,table里面很多参数都是对javaModelGenerator,context等元素的默认属性的一个复写; --> - +
diff --git a/orm/src/test/java/cn/skcks/docking/gb28181/orm/mybatis/GenerateSchemaTest.java b/orm/src/test/java/cn/skcks/docking/gb28181/orm/mybatis/GenerateSchemaTest.java index ac30b6c..79170b5 100644 --- a/orm/src/test/java/cn/skcks/docking/gb28181/orm/mybatis/GenerateSchemaTest.java +++ b/orm/src/test/java/cn/skcks/docking/gb28181/orm/mybatis/GenerateSchemaTest.java @@ -21,5 +21,6 @@ public class GenerateSchemaTest { @Test void contextLoads(){ operateTableMapper.createDeviceTable(); + operateTableMapper.createDeviceChannelTable(); } }