Browse Source

fix group peers

ljw 1 year ago
parent
commit
a1d495f2db

+ 22 - 22
docs/admin/admin_docs.go

@@ -1185,7 +1185,7 @@ const docTemplateadmin = `{
1185
                         "token": []
1185
                         "token": []
1186
                     }
1186
                     }
1187
                 ],
1187
                 ],
1188
-                "description": "创建机器",
1188
+                "description": "创建设备",
1189
                 "consumes": [
1189
                 "consumes": [
1190
                     "application/json"
1190
                     "application/json"
1191
                 ],
1191
                 ],
@@ -1193,12 +1193,12 @@ const docTemplateadmin = `{
1193
                     "application/json"
1193
                     "application/json"
1194
                 ],
1194
                 ],
1195
                 "tags": [
1195
                 "tags": [
1196
-                    "机器"
1196
+                    "设备"
1197
                 ],
1197
                 ],
1198
-                "summary": "创建机器",
1198
+                "summary": "创建设备",
1199
                 "parameters": [
1199
                 "parameters": [
1200
                     {
1200
                     {
1201
-                        "description": "机器信息",
1201
+                        "description": "设备信息",
1202
                         "name": "body",
1202
                         "name": "body",
1203
                         "in": "body",
1203
                         "in": "body",
1204
                         "required": true,
1204
                         "required": true,
@@ -1242,7 +1242,7 @@ const docTemplateadmin = `{
1242
                         "token": []
1242
                         "token": []
1243
                     }
1243
                     }
1244
                 ],
1244
                 ],
1245
-                "description": "机器删除",
1245
+                "description": "设备删除",
1246
                 "consumes": [
1246
                 "consumes": [
1247
                     "application/json"
1247
                     "application/json"
1248
                 ],
1248
                 ],
@@ -1250,12 +1250,12 @@ const docTemplateadmin = `{
1250
                     "application/json"
1250
                     "application/json"
1251
                 ],
1251
                 ],
1252
                 "tags": [
1252
                 "tags": [
1253
-                    "机器"
1253
+                    "设备"
1254
                 ],
1254
                 ],
1255
-                "summary": "机器删除",
1255
+                "summary": "设备删除",
1256
                 "parameters": [
1256
                 "parameters": [
1257
                     {
1257
                     {
1258
-                        "description": "机器信息",
1258
+                        "description": "设备信息",
1259
                         "name": "body",
1259
                         "name": "body",
1260
                         "in": "body",
1260
                         "in": "body",
1261
                         "required": true,
1261
                         "required": true,
@@ -1287,7 +1287,7 @@ const docTemplateadmin = `{
1287
                         "token": []
1287
                         "token": []
1288
                     }
1288
                     }
1289
                 ],
1289
                 ],
1290
-                "description": "机器详情",
1290
+                "description": "设备详情",
1291
                 "consumes": [
1291
                 "consumes": [
1292
                     "application/json"
1292
                     "application/json"
1293
                 ],
1293
                 ],
@@ -1295,9 +1295,9 @@ const docTemplateadmin = `{
1295
                     "application/json"
1295
                     "application/json"
1296
                 ],
1296
                 ],
1297
                 "tags": [
1297
                 "tags": [
1298
-                    "机器"
1298
+                    "设备"
1299
                 ],
1299
                 ],
1300
-                "summary": "机器详情",
1300
+                "summary": "设备详情",
1301
                 "parameters": [
1301
                 "parameters": [
1302
                     {
1302
                     {
1303
                         "type": "integer",
1303
                         "type": "integer",
@@ -1342,7 +1342,7 @@ const docTemplateadmin = `{
1342
                         "token": []
1342
                         "token": []
1343
                     }
1343
                     }
1344
                 ],
1344
                 ],
1345
-                "description": "机器列表",
1345
+                "description": "设备列表",
1346
                 "consumes": [
1346
                 "consumes": [
1347
                     "application/json"
1347
                     "application/json"
1348
                 ],
1348
                 ],
@@ -1350,9 +1350,9 @@ const docTemplateadmin = `{
1350
                     "application/json"
1350
                     "application/json"
1351
                 ],
1351
                 ],
1352
                 "tags": [
1352
                 "tags": [
1353
-                    "机器"
1353
+                    "设备"
1354
                 ],
1354
                 ],
1355
-                "summary": "机器列表",
1355
+                "summary": "设备列表",
1356
                 "parameters": [
1356
                 "parameters": [
1357
                     {
1357
                     {
1358
                         "type": "integer",
1358
                         "type": "integer",
@@ -1402,7 +1402,7 @@ const docTemplateadmin = `{
1402
                         "token": []
1402
                         "token": []
1403
                     }
1403
                     }
1404
                 ],
1404
                 ],
1405
-                "description": "机器编辑",
1405
+                "description": "设备编辑",
1406
                 "consumes": [
1406
                 "consumes": [
1407
                     "application/json"
1407
                     "application/json"
1408
                 ],
1408
                 ],
@@ -1410,12 +1410,12 @@ const docTemplateadmin = `{
1410
                     "application/json"
1410
                     "application/json"
1411
                 ],
1411
                 ],
1412
                 "tags": [
1412
                 "tags": [
1413
-                    "机器"
1413
+                    "设备"
1414
                 ],
1414
                 ],
1415
-                "summary": "机器编辑",
1415
+                "summary": "设备编辑",
1416
                 "parameters": [
1416
                 "parameters": [
1417
                     {
1417
                     {
1418
-                        "description": "机器信息",
1418
+                        "description": "设备信息",
1419
                         "name": "body",
1419
                         "name": "body",
1420
                         "in": "body",
1420
                         "in": "body",
1421
                         "required": true,
1421
                         "required": true,
@@ -2278,7 +2278,7 @@ const docTemplateadmin = `{
2278
                 "id": {
2278
                 "id": {
2279
                     "type": "string"
2279
                     "type": "string"
2280
                 },
2280
                 },
2281
-                "login_name": {
2281
+                "loginName": {
2282
                     "type": "string"
2282
                     "type": "string"
2283
                 },
2283
                 },
2284
                 "online": {
2284
                 "online": {
@@ -2290,16 +2290,16 @@ const docTemplateadmin = `{
2290
                 "platform": {
2290
                 "platform": {
2291
                     "type": "string"
2291
                     "type": "string"
2292
                 },
2292
                 },
2293
-                "rdp_port": {
2293
+                "rdpPort": {
2294
                     "type": "string"
2294
                     "type": "string"
2295
                 },
2295
                 },
2296
-                "rdp_username": {
2296
+                "rdpUsername": {
2297
                     "type": "string"
2297
                     "type": "string"
2298
                 },
2298
                 },
2299
                 "row_id": {
2299
                 "row_id": {
2300
                     "type": "integer"
2300
                     "type": "integer"
2301
                 },
2301
                 },
2302
-                "same_server": {
2302
+                "sameServer": {
2303
                     "type": "boolean"
2303
                     "type": "boolean"
2304
                 },
2304
                 },
2305
                 "tags": {
2305
                 "tags": {

+ 22 - 22
docs/admin/admin_swagger.json

@@ -1178,7 +1178,7 @@
1178
                         "token": []
1178
                         "token": []
1179
                     }
1179
                     }
1180
                 ],
1180
                 ],
1181
-                "description": "创建机器",
1181
+                "description": "创建设备",
1182
                 "consumes": [
1182
                 "consumes": [
1183
                     "application/json"
1183
                     "application/json"
1184
                 ],
1184
                 ],
@@ -1186,12 +1186,12 @@
1186
                     "application/json"
1186
                     "application/json"
1187
                 ],
1187
                 ],
1188
                 "tags": [
1188
                 "tags": [
1189
-                    "机器"
1189
+                    "设备"
1190
                 ],
1190
                 ],
1191
-                "summary": "创建机器",
1191
+                "summary": "创建设备",
1192
                 "parameters": [
1192
                 "parameters": [
1193
                     {
1193
                     {
1194
-                        "description": "机器信息",
1194
+                        "description": "设备信息",
1195
                         "name": "body",
1195
                         "name": "body",
1196
                         "in": "body",
1196
                         "in": "body",
1197
                         "required": true,
1197
                         "required": true,
@@ -1235,7 +1235,7 @@
1235
                         "token": []
1235
                         "token": []
1236
                     }
1236
                     }
1237
                 ],
1237
                 ],
1238
-                "description": "机器删除",
1238
+                "description": "设备删除",
1239
                 "consumes": [
1239
                 "consumes": [
1240
                     "application/json"
1240
                     "application/json"
1241
                 ],
1241
                 ],
@@ -1243,12 +1243,12 @@
1243
                     "application/json"
1243
                     "application/json"
1244
                 ],
1244
                 ],
1245
                 "tags": [
1245
                 "tags": [
1246
-                    "机器"
1246
+                    "设备"
1247
                 ],
1247
                 ],
1248
-                "summary": "机器删除",
1248
+                "summary": "设备删除",
1249
                 "parameters": [
1249
                 "parameters": [
1250
                     {
1250
                     {
1251
-                        "description": "机器信息",
1251
+                        "description": "设备信息",
1252
                         "name": "body",
1252
                         "name": "body",
1253
                         "in": "body",
1253
                         "in": "body",
1254
                         "required": true,
1254
                         "required": true,
@@ -1280,7 +1280,7 @@
1280
                         "token": []
1280
                         "token": []
1281
                     }
1281
                     }
1282
                 ],
1282
                 ],
1283
-                "description": "机器详情",
1283
+                "description": "设备详情",
1284
                 "consumes": [
1284
                 "consumes": [
1285
                     "application/json"
1285
                     "application/json"
1286
                 ],
1286
                 ],
@@ -1288,9 +1288,9 @@
1288
                     "application/json"
1288
                     "application/json"
1289
                 ],
1289
                 ],
1290
                 "tags": [
1290
                 "tags": [
1291
-                    "机器"
1291
+                    "设备"
1292
                 ],
1292
                 ],
1293
-                "summary": "机器详情",
1293
+                "summary": "设备详情",
1294
                 "parameters": [
1294
                 "parameters": [
1295
                     {
1295
                     {
1296
                         "type": "integer",
1296
                         "type": "integer",
@@ -1335,7 +1335,7 @@
1335
                         "token": []
1335
                         "token": []
1336
                     }
1336
                     }
1337
                 ],
1337
                 ],
1338
-                "description": "机器列表",
1338
+                "description": "设备列表",
1339
                 "consumes": [
1339
                 "consumes": [
1340
                     "application/json"
1340
                     "application/json"
1341
                 ],
1341
                 ],
@@ -1343,9 +1343,9 @@
1343
                     "application/json"
1343
                     "application/json"
1344
                 ],
1344
                 ],
1345
                 "tags": [
1345
                 "tags": [
1346
-                    "机器"
1346
+                    "设备"
1347
                 ],
1347
                 ],
1348
-                "summary": "机器列表",
1348
+                "summary": "设备列表",
1349
                 "parameters": [
1349
                 "parameters": [
1350
                     {
1350
                     {
1351
                         "type": "integer",
1351
                         "type": "integer",
@@ -1395,7 +1395,7 @@
1395
                         "token": []
1395
                         "token": []
1396
                     }
1396
                     }
1397
                 ],
1397
                 ],
1398
-                "description": "机器编辑",
1398
+                "description": "设备编辑",
1399
                 "consumes": [
1399
                 "consumes": [
1400
                     "application/json"
1400
                     "application/json"
1401
                 ],
1401
                 ],
@@ -1403,12 +1403,12 @@
1403
                     "application/json"
1403
                     "application/json"
1404
                 ],
1404
                 ],
1405
                 "tags": [
1405
                 "tags": [
1406
-                    "机器"
1406
+                    "设备"
1407
                 ],
1407
                 ],
1408
-                "summary": "机器编辑",
1408
+                "summary": "设备编辑",
1409
                 "parameters": [
1409
                 "parameters": [
1410
                     {
1410
                     {
1411
-                        "description": "机器信息",
1411
+                        "description": "设备信息",
1412
                         "name": "body",
1412
                         "name": "body",
1413
                         "in": "body",
1413
                         "in": "body",
1414
                         "required": true,
1414
                         "required": true,
@@ -2271,7 +2271,7 @@
2271
                 "id": {
2271
                 "id": {
2272
                     "type": "string"
2272
                     "type": "string"
2273
                 },
2273
                 },
2274
-                "login_name": {
2274
+                "loginName": {
2275
                     "type": "string"
2275
                     "type": "string"
2276
                 },
2276
                 },
2277
                 "online": {
2277
                 "online": {
@@ -2283,16 +2283,16 @@
2283
                 "platform": {
2283
                 "platform": {
2284
                     "type": "string"
2284
                     "type": "string"
2285
                 },
2285
                 },
2286
-                "rdp_port": {
2286
+                "rdpPort": {
2287
                     "type": "string"
2287
                     "type": "string"
2288
                 },
2288
                 },
2289
-                "rdp_username": {
2289
+                "rdpUsername": {
2290
                     "type": "string"
2290
                     "type": "string"
2291
                 },
2291
                 },
2292
                 "row_id": {
2292
                 "row_id": {
2293
                     "type": "integer"
2293
                     "type": "integer"
2294
                 },
2294
                 },
2295
-                "same_server": {
2295
+                "sameServer": {
2296
                     "type": "boolean"
2296
                     "type": "boolean"
2297
                 },
2297
                 },
2298
                 "tags": {
2298
                 "tags": {

+ 22 - 22
docs/admin/admin_swagger.yaml

@@ -24,7 +24,7 @@ definitions:
24
         type: string
24
         type: string
25
       id:
25
       id:
26
         type: string
26
         type: string
27
-      login_name:
27
+      loginName:
28
         type: string
28
         type: string
29
       online:
29
       online:
30
         type: boolean
30
         type: boolean
@@ -32,13 +32,13 @@ definitions:
32
         type: string
32
         type: string
33
       platform:
33
       platform:
34
         type: string
34
         type: string
35
-      rdp_port:
35
+      rdpPort:
36
         type: string
36
         type: string
37
-      rdp_username:
37
+      rdpUsername:
38
         type: string
38
         type: string
39
       row_id:
39
       row_id:
40
         type: integer
40
         type: integer
41
-      same_server:
41
+      sameServer:
42
         type: boolean
42
         type: boolean
43
       tags:
43
       tags:
44
         items:
44
         items:
@@ -1162,9 +1162,9 @@ paths:
1162
     post:
1162
     post:
1163
       consumes:
1163
       consumes:
1164
       - application/json
1164
       - application/json
1165
-      description: 创建机器
1165
+      description: 创建设备
1166
       parameters:
1166
       parameters:
1167
-      - description: 机器信息
1167
+      - description: 设备信息
1168
         in: body
1168
         in: body
1169
         name: body
1169
         name: body
1170
         required: true
1170
         required: true
@@ -1188,16 +1188,16 @@ paths:
1188
             $ref: '#/definitions/response.Response'
1188
             $ref: '#/definitions/response.Response'
1189
       security:
1189
       security:
1190
       - token: []
1190
       - token: []
1191
-      summary: 创建机器
1191
+      summary: 创建设备
1192
       tags:
1192
       tags:
1193
-      - 机器
1193
+      - 设备
1194
   /admin/peer/delete:
1194
   /admin/peer/delete:
1195
     post:
1195
     post:
1196
       consumes:
1196
       consumes:
1197
       - application/json
1197
       - application/json
1198
-      description: 机器删除
1198
+      description: 设备删除
1199
       parameters:
1199
       parameters:
1200
-      - description: 机器信息
1200
+      - description: 设备信息
1201
         in: body
1201
         in: body
1202
         name: body
1202
         name: body
1203
         required: true
1203
         required: true
@@ -1216,14 +1216,14 @@ paths:
1216
             $ref: '#/definitions/response.Response'
1216
             $ref: '#/definitions/response.Response'
1217
       security:
1217
       security:
1218
       - token: []
1218
       - token: []
1219
-      summary: 机器删除
1219
+      summary: 设备删除
1220
       tags:
1220
       tags:
1221
-      - 机器
1221
+      - 设备
1222
   /admin/peer/detail/{id}:
1222
   /admin/peer/detail/{id}:
1223
     get:
1223
     get:
1224
       consumes:
1224
       consumes:
1225
       - application/json
1225
       - application/json
1226
-      description: 机器详情
1226
+      description: 设备详情
1227
       parameters:
1227
       parameters:
1228
       - description: ID
1228
       - description: ID
1229
         in: path
1229
         in: path
@@ -1248,14 +1248,14 @@ paths:
1248
             $ref: '#/definitions/response.Response'
1248
             $ref: '#/definitions/response.Response'
1249
       security:
1249
       security:
1250
       - token: []
1250
       - token: []
1251
-      summary: 机器详情
1251
+      summary: 设备详情
1252
       tags:
1252
       tags:
1253
-      - 机器
1253
+      - 设备
1254
   /admin/peer/list:
1254
   /admin/peer/list:
1255
     get:
1255
     get:
1256
       consumes:
1256
       consumes:
1257
       - application/json
1257
       - application/json
1258
-      description: 机器列表
1258
+      description: 设备列表
1259
       parameters:
1259
       parameters:
1260
       - description: 页码
1260
       - description: 页码
1261
         in: query
1261
         in: query
@@ -1283,16 +1283,16 @@ paths:
1283
             $ref: '#/definitions/response.Response'
1283
             $ref: '#/definitions/response.Response'
1284
       security:
1284
       security:
1285
       - token: []
1285
       - token: []
1286
-      summary: 机器列表
1286
+      summary: 设备列表
1287
       tags:
1287
       tags:
1288
-      - 机器
1288
+      - 设备
1289
   /admin/peer/update:
1289
   /admin/peer/update:
1290
     post:
1290
     post:
1291
       consumes:
1291
       consumes:
1292
       - application/json
1292
       - application/json
1293
-      description: 机器编辑
1293
+      description: 设备编辑
1294
       parameters:
1294
       parameters:
1295
-      - description: 机器信息
1295
+      - description: 设备信息
1296
         in: body
1296
         in: body
1297
         name: body
1297
         name: body
1298
         required: true
1298
         required: true
@@ -1316,9 +1316,9 @@ paths:
1316
             $ref: '#/definitions/response.Response'
1316
             $ref: '#/definitions/response.Response'
1317
       security:
1317
       security:
1318
       - token: []
1318
       - token: []
1319
-      summary: 机器编辑
1319
+      summary: 设备编辑
1320
       tags:
1320
       tags:
1321
-      - 机器
1321
+      - 设备
1322
   /admin/server-config:
1322
   /admin/server-config:
1323
     get:
1323
     get:
1324
       consumes:
1324
       consumes:

+ 3 - 1
go.mod

@@ -3,6 +3,7 @@ module Gwen
3
 go 1.22
3
 go 1.22
4
 
4
 
5
 require (
5
 require (
6
+	github.com/BurntSushi/toml v1.3.2
6
 	github.com/antonfisher/nested-logrus-formatter v1.3.1
7
 	github.com/antonfisher/nested-logrus-formatter v1.3.1
7
 	github.com/fsnotify/fsnotify v1.5.1
8
 	github.com/fsnotify/fsnotify v1.5.1
8
 	github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
9
 	github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
@@ -12,12 +13,14 @@ require (
12
 	github.com/go-playground/validator/v10 v10.11.2
13
 	github.com/go-playground/validator/v10 v10.11.2
13
 	github.com/go-redis/redis/v8 v8.11.4
14
 	github.com/go-redis/redis/v8 v8.11.4
14
 	github.com/golang-jwt/jwt/v5 v5.2.1
15
 	github.com/golang-jwt/jwt/v5 v5.2.1
16
+	github.com/nicksnyder/go-i18n/v2 v2.4.0
15
 	github.com/sirupsen/logrus v1.8.1
17
 	github.com/sirupsen/logrus v1.8.1
16
 	github.com/spf13/viper v1.9.0
18
 	github.com/spf13/viper v1.9.0
17
 	github.com/swaggo/files v1.0.1
19
 	github.com/swaggo/files v1.0.1
18
 	github.com/swaggo/gin-swagger v1.6.0
20
 	github.com/swaggo/gin-swagger v1.6.0
19
 	github.com/swaggo/swag v1.16.3
21
 	github.com/swaggo/swag v1.16.3
20
 	golang.org/x/oauth2 v0.23.0
22
 	golang.org/x/oauth2 v0.23.0
23
+	golang.org/x/text v0.15.0
21
 	gorm.io/driver/mysql v1.5.7
24
 	gorm.io/driver/mysql v1.5.7
22
 	gorm.io/driver/sqlite v1.5.6
25
 	gorm.io/driver/sqlite v1.5.6
23
 	gorm.io/gorm v1.25.7
26
 	gorm.io/gorm v1.25.7
@@ -66,7 +69,6 @@ require (
66
 	golang.org/x/crypto v0.23.0 // indirect
69
 	golang.org/x/crypto v0.23.0 // indirect
67
 	golang.org/x/net v0.21.0 // indirect
70
 	golang.org/x/net v0.21.0 // indirect
68
 	golang.org/x/sys v0.25.0 // indirect
71
 	golang.org/x/sys v0.25.0 // indirect
69
-	golang.org/x/text v0.15.0 // indirect
70
 	golang.org/x/tools v0.7.0 // indirect
72
 	golang.org/x/tools v0.7.0 // indirect
71
 	google.golang.org/protobuf v1.33.0 // indirect
73
 	google.golang.org/protobuf v1.33.0 // indirect
72
 	gopkg.in/ini.v1 v1.63.2 // indirect
74
 	gopkg.in/ini.v1 v1.63.2 // indirect

+ 20 - 20
http/controller/admin/peer.go

@@ -12,10 +12,10 @@ import (
12
 type Peer struct {
12
 type Peer struct {
13
 }
13
 }
14
 
14
 
15
-// Detail 机器
16
-// @Tags 机器
17
-// @Summary 机器详情
18
-// @Description 机器详情
15
+// Detail 设备
16
+// @Tags 设备
17
+// @Summary 设备详情
18
+// @Description 设备详情
19
 // @Accept  json
19
 // @Accept  json
20
 // @Produce  json
20
 // @Produce  json
21
 // @Param id path int true "ID"
21
 // @Param id path int true "ID"
@@ -35,13 +35,13 @@ func (ct *Peer) Detail(c *gin.Context) {
35
 	return
35
 	return
36
 }
36
 }
37
 
37
 
38
-// Create 创建机器
39
-// @Tags 机器
40
-// @Summary 创建机器
41
-// @Description 创建机器
38
+// Create 创建设备
39
+// @Tags 设备
40
+// @Summary 创建设备
41
+// @Description 创建设备
42
 // @Accept  json
42
 // @Accept  json
43
 // @Produce  json
43
 // @Produce  json
44
-// @Param body body admin.PeerForm true "机器信息"
44
+// @Param body body admin.PeerForm true "设备信息"
45
 // @Success 200 {object} response.Response{data=model.Peer}
45
 // @Success 200 {object} response.Response{data=model.Peer}
46
 // @Failure 500 {object} response.Response
46
 // @Failure 500 {object} response.Response
47
 // @Router /admin/peer/create [post]
47
 // @Router /admin/peer/create [post]
@@ -67,9 +67,9 @@ func (ct *Peer) Create(c *gin.Context) {
67
 }
67
 }
68
 
68
 
69
 // List 列表
69
 // List 列表
70
-// @Tags 机器
71
-// @Summary 机器列表
72
-// @Description 机器列表
70
+// @Tags 设备
71
+// @Summary 设备列表
72
+// @Description 设备列表
73
 // @Accept  json
73
 // @Accept  json
74
 // @Produce  json
74
 // @Produce  json
75
 // @Param page query int false "页码"
75
 // @Param page query int false "页码"
@@ -89,12 +89,12 @@ func (ct *Peer) List(c *gin.Context) {
89
 }
89
 }
90
 
90
 
91
 // Update 编辑
91
 // Update 编辑
92
-// @Tags 机器
93
-// @Summary 机器编辑
94
-// @Description 机器编辑
92
+// @Tags 设备
93
+// @Summary 设备编辑
94
+// @Description 设备编辑
95
 // @Accept  json
95
 // @Accept  json
96
 // @Produce  json
96
 // @Produce  json
97
-// @Param body body admin.PeerForm true "机器信息"
97
+// @Param body body admin.PeerForm true "设备信息"
98
 // @Success 200 {object} response.Response{data=model.Peer}
98
 // @Success 200 {object} response.Response{data=model.Peer}
99
 // @Failure 500 {object} response.Response
99
 // @Failure 500 {object} response.Response
100
 // @Router /admin/peer/update [post]
100
 // @Router /admin/peer/update [post]
@@ -124,12 +124,12 @@ func (ct *Peer) Update(c *gin.Context) {
124
 }
124
 }
125
 
125
 
126
 // Delete 删除
126
 // Delete 删除
127
-// @Tags 机器
128
-// @Summary 机器删除
129
-// @Description 机器删除
127
+// @Tags 设备
128
+// @Summary 设备删除
129
+// @Description 设备删除
130
 // @Accept  json
130
 // @Accept  json
131
 // @Produce  json
131
 // @Produce  json
132
-// @Param body body admin.PeerForm true "机器信息"
132
+// @Param body body admin.PeerForm true "设备信息"
133
 // @Success 200 {object} response.Response
133
 // @Success 200 {object} response.Response
134
 // @Failure 500 {object} response.Response
134
 // @Failure 500 {object} response.Response
135
 // @Router /admin/peer/delete [post]
135
 // @Router /admin/peer/delete [post]

+ 4 - 4
http/controller/api/group.go

@@ -96,15 +96,15 @@ func (g *Group) Peers(c *gin.Context) {
96
 		namesById[user.Id] = user.Username
96
 		namesById[user.Id] = user.Username
97
 		userIds = append(userIds, user.Id)
97
 		userIds = append(userIds, user.Id)
98
 	}
98
 	}
99
-	peerList := service.AllService.AddressBookService.ListByUserIds(userIds, q.Page, q.PageSize)
99
+	peerList := service.AllService.PeerService.ListByUserIds(userIds, q.Page, q.PageSize)
100
 	var data []*apiResp.GroupPeerPayload
100
 	var data []*apiResp.GroupPeerPayload
101
-	for _, ab := range peerList.AddressBooks {
102
-		uname, ok := namesById[ab.UserId]
101
+	for _, peer := range peerList.Peers {
102
+		uname, ok := namesById[peer.UserId]
103
 		if !ok {
103
 		if !ok {
104
 			uname = ""
104
 			uname = ""
105
 		}
105
 		}
106
 		pp := &apiResp.GroupPeerPayload{}
106
 		pp := &apiResp.GroupPeerPayload{}
107
-		pp.FromAddressBook(ab, uname)
107
+		pp.FromPeer(peer, uname)
108
 		data = append(data, pp)
108
 		data = append(data, pp)
109
 
109
 
110
 	}
110
 	}

+ 5 - 0
http/controller/api/index.go

@@ -35,5 +35,10 @@ func (i *Index) Index(c *gin.Context) {
35
 // @Failure 500 {object} response.Response
35
 // @Failure 500 {object} response.Response
36
 // @Router /heartbeat [post]
36
 // @Router /heartbeat [post]
37
 func (i *Index) Heartbeat(c *gin.Context) {
37
 func (i *Index) Heartbeat(c *gin.Context) {
38
+	//b := &gin.H{}
39
+	//err := c.BindJSON(b)
40
+	//body : &map[id:ljwzhuwo modified_at:0 uuid:NGIxZTZjM2YtNmNkMy00YTMwLWFiNjQtMzQ0MTA0NGE5ZDgz ver:1.003e+06]
41
+	//fmt.Println(b, err, c.Request.Header)
42
+	//header : map[Accept:[*/*] Accept-Encoding:[gzip] Content-Length:[105] Content-Type:[application/json]]
38
 	c.JSON(http.StatusOK, gin.H{})
43
 	c.JSON(http.StatusOK, gin.H{})
39
 }
44
 }

+ 4 - 4
http/request/admin/addressBook.go

@@ -17,11 +17,11 @@ type AddressBookForm struct {
17
 	Hash             string   `json:"hash"`
17
 	Hash             string   `json:"hash"`
18
 	UserId           uint     `json:"user_id"`
18
 	UserId           uint     `json:"user_id"`
19
 	ForceAlwaysRelay bool     `json:"forceAlwaysRelay"`
19
 	ForceAlwaysRelay bool     `json:"forceAlwaysRelay"`
20
-	RdpPort          string   `json:"rdp_port"`
21
-	RdpUsername      string   `json:"rdp_username"`
20
+	RdpPort          string   `json:"rdpPort"`
21
+	RdpUsername      string   `json:"rdpUsername"`
22
 	Online           bool     `json:"online"`
22
 	Online           bool     `json:"online"`
23
-	LoginName        string   `json:"login_name" `
24
-	SameServer       bool     `json:"same_server"`
23
+	LoginName        string   `json:"loginName" `
24
+	SameServer       bool     `json:"sameServer"`
25
 }
25
 }
26
 
26
 
27
 func (a AddressBookForm) ToAddressBook() *model.AddressBook {
27
 func (a AddressBookForm) ToAddressBook() *model.AddressBook {

+ 2 - 2
http/response/api/peer.go

@@ -59,7 +59,7 @@ func (gpp *GroupPeerPayload) FromAddressBook(a *model.AddressBook, username stri
59
 	gpp.UserName = username
59
 	gpp.UserName = username
60
 }
60
 }
61
 
61
 
62
-func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
62
+func (gpp *GroupPeerPayload) FromPeer(p *model.Peer, username string) {
63
 	gpp.Id = p.Id
63
 	gpp.Id = p.Id
64
 	gpp.Info = &PeerPayloadInfo{
64
 	gpp.Info = &PeerPayloadInfo{
65
 		DeviceName: p.Hostname,
65
 		DeviceName: p.Hostname,
@@ -67,5 +67,5 @@ func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
67
 		Username:   p.Username,
67
 		Username:   p.Username,
68
 	}
68
 	}
69
 	gpp.Note = ""
69
 	gpp.Note = ""
70
-	gpp.UserName = p.User.Username
70
+	gpp.UserName = username
71
 }
71
 }

+ 26 - 12
service/peer.go

@@ -15,24 +15,38 @@ func (ps *PeerService) FindById(id string) *model.Peer {
15
 	global.DB.Where("id = ?", id).First(p)
15
 	global.DB.Where("id = ?", id).First(p)
16
 	return p
16
 	return p
17
 }
17
 }
18
+func (ps *PeerService) FindByUuid(uuid string) *model.Peer {
19
+	p := &model.Peer{}
20
+	global.DB.Where("uuid = ?", uuid).First(p)
21
+	return p
22
+}
18
 func (ps *PeerService) InfoByRowId(id uint) *model.Peer {
23
 func (ps *PeerService) InfoByRowId(id uint) *model.Peer {
19
 	p := &model.Peer{}
24
 	p := &model.Peer{}
20
 	global.DB.Where("row_id = ?", id).First(p)
25
 	global.DB.Where("row_id = ?", id).First(p)
21
 	return p
26
 	return p
22
 }
27
 }
23
 
28
 
24
-//// ListByUserIds 根据用户id取列表
25
-//func (ps *PeerService) ListByUserIds(userIds []uint, page, pageSize uint) (res *model.PeerList) {
26
-//	res = &model.PeerList{}
27
-//	res.Page = int64(page)
28
-//	res.PageSize = int64(pageSize)
29
-//	tx := global.DB.Model(&model.Peer{}).Preload("User")
30
-//	tx.Where("user_id in (?)", userIds)
31
-//	tx.Count(&res.Total)
32
-//	tx.Scopes(Paginate(page, pageSize))
33
-//	tx.Find(&res.Peers)
34
-//	return
35
-//}
29
+// UuidBindUserId 绑定用户id
30
+func (ps *PeerService) UuidBindUserId(uuid string, userId uint) {
31
+	peer := ps.FindByUuid(uuid)
32
+	if peer.RowId > 0 {
33
+		peer.UserId = userId
34
+		ps.Update(peer)
35
+	}
36
+}
37
+
38
+// ListByUserIds 根据用户id取列表
39
+func (ps *PeerService) ListByUserIds(userIds []uint, page, pageSize uint) (res *model.PeerList) {
40
+	res = &model.PeerList{}
41
+	res.Page = int64(page)
42
+	res.PageSize = int64(pageSize)
43
+	tx := global.DB.Model(&model.Peer{})
44
+	tx.Where("user_id in (?)", userIds)
45
+	tx.Count(&res.Total)
46
+	tx.Scopes(Paginate(page, pageSize))
47
+	tx.Find(&res.Peers)
48
+	return
49
+}
36
 
50
 
37
 func (ps *PeerService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.PeerList) {
51
 func (ps *PeerService) List(page, pageSize uint, where func(tx *gorm.DB)) (res *model.PeerList) {
38
 	res = &model.PeerList{}
52
 	res = &model.PeerList{}

+ 3 - 0
service/user.go

@@ -66,6 +66,9 @@ func (us *UserService) Login(u *model.User, llog *model.LoginLog) *model.UserTok
66
 	}
66
 	}
67
 	global.DB.Create(ut)
67
 	global.DB.Create(ut)
68
 	global.DB.Create(llog)
68
 	global.DB.Create(llog)
69
+	if llog.Uuid != "" {
70
+		AllService.PeerService.UuidBindUserId(llog.Uuid, u.Id)
71
+	}
69
 	return ut
72
 	return ut
70
 }
73
 }
71
 
74