MockingOrmInitService + MockingOperateTableMapper 自动建表

This commit is contained in:
shikong 2023-09-05 14:05:10 +08:00
parent 8307595063
commit 5e6f0dadbe
5 changed files with 113 additions and 4 deletions

View File

@ -3,7 +3,7 @@ package cn.skcks.docking.gb28181.mocking.orm.mybatis.operation;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface OperateTableMapper {
public interface MockingOperateTableMapper {
// int createNewTable(@Param("tableName")String tableName);
void createDeviceTable();
}

View File

@ -2,9 +2,9 @@
<!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">
<mapper namespace="cn.skcks.docking.gb28181.mocking.orm.mybatis.operation.MockingOperateTableMapper">
<update id="createDeviceTable">
CREATE TABLE `mocking_device` (
CREATE TABLE IF NOT EXISTS `mocking_device` (
`id` bigint NOT NULL AUTO_INCREMENT,
`device_code` varchar(50) NOT NULL,
`gb_device_id` varbinary(50) NOT NULL,

View File

@ -19,6 +19,12 @@
</properties>
<dependencies>
<dependency>
<groupId>cn.skcks.docking.gb28181</groupId>
<artifactId>gb28181-mocking-orm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.skcks.docking.gb28181</groupId>
<artifactId>common</artifactId>
@ -28,5 +34,80 @@
<groupId>cn.skcks.docking</groupId>
<artifactId>zlmediakit-service</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<!-- sip协议栈 -->
<dependency>
<groupId>javax.sip</groupId>
<artifactId>jain-sip-ri</artifactId>
<version>1.3.0-91</version>
</dependency>
<!-- xml解析库 -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.4</version>
</dependency>
<!--MapStruct-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<scope>compile</scope>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!--hutool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,28 @@
package cn.skcks.docking.gb28181.mocking.orm;
import cn.skcks.docking.gb28181.mocking.orm.mybatis.operation.MockingOperateTableMapper;
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.mocking.orm.mybatis.dynamic"),
@MapperScan("cn.skcks.docking.gb28181.mocking.orm.mybatis.operation"),
})
public class MockingOrmInitService {
private final MockingOperateTableMapper mapper;
@PostConstruct
public void init(){
log.info("[orm] 自动建表");
mapper.createDeviceTable();
}
}

View File

@ -1,5 +1,5 @@
server:
port: 28181
port: 18182
project:
version: @project.version@