From e337a9c08e85188660301aa54e27802bff350d31 Mon Sep 17 00:00:00 2001 From: luorijun Date: Wed, 26 Mar 2025 16:34:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=8A=82=E7=82=B9=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E5=87=BD=E6=95=B0=EF=BC=8C=E8=B0=83=E6=95=B4=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=95=B0=E6=8D=AE=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + cmd/main/main.go | 2 + docs/数据表结构.excalidraw | 772 +++++++++++++++++++++++-------------- pkg/orm/orm.go | 4 + pkg/remote/remote.go | 4 +- scripts/sql/init.sql | 16 +- web/models/node.gen.go | 5 +- web/queries/node.gen.go | 22 +- web/services/node.go | 61 ++- 9 files changed, 572 insertions(+), 316 deletions(-) diff --git a/README.md b/README.md index d1ef54e..8d5a1cc 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ - [ ] Limiter - [ ] Compress +考虑将鉴权逻辑放到 handler 里,统一动静态鉴权以及解耦服务层 + 有些地方在用手动事务,有时间改成自动事务 remote 用环境变量保存账号密码! diff --git a/cmd/main/main.go b/cmd/main/main.go index 8988691..bdd84bb 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -8,6 +8,7 @@ import ( "platform/pkg/logs" "platform/pkg/orm" "platform/pkg/rds" + "platform/pkg/remote" "platform/web" "syscall" ) @@ -23,6 +24,7 @@ func main() { logs.Init() orm.Init() rds.Init() + remote.Init() // web 服务 app, err := web.New(&web.Config{ diff --git a/docs/数据表结构.excalidraw b/docs/数据表结构.excalidraw index 78ba35e..098b64b 100644 --- a/docs/数据表结构.excalidraw +++ b/docs/数据表结构.excalidraw @@ -6,7 +6,7 @@ { "id": "sWVhyKNTaf6c4MTpx5iEK", "type": "rectangle", - "x": 1200, + "x": 1300, "y": 900, "width": 200, "height": 100, @@ -25,8 +25,8 @@ "type": 3 }, "seed": 1485411871, - "version": 186, - "versionNonce": 988130497, + "version": 192, + "versionNonce": 496678716, "isDeleted": false, "boundElements": [ { @@ -60,16 +60,20 @@ { "id": "vI7N6o6RZuvuZqC72CrG0", "type": "arrow" + }, + { + "id": "R_-u_XvFXVoOYZdQkVqEP", + "type": "arrow" } ], - "updated": 1742547819139, + "updated": 1742973068213, "link": null, "locked": false }, { "id": "QC5avpKjA0ubD5Uww0Z04", "type": "text", - "x": 1278, + "x": 1378, "y": 925, "width": 44, "height": 50, @@ -86,11 +90,11 @@ "index": "b17", "roundness": null, "seed": 2016096557, - "version": 129, - "versionNonce": 1606554369, + "version": 134, + "versionNonce": 897470852, "isDeleted": false, "boundElements": [], - "updated": 1742547653072, + "updated": 1742972920520, "link": null, "locked": false, "text": "用户\nuser", @@ -106,7 +110,7 @@ { "id": "6tM6EIcU9Lu7p7gOOmQwo", "type": "rectangle", - "x": 1200, + "x": 1300, "y": 1300, "width": 200, "height": 100, @@ -125,8 +129,8 @@ "type": 3 }, "seed": 724897029, - "version": 209, - "versionNonce": 885626127, + "version": 249, + "versionNonce": 779990020, "isDeleted": false, "boundElements": [ { @@ -141,10 +145,6 @@ "id": "YL-GQEx6_yX_IbTW-WC-i", "type": "arrow" }, - { - "id": "t9vgGJQkbyPaY_d19wdEf", - "type": "arrow" - }, { "id": "CZYYCHaD7DXcd4W6XNA--", "type": "arrow" @@ -170,14 +170,14 @@ "type": "arrow" } ], - "updated": 1742547823273, + "updated": 1742973023097, "link": null, "locked": false }, { "id": "VO1P5bEva1XiIHszRSHAb", "type": "text", - "x": 1270, + "x": 1370, "y": 1325, "width": 60, "height": 50, @@ -194,11 +194,11 @@ "index": "b17V", "roundness": null, "seed": 405926347, - "version": 172, - "versionNonce": 1442304929, + "version": 212, + "versionNonce": 674272132, "isDeleted": false, "boundElements": [], - "updated": 1742547783444, + "updated": 1742973023097, "link": null, "locked": false, "text": "管理员\nadmin", @@ -214,8 +214,8 @@ { "id": "h5j5btibJLrw6noInTqeP", "type": "rectangle", - "x": 500, - "y": 900, + "x": 1100, + "y": 1100, "width": 200, "height": 100, "angle": 0, @@ -233,8 +233,8 @@ "type": 3 }, "seed": 683797792, - "version": 408, - "versionNonce": 1712936143, + "version": 531, + "versionNonce": 1568318084, "isDeleted": false, "boundElements": [ { @@ -249,10 +249,6 @@ "id": "YL-GQEx6_yX_IbTW-WC-i", "type": "arrow" }, - { - "id": "t9vgGJQkbyPaY_d19wdEf", - "type": "arrow" - }, { "id": "CZYYCHaD7DXcd4W6XNA--", "type": "arrow" @@ -282,15 +278,15 @@ "type": "arrow" } ], - "updated": 1742547850508, + "updated": 1742973021611, "link": null, "locked": false }, { "id": "EST9AHZp3TyEeX246ziJX", "type": "text", - "x": 567, - "y": 925, + "x": 1167, + "y": 1125, "width": 66, "height": 50, "angle": 0, @@ -306,11 +302,11 @@ "index": "b17l", "roundness": null, "seed": 779547872, - "version": 395, - "versionNonce": 1288954607, + "version": 518, + "versionNonce": 1988866564, "isDeleted": false, "boundElements": [], - "updated": 1742547850508, + "updated": 1742973021611, "link": null, "locked": false, "text": "客户端\nclient", @@ -326,8 +322,8 @@ { "id": "U3ry809DLSs3z2kp6IH9m", "type": "rectangle", - "x": 1500, - "y": 1100, + "x": 1400, + "y": 600, "width": 200, "height": 100, "angle": 0, @@ -345,8 +341,8 @@ "type": 3 }, "seed": 1347385919, - "version": 399, - "versionNonce": 942170245, + "version": 439, + "versionNonce": 359920260, "isDeleted": false, "boundElements": [ { @@ -362,15 +358,15 @@ "type": "arrow" } ], - "updated": 1742174887162, + "updated": 1742973056793, "link": null, "locked": false }, { "id": "YtfjI3Ub26xOmra4IKz1o", "type": "text", - "x": 1550.5, - "y": 1125, + "x": 1450.5, + "y": 625, "width": 99, "height": 50, "angle": 0, @@ -386,11 +382,11 @@ "index": "b19", "roundness": null, "seed": 1525460899, - "version": 387, - "versionNonce": 204528527, + "version": 427, + "versionNonce": 47907332, "isDeleted": false, "boundElements": [], - "updated": 1742547659072, + "updated": 1742973056793, "link": null, "locked": false, "text": "白名单\nwhitelist", @@ -406,7 +402,7 @@ { "id": "02tdc6VRdsQxJlfDZOFSa", "type": "rectangle", - "x": 1500, + "x": 1700, "y": 900, "width": 200, "height": 100, @@ -425,8 +421,8 @@ "type": 3 }, "seed": 1317855935, - "version": 695, - "versionNonce": 128501221, + "version": 722, + "versionNonce": 27113660, "isDeleted": false, "boundElements": [ { @@ -448,16 +444,20 @@ { "id": "UFwaLWIsE6V1u0wBoIki2", "type": "arrow" + }, + { + "id": "T52SsxzLXkd_eJm6oq5m7", + "type": "arrow" } ], - "updated": 1742174885226, + "updated": 1742973093801, "link": null, "locked": false }, { "id": "thsyIU4pVZ0BNyjfcbiI2", "type": "text", - "x": 1561.5, + "x": 1761.5, "y": 925, "width": 77, "height": 50, @@ -474,11 +474,11 @@ "index": "b1H", "roundness": null, "seed": 158171427, - "version": 658, - "versionNonce": 254689793, + "version": 684, + "versionNonce": 1166596796, "isDeleted": false, "boundElements": [], - "updated": 1742547656056, + "updated": 1742973047427, "link": null, "locked": false, "text": "通道\nchannel", @@ -494,7 +494,7 @@ { "id": "-N71FG00rsWr4m7fJmQlh", "type": "rectangle", - "x": 1800, + "x": 2100, "y": 900, "width": 200, "height": 100, @@ -513,8 +513,8 @@ "type": 3 }, "seed": 232029951, - "version": 833, - "versionNonce": 1736773323, + "version": 861, + "versionNonce": 98739772, "isDeleted": false, "boundElements": [ { @@ -524,16 +524,20 @@ { "id": "CS9A3vJgDw6jBX1HSPB-Y", "type": "arrow" + }, + { + "id": "T52SsxzLXkd_eJm6oq5m7", + "type": "arrow" } ], - "updated": 1742174886146, + "updated": 1742973122089, "link": null, "locked": false }, { "id": "cKMWTO2RhuSj25E3cuaqQ", "type": "text", - "x": 1878, + "x": 2178, "y": 925, "width": 44, "height": 50, @@ -550,11 +554,11 @@ "index": "b1L", "roundness": null, "seed": 392732365, - "version": 815, - "versionNonce": 1183996687, + "version": 842, + "versionNonce": 1269464764, "isDeleted": false, "boundElements": [], - "updated": 1742547657496, + "updated": 1742973122089, "link": null, "locked": false, "text": "节点\nnode", @@ -570,7 +574,7 @@ { "id": "53l07ISb323iIFZb5LcXi", "type": "rectangle", - "x": 1500, + "x": 1700, "y": 600, "width": 200, "height": 100, @@ -589,8 +593,8 @@ "type": 3 }, "seed": 1913276191, - "version": 760, - "versionNonce": 922508933, + "version": 772, + "versionNonce": 1530224316, "isDeleted": false, "boundElements": [ { @@ -610,14 +614,14 @@ "type": "arrow" } ], - "updated": 1742174017442, + "updated": 1742973047427, "link": null, "locked": false }, { "id": "-m-bUxtn95FYB5WDm-3ZL", "type": "text", - "x": 1561.5, + "x": 1761.5, "y": 625, "width": 77, "height": 50, @@ -634,11 +638,11 @@ "index": "b1N", "roundness": null, "seed": 338615501, - "version": 816, - "versionNonce": 2001759457, + "version": 828, + "versionNonce": 1192372028, "isDeleted": false, "boundElements": [], - "updated": 1742547642752, + "updated": 1742973047427, "link": null, "locked": false, "text": "套餐\npackage", @@ -757,8 +761,8 @@ "type": 3 }, "seed": 1036798815, - "version": 684, - "versionNonce": 1363126540, + "version": 686, + "versionNonce": 1394767804, "isDeleted": false, "boundElements": [ { @@ -770,15 +774,15 @@ "type": "arrow" }, { - "id": "2PC9t5zZFGDGscVW0UDJj", + "id": "qFfFxWmqoOyrikrAZnpf6", "type": "arrow" }, { - "id": "qFfFxWmqoOyrikrAZnpf6", + "id": "2PC9t5zZFGDGscVW0UDJj", "type": "arrow" } ], - "updated": 1742290543715, + "updated": 1742973044310, "link": null, "locked": false }, @@ -802,11 +806,11 @@ "index": "b1R", "roundness": null, "seed": 1195160593, - "version": 705, - "versionNonce": 479957729, + "version": 707, + "versionNonce": 226277564, "isDeleted": false, "boundElements": [], - "updated": 1742547626824, + "updated": 1742973044310, "link": null, "locked": false, "text": "账单\nbill", @@ -822,7 +826,7 @@ { "id": "o0zljZV7sfR-BL9k3f94Z", "type": "rectangle", - "x": 1500, + "x": 1700, "y": 400, "width": 200, "height": 100, @@ -841,8 +845,8 @@ "type": 3 }, "seed": 2099894481, - "version": 737, - "versionNonce": 1348738383, + "version": 751, + "versionNonce": 1909893436, "isDeleted": false, "boundElements": [ { @@ -862,14 +866,14 @@ "type": "arrow" } ], - "updated": 1742547637469, + "updated": 1742973047427, "link": null, "locked": false }, { "id": "3dVMCq4yFNWbC1kdkfaPf", "type": "text", - "x": 1561.5, + "x": 1761.5, "y": 425, "width": 77, "height": 50, @@ -886,11 +890,11 @@ "index": "b1RV", "roundness": null, "seed": 630823103, - "version": 791, - "versionNonce": 598842223, + "version": 805, + "versionNonce": 1076240828, "isDeleted": false, "boundElements": [], - "updated": 1742547637469, + "updated": 1742973047427, "link": null, "locked": false, "text": "产品\nproduct", @@ -1005,8 +1009,8 @@ "type": 3 }, "seed": 209646527, - "version": 321, - "versionNonce": 240123531, + "version": 392, + "versionNonce": 4119428, "isDeleted": false, "boundElements": [ { @@ -1022,7 +1026,7 @@ "type": "arrow" } ], - "updated": 1742174882430, + "updated": 1742973015295, "link": null, "locked": false }, @@ -1046,11 +1050,11 @@ "index": "b1X", "roundness": null, "seed": 76718787, - "version": 303, - "versionNonce": 246680193, + "version": 374, + "versionNonce": 107006724, "isDeleted": false, "boundElements": [], - "updated": 1742547654536, + "updated": 1742973015295, "link": null, "locked": false, "text": "用户角色\nuser_role", @@ -1085,8 +1089,8 @@ "type": 3 }, "seed": 1873203493, - "version": 397, - "versionNonce": 1528157025, + "version": 495, + "versionNonce": 1037826748, "isDeleted": false, "boundElements": [ { @@ -1110,7 +1114,7 @@ "type": "arrow" } ], - "updated": 1742547785978, + "updated": 1742973025245, "link": null, "locked": false }, @@ -1134,11 +1138,11 @@ "index": "b1XV", "roundness": null, "seed": 1606811563, - "version": 404, - "versionNonce": 1587986241, + "version": 502, + "versionNonce": 1384465212, "isDeleted": false, "boundElements": [], - "updated": 1742547785978, + "updated": 1742973025245, "link": null, "locked": false, "text": "管理员角色\nadmin_role", @@ -1154,8 +1158,8 @@ { "id": "4ThQqzkM9HN9O8tBl9SsM", "type": "rectangle", - "x": 700, - "y": 1100, + "x": 500, + "y": 900, "width": 200, "height": 100, "angle": 0, @@ -1173,8 +1177,8 @@ "type": 3 }, "seed": 1795815455, - "version": 505, - "versionNonce": 1642908033, + "version": 527, + "versionNonce": 583863300, "isDeleted": false, "boundElements": [ { @@ -1198,15 +1202,15 @@ "type": "arrow" } ], - "updated": 1742547852808, + "updated": 1742972968646, "link": null, "locked": false }, { "id": "fLEdgF1aVywlo7aJh2mxw", "type": "text", - "x": 745, - "y": 1125, + "x": 545, + "y": 925, "width": 110, "height": 50, "angle": 0, @@ -1222,11 +1226,11 @@ "index": "b1d", "roundness": null, "seed": 126885251, - "version": 489, - "versionNonce": 2004480353, + "version": 511, + "versionNonce": 148171652, "isDeleted": false, "boundElements": [], - "updated": 1742547852808, + "updated": 1742972968646, "link": null, "locked": false, "text": "权限\npermission", @@ -1242,10 +1246,10 @@ { "id": "dBnEj97v4n07GNk5DIfL0", "type": "arrow", - "x": 1299.9999999980096, - "y": 899.5492546400992, - "width": 1.7673755792202428e-9, - "height": 399.0985092801986, + "x": 1389.9098509223218, + "y": 899.5492546400994, + "width": 79.81970190111679, + "height": 399.0985092801989, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1261,11 +1265,11 @@ "type": 2 }, "seed": 947100735, - "version": 1009, - "versionNonce": 297520268, + "version": 1046, + "versionNonce": 134718724, "isDeleted": false, "boundElements": [], - "updated": 1742290541388, + "updated": 1742972920834, "link": null, "locked": false, "points": [ @@ -1274,8 +1278,8 @@ 0 ], [ - 1.7673755792202428e-9, - -399.0985092801986 + -79.81970190111679, + -399.0985092801989 ] ], "lastCommittedPoint": null, @@ -1296,9 +1300,9 @@ { "id": "SZvrwxNELkT_FwX9do5gG", "type": "arrow", - "x": 1599.9999967373865, + "x": 1800.0011339028972, "y": 700.4507453599007, - "width": 0.00001294994103773206, + "width": 0.004475210371083449, "height": 199.09850928019864, "angle": 0, "strokeColor": "#1e1e1e", @@ -1315,11 +1319,11 @@ "type": 2 }, "seed": 445646015, - "version": 996, - "versionNonce": 180926245, + "version": 1136, + "versionNonce": 1038084996, "isDeleted": false, "boundElements": [], - "updated": 1742174885393, + "updated": 1742973047879, "link": null, "locked": false, "points": [ @@ -1328,19 +1332,19 @@ 0 ], [ - -0.00001294994103773206, + 0.004475210371083449, 199.09850928019864 ] ], "lastCommittedPoint": null, "startBinding": { "elementId": "53l07ISb323iIFZb5LcXi", - "focus": 0, + "focus": 9.704790500113347e-10, "gap": 1 }, "endBinding": { "elementId": "02tdc6VRdsQxJlfDZOFSa", - "focus": 0, + "focus": 0.00006743037432033816, "gap": 1 }, "startArrowhead": null, @@ -1350,10 +1354,10 @@ { "id": "CZYYCHaD7DXcd4W6XNA--", "type": "arrow", - "x": 1406.07492398138, - "y": 950.360013516292, - "width": 87.8501520372406, - "height": 1.7817679327238238, + "x": 1506.0749239813804, + "y": 949.8240300990922, + "width": 187.8501520372406, + "height": 2.828929287308597, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1369,11 +1373,11 @@ "type": 2 }, "seed": 1892619487, - "version": 755, - "versionNonce": 1896665612, + "version": 883, + "versionNonce": 1465827644, "isDeleted": false, "boundElements": [], - "updated": 1742290534477, + "updated": 1742973047693, "link": null, "locked": false, "points": [ @@ -1382,8 +1386,8 @@ 0 ], [ - 87.8501520372406, - 1.7817679327238238 + 187.8501520372406, + 2.828929287308597 ] ], "lastCommittedPoint": null, @@ -1404,10 +1408,10 @@ { "id": "CS9A3vJgDw6jBX1HSPB-Y", "type": "arrow", - "x": 1799.1073474245104, - "y": 949.7125996559935, - "width": 98.21469484902082, - "height": 0.1952007666282043, + "x": 2099.1073474245104, + "y": 949.7653075603193, + "width": 198.21469484902082, + "height": 0.2903744372918027, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1423,11 +1427,11 @@ "type": 2 }, "seed": 687284479, - "version": 1334, - "versionNonce": 1486529131, + "version": 1532, + "versionNonce": 1376636220, "isDeleted": false, "boundElements": [], - "updated": 1742174886326, + "updated": 1742973122207, "link": null, "locked": false, "points": [ @@ -1436,19 +1440,19 @@ 0 ], [ - -98.21469484902082, - -0.1952007666282043 + -198.21469484902082, + -0.2903744372918027 ] ], "lastCommittedPoint": null, "startBinding": { "elementId": "-N71FG00rsWr4m7fJmQlh", - "focus": 0.0017318665472098472, + "focus": 0.0017318985041347335, "gap": 1 }, "endBinding": { "elementId": "02tdc6VRdsQxJlfDZOFSa", - "focus": -0.013608399145615294, + "focus": -0.013608399145827664, "gap": 1 }, "startArrowhead": "crowfoot_one", @@ -1458,10 +1462,10 @@ { "id": "0mjZSajWpy3Yilllikfkw", "type": "arrow", - "x": 1376.503084564913, - "y": 1001.7893826024881, - "width": 148.15785181545561, - "height": 96.67020783035014, + "x": 1418.3613088897357, + "y": 898.2106173975121, + "width": 62.786640350708694, + "height": 196.67020783035014, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1477,11 +1481,11 @@ "type": 2 }, "seed": 344500511, - "version": 812, - "versionNonce": 507424908, + "version": 1022, + "versionNonce": 707084164, "isDeleted": false, "boundElements": [], - "updated": 1742290534477, + "updated": 1742973056826, "link": null, "locked": false, "points": [ @@ -1490,8 +1494,8 @@ 0 ], [ - 148.15785181545561, - 96.67020783035014 + 62.786640350708694, + -196.67020783035014 ] ], "lastCommittedPoint": null, @@ -1512,10 +1516,10 @@ { "id": "X14BlJ5OoZr9srJ2jqOq0", "type": "arrow", - "x": 1193.9250760186205, - "y": 949.848464935628, - "width": 88.49772369630364, - "height": 2.5791852502960637, + "x": 1293.9250760186208, + "y": 949.0170961903538, + "width": 188.49772369630386, + "height": 3.92572155983612, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1531,11 +1535,11 @@ "type": 2 }, "seed": 16002367, - "version": 718, - "versionNonce": 917552908, + "version": 978, + "versionNonce": 986191748, "isDeleted": false, "boundElements": [], - "updated": 1742290534478, + "updated": 1742973015345, "link": null, "locked": false, "points": [ @@ -1544,8 +1548,8 @@ 0 ], [ - -88.49772369630364, - 2.5791852502960637 + -188.49772369630386, + 3.92572155983612 ] ], "lastCommittedPoint": null, @@ -1566,10 +1570,10 @@ { "id": "bYVMpDpG7ITLMefjWqJ3H", "type": "arrow", - "x": 949.5484070730799, - "y": 1000.4507453599007, - "width": 99.09795091921103, - "height": 99.09850928019853, + "x": 899.1073474245105, + "y": 949.8061010423091, + "width": 198.21469484902093, + "height": 0.12848360698376382, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1585,11 +1589,11 @@ "type": 2 }, "seed": 966405471, - "version": 1302, - "versionNonce": 676649281, + "version": 1581, + "versionNonce": 342001412, "isDeleted": false, "boundElements": [], - "updated": 1742547853207, + "updated": 1742973015345, "link": null, "locked": false, "points": [ @@ -1598,8 +1602,8 @@ 0 ], [ - -99.09795091921103, - 99.09850928019853 + -198.21469484902093, + 0.12848360698376382 ] ], "lastCommittedPoint": null, @@ -1620,10 +1624,10 @@ { "id": "YL-GQEx6_yX_IbTW-WC-i", "type": "arrow", - "x": 1387.4916965952257, - "y": 894.5241995657749, - "width": 135.34951954950702, - "height": 189.58704596901066, + "x": 1503.5248675113753, + "y": 900.4475792746846, + "width": 200.48781294874243, + "height": 197.43789177088695, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1639,11 +1643,11 @@ "type": 2 }, "seed": 2127012255, - "version": 727, - "versionNonce": 526459788, + "version": 806, + "versionNonce": 1263696828, "isDeleted": false, "boundElements": [], - "updated": 1742290534476, + "updated": 1742973047693, "link": null, "locked": false, "points": [ @@ -1652,8 +1656,8 @@ 0 ], [ - 135.34951954950702, - -189.58704596901066 + 200.48781294874243, + -197.43789177088695 ] ], "lastCommittedPoint": null, @@ -1674,10 +1678,10 @@ { "id": "UFwaLWIsE6V1u0wBoIki2", "type": "arrow", - "x": 1599.9991233067074, - "y": 1099.5492546400994, - "width": 0.0017209111779266095, - "height": 99.09850928019887, + "x": 1550.476799787434, + "y": 700.4507453599007, + "width": 199.2013303179067, + "height": 199.09850928019864, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1693,11 +1697,11 @@ "type": 2 }, "seed": 700454335, - "version": 1081, - "versionNonce": 219276069, + "version": 1345, + "versionNonce": 1843048196, "isDeleted": false, "boundElements": [], - "updated": 1742174887260, + "updated": 1742973056826, "link": null, "locked": false, "points": [ @@ -1706,8 +1710,8 @@ 0 ], [ - -0.0017209111779266095, - -99.09850928019887 + 199.2013303179067, + 199.09850928019864 ] ], "lastCommittedPoint": null, @@ -1801,11 +1805,11 @@ "type": 2 }, "seed": 557170239, - "version": 499, - "versionNonce": 811557044, + "version": 500, + "versionNonce": 1905164420, "isDeleted": false, "boundElements": [], - "updated": 1742290543717, + "updated": 1742973044311, "link": null, "locked": false, "points": [ @@ -1836,10 +1840,10 @@ { "id": "2PC9t5zZFGDGscVW0UDJj", "type": "arrow", - "x": 1524.5140286417316, - "y": 399.5492546400994, - "width": 148.77376423193277, - "height": 99.09850928019875, + "x": 1701.8456755735172, + "y": 410.7396882130385, + "width": 303.6920798401809, + "height": 121.47790349571136, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1855,11 +1859,11 @@ "type": 2 }, "seed": 2104703519, - "version": 338, - "versionNonce": 198966383, + "version": 400, + "versionNonce": 1675412796, "isDeleted": false, "boundElements": [], - "updated": 1742547637519, + "updated": 1742973047693, "link": null, "locked": false, "points": [ @@ -1868,8 +1872,8 @@ 0 ], [ - -148.77376423193277, - -99.09850928019875 + -303.6920798401809, + -121.47790349571136 ] ], "lastCommittedPoint": null, @@ -1890,10 +1894,10 @@ { "id": "odssVsu1VEaRNn0teEV6c", "type": "arrow", - "x": 1600.1911859049937, - "y": 500.45074535990057, - "width": 0.12668899335676542, - "height": 99.09850928019864, + "x": 1800.0195312241156, + "y": 500.4507453599006, + "width": 0.04496446972530066, + "height": 99.0985092801987, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1909,11 +1913,11 @@ "type": 2 }, "seed": 350907519, - "version": 101, - "versionNonce": 1049009743, + "version": 196, + "versionNonce": 1998326148, "isDeleted": false, "boundElements": [], - "updated": 1742547637519, + "updated": 1742973047880, "link": null, "locked": false, "points": [ @@ -1922,19 +1926,19 @@ 0 ], [ - -0.12668899335676542, - 99.09850928019864 + 0.04496446972530066, + 99.0985092801987 ] ], "lastCommittedPoint": null, "startBinding": { "elementId": "o0zljZV7sfR-BL9k3f94Z", - "focus": 0, + "focus": 0.000033592865949458434, "gap": 1 }, "endBinding": { "elementId": "53l07ISb323iIFZb5LcXi", - "focus": 0, + "focus": 0.0008736714589508666, "gap": 1 }, "startArrowhead": null, @@ -1944,10 +1948,10 @@ { "id": "PgEvRszvDjVUltON9B_ah", "type": "arrow", - "x": 949.5484070730797, - "y": 1299.5492546400992, - "width": 99.09795091921092, - "height": 99.09850928019841, + "x": 949.5492545095091, + "y": 1299.5492546400994, + "width": 299.09850916845664, + "height": 299.09850928019887, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -1963,11 +1967,11 @@ "type": 2 }, "seed": 50455717, - "version": 326, - "versionNonce": 499779873, + "version": 673, + "versionNonce": 334218428, "isDeleted": false, "boundElements": [], - "updated": 1742547853207, + "updated": 1742973025461, "link": null, "locked": false, "points": [ @@ -1976,8 +1980,8 @@ 0 ], [ - -99.09795091921092, - -99.09850928019841 + -299.09850916845664, + -299.09850928019887 ] ], "lastCommittedPoint": null, @@ -1998,10 +2002,10 @@ { "id": "vZgnKG8BBOWQG2tFtJ1LQ", "type": "arrow", - "x": 1199.1073474245104, - "y": 1351.6037029870622, - "width": 98.21469484902082, - "height": 1.7490579025375155, + "x": 1299.1073474245104, + "y": 1350.0000916259128, + "width": 198.21469484902082, + "height": 0.00017997906616074033, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2017,11 +2021,11 @@ "type": 2 }, "seed": 468722923, - "version": 224, - "versionNonce": 348165825, + "version": 641, + "versionNonce": 671862076, "isDeleted": false, "boundElements": [], - "updated": 1742547785995, + "updated": 1742973025462, "link": null, "locked": false, "points": [ @@ -2030,8 +2034,8 @@ 0 ], [ - -98.21469484902082, - 1.7490579025375155 + -198.21469484902082, + 0.00017997906616074033 ] ], "lastCommittedPoint": null, @@ -2052,7 +2056,7 @@ { "id": "k8yWnHxYqT8tFxjwpm1CE", "type": "arrow", - "x": 1300.0000000000002, + "x": 1400, "y": 1299.5492546400994, "width": 0, "height": 299.09850928019875, @@ -2071,11 +2075,11 @@ "type": 2 }, "seed": 483548805, - "version": 60, - "versionNonce": 1049358753, + "version": 223, + "versionNonce": 828631044, "isDeleted": false, "boundElements": [], - "updated": 1742547783561, + "updated": 1742973023316, "link": null, "locked": false, "points": [ @@ -2106,10 +2110,10 @@ { "id": "waO6Ar3IuQFLgZC7RgVw8", "type": "arrow", - "x": 650.4498977928811, - "y": 1000.4507453599006, - "width": 99.09906764118648, - "height": 99.09850928019887, + "x": 1099.856023842517, + "y": 1116.6453220989154, + "width": 399.7183020631786, + "height": 133.2608321692012, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2125,11 +2129,11 @@ "type": 2 }, "seed": 775373088, - "version": 518, - "versionNonce": 818822401, + "version": 907, + "versionNonce": 1519181444, "isDeleted": false, "boundElements": [], - "updated": 1742547853207, + "updated": 1742973021661, "link": null, "locked": false, "points": [ @@ -2138,8 +2142,8 @@ 0 ], [ - 99.09906764118648, - 99.09850928019887 + -399.7183020631786, + -133.2608321692012 ] ], "lastCommittedPoint": null, @@ -2160,7 +2164,7 @@ { "id": "mKaBRuEfi2IsHiKLhkmSo", "type": "rectangle", - "x": 1000, + "x": 500, "y": 1100, "width": 200, "height": 100, @@ -2179,8 +2183,8 @@ "type": 3 }, "seed": 1599772691, - "version": 369, - "versionNonce": 694500559, + "version": 428, + "versionNonce": 2131959044, "isDeleted": false, "boundElements": [ { @@ -2204,14 +2208,14 @@ "type": "arrow" } ], - "updated": 1742547823272, + "updated": 1742973030961, "link": null, "locked": false }, { "id": "Mo8NPgGcHKL4d4B1GxZ5n", "type": "text", - "x": 1061.5, + "x": 561.5, "y": 1125, "width": 77, "height": 50, @@ -2228,11 +2232,11 @@ "index": "b2A", "roundness": null, "seed": 387194291, - "version": 382, - "versionNonce": 661916513, + "version": 441, + "versionNonce": 1949359236, "isDeleted": false, "boundElements": [], - "updated": 1742547810327, + "updated": 1742973030961, "link": null, "locked": false, "text": "会话\nsession", @@ -2248,10 +2252,10 @@ { "id": "42AGZYgRgHI8zEbq5zbGL", "type": "arrow", - "x": 698.1537868311694, - "y": 989.2613984736022, - "width": 303.6928037196185, - "height": 121.47644031411915, + "x": 1099.1073474245106, + "y": 1150, + "width": 398.21469484902116, + "height": 0, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2267,11 +2271,11 @@ "type": 2 }, "seed": 1515488609, - "version": 425, - "versionNonce": 728548527, + "version": 958, + "versionNonce": 1066411012, "isDeleted": false, - "boundElements": null, - "updated": 1742547850757, + "boundElements": [], + "updated": 1742973031094, "link": null, "locked": false, "points": [ @@ -2280,8 +2284,8 @@ 0 ], [ - 303.6928037196185, - 121.47644031411915 + -398.21469484902116, + 0 ] ], "lastCommittedPoint": null, @@ -2302,10 +2306,10 @@ { "id": "RiId3-0t2GKp-zIkPXpSv", "type": "arrow", - "x": 900.8926525754894, - "y": 1150.0000000000045, - "width": 98.21469484902116, - "height": 2.7284841053187847e-12, + "x": 599.9355030420988, + "y": 1000.4507453599006, + "width": 0.042738782193509905, + "height": 99.09850928019887, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2321,11 +2325,11 @@ "type": 2 }, "seed": 744247489, - "version": 191, - "versionNonce": 1625355489, + "version": 447, + "versionNonce": 1299514244, "isDeleted": false, - "boundElements": null, - "updated": 1742547853208, + "boundElements": [], + "updated": 1742973031094, "link": null, "locked": false, "points": [ @@ -2334,8 +2338,8 @@ 0 ], [ - 98.21469484902116, - -2.7284841053187847e-12 + 0.042738782193509905, + 99.09850928019887 ] ], "lastCommittedPoint": null, @@ -2356,10 +2360,10 @@ { "id": "vI7N6o6RZuvuZqC72CrG0", "type": "arrow", - "x": 1160, - "y": 1100, - "width": 80, - "height": 100, + "x": 700.8926525754895, + "y": 1133.0853546217795, + "width": 598.2146948490207, + "height": 166.17088438484848, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2375,11 +2379,11 @@ "type": 2 }, "seed": 431825377, - "version": 19, - "versionNonce": 271078927, + "version": 256, + "versionNonce": 445772548, "isDeleted": false, - "boundElements": null, - "updated": 1742547827591, + "boundElements": [], + "updated": 1742973031095, "link": null, "locked": false, "points": [ @@ -2388,8 +2392,8 @@ 0 ], [ - 80, - -100 + 598.2146948490207, + -166.17088438484848 ] ], "lastCommittedPoint": null, @@ -2410,10 +2414,10 @@ { "id": "ZGl1k8DptaKTTqI5hm8V3", "type": "arrow", - "x": 1160, - "y": 1200, - "width": 60, - "height": 100, + "x": 700.8926525754895, + "y": 1162.77896093584, + "width": 598.2146948490209, + "height": 186.94214599950806, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", @@ -2429,11 +2433,11 @@ "type": 2 }, "seed": 1423978625, - "version": 12, - "versionNonce": 241355503, + "version": 338, + "versionNonce": 627372676, "isDeleted": false, - "boundElements": null, - "updated": 1742547823273, + "boundElements": [], + "updated": 1742973031095, "link": null, "locked": false, "points": [ @@ -2442,8 +2446,8 @@ 0 ], [ - 60, - 100 + 598.2146948490209, + 186.94214599950806 ] ], "lastCommittedPoint": null, @@ -2460,6 +2464,194 @@ "startArrowhead": "crowfoot_many", "endArrowhead": "crowfoot_many", "elbowed": false + }, + { + "id": "P5uYFnh0fSXvOjdD6id2Z", + "type": "rectangle", + "x": 1700, + "y": 1100, + "width": 200, + "height": 100, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "groupIds": [], + "frameId": null, + "index": "b2F", + "roundness": { + "type": 3 + }, + "seed": 1923867452, + "version": 59, + "versionNonce": 491897220, + "isDeleted": false, + "boundElements": [ + { + "type": "text", + "id": "Oj556Bsm2Nn-HR-S3tRl2" + }, + { + "id": "R_-u_XvFXVoOYZdQkVqEP", + "type": "arrow" + }, + { + "id": "T52SsxzLXkd_eJm6oq5m7", + "type": "arrow" + } + ], + "updated": 1742973114524, + "link": null, + "locked": false + }, + { + "id": "Oj556Bsm2Nn-HR-S3tRl2", + "type": "text", + "x": 1767, + "y": 1125, + "width": 66, + "height": 50, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "groupIds": [], + "frameId": null, + "index": "b2G", + "roundness": null, + "seed": 220752260, + "version": 71, + "versionNonce": 1899879740, + "isDeleted": false, + "boundElements": null, + "updated": 1742973149462, + "link": null, + "locked": false, + "text": "分配\nassign", + "fontSize": 20, + "fontFamily": 8, + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "P5uYFnh0fSXvOjdD6id2Z", + "originalText": "分配\nassign", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "id": "R_-u_XvFXVoOYZdQkVqEP", + "type": "arrow", + "x": 1500.8926525754896, + "y": 973.3353179908356, + "width": 201.09954604136533, + "height": 137.1139381444691, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "groupIds": [], + "frameId": null, + "index": "b2H", + "roundness": { + "type": 2 + }, + "seed": 1509277188, + "version": 74, + "versionNonce": 1128401540, + "isDeleted": false, + "boundElements": null, + "updated": 1742973114690, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + 201.09954604136533, + 137.1139381444691 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "sWVhyKNTaf6c4MTpx5iEK", + "focus": -0.38461538461538525, + "gap": 1 + }, + "endBinding": { + "elementId": "P5uYFnh0fSXvOjdD6id2Z", + "focus": -0.23076923076923048, + "gap": 1 + }, + "startArrowhead": "crowfoot_one", + "endArrowhead": "crowfoot_many", + "elbowed": false + }, + { + "id": "T52SsxzLXkd_eJm6oq5m7", + "type": "arrow", + "x": 1899.1992946011076, + "y": 1113.2297037375934, + "width": 200.80070539889243, + "height": 133.22970373759335, + "angle": 0, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "groupIds": [], + "frameId": null, + "index": "b2I", + "roundness": { + "type": 2 + }, + "seed": 2030181436, + "version": 152, + "versionNonce": 257905468, + "isDeleted": false, + "boundElements": null, + "updated": 1742973125284, + "link": null, + "locked": false, + "points": [ + [ + 0, + 0 + ], + [ + 200.80070539889243, + -133.22970373759335 + ] + ], + "lastCommittedPoint": null, + "startBinding": { + "elementId": "P5uYFnh0fSXvOjdD6id2Z", + "focus": 0.24965928153333428, + "gap": 1 + }, + "endBinding": { + "elementId": "-N71FG00rsWr4m7fJmQlh", + "focus": 0.31241482038333335, + "gap": 1 + }, + "startArrowhead": "crowfoot_many", + "endArrowhead": "crowfoot_one", + "elbowed": false } ], "appState": { diff --git a/pkg/orm/orm.go b/pkg/orm/orm.go index df6175a..ccdd8fc 100644 --- a/pkg/orm/orm.go +++ b/pkg/orm/orm.go @@ -11,6 +11,8 @@ import ( ) import "gorm.io/driver/postgres" +var DB *gorm.DB + func Init() { // 连接数据库 @@ -39,4 +41,6 @@ func Init() { // 初始化查询工具 queries.SetDefault(db) + + DB = db } diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 9d57881..2b32db0 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -18,7 +18,7 @@ type client struct { var Client client -func Init() error { +func Init() { // todo 从环境变量中获取参数 Client = client{ gatewayUrl: "http://110.40.82.248:9990", @@ -26,8 +26,6 @@ func Init() error { password: "123456", cloudUrl: "http://103.139.212.110", } - - return nil } type PortConfig struct { diff --git a/scripts/sql/init.sql b/scripts/sql/init.sql index a527ba1..e5ee514 100644 --- a/scripts/sql/init.sql +++ b/scripts/sql/init.sql @@ -387,14 +387,17 @@ create table node ( name varchar(255) not null unique, version int not null, fwd_port int not null, - provider varchar(255) not null, - location varchar(255) not null, + isp varchar(255) not null, + prov varchar(255) not null, + city varchar(255) not null, + created_at timestamp default current_timestamp, updated_at timestamp default current_timestamp, deleted_at timestamp ); -create index node_provider_index on node (provider); -create index node_location_index on node (location); +create index node_isp_index on node (isp); +create index node_prov_index on node (prov); +create index node_city_index on node (city); -- node表字段注释 comment on table node is '节点表'; @@ -402,8 +405,9 @@ comment on column node.id is '节点ID'; comment on column node.name is '节点名称'; comment on column node.version is '节点版本'; comment on column node.fwd_port is '转发端口'; -comment on column node.provider is '运营商'; -comment on column node.location is '位置'; +comment on column node.isp is '运营商'; +comment on column node.prov is '省份'; +comment on column node.city is '城市'; comment on column node.created_at is '创建时间'; comment on column node.updated_at is '更新时间'; comment on column node.deleted_at is '删除时间'; diff --git a/web/models/node.gen.go b/web/models/node.gen.go index 65b4d16..c075ba4 100644 --- a/web/models/node.gen.go +++ b/web/models/node.gen.go @@ -18,8 +18,9 @@ type Node struct { Name string `gorm:"column:name;not null;comment:节点名称" json:"name"` // 节点名称 Version int32 `gorm:"column:version;not null;comment:节点版本" json:"version"` // 节点版本 FwdPort int32 `gorm:"column:fwd_port;not null;comment:转发端口" json:"fwd_port"` // 转发端口 - Provider string `gorm:"column:provider;not null;comment:运营商" json:"provider"` // 运营商 - Location string `gorm:"column:location;not null;comment:位置" json:"location"` // 位置 + Isp string `gorm:"column:isp;not null;comment:运营商" json:"isp"` // 运营商 + Prov string `gorm:"column:prov;not null;comment:省份" json:"prov"` // 省份 + City string `gorm:"column:city;not null;comment:城市" json:"city"` // 城市 CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间 UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP;comment:更新时间" json:"updated_at"` // 更新时间 DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:删除时间" json:"deleted_at"` // 删除时间 diff --git a/web/queries/node.gen.go b/web/queries/node.gen.go index 1dfdda2..23f7e00 100644 --- a/web/queries/node.gen.go +++ b/web/queries/node.gen.go @@ -31,8 +31,9 @@ func newNode(db *gorm.DB, opts ...gen.DOOption) node { _node.Name = field.NewString(tableName, "name") _node.Version = field.NewInt32(tableName, "version") _node.FwdPort = field.NewInt32(tableName, "fwd_port") - _node.Provider = field.NewString(tableName, "provider") - _node.Location = field.NewString(tableName, "location") + _node.Isp = field.NewString(tableName, "isp") + _node.Prov = field.NewString(tableName, "prov") + _node.City = field.NewString(tableName, "city") _node.CreatedAt = field.NewTime(tableName, "created_at") _node.UpdatedAt = field.NewTime(tableName, "updated_at") _node.DeletedAt = field.NewField(tableName, "deleted_at") @@ -50,8 +51,9 @@ type node struct { Name field.String // 节点名称 Version field.Int32 // 节点版本 FwdPort field.Int32 // 转发端口 - Provider field.String // 运营商 - Location field.String // 位置 + Isp field.String // 运营商 + Prov field.String // 省份 + City field.String // 城市 CreatedAt field.Time // 创建时间 UpdatedAt field.Time // 更新时间 DeletedAt field.Field // 删除时间 @@ -75,8 +77,9 @@ func (n *node) updateTableName(table string) *node { n.Name = field.NewString(table, "name") n.Version = field.NewInt32(table, "version") n.FwdPort = field.NewInt32(table, "fwd_port") - n.Provider = field.NewString(table, "provider") - n.Location = field.NewString(table, "location") + n.Isp = field.NewString(table, "isp") + n.Prov = field.NewString(table, "prov") + n.City = field.NewString(table, "city") n.CreatedAt = field.NewTime(table, "created_at") n.UpdatedAt = field.NewTime(table, "updated_at") n.DeletedAt = field.NewField(table, "deleted_at") @@ -96,13 +99,14 @@ func (n *node) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (n *node) fillFieldMap() { - n.fieldMap = make(map[string]field.Expr, 9) + n.fieldMap = make(map[string]field.Expr, 10) n.fieldMap["id"] = n.ID n.fieldMap["name"] = n.Name n.fieldMap["version"] = n.Version n.fieldMap["fwd_port"] = n.FwdPort - n.fieldMap["provider"] = n.Provider - n.fieldMap["location"] = n.Location + n.fieldMap["isp"] = n.Isp + n.fieldMap["prov"] = n.Prov + n.fieldMap["city"] = n.City n.fieldMap["created_at"] = n.CreatedAt n.fieldMap["updated_at"] = n.UpdatedAt n.fieldMap["deleted_at"] = n.DeletedAt diff --git a/web/services/node.go b/web/services/node.go index ca2ddb8..b8279fa 100644 --- a/web/services/node.go +++ b/web/services/node.go @@ -1,18 +1,67 @@ package services -import "platform/web/models" +import ( + "encoding/json" + "fmt" + "platform/pkg/orm" +) var Node = &nodeService{} type nodeService struct{} -func (s *nodeService) Filter(userId int32, proto ChannelProtocol, count int, config ...NodeFilterConfig) ([]*models.Node, error) { +func (s *nodeService) Filter(userId int32, count int, config ...NodeFilterConfig) ([]*FilteredNode, error) { + _config := NodeFilterConfig{} + if len(config) > 0 { + _config = config[0] + } - return make([]*models.Node, 0), nil + // 筛选符合条件且未分配给用户过的节点 + // 静态条件:省,市,运营商 + // 排序方式,1.分配给该用户的次数 2.分配给全部用户的次数 3.todo 节点的健康状态 + var nodes []*FilteredNode + orm.DB.Raw(filterSqlRaw, userId, _config.Isp, _config.Prov, _config.City). + Limit(count). + Find(&nodes) + + rs, _ := json.Marshal(nodes) + fmt.Printf(string(rs)) + + // 返回节点列表 + return nodes, nil } type NodeFilterConfig struct { - province string - city string - provider string + Isp string + Prov string + City string +} + +const filterSqlRaw = ` +select + n.id as id, + n.name as name, + n.fwd_port as port, + count(c.*) as total, + count(c.*) filter ( where c.user_id = ? ) as assigned +from + node n + left join public.channel c + on n.id = c.node_id and c.expiration > now() and c.deleted_at is null +where + n.isp = ? and + n.prov = ? and + n.city = ? +group by + n.id +order by + assigned, total +` + +type FilteredNode struct { + Id int32 `json:"id"` + Name string `json:"name"` + Port int32 `json:"port"` + Total int32 `json:"total"` + Assigned int32 `json:"assigned"` }