mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-07 02:06:38 +08:00
feat: add inx ordering for tunnel and node
This commit is contained in:
@@ -15,6 +15,12 @@ public class TunnelDetailDto {
|
|||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display/order index for drag-sorting in admin UI.
|
||||||
|
* Lower value appears first.
|
||||||
|
*/
|
||||||
|
private Integer inx;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Integer type; // 1: 端口转发, 2: 隧道转发
|
private Integer type; // 1: 端口转发, 2: 隧道转发
|
||||||
@@ -40,4 +46,3 @@ public class TunnelDetailDto {
|
|||||||
// 出口节点列表
|
// 出口节点列表
|
||||||
private List<ChainTunnel> outNodeId = new ArrayList<>();
|
private List<ChainTunnel> outNodeId = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
package com.admin.common.migration;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lightweight SQLite schema migration.
|
||||||
|
*
|
||||||
|
* Spring Boot SQL init uses CREATE TABLE IF NOT EXISTS, so existing installations
|
||||||
|
* won't automatically receive new columns. This runner adds missing columns in-place.
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||||
|
public class SqliteSchemaMigration implements ApplicationRunner {
|
||||||
|
|
||||||
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
public SqliteSchemaMigration(JdbcTemplate jdbcTemplate) {
|
||||||
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
ensureColumn("node", "inx", "INTEGER NOT NULL DEFAULT 0");
|
||||||
|
ensureColumn("tunnel", "inx", "INTEGER NOT NULL DEFAULT 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureColumn(String table, String column, String columnDefinition) {
|
||||||
|
Set<String> columns = new HashSet<>(
|
||||||
|
jdbcTemplate.query(
|
||||||
|
"PRAGMA table_info(" + table + ")",
|
||||||
|
(rs, rowNum) -> rs.getString("name")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (columns.contains(column)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Adding missing column {}.{}", table, column);
|
||||||
|
jdbcTemplate.execute(
|
||||||
|
"ALTER TABLE " + table + " ADD COLUMN " + column + " " + columnDefinition
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,4 +40,10 @@ public class Node extends BaseEntity {
|
|||||||
|
|
||||||
private String udpListenAddr;
|
private String udpListenAddr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display/order index for drag-sorting in admin UI.
|
||||||
|
* Lower value appears first.
|
||||||
|
*/
|
||||||
|
private Integer inx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,10 @@ public class Tunnel extends BaseEntity {
|
|||||||
private BigDecimal trafficRatio;
|
private BigDecimal trafficRatio;
|
||||||
|
|
||||||
private String inIp;
|
private String inIp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display/order index for drag-sorting in admin UI.
|
||||||
|
* Lower value appears first.
|
||||||
|
*/
|
||||||
|
private Integer inx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ CREATE TABLE IF NOT EXISTS node (
|
|||||||
updated_time INTEGER,
|
updated_time INTEGER,
|
||||||
status INTEGER NOT NULL,
|
status INTEGER NOT NULL,
|
||||||
tcp_listen_addr VARCHAR(100) NOT NULL DEFAULT '[::]',
|
tcp_listen_addr VARCHAR(100) NOT NULL DEFAULT '[::]',
|
||||||
udp_listen_addr VARCHAR(100) NOT NULL DEFAULT '[::]'
|
udp_listen_addr VARCHAR(100) NOT NULL DEFAULT '[::]',
|
||||||
|
inx INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS speed_limit (
|
CREATE TABLE IF NOT EXISTS speed_limit (
|
||||||
@@ -72,7 +73,8 @@ CREATE TABLE IF NOT EXISTS tunnel (
|
|||||||
created_time INTEGER NOT NULL,
|
created_time INTEGER NOT NULL,
|
||||||
updated_time INTEGER NOT NULL,
|
updated_time INTEGER NOT NULL,
|
||||||
status INTEGER NOT NULL,
|
status INTEGER NOT NULL,
|
||||||
in_ip TEXT
|
in_ip TEXT,
|
||||||
|
inx INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS chain_tunnel (
|
CREATE TABLE IF NOT EXISTS chain_tunnel (
|
||||||
@@ -123,4 +125,3 @@ CREATE TABLE IF NOT EXISTS vite_config (
|
|||||||
value VARCHAR(200) NOT NULL,
|
value VARCHAR(200) NOT NULL,
|
||||||
time INTEGER NOT NULL
|
time INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user