From f113719e797b85b03e837ed54af3a80486dc6ac8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 24 Jul 2024 17:23:44 +0800 Subject: [PATCH] :sparkles: Account groups --- .../74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml | 867 ++++++++++-------- .../schema/public.abK9xQ.meta | 2 +- .idea/workspace.xml | 11 +- pkg/internal/database/migrator.go | 2 + pkg/internal/models/account_groups.go | 19 + pkg/internal/services/account_groups.go | 25 + pkg/internal/services/accounts.go | 25 +- pkg/internal/services/auth.go | 12 + 8 files changed, 560 insertions(+), 403 deletions(-) create mode 100644 pkg/internal/models/account_groups.go create mode 100644 pkg/internal/services/account_groups.go diff --git a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml index e3f5756..197b093 100644 --- a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml +++ b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml @@ -3,17 +3,9 @@ mdy - 1||-9223372036854775808|c|G -1||10|c|G -1||10|C|G -1||10|T|G -4||-9223372036854775808|c|G -4||10|c|G -4||10|C|G -4||10|T|G - 10102 + 10192 16.3 - 1719810879 + 1721488981 true ACDT true ACSST false ACST @@ -808,7 +800,7 @@ false Zulu 13474||10|C|G 13474||-9223372036854775808|U|G 13474||10|U|G - 10102 + 10192 37312 postgres @@ -4249,8 +4241,8 @@ false Zulu standard public schema 1 - 10102 - 2024-07-04.15:02:40 + 10192 + 2024-07-24.08:06:15 2200 523 pg_database_owner @@ -4263,21 +4255,21 @@ false Zulu 6233 littlesheep - + bigint|0s - 37385 + 47483 1 1 - 6236 - littlesheep + 10189 + postgres - + bigint|0s - 37354 + 47473 1 1 - 6231 - littlesheep + 10185 + postgres bigint|0s @@ -4287,7 +4279,15 @@ false Zulu 6229 littlesheep - + + bigint|0s + 47423 + 1 + 1 + 10149 + postgres + + bigint|0s 37313 1 @@ -4295,7 +4295,7 @@ false Zulu 6224 littlesheep - + bigint|0s 37474 1 @@ -4303,7 +4303,7 @@ false Zulu 6247 littlesheep - + bigint|0s 47413 1 @@ -4311,7 +4311,7 @@ false Zulu 10006 postgres - + bigint|0s 37324 1 @@ -4319,7 +4319,7 @@ false Zulu 6227 littlesheep - + bigint|0s 37526 1 @@ -4327,7 +4327,7 @@ false Zulu 6259 littlesheep - + bigint|0s 47120 1 @@ -4335,7 +4335,7 @@ false Zulu 8941 postgres - + bigint|0s 37459 1 @@ -4343,7 +4343,7 @@ false Zulu 6245 littlesheep - + bigint|0s 37509 1 @@ -4351,7 +4351,7 @@ false Zulu 6251 littlesheep - + bigint|0s 37489 1 @@ -4359,7 +4359,7 @@ false Zulu 6249 littlesheep - + bigint|0s 37562 1 @@ -4367,7 +4367,7 @@ false Zulu 6430 littlesheep - + bigint|0s 37551 1 @@ -4375,7 +4375,7 @@ false Zulu 6427 littlesheep - + bigint|0s 47321 1 @@ -4383,7 +4383,7 @@ false Zulu 9536 postgres - + bigint|0s 37403 1 @@ -4391,109 +4391,115 @@ false Zulu 6238 littlesheep - +
3737062332littlesheep
- - 37386 - 6236 +
+ 47484 + 101892 - littlesheep + postgres
- - 37355 - 6231 +
+ 47474 + 101892 - littlesheep + postgres
- +
3734095482littlesheep
- +
+ 47424 + 10149 + 2 + postgres +
+ 37314 - 7432 + 101202littlesheep
- +
3747562472littlesheep
- +
47414100062postgres
- +
3732562272littlesheep
- +
3752762592littlesheep
- +
4712189452postgres
- +
3746095252littlesheep
- +
3751070112littlesheep
- +
37490 - 8944 + 101882littlesheep
- +
3756364302littlesheep
- +
3755264302littlesheep
- +
4732295492postgres
- +
3740462382littlesheep
- + bigint|0s nextval('passport_account_contacts_id_seq'::regclass) 1 @@ -4502,68 +4508,68 @@ false Zulu 37369 20 - + timestamp with time zone|0s 2 6233 1184 - + timestamp with time zone|0s 3 6233 1184 - + timestamp with time zone|0s 4 6233 1184 - + smallint|0s 5 6233 21 - + text|0s 6 6233 25 - + boolean|0s 7 6233 16 - + boolean|0s 8 6233 16 - + timestamp with time zone|0s 9 6233 1184 - + bigint|0s 10 6233 20 - + account_id 37378 6233 1 37314 - + id 1 37376 @@ -4572,7 +4578,7 @@ false Zulu 1 403 - + content 37383 6234 @@ -4582,193 +4588,156 @@ false Zulu 100 pg_catalog - + deleted_at 37384 6235 403 - + 1 37377 1 6233 37376 - + bigint|0s - nextval('passport_account_friendships_id_seq'::regclass) + nextval('passport_account_group_members_id_seq'::regclass) 1 1 - 6236 - 37385 + 10189 + 47483 20 - + timestamp with time zone|0s 2 - 6236 + 10189 1184 - + timestamp with time zone|0s 3 - 6236 + 10189 1184 - + timestamp with time zone|0s 4 - 6236 + 10189 1184 - + bigint|0s 5 - 6236 + 10189 20 - + bigint|0s 6 - 6236 + 10189 20 - - bigint|0s - 7 - 6236 - 20 - - - smallint|0s - 8 - 6236 - 21 - - + account_id - 37392 - 6236 + 47490 + 10189 1 37314 - - related_id - 37397 - 6236 + + group_id + 47495 + 10189 1 - 37314 + 47474 - + id 1 - 37390 + 47488 1 - 6236 + 10189 1 403 - + deleted_at - 37402 - 6237 + 47500 + 10190 403 - + 1 - 37391 + 47489 1 - 6236 - 37390 + 10189 + 47488 - + bigint|0s - nextval('passport_account_pages_id_seq'::regclass) + nextval('passport_account_groups_id_seq'::regclass) 1 1 - 6231 - 37354 + 10185 + 47473 20 - + timestamp with time zone|0s 2 - 6231 + 10185 1184 - + timestamp with time zone|0s 3 - 6231 + 10185 1184 - + timestamp with time zone|0s 4 - 6231 + 10185 1184 - + text|0s 5 - 6231 + 10185 25 - - text|0s - 6 - 6231 - 25 - - - text|0s - 7 - 6231 - 25 - - + jsonb|0s - 8 - 6231 + 6 + 10185 3802 - - bigint|0s - 9 - 6231 - 20 - - - account_id - 37363 - 6231 - 1 - 37314 - - + id 1 - 37361 + 47480 1 - 6231 + 10185 1 403 - + deleted_at - 37368 - 6232 + 47482 + 10186 403 - + 1 - 37362 + 47481 1 - 6231 - 37361 + 10185 + 47480 - + bigint|0s nextval('passport_account_profiles_id_seq'::regclass) 1 @@ -4777,68 +4746,68 @@ false Zulu 37339 20 - + timestamp with time zone|0s 2 6229 1184 - + timestamp with time zone|0s 3 6229 1184 - + timestamp with time zone|0s 4 6229 1184 - + text|0s 5 6229 25 - + text|0s 6 6229 25 - + bigint|0s 7 6229 20 - + timestamp with time zone|0s 8 6229 1184 - + bigint|0s 9 6229 20 - + timestamp with time zone|0s 10 9548 1184 - + account_id 37348 6229 1 37314 - + id 1 37346 @@ -4847,20 +4816,107 @@ false Zulu 1 403 - + deleted_at 37353 6230 403 - + 1 37347 1 6229 37346 - + + bigint|0s + nextval('passport_account_relationships_id_seq'::regclass) + 1 + 1 + 10149 + 47423 + 20 + + + timestamp with time zone|0s + 2 + 10149 + 1184 + + + timestamp with time zone|0s + 3 + 10149 + 1184 + + + timestamp with time zone|0s + 4 + 10149 + 1184 + + + bigint|0s + 5 + 10149 + 20 + + + bigint|0s + 6 + 10149 + 20 + + + smallint|0s + 7 + 10149 + 21 + + + jsonb|0s + 8 + 10149 + 3802 + + + account_id + 47437 + 10149 + 1 + 37314 + + + related_id + 47432 + 10149 + 1 + 37314 + + + id + 1 + 47430 + 1 + 10149 + 1 + 403 + + + deleted_at + 47442 + 10150 + 403 + + + 1 + 47431 + 1 + 10149 + 47430 + + bigint|0s nextval('passport_accounts_id_seq'::regclass) 1 @@ -4869,73 +4925,79 @@ false Zulu 37313 20 - + timestamp with time zone|0s 2 6224 1184 - + timestamp with time zone|0s 3 6224 1184 - + timestamp with time zone|0s 4 6224 1184 - + text|0s 5 6224 25 - + text|0s 6 6224 25 - + text|0s 7 6224 25 - + timestamp with time zone|0s 10 6224 1184 - + bigint|0s 11 6224 20 - + jsonb|0s 12 7177 3802 - + bigint|0s 13 7431 20 - + bigint|0s 14 7432 20 - + + timestamp with time zone|0s + 15 + 10120 + 1184 + + id 1 37320 @@ -4944,7 +5006,7 @@ false Zulu 1 403 - + name 37322 6225 @@ -4954,20 +5016,20 @@ false Zulu 100 pg_catalog - + deleted_at 37323 6226 403 - + 1 37321 1 6224 37320 - + bigint|0s nextval('passport_action_events_id_seq'::regclass) 1 @@ -4976,68 +5038,68 @@ false Zulu 37474 20 - + timestamp with time zone|0s 2 6247 1184 - + timestamp with time zone|0s 3 6247 1184 - + timestamp with time zone|0s 4 6247 1184 - + text|0s 5 6247 25 - + text|0s 6 6247 25 - + text|0s 7 6247 25 - + text|0s 8 6247 25 - + text|0s 9 6247 25 - + bigint|0s 10 6247 20 - + account_id 37483 6247 1 37314 - + id 1 37481 @@ -5046,20 +5108,20 @@ false Zulu 1 403 - + deleted_at 37488 6248 403 - + 1 37482 1 6247 37481 - + bigint|0s nextval('passport_audit_records_id_seq'::regclass) 1 @@ -5068,55 +5130,55 @@ false Zulu 47413 20 - + timestamp with time zone|0s 2 10006 1184 - + timestamp with time zone|0s 3 10006 1184 - + timestamp with time zone|0s 4 10006 1184 - + text|0s 5 10006 25 - + jsonb|0s 6 10006 3802 - + text|0s 7 10006 25 - + text|0s 8 10006 25 - + bigint|0s 9 10006 20 - + id 1 47420 @@ -5125,20 +5187,20 @@ false Zulu 1 403 - + deleted_at 47422 10007 403 - + 1 47421 1 10006 47420 - + bigint|0s nextval('passport_auth_factors_id_seq'::regclass) 1 @@ -5147,56 +5209,56 @@ false Zulu 37324 20 - + timestamp with time zone|0s 2 6227 1184 - + timestamp with time zone|0s 3 6227 1184 - + timestamp with time zone|0s 4 6227 1184 - + smallint|0s 5 6227 21 - + text|0s 6 6227 25 - + jsonb|0s 7 6227 3802 - + bigint|0s 8 6227 20 - + account_id 37333 6227 1 37314 - + id 1 37331 @@ -5205,20 +5267,20 @@ false Zulu 1 403 - + deleted_at 37338 6228 403 - + 1 37332 1 6227 37331 - + bigint|0s nextval('passport_auth_tickets_id_seq'::regclass) 1 @@ -5227,136 +5289,136 @@ false Zulu 37526 20 - + timestamp with time zone|0s 2 6259 1184 - + timestamp with time zone|0s 3 6259 1184 - + timestamp with time zone|0s 4 6259 1184 - + text|0s 5 6259 25 - + text|0s 6 6259 25 - + text|0s 7 6259 25 - + boolean|0s 8 6259 16 - + boolean|0s 9 6259 16 - + jsonb|0s 10 6259 3802 - + jsonb|0s 11 6259 3802 - + text|0s 12 6259 25 - + text|0s 13 6259 25 - + text|0s 14 6259 25 - + timestamp with time zone|0s 15 6259 1184 - + timestamp with time zone|0s 16 6259 1184 - + timestamp with time zone|0s 17 6259 1184 - + bigint|0s 18 6259 20 - + bigint|0s 19 6259 20 - + client_id 37540 6259 1 37404 - + account_id 37535 6259 1 37314 - + account_id 37546 6301 1 37314 - + id 1 37533 @@ -5365,20 +5427,20 @@ false Zulu 1 403 - + deleted_at 37545 6260 403 - + 1 37534 1 6259 37533 - + bigint|0s nextval('passport_badges_id_seq'::regclass) 1 @@ -5387,62 +5449,62 @@ false Zulu 47120 20 - + timestamp with time zone|0s 2 8941 1184 - + timestamp with time zone|0s 3 8941 1184 - + timestamp with time zone|0s 4 8941 1184 - + text|0s 5 8941 25 - + text|0s 6 8941 25 - + text|0s 7 8941 25 - + bigint|0s 8 8941 20 - + jsonb|0s 9 8945 3802 - + account_id 47129 8941 1 37314 - + id 1 47127 @@ -5451,20 +5513,20 @@ false Zulu 1 403 - + deleted_at 47134 8942 403 - + 1 47128 1 8941 47127 - + bigint|0s nextval('passport_magic_tokens_id_seq'::regclass) 1 @@ -5473,62 +5535,62 @@ false Zulu 37459 20 - + timestamp with time zone|0s 2 6245 1184 - + timestamp with time zone|0s 3 6245 1184 - + timestamp with time zone|0s 4 6245 1184 - + text|0s 5 6245 25 - + smallint|0s 6 6245 21 - + bigint|0s 7 6245 20 - + timestamp with time zone|0s 8 6245 1184 - + bigint|0s 9 9525 20 - + assign_to 37468 6245 1 37314 - + id 1 37466 @@ -5537,20 +5599,20 @@ false Zulu 1 403 - + deleted_at 37473 6246 403 - + 1 37467 1 6245 37466 - + bigint|0s nextval('passport_notification_subscribers_id_seq'::regclass) 1 @@ -5559,62 +5621,62 @@ false Zulu 37509 20 - + timestamp with time zone|0s 2 6251 1184 - + timestamp with time zone|0s 3 6251 1184 - + timestamp with time zone|0s 4 6251 1184 - + text|0s 5 6251 25 - + text|0s 6 6251 25 - + text|0s 7 6251 25 - + bigint|0s 8 6251 20 - + text|0s 9 7011 25 - + account_id 37518 6251 1 37314 - + id 1 37516 @@ -5623,7 +5685,7 @@ false Zulu 1 403 - + device_id 37523 6252 @@ -5633,20 +5695,20 @@ false Zulu 100 pg_catalog - + deleted_at 37524 6253 403 - + 1 37517 1 6251 37516 - + bigint|0s nextval('passport_notifications_id_seq'::regclass) 1 @@ -5655,93 +5717,135 @@ false Zulu 37489 20 - + timestamp with time zone|0s 2 6249 1184 - + timestamp with time zone|0s 3 6249 1184 - + timestamp with time zone|0s 4 6249 1184 - + text|0s 5 6249 25 - + text|0s 6 6249 25 - + jsonb|0s 7 6249 3802 - + boolean|0s 8 6249 16 - + timestamp with time zone|0s 9 6249 1184 - + bigint|0s 10 6249 20 - + bigint|0s 11 6249 20 - + text|0s 12 8943 25 - + jsonb|0s 13 8944 3802 - + + text|0s + 14 + 10152 + 25 + + + text|0s + 15 + 10153 + 25 + + + text|0s + 16 + 10154 + 25 + + + text|0s + 17 + 10155 + 25 + + + bigint|0s + 18 + 10156 + 20 + + + text|0s + 19 + 10187 + 25 + + + text|0s + 20 + 10188 + 25 + + sender_id 37498 6249 1 37404 - + recipient_id 37503 6249 1 37314 - + id 1 37496 @@ -5750,20 +5854,20 @@ false Zulu 1 403 - + deleted_at 37508 6250 403 - + 1 37497 1 6249 37496 - + bigint|0s nextval('passport_realm_members_id_seq'::regclass) 1 @@ -5772,64 +5876,71 @@ false Zulu 37562 20 - + timestamp with time zone|0s 2 6430 1184 - + timestamp with time zone|0s 3 6430 1184 - + timestamp with time zone|0s 4 6430 1184 - + bigint|0s 5 6430 20 - + bigint|0s 6 6430 20 - + bigint|0s 7 6430 20 - + realm_id 37574 6430 1 37552 - + + account_id + 47443 + 10151 + 1 + 37314 + + account_id 38570 7010 1 37314 - + account_id 37569 6430 1 37314 - + id 1 37567 @@ -5838,20 +5949,20 @@ false Zulu 1 403 - + deleted_at 37579 6431 403 - + 1 37568 1 6430 37567 - + bigint|0s nextval('passport_realms_id_seq'::regclass) 1 @@ -5860,61 +5971,61 @@ false Zulu 37551 20 - + timestamp with time zone|0s 2 6427 1184 - + timestamp with time zone|0s 3 6427 1184 - + timestamp with time zone|0s 4 6427 1184 - + text|0s 5 6427 25 - + text|0s 6 6427 25 - + text|0s 7 6427 25 - + boolean|0s 8 6427 16 - + boolean|0s 9 6427 16 - + bigint|0s 10 6427 20 - + id 1 37558 @@ -5923,7 +6034,7 @@ false Zulu 1 403 - + alias 37561 6429 @@ -5933,20 +6044,20 @@ false Zulu 100 pg_catalog - + deleted_at 37560 6428 403 - + 1 37559 1 6427 37558 - + bigint|0s nextval('passport_statuses_id_seq'::regclass) 1 @@ -5955,74 +6066,74 @@ false Zulu 47321 20 - + timestamp with time zone|0s 2 9536 1184 - + timestamp with time zone|0s 3 9536 1184 - + timestamp with time zone|0s 4 9536 1184 - + text|0s 5 9536 25 - + text|0s 6 9536 25 - + smallint|0s 7 9536 21 - + boolean|0s 8 9536 16 - + boolean|0s 9 9536 16 - + bigint|0s 10 9536 20 - + timestamp with time zone|0s 11 9549 1184 - + account_id 47330 9536 1 37314 - + id 1 47328 @@ -6031,20 +6142,20 @@ false Zulu 1 403 - + deleted_at 47335 9537 403 - + 1 47329 1 9536 47328 - + bigint|0s nextval('passport_third_clients_id_seq'::regclass) 1 @@ -6053,80 +6164,80 @@ false Zulu 37403 20 - + timestamp with time zone|0s 2 6238 1184 - + timestamp with time zone|0s 3 6238 1184 - + timestamp with time zone|0s 4 6238 1184 - + text|0s 5 6238 25 - + text|0s 6 6238 25 - + text|0s 7 6238 25 - + text|0s 8 6238 25 - + jsonb|0s 9 6238 3802 - + jsonb|0s 10 6238 3802 - + boolean|0s 11 6238 16 - + bigint|0s 12 6238 20 - + account_id 37412 6238 1 37314 - + id 1 37410 @@ -6135,7 +6246,7 @@ false Zulu 1 403 - + alias 37417 6239 @@ -6145,13 +6256,13 @@ false Zulu 100 pg_catalog - + deleted_at 37418 6240 403 - + 1 37411 1 diff --git a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta index f65899d..b6a23bb 100644 --- a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta +++ b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta @@ -1,2 +1,2 @@ #n:public -! [10102, 0, null, null, -2147483648, -2147483648] +! [10192, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 91aea13..db7787f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,7 +4,16 @@