ljw 1 год назад
Родитель
Сommit
c485035e74

+ 1 - 0
README.md

@@ -127,6 +127,7 @@ rustdesk:
127 127
 | RUSTDESK_API_GORM_TYPE              | 数据库类型sqlite或者mysql,默认sqlite          | sqlite                      |
128 128
 | RUSTDESK_API_GORM_MAX_IDLE_CONNS    | 数据库最大空闲连接数                           | 10                          |
129 129
 | RUSTDESK_API_GORM_MAX_OPEN_CONNS    | 数据库最大打开连接数                           | 100                         |
130
+| RUSTDESK_PERSONAL                   | 是否启用个人版API, 1:启用,0:不启用; 默认启用         | 1                           |
130 131
 | -----MYSQL配置-----                   | -----数据库类型为sqlite时不用填-----           | ----------                  |
131 132
 | RUSTDESK_API_MYSQL_USERNAME         | mysql用户名                             | root                        |
132 133
 | RUSTDESK_API_MYSQL_PASSWORD         | mysql密码                              | 111111                      |

+ 1 - 1
cmd/apimain.go

@@ -157,7 +157,7 @@ func ApiInitValidator() {
157 157
 }
158 158
 
159 159
 func DatabaseAutoUpdate() {
160
-	version := 103
160
+	version := 126
161 161
 
162 162
 	db := global.DB
163 163
 

+ 1 - 0
conf/config.yaml

@@ -17,6 +17,7 @@ rustdesk:
17 17
   relay-server: "192.168.1.66:21117"
18 18
   api-server: "http://192.168.1.66:21114"
19 19
   key: "123456789"
20
+  personal: 1
20 21
 logger:
21 22
   path: "./runtime/log.txt"
22 23
   level: "warn" #trace,debug,info,warn,error,fatal

+ 1 - 0
config/rustdesk.go

@@ -5,4 +5,5 @@ type Rustdesk struct {
5 5
 	RelayServer string `mapstructure:"relay-server"`
6 6
 	ApiServer   string `mapstructure:"api-server"`
7 7
 	Key         string `mapstructure:"key"`
8
+	Personal    int    `mapstructure:"personal"`
8 9
 }

+ 2 - 3
docs/admin/admin_docs.go

@@ -2266,7 +2266,7 @@ const docTemplateadmin = `{
2266 2266
                 "alias": {
2267 2267
                     "type": "string"
2268 2268
                 },
2269
-                "force_always_relay": {
2269
+                "forceAlwaysRelay": {
2270 2270
                     "type": "boolean"
2271 2271
                 },
2272 2272
                 "hash": {
@@ -2434,8 +2434,7 @@ const docTemplateadmin = `{
2434 2434
             "type": "object",
2435 2435
             "required": [
2436 2436
                 "color",
2437
-                "name",
2438
-                "user_id"
2437
+                "name"
2439 2438
             ],
2440 2439
             "properties": {
2441 2440
                 "color": {

+ 2 - 3
docs/admin/admin_swagger.json

@@ -2259,7 +2259,7 @@
2259 2259
                 "alias": {
2260 2260
                     "type": "string"
2261 2261
                 },
2262
-                "force_always_relay": {
2262
+                "forceAlwaysRelay": {
2263 2263
                     "type": "boolean"
2264 2264
                 },
2265 2265
                 "hash": {
@@ -2427,8 +2427,7 @@
2427 2427
             "type": "object",
2428 2428
             "required": [
2429 2429
                 "color",
2430
-                "name",
2431
-                "user_id"
2430
+                "name"
2432 2431
             ],
2433 2432
             "properties": {
2434 2433
                 "color": {

+ 1 - 2
docs/admin/admin_swagger.yaml

@@ -16,7 +16,7 @@ definitions:
16 16
     properties:
17 17
       alias:
18 18
         type: string
19
-      force_always_relay:
19
+      forceAlwaysRelay:
20 20
         type: boolean
21 21
       hash:
22 22
         type: string
@@ -141,7 +141,6 @@ definitions:
141 141
     required:
142 142
     - color
143 143
     - name
144
-    - user_id
145 144
     type: object
146 145
   admin.UserForm:
147 146
     properties:

+ 241 - 32
docs/api/api_docs.go

@@ -155,6 +155,93 @@ const docTemplateapi = `{
155 155
                 }
156 156
             }
157 157
         },
158
+        "/ab/peer/add/{id}": {
159
+            "post": {
160
+                "security": [
161
+                    {
162
+                        "BearerAuth": []
163
+                    }
164
+                ],
165
+                "description": "添加地址",
166
+                "consumes": [
167
+                    "application/json"
168
+                ],
169
+                "produces": [
170
+                    "application/json"
171
+                ],
172
+                "tags": [
173
+                    "地址[Personal]"
174
+                ],
175
+                "summary": "添加地址",
176
+                "parameters": [
177
+                    {
178
+                        "type": "string",
179
+                        "description": "id",
180
+                        "name": "id",
181
+                        "in": "path",
182
+                        "required": true
183
+                    }
184
+                ],
185
+                "responses": {
186
+                    "200": {
187
+                        "description": "OK",
188
+                        "schema": {
189
+                            "type": "string"
190
+                        }
191
+                    },
192
+                    "500": {
193
+                        "description": "Internal Server Error",
194
+                        "schema": {
195
+                            "$ref": "#/definitions/response.ErrorResponse"
196
+                        }
197
+                    }
198
+                }
199
+            }
200
+        },
201
+        "/ab/peers": {
202
+            "post": {
203
+                "security": [
204
+                    {
205
+                        "BearerAuth": []
206
+                    }
207
+                ],
208
+                "description": "地址",
209
+                "consumes": [
210
+                    "application/json"
211
+                ],
212
+                "produces": [
213
+                    "application/json"
214
+                ],
215
+                "tags": [
216
+                    "地址[Personal]"
217
+                ],
218
+                "summary": "地址列表",
219
+                "parameters": [
220
+                    {
221
+                        "description": "string valid",
222
+                        "name": "string",
223
+                        "in": "body",
224
+                        "schema": {
225
+                            "type": "string"
226
+                        }
227
+                    }
228
+                ],
229
+                "responses": {
230
+                    "200": {
231
+                        "description": "OK",
232
+                        "schema": {
233
+                            "$ref": "#/definitions/response.Response"
234
+                        }
235
+                    },
236
+                    "500": {
237
+                        "description": "Internal Server Error",
238
+                        "schema": {
239
+                            "$ref": "#/definitions/response.Response"
240
+                        }
241
+                    }
242
+                }
243
+            }
244
+        },
158 245
         "/ab/personal": {
159 246
             "post": {
160 247
                 "security": [
@@ -162,7 +249,7 @@ const docTemplateapi = `{
162 249
                         "BearerAuth": []
163 250
                     }
164 251
                 ],
165
-                "description": "个人信息",
252
+                "description": "个人地址",
166 253
                 "consumes": [
167 254
                     "application/json"
168 255
                 ],
@@ -170,9 +257,97 @@ const docTemplateapi = `{
170 257
                     "application/json"
171 258
                 ],
172 259
                 "tags": [
173
-                    "用户"
260
+                    "地址[Personal]"
261
+                ],
262
+                "summary": "个人地址",
263
+                "parameters": [
264
+                    {
265
+                        "description": "string valid",
266
+                        "name": "string",
267
+                        "in": "body",
268
+                        "schema": {
269
+                            "type": "string"
270
+                        }
271
+                    }
272
+                ],
273
+                "responses": {
274
+                    "200": {
275
+                        "description": "OK",
276
+                        "schema": {
277
+                            "$ref": "#/definitions/response.Response"
278
+                        }
279
+                    },
280
+                    "500": {
281
+                        "description": "Internal Server Error",
282
+                        "schema": {
283
+                            "$ref": "#/definitions/response.Response"
284
+                        }
285
+                    }
286
+                }
287
+            }
288
+        },
289
+        "/ab/settings": {
290
+            "post": {
291
+                "security": [
292
+                    {
293
+                        "BearerAuth": []
294
+                    }
295
+                ],
296
+                "description": "设置",
297
+                "consumes": [
298
+                    "application/json"
299
+                ],
300
+                "produces": [
301
+                    "application/json"
302
+                ],
303
+                "tags": [
304
+                    "地址[Personal]"
305
+                ],
306
+                "summary": "设置",
307
+                "parameters": [
308
+                    {
309
+                        "description": "string valid",
310
+                        "name": "string",
311
+                        "in": "body",
312
+                        "schema": {
313
+                            "type": "string"
314
+                        }
315
+                    }
316
+                ],
317
+                "responses": {
318
+                    "200": {
319
+                        "description": "OK",
320
+                        "schema": {
321
+                            "$ref": "#/definitions/response.Response"
322
+                        }
323
+                    },
324
+                    "500": {
325
+                        "description": "Internal Server Error",
326
+                        "schema": {
327
+                            "$ref": "#/definitions/response.Response"
328
+                        }
329
+                    }
330
+                }
331
+            }
332
+        },
333
+        "/ab/shared/profiles": {
334
+            "post": {
335
+                "security": [
336
+                    {
337
+                        "BearerAuth": []
338
+                    }
174 339
                 ],
175
-                "summary": "个人信息",
340
+                "description": "共享",
341
+                "consumes": [
342
+                    "application/json"
343
+                ],
344
+                "produces": [
345
+                    "application/json"
346
+                ],
347
+                "tags": [
348
+                    "地址[Personal]"
349
+                ],
350
+                "summary": "共享地址簿",
176 351
                 "parameters": [
177 352
                     {
178 353
                         "description": "string valid",
@@ -199,6 +374,49 @@ const docTemplateapi = `{
199 374
                 }
200 375
             }
201 376
         },
377
+        "/ab/tags/{id}": {
378
+            "post": {
379
+                "security": [
380
+                    {
381
+                        "BearerAuth": []
382
+                    }
383
+                ],
384
+                "description": "标签",
385
+                "consumes": [
386
+                    "application/json"
387
+                ],
388
+                "produces": [
389
+                    "application/json"
390
+                ],
391
+                "tags": [
392
+                    "地址[Personal]"
393
+                ],
394
+                "summary": "标签",
395
+                "parameters": [
396
+                    {
397
+                        "type": "string",
398
+                        "description": "id",
399
+                        "name": "id",
400
+                        "in": "path",
401
+                        "required": true
402
+                    }
403
+                ],
404
+                "responses": {
405
+                    "200": {
406
+                        "description": "OK",
407
+                        "schema": {
408
+                            "$ref": "#/definitions/model.TagList"
409
+                        }
410
+                    },
411
+                    "500": {
412
+                        "description": "Internal Server Error",
413
+                        "schema": {
414
+                            "$ref": "#/definitions/response.ErrorResponse"
415
+                        }
416
+                    }
417
+                }
418
+            }
419
+        },
202 420
         "/api": {
203 421
             "get": {
204 422
                 "security": [
@@ -389,35 +607,6 @@ const docTemplateapi = `{
389 607
                 }
390 608
             }
391 609
         },
392
-        "/oauth/login": {
393
-            "get": {
394
-                "description": "WebOauthLogin",
395
-                "consumes": [
396
-                    "application/json"
397
-                ],
398
-                "produces": [
399
-                    "application/json"
400
-                ],
401
-                "tags": [
402
-                    "Oauth"
403
-                ],
404
-                "summary": "WebOauthLogin",
405
-                "responses": {
406
-                    "200": {
407
-                        "description": "OK",
408
-                        "schema": {
409
-                            "type": "string"
410
-                        }
411
-                    },
412
-                    "500": {
413
-                        "description": "Internal Server Error",
414
-                        "schema": {
415
-                            "type": "string"
416
-                        }
417
-                    }
418
-                }
419
-            }
420
-        },
421 610
         "/oidc/auth": {
422 611
             "post": {
423 612
                 "description": "OidcAuth",
@@ -882,6 +1071,26 @@ const docTemplateapi = `{
882 1071
                 }
883 1072
             }
884 1073
         },
1074
+        "model.TagList": {
1075
+            "type": "object",
1076
+            "properties": {
1077
+                "list": {
1078
+                    "type": "array",
1079
+                    "items": {
1080
+                        "$ref": "#/definitions/model.Tag"
1081
+                    }
1082
+                },
1083
+                "page": {
1084
+                    "type": "integer"
1085
+                },
1086
+                "page_size": {
1087
+                    "type": "integer"
1088
+                },
1089
+                "total": {
1090
+                    "type": "integer"
1091
+                }
1092
+            }
1093
+        },
885 1094
         "response.DataResponse": {
886 1095
             "type": "object",
887 1096
             "properties": {

+ 241 - 32
docs/api/api_swagger.json

@@ -148,6 +148,93 @@
148 148
                 }
149 149
             }
150 150
         },
151
+        "/ab/peer/add/{id}": {
152
+            "post": {
153
+                "security": [
154
+                    {
155
+                        "BearerAuth": []
156
+                    }
157
+                ],
158
+                "description": "添加地址",
159
+                "consumes": [
160
+                    "application/json"
161
+                ],
162
+                "produces": [
163
+                    "application/json"
164
+                ],
165
+                "tags": [
166
+                    "地址[Personal]"
167
+                ],
168
+                "summary": "添加地址",
169
+                "parameters": [
170
+                    {
171
+                        "type": "string",
172
+                        "description": "id",
173
+                        "name": "id",
174
+                        "in": "path",
175
+                        "required": true
176
+                    }
177
+                ],
178
+                "responses": {
179
+                    "200": {
180
+                        "description": "OK",
181
+                        "schema": {
182
+                            "type": "string"
183
+                        }
184
+                    },
185
+                    "500": {
186
+                        "description": "Internal Server Error",
187
+                        "schema": {
188
+                            "$ref": "#/definitions/response.ErrorResponse"
189
+                        }
190
+                    }
191
+                }
192
+            }
193
+        },
194
+        "/ab/peers": {
195
+            "post": {
196
+                "security": [
197
+                    {
198
+                        "BearerAuth": []
199
+                    }
200
+                ],
201
+                "description": "地址",
202
+                "consumes": [
203
+                    "application/json"
204
+                ],
205
+                "produces": [
206
+                    "application/json"
207
+                ],
208
+                "tags": [
209
+                    "地址[Personal]"
210
+                ],
211
+                "summary": "地址列表",
212
+                "parameters": [
213
+                    {
214
+                        "description": "string valid",
215
+                        "name": "string",
216
+                        "in": "body",
217
+                        "schema": {
218
+                            "type": "string"
219
+                        }
220
+                    }
221
+                ],
222
+                "responses": {
223
+                    "200": {
224
+                        "description": "OK",
225
+                        "schema": {
226
+                            "$ref": "#/definitions/response.Response"
227
+                        }
228
+                    },
229
+                    "500": {
230
+                        "description": "Internal Server Error",
231
+                        "schema": {
232
+                            "$ref": "#/definitions/response.Response"
233
+                        }
234
+                    }
235
+                }
236
+            }
237
+        },
151 238
         "/ab/personal": {
152 239
             "post": {
153 240
                 "security": [
@@ -155,7 +242,7 @@
155 242
                         "BearerAuth": []
156 243
                     }
157 244
                 ],
158
-                "description": "个人信息",
245
+                "description": "个人地址",
159 246
                 "consumes": [
160 247
                     "application/json"
161 248
                 ],
@@ -163,9 +250,97 @@
163 250
                     "application/json"
164 251
                 ],
165 252
                 "tags": [
166
-                    "用户"
253
+                    "地址[Personal]"
254
+                ],
255
+                "summary": "个人地址",
256
+                "parameters": [
257
+                    {
258
+                        "description": "string valid",
259
+                        "name": "string",
260
+                        "in": "body",
261
+                        "schema": {
262
+                            "type": "string"
263
+                        }
264
+                    }
265
+                ],
266
+                "responses": {
267
+                    "200": {
268
+                        "description": "OK",
269
+                        "schema": {
270
+                            "$ref": "#/definitions/response.Response"
271
+                        }
272
+                    },
273
+                    "500": {
274
+                        "description": "Internal Server Error",
275
+                        "schema": {
276
+                            "$ref": "#/definitions/response.Response"
277
+                        }
278
+                    }
279
+                }
280
+            }
281
+        },
282
+        "/ab/settings": {
283
+            "post": {
284
+                "security": [
285
+                    {
286
+                        "BearerAuth": []
287
+                    }
288
+                ],
289
+                "description": "设置",
290
+                "consumes": [
291
+                    "application/json"
292
+                ],
293
+                "produces": [
294
+                    "application/json"
295
+                ],
296
+                "tags": [
297
+                    "地址[Personal]"
298
+                ],
299
+                "summary": "设置",
300
+                "parameters": [
301
+                    {
302
+                        "description": "string valid",
303
+                        "name": "string",
304
+                        "in": "body",
305
+                        "schema": {
306
+                            "type": "string"
307
+                        }
308
+                    }
309
+                ],
310
+                "responses": {
311
+                    "200": {
312
+                        "description": "OK",
313
+                        "schema": {
314
+                            "$ref": "#/definitions/response.Response"
315
+                        }
316
+                    },
317
+                    "500": {
318
+                        "description": "Internal Server Error",
319
+                        "schema": {
320
+                            "$ref": "#/definitions/response.Response"
321
+                        }
322
+                    }
323
+                }
324
+            }
325
+        },
326
+        "/ab/shared/profiles": {
327
+            "post": {
328
+                "security": [
329
+                    {
330
+                        "BearerAuth": []
331
+                    }
167 332
                 ],
168
-                "summary": "个人信息",
333
+                "description": "共享",
334
+                "consumes": [
335
+                    "application/json"
336
+                ],
337
+                "produces": [
338
+                    "application/json"
339
+                ],
340
+                "tags": [
341
+                    "地址[Personal]"
342
+                ],
343
+                "summary": "共享地址簿",
169 344
                 "parameters": [
170 345
                     {
171 346
                         "description": "string valid",
@@ -192,6 +367,49 @@
192 367
                 }
193 368
             }
194 369
         },
370
+        "/ab/tags/{id}": {
371
+            "post": {
372
+                "security": [
373
+                    {
374
+                        "BearerAuth": []
375
+                    }
376
+                ],
377
+                "description": "标签",
378
+                "consumes": [
379
+                    "application/json"
380
+                ],
381
+                "produces": [
382
+                    "application/json"
383
+                ],
384
+                "tags": [
385
+                    "地址[Personal]"
386
+                ],
387
+                "summary": "标签",
388
+                "parameters": [
389
+                    {
390
+                        "type": "string",
391
+                        "description": "id",
392
+                        "name": "id",
393
+                        "in": "path",
394
+                        "required": true
395
+                    }
396
+                ],
397
+                "responses": {
398
+                    "200": {
399
+                        "description": "OK",
400
+                        "schema": {
401
+                            "$ref": "#/definitions/model.TagList"
402
+                        }
403
+                    },
404
+                    "500": {
405
+                        "description": "Internal Server Error",
406
+                        "schema": {
407
+                            "$ref": "#/definitions/response.ErrorResponse"
408
+                        }
409
+                    }
410
+                }
411
+            }
412
+        },
195 413
         "/api": {
196 414
             "get": {
197 415
                 "security": [
@@ -382,35 +600,6 @@
382 600
                 }
383 601
             }
384 602
         },
385
-        "/oauth/login": {
386
-            "get": {
387
-                "description": "WebOauthLogin",
388
-                "consumes": [
389
-                    "application/json"
390
-                ],
391
-                "produces": [
392
-                    "application/json"
393
-                ],
394
-                "tags": [
395
-                    "Oauth"
396
-                ],
397
-                "summary": "WebOauthLogin",
398
-                "responses": {
399
-                    "200": {
400
-                        "description": "OK",
401
-                        "schema": {
402
-                            "type": "string"
403
-                        }
404
-                    },
405
-                    "500": {
406
-                        "description": "Internal Server Error",
407
-                        "schema": {
408
-                            "type": "string"
409
-                        }
410
-                    }
411
-                }
412
-            }
413
-        },
414 603
         "/oidc/auth": {
415 604
             "post": {
416 605
                 "description": "OidcAuth",
@@ -875,6 +1064,26 @@
875 1064
                 }
876 1065
             }
877 1066
         },
1067
+        "model.TagList": {
1068
+            "type": "object",
1069
+            "properties": {
1070
+                "list": {
1071
+                    "type": "array",
1072
+                    "items": {
1073
+                        "$ref": "#/definitions/model.Tag"
1074
+                    }
1075
+                },
1076
+                "page": {
1077
+                    "type": "integer"
1078
+                },
1079
+                "page_size": {
1080
+                    "type": "integer"
1081
+                },
1082
+                "total": {
1083
+                    "type": "integer"
1084
+                }
1085
+            }
1086
+        },
878 1087
         "response.DataResponse": {
879 1088
             "type": "object",
880 1089
             "properties": {

+ 151 - 22
docs/api/api_swagger.yaml

@@ -103,6 +103,19 @@ definitions:
103 103
       user_id:
104 104
         type: integer
105 105
     type: object
106
+  model.TagList:
107
+    properties:
108
+      list:
109
+        items:
110
+          $ref: '#/definitions/model.Tag'
111
+        type: array
112
+      page:
113
+        type: integer
114
+      page_size:
115
+        type: integer
116
+      total:
117
+        type: integer
118
+    type: object
106 119
   response.DataResponse:
107 120
     properties:
108 121
       data: {}
@@ -216,11 +229,65 @@ paths:
216 229
       summary: 标签添加
217 230
       tags:
218 231
       - 地址
232
+  /ab/peer/add/{id}:
233
+    post:
234
+      consumes:
235
+      - application/json
236
+      description: 添加地址
237
+      parameters:
238
+      - description: id
239
+        in: path
240
+        name: id
241
+        required: true
242
+        type: string
243
+      produces:
244
+      - application/json
245
+      responses:
246
+        "200":
247
+          description: OK
248
+          schema:
249
+            type: string
250
+        "500":
251
+          description: Internal Server Error
252
+          schema:
253
+            $ref: '#/definitions/response.ErrorResponse'
254
+      security:
255
+      - BearerAuth: []
256
+      summary: 添加地址
257
+      tags:
258
+      - 地址[Personal]
259
+  /ab/peers:
260
+    post:
261
+      consumes:
262
+      - application/json
263
+      description: 地址
264
+      parameters:
265
+      - description: string valid
266
+        in: body
267
+        name: string
268
+        schema:
269
+          type: string
270
+      produces:
271
+      - application/json
272
+      responses:
273
+        "200":
274
+          description: OK
275
+          schema:
276
+            $ref: '#/definitions/response.Response'
277
+        "500":
278
+          description: Internal Server Error
279
+          schema:
280
+            $ref: '#/definitions/response.Response'
281
+      security:
282
+      - BearerAuth: []
283
+      summary: 地址列表
284
+      tags:
285
+      - 地址[Personal]
219 286
   /ab/personal:
220 287
     post:
221 288
       consumes:
222 289
       - application/json
223
-      description: 个人信息
290
+      description: 个人地址
224 291
       parameters:
225 292
       - description: string valid
226 293
         in: body
@@ -240,9 +307,90 @@ paths:
240 307
             $ref: '#/definitions/response.Response'
241 308
       security:
242 309
       - BearerAuth: []
243
-      summary: 个人信息
310
+      summary: 个人地址
244 311
       tags:
245
-      - 用户
312
+      - 地址[Personal]
313
+  /ab/settings:
314
+    post:
315
+      consumes:
316
+      - application/json
317
+      description: 设置
318
+      parameters:
319
+      - description: string valid
320
+        in: body
321
+        name: string
322
+        schema:
323
+          type: string
324
+      produces:
325
+      - application/json
326
+      responses:
327
+        "200":
328
+          description: OK
329
+          schema:
330
+            $ref: '#/definitions/response.Response'
331
+        "500":
332
+          description: Internal Server Error
333
+          schema:
334
+            $ref: '#/definitions/response.Response'
335
+      security:
336
+      - BearerAuth: []
337
+      summary: 设置
338
+      tags:
339
+      - 地址[Personal]
340
+  /ab/shared/profiles:
341
+    post:
342
+      consumes:
343
+      - application/json
344
+      description: 共享
345
+      parameters:
346
+      - description: string valid
347
+        in: body
348
+        name: string
349
+        schema:
350
+          type: string
351
+      produces:
352
+      - application/json
353
+      responses:
354
+        "200":
355
+          description: OK
356
+          schema:
357
+            $ref: '#/definitions/response.Response'
358
+        "500":
359
+          description: Internal Server Error
360
+          schema:
361
+            $ref: '#/definitions/response.Response'
362
+      security:
363
+      - BearerAuth: []
364
+      summary: 共享地址簿
365
+      tags:
366
+      - 地址[Personal]
367
+  /ab/tags/{id}:
368
+    post:
369
+      consumes:
370
+      - application/json
371
+      description: 标签
372
+      parameters:
373
+      - description: id
374
+        in: path
375
+        name: id
376
+        required: true
377
+        type: string
378
+      produces:
379
+      - application/json
380
+      responses:
381
+        "200":
382
+          description: OK
383
+          schema:
384
+            $ref: '#/definitions/model.TagList'
385
+        "500":
386
+          description: Internal Server Error
387
+          schema:
388
+            $ref: '#/definitions/response.ErrorResponse'
389
+      security:
390
+      - BearerAuth: []
391
+      summary: 标签
392
+      tags:
393
+      - 地址[Personal]
246 394
   /api:
247 395
     get:
248 396
       consumes:
@@ -366,25 +514,6 @@ paths:
366 514
       summary: OauthCallback
367 515
       tags:
368 516
       - Oauth
369
-  /oauth/login:
370
-    get:
371
-      consumes:
372
-      - application/json
373
-      description: WebOauthLogin
374
-      produces:
375
-      - application/json
376
-      responses:
377
-        "200":
378
-          description: OK
379
-          schema:
380
-            type: string
381
-        "500":
382
-          description: Internal Server Error
383
-          schema:
384
-            type: string
385
-      summary: WebOauthLogin
386
-      tags:
387
-      - Oauth
388 517
   /oidc/auth:
389 518
     post:
390 519
       consumes:

+ 356 - 8
http/controller/api/ab.go

@@ -1,14 +1,17 @@
1 1
 package api
2 2
 
3 3
 import (
4
+	"Gwen/global"
4 5
 	requstform "Gwen/http/request/api"
5 6
 	"Gwen/http/response"
6 7
 	"Gwen/http/response/api"
7 8
 	"Gwen/model"
8 9
 	"Gwen/service"
9 10
 	"encoding/json"
11
+	"fmt"
10 12
 	"github.com/gin-gonic/gin"
11 13
 	"net/http"
14
+	"strconv"
12 15
 )
13 16
 
14 17
 type Ab struct {
@@ -118,7 +121,7 @@ func (a *Ab) Tags(c *gin.Context) {
118 121
 }
119 122
 
120 123
 // TagAdd
121
-// @Tags 地址
124
+// @Tags 地址[Personal]
122 125
 // @Summary 标签添加
123 126
 // @Description 标签
124 127
 // @Accept  json
@@ -133,14 +136,359 @@ func (a *Ab) TagAdd(c *gin.Context) {
133 136
 	if err != nil {
134 137
 		response.Error(c, "参数错误")
135 138
 		return
139
+	}
140
+	u := service.AllService.UserService.CurUser(c)
141
+	tag := service.AllService.TagService.InfoByUserIdAndName(u.Id, t.Name)
142
+	if tag != nil && tag.Id != 0 {
143
+		response.Error(c, "已存在")
144
+		return
145
+	}
146
+	t.UserId = u.Id
147
+	err = service.AllService.TagService.Create(t)
148
+	if err != nil {
149
+		response.Error(c, "操作失败")
150
+		return
151
+	}
152
+	c.String(http.StatusOK, "")
153
+}
136 154
 
155
+// TagRename
156
+// @Tags 地址[Personal]
157
+// @Summary 标签重命名
158
+// @Description 标签
159
+// @Accept  json
160
+// @Produce  json
161
+// @Success 200 {string} string
162
+// @Failure 500 {object} response.ErrorResponse
163
+// @Router /ab/tag/rename/{guid} [put]
164
+// @Security BearerAuth
165
+func (a *Ab) TagRename(c *gin.Context) {
166
+	t := &requstform.TagRenameForm{}
167
+	err := c.ShouldBindJSON(t)
168
+	if err != nil {
169
+		response.Error(c, "参数错误")
170
+		return
137 171
 	}
138
-	//u := service.AllService.UserService.CurUser(c)
172
+	u := service.AllService.UserService.CurUser(c)
173
+	tag := service.AllService.TagService.InfoByUserIdAndName(u.Id, t.Old)
174
+	if tag == nil || tag.Id == 0 {
175
+		response.Error(c, "参数错误")
176
+		return
177
+	}
178
+	ntag := service.AllService.TagService.InfoByUserIdAndName(u.Id, t.New)
179
+	if ntag != nil && ntag.Id != 0 {
180
+		response.Error(c, "已存在")
181
+		return
182
+	}
183
+	tag.Name = t.New
184
+	err = service.AllService.TagService.Update(tag)
185
+	if err != nil {
186
+		response.Error(c, "操作失败")
187
+		return
188
+	}
189
+	c.String(http.StatusOK, "")
190
+}
139 191
 
140
-	//err = service.AllService.TagService.UpdateTags(t.Name, t.Color, user.Id)
141
-	//if err != nil {
142
-	//	response.Error(c, "操作失败")
143
-	//	return
144
-	//}
145
-	c.JSON(http.StatusOK, "")
192
+// TagUpdate
193
+// @Tags 地址[Personal]
194
+// @Summary 标签修改颜色
195
+// @Description 标签
196
+// @Accept  json
197
+// @Produce  json
198
+// @Success 200 {string} string
199
+// @Failure 500 {object} response.ErrorResponse
200
+// @Router /ab/tag/update/{guid} [put]
201
+// @Security BearerAuth
202
+func (a *Ab) TagUpdate(c *gin.Context) {
203
+	t := &requstform.TagColorForm{}
204
+	err := c.ShouldBindJSON(t)
205
+	if err != nil {
206
+		response.Error(c, "参数错误")
207
+		return
208
+	}
209
+	u := service.AllService.UserService.CurUser(c)
210
+	tag := service.AllService.TagService.InfoByUserIdAndName(u.Id, t.Name)
211
+	if tag == nil || tag.Id == 0 {
212
+		response.Error(c, "参数错误")
213
+		return
214
+	}
215
+	tag.Color = t.Color
216
+	err = service.AllService.TagService.Update(tag)
217
+	if err != nil {
218
+		response.Error(c, "操作失败")
219
+		return
220
+	}
221
+	c.String(http.StatusOK, "")
222
+}
223
+
224
+// TagDel
225
+// @Tags 地址[Personal]
226
+// @Summary 标签删除
227
+// @Description 标签
228
+// @Accept  json
229
+// @Produce  json
230
+// @Success 200 {string} string
231
+// @Failure 500 {object} response.ErrorResponse
232
+// @Router /ab/tag/{guid} [delete]
233
+// @Security BearerAuth
234
+func (a *Ab) TagDel(c *gin.Context) {
235
+	t := &[]string{}
236
+	err := c.ShouldBind(t)
237
+	if err != nil {
238
+		response.Error(c, "参数错误")
239
+		return
240
+	}
241
+	//fmt.Println(t)
242
+	u := service.AllService.UserService.CurUser(c)
243
+	for _, name := range *t {
244
+		tag := service.AllService.TagService.InfoByUserIdAndName(u.Id, name)
245
+		if tag == nil || tag.Id == 0 {
246
+			response.Error(c, "参数错误")
247
+			return
248
+		}
249
+		err = service.AllService.TagService.Delete(tag)
250
+		if err != nil {
251
+			response.Error(c, "操作失败")
252
+			return
253
+		}
254
+	}
255
+	c.String(http.StatusOK, "")
256
+}
257
+
258
+// Personal
259
+// @Tags 地址[Personal]
260
+// @Summary 个人地址
261
+// @Description 个人地址
262
+// @Accept  json
263
+// @Produce  json
264
+// @Param string body string false  "string valid"
265
+// @Success 200 {object} response.Response
266
+// @Failure 500 {object} response.Response
267
+// @Router /ab/personal [post]
268
+// @Security BearerAuth
269
+func (a *Ab) Personal(c *gin.Context) {
270
+	user := service.AllService.UserService.CurUser(c)
271
+	/**
272
+	guid = json['guid'] ?? '',
273
+	       name = json['name'] ?? '',
274
+	       owner = json['owner'] ?? '',
275
+	       note = json['note'] ?? '',
276
+	       rule = json['rule'] ?? 0;
277
+	*/
278
+	if global.Config.Rustdesk.Personal == 1 {
279
+		guid := strconv.Itoa(int(user.GroupId)) + "-" + strconv.Itoa(int(user.Id))
280
+		//如果返回了guid,后面的请求会有变化
281
+		c.JSON(http.StatusOK, gin.H{
282
+			"guid": guid,
283
+			"name": user.Username,
284
+			"rule": 0,
285
+		})
286
+	} else {
287
+		c.JSON(http.StatusOK, nil)
288
+	}
289
+
290
+}
291
+
292
+// Settings
293
+// @Tags 地址[Personal]
294
+// @Summary 设置
295
+// @Description 设置
296
+// @Accept  json
297
+// @Produce  json
298
+// @Param string body string false  "string valid"
299
+// @Success 200 {object} response.Response
300
+// @Failure 500 {object} response.Response
301
+// @Router /ab/settings [post]
302
+// @Security BearerAuth
303
+func (a *Ab) Settings(c *gin.Context) {
304
+	c.JSON(http.StatusOK, gin.H{
305
+		"max_peer_one_ab": 0, //最大peer数,0表示不限制
306
+	})
307
+}
308
+
309
+// SharedProfiles
310
+// @Tags 地址[Personal]
311
+// @Summary 共享地址簿
312
+// @Description 共享
313
+// @Accept  json
314
+// @Produce  json
315
+// @Param string body string false  "string valid"
316
+// @Success 200 {object} response.Response
317
+// @Failure 500 {object} response.Response
318
+// @Router /ab/shared/profiles [post]
319
+// @Security BearerAuth
320
+func (a *Ab) SharedProfiles(c *gin.Context) {
321
+	//AbProfile.fromJson(Map<String, dynamic> json)
322
+	//: guid = json['guid'] ?? '',
323
+	//	name = json['name'] ?? '',
324
+	//	owner = json['owner'] ?? '',
325
+	//	note = json['note'] ?? '',
326
+	//	rule = json['rule'] ?? 0;
327
+	//暂时没必要返回数据,可能是为了共享地址簿
328
+	/*item := map[string]interface{}{
329
+		"guid":  "1",
330
+		"name":  "admin",
331
+		"owner": "admin",
332
+		"note":  "admin11",
333
+		"rule":  0,
334
+	}
335
+	item2 := map[string]interface{}{
336
+		"guid":  "2",
337
+		"name":  "admin2",
338
+		"owner": "admin2",
339
+		"note":  "admin22",
340
+		"rule":  0,
341
+	}
342
+	c.JSON(http.StatusOK, gin.H{
343
+		"total": 2,
344
+		"data":  []interface{}{item, item2},
345
+	})*/
346
+
347
+	c.JSON(http.StatusOK, gin.H{
348
+		"total": 0,
349
+		"data":  nil,
350
+	})
351
+}
352
+
353
+// Peers
354
+// @Tags 地址[Personal]
355
+// @Summary 地址列表
356
+// @Description 地址
357
+// @Accept  json
358
+// @Produce  json
359
+// @Param string body string false  "string valid"
360
+// @Success 200 {object} response.Response
361
+// @Failure 500 {object} response.Response
362
+// @Router /ab/peers [post]
363
+// @Security BearerAuth
364
+func (a *Ab) Peers(c *gin.Context) {
365
+	user := service.AllService.UserService.CurUser(c)
366
+	al := service.AllService.AddressBookService.ListByUserId(user.Id, 1, 1000)
367
+	c.JSON(http.StatusOK, gin.H{
368
+		"total":            al.Total,
369
+		"data":             al.AddressBooks,
370
+		"licensed_devices": 99999,
371
+	})
372
+}
373
+
374
+// PTags
375
+// @Tags 地址[Personal]
376
+// @Summary 标签
377
+// @Description 标签
378
+// @Accept  json
379
+// @Produce  json
380
+// @Param id path string true "id"
381
+// @Success 200 {object} model.TagList
382
+// @Failure 500 {object} response.ErrorResponse
383
+// @Router /ab/tags/{guid} [post]
384
+// @Security BearerAuth
385
+func (a *Ab) PTags(c *gin.Context) {
386
+	user := service.AllService.UserService.CurUser(c)
387
+
388
+	tags := service.AllService.TagService.ListByUserId(user.Id)
389
+	c.JSON(http.StatusOK, tags.Tags)
390
+}
391
+
392
+// PeerAdd
393
+// @Tags 地址[Personal]
394
+// @Summary 添加地址
395
+// @Description 添加地址
396
+// @Accept  json
397
+// @Produce  json
398
+// @Param id path string true "id"
399
+// @Success 200 {string} string
400
+// @Failure 500 {object} response.ErrorResponse
401
+// @Router /ab/peer/add/{guid} [post]
402
+// @Security BearerAuth
403
+func (a *Ab) PeerAdd(c *gin.Context) {
404
+	// forceAlwaysRelay永远是字符串"false",真是坑
405
+	//f := &gin.H{}
406
+	f := &requstform.PersonalAddressBookForm{}
407
+	err := c.ShouldBindJSON(f)
408
+	if err != nil {
409
+		response.Error(c, "参数错误"+err.Error())
410
+		return
411
+	}
412
+	fmt.Println(f)
413
+	u := service.AllService.UserService.CurUser(c)
414
+	f.UserId = u.Id
415
+	ab := f.ToAddressBook()
416
+	err = service.AllService.AddressBookService.AddAddressBook(ab)
417
+	if err != nil {
418
+		response.Error(c, "操作失败")
419
+		return
420
+	}
421
+	c.String(http.StatusOK, "")
422
+}
423
+
424
+// PeerDel
425
+// @Tags 地址[Personal]
426
+// @Summary 删除地址
427
+// @Description 删除地址
428
+// @Accept  json
429
+// @Produce  json
430
+// @Param id path string true "id"
431
+// @Success 200 {string} string
432
+// @Failure 500 {object} response.ErrorResponse
433
+// @Router /ab/peer/add/{guid} [delete]
434
+// @Security BearerAuth
435
+func (a *Ab) PeerDel(c *gin.Context) {
436
+	f := &[]string{}
437
+	err := c.ShouldBind(f)
438
+	if err != nil {
439
+		response.Error(c, "参数错误")
440
+		return
441
+	}
442
+	u := service.AllService.UserService.CurUser(c)
443
+	for _, id := range *f {
444
+		ab := service.AllService.AddressBookService.InfoByUserIdAndId(u.Id, id)
445
+		if ab == nil || ab.RowId == 0 {
446
+			response.Error(c, "参数错误")
447
+			return
448
+		}
449
+		err = service.AllService.AddressBookService.Delete(ab)
450
+		if err != nil {
451
+			response.Error(c, "操作失败")
452
+			return
453
+		}
454
+	}
455
+
456
+	c.String(http.StatusOK, "")
457
+}
458
+
459
+// PeerUpdate
460
+// @Tags 地址[Personal]
461
+// @Summary 更新地址
462
+// @Description 更新地址
463
+// @Accept  json
464
+// @Produce  json
465
+// @Param id path string true "id"
466
+// @Success 200 {string} string
467
+// @Failure 500 {object} response.ErrorResponse
468
+// @Router /ab/peer/update/{guid} [put]
469
+// @Security BearerAuth
470
+func (a *Ab) PeerUpdate(c *gin.Context) {
471
+	//f := &gin.H{}
472
+	f := &requstform.PersonalAddressBookForm{}
473
+	err := c.ShouldBindJSON(f)
474
+	if err != nil {
475
+		response.Error(c, "参数错误")
476
+		return
477
+	}
478
+	fmt.Println(f)
479
+	//return
480
+	u := service.AllService.UserService.CurUser(c)
481
+	ab := service.AllService.AddressBookService.InfoByUserIdAndId(u.Id, f.Id)
482
+	if ab == nil || ab.RowId == 0 {
483
+		response.Error(c, "参数错误")
484
+		return
485
+	}
486
+	nab := f.ToAddressBook()
487
+	nab.RowId = ab.RowId
488
+	err = service.AllService.AddressBookService.Update(nab)
489
+	if err != nil {
490
+		response.Error(c, "操作失败")
491
+		return
492
+	}
493
+	c.String(http.StatusOK, "")
146 494
 }

+ 0 - 13
http/controller/api/ouath.go

@@ -264,16 +264,3 @@ func (o *Oauth) OauthCallback(c *gin.Context) {
264 264
 	c.String(http.StatusInternalServerError, "授权配置错误,请联系管理员")
265 265
 
266 266
 }
267
-
268
-// WebOauthLogin
269
-// @Tags Oauth
270
-// @Summary WebOauthLogin
271
-// @Description WebOauthLogin
272
-// @Accept  json
273
-// @Produce  json
274
-// @Success 200 {string} string
275
-// @Failure 500 {string} string
276
-// @Router /oauth/login [get]
277
-func (o *Oauth) WebOauthLogin(c *gin.Context) {
278
-
279
-}

+ 0 - 31
http/controller/api/user.go

@@ -3,7 +3,6 @@ package api
3 3
 import (
4 4
 	apiResp "Gwen/http/response/api"
5 5
 	"Gwen/service"
6
-	"fmt"
7 6
 	"github.com/gin-gonic/gin"
8 7
 	"net/http"
9 8
 )
@@ -42,33 +41,3 @@ func (u *User) Info(c *gin.Context) {
42 41
 	up := (&apiResp.UserPayload{}).FromUser(user)
43 42
 	c.JSON(http.StatusOK, up)
44 43
 }
45
-
46
-// Personal
47
-// @Tags 用户
48
-// @Summary 个人信息
49
-// @Description 个人信息
50
-// @Accept  json
51
-// @Produce  json
52
-// @Param string body string false  "string valid"
53
-// @Success 200 {object} response.Response
54
-// @Failure 500 {object} response.Response
55
-// @Router /ab/personal [post]
56
-// @Security BearerAuth
57
-func (u *User) Personal(c *gin.Context) {
58
-	//打印全部body
59
-	fmt.Println(c.Request.Body)
60
-
61
-	/**
62
-	guid = json['guid'] ?? '',
63
-	       name = json['name'] ?? '',
64
-	       owner = json['owner'] ?? '',
65
-	       note = json['note'] ?? '',
66
-	       rule = json['rule'] ?? 0;
67
-	*/
68
-	//如果返回了guid,后面的请求会有变化
69
-	c.JSON(http.StatusOK, gin.H{
70
-		//"guid": "123456",
71
-		//"name": "admindddd",
72
-		//"rule": 1,
73
-	})
74
-}

+ 4 - 0
http/controller/web/index.go

@@ -8,6 +8,10 @@ import (
8 8
 type Index struct {
9 9
 }
10 10
 
11
+func (i *Index) Index(c *gin.Context) {
12
+	c.Redirect(302, "/_admin/")
13
+}
14
+
11 15
 func (i *Index) ConfigJs(c *gin.Context) {
12 16
 	apiServer := global.Config.Rustdesk.ApiServer
13 17
 

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

@@ -16,7 +16,7 @@ type AddressBookForm struct {
16 16
 	Tags             []string `json:"tags"`
17 17
 	Hash             string   `json:"hash"`
18 18
 	UserId           uint     `json:"user_id"`
19
-	ForceAlwaysRelay bool     `json:"force_always_relay"`
19
+	ForceAlwaysRelay bool     `json:"forceAlwaysRelay"`
20 20
 	RdpPort          string   `json:"rdp_port"`
21 21
 	RdpUsername      string   `json:"rdp_username"`
22 22
 	Online           bool     `json:"online"`

+ 36 - 0
http/request/api/peer.go

@@ -35,3 +35,39 @@ func (pf *PeerForm) ToPeer() *model.Peer {
35 35
 		Version:  pf.Version,
36 36
 	}
37 37
 }
38
+
39
+// PersonalAddressBookForm 个人地址簿表单
40
+type PersonalAddressBookForm struct {
41
+	model.AddressBook
42
+	ForceAlwaysRelay string `json:"forceAlwaysRelay"`
43
+}
44
+
45
+func (pabf *PersonalAddressBookForm) ToAddressBook() *model.AddressBook {
46
+	return &model.AddressBook{
47
+		RowId:            pabf.RowId,
48
+		Id:               pabf.Id,
49
+		Username:         pabf.Username,
50
+		Password:         pabf.Password,
51
+		Hostname:         pabf.Hostname,
52
+		Alias:            pabf.Alias,
53
+		Platform:         pabf.Platform,
54
+		Tags:             pabf.Tags,
55
+		Hash:             pabf.Hash,
56
+		UserId:           pabf.UserId,
57
+		ForceAlwaysRelay: pabf.ForceAlwaysRelay == "true",
58
+		RdpPort:          pabf.RdpPort,
59
+		RdpUsername:      pabf.RdpUsername,
60
+		Online:           pabf.Online,
61
+		LoginName:        pabf.LoginName,
62
+		SameServer:       pabf.SameServer,
63
+	}
64
+}
65
+
66
+type TagRenameForm struct {
67
+	Old string `json:"old"`
68
+	New string `json:"new"`
69
+}
70
+type TagColorForm struct {
71
+	Name  string `json:"name"`
72
+	Color uint   `json:"color"`
73
+}

+ 10 - 13
http/response/api/peer.go

@@ -59,16 +59,13 @@ func (gpp *GroupPeerPayload) FromAddressBook(a *model.AddressBook, username stri
59 59
 	gpp.UserName = username
60 60
 }
61 61
 
62
-//func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
63
-//	gpp.Id = p.Id
64
-//	gpp.Info = &PeerPayloadInfo{
65
-//		DeviceName: p.Hostname,
66
-//		Os:         p.Os,
67
-//		Username:   p.Username,
68
-//	}
69
-//	gpp.Note = ""
70
-//	if p.User.Id != 0 {
71
-//		//gpp.User = p.User.Username
72
-//		gpp.UserName = p.User.Username
73
-//	}
74
-//}
62
+func (gpp *GroupPeerPayload) FromPeer(p *model.Peer) {
63
+	gpp.Id = p.Id
64
+	gpp.Info = &PeerPayloadInfo{
65
+		DeviceName: p.Hostname,
66
+		Os:         p.Os,
67
+		Username:   p.Username,
68
+	}
69
+	gpp.Note = ""
70
+	gpp.UserName = p.User.Username
71
+}

+ 32 - 1
http/router/api.go

@@ -74,7 +74,38 @@ func ApiInit(g *gin.Engine) {
74 74
 		//更新地址
75 75
 		frg.POST("/ab", ab.UpAb)
76 76
 	}
77
-
77
+	PersonalRoutes(frg)
78 78
 	//访问静态文件
79 79
 	g.StaticFS("/upload", http.Dir(global.Config.Gin.ResourcesPath+"/public/upload"))
80 80
 }
81
+
82
+func PersonalRoutes(frg *gin.RouterGroup) {
83
+	{
84
+		ab := &api.Ab{}
85
+		frg.POST("/ab/personal", ab.Personal)
86
+		//[method:POST] [uri:/api/ab/settings] Request
87
+		frg.POST("/ab/settings", ab.Settings)
88
+		// [method:POST] [uri:/api/ab/shared/profiles?current=1&pageSize=100]
89
+		frg.POST("/ab/shared/profiles", ab.SharedProfiles)
90
+		//[method:POST] [uri:/api/ab/peers?current=1&pageSize=100&ab=1]
91
+		frg.POST("/ab/peers", ab.Peers)
92
+		// [method:POST] [uri:/api/ab/tags/1]
93
+		frg.POST("/ab/tags/:guid", ab.PTags)
94
+		//[method:POST] api/ab/peer/add/1
95
+		frg.POST("/ab/peer/add/:guid", ab.PeerAdd)
96
+		//[method:DELETE] [uri:/api/ab/peer/1]
97
+		frg.DELETE("/ab/peer/:guid", ab.PeerDel)
98
+		//[method:PUT] [uri:/api/ab/peer/update/1]
99
+		frg.PUT("/ab/peer/update/:guid", ab.PeerUpdate)
100
+		//[method:POST] [uri:/api/ab/tag/add/1]
101
+		frg.POST("/ab/tag/add/:guid", ab.TagAdd)
102
+		//[method:PUT] [uri:/api/ab/tag/rename/1]
103
+		frg.PUT("/ab/tag/rename/:guid", ab.TagRename)
104
+		//[method:PUT] [uri:/api/ab/tag/update/1]
105
+		frg.PUT("/ab/tag/update/:guid", ab.TagUpdate)
106
+		//[method:DELETE] [uri:/api/ab/tag/1]
107
+		frg.DELETE("/ab/tag/:guid", ab.TagDel)
108
+
109
+	}
110
+
111
+}

+ 1 - 0
http/router/router.go

@@ -9,6 +9,7 @@ import (
9 9
 
10 10
 func WebInit(g *gin.Engine) {
11 11
 	i := &web.Index{}
12
+	g.GET("/", i.Index)
12 13
 	g.GET("/webclient-config/index.js", i.ConfigJs)
13 14
 	g.StaticFS("/webclient", http.Dir(global.Config.Gin.ResourcesPath+"/web"))
14 15
 	g.StaticFS("/_admin", http.Dir(global.Config.Gin.ResourcesPath+"/admin"))

+ 7 - 1
service/addressBook.go

@@ -9,11 +9,17 @@ import (
9 9
 type AddressBookService struct {
10 10
 }
11 11
 
12
-func (s *AddressBookService) Info(id uint) *model.AddressBook {
12
+func (s *AddressBookService) Info(id string) *model.AddressBook {
13 13
 	p := &model.AddressBook{}
14 14
 	global.DB.Where("id = ?", id).First(p)
15 15
 	return p
16 16
 }
17
+
18
+func (s *AddressBookService) InfoByUserIdAndId(userid uint, id string) *model.AddressBook {
19
+	p := &model.AddressBook{}
20
+	global.DB.Where("user_id = ? and id = ?", userid, id).First(p)
21
+	return p
22
+}
17 23
 func (s *AddressBookService) InfoByRowId(id uint) *model.AddressBook {
18 24
 	p := &model.AddressBook{}
19 25
 	global.DB.Where("row_id = ?", id).First(p)

+ 5 - 0
service/tag.go

@@ -14,6 +14,11 @@ func (s *TagService) Info(id uint) *model.Tag {
14 14
 	global.DB.Where("id = ?", id).First(p)
15 15
 	return p
16 16
 }
17
+func (s *TagService) InfoByUserIdAndName(userid uint, name string) *model.Tag {
18
+	p := &model.Tag{}
19
+	global.DB.Where("user_id = ? and name = ?", userid, name).First(p)
20
+	return p
21
+}
17 22
 
18 23
 func (s *TagService) ListByUserId(userId uint) (res *model.TagList) {
19 24
 	res = s.List(1, 1000, func(tx *gorm.DB) {