Browse Source

Новое новое начало

Vadim 4 months ago
parent
commit
f3c9bd7027

+ 57 - 24
src/api/api.ts

@@ -24,9 +24,8 @@ class authApi {
   POST_ConfirmRegistration = {
     req: z.object({
       password: z.string(),
-      name: z.string(),
       transactionId: z.string().uuid(),
-      confirmPin: z.number().min(1000).max(9999),
+      confirmPin: z.string(),
     }),
     res: z.discriminatedUnion("code", [
       z.object({
@@ -112,42 +111,76 @@ class authApi {
 }
 export const AuthApi = new authApi();
 
-class eventManagementApi {
-  POST_Event = {
-    req: z.object({
-      localName: z.string(),
-      timezone: z.string(),
-      dates: z.array(z.string()),
-    }),
+class partEntitiesApi {
+  GET_PartEntities = {
     res: z.object({
       code: z.enum(["success"]),
-      eventId: z.string().uuid(),
+      partEntities: z.array(
+        z.object({ peId: z.string().uuid(), name: z.string() }),
+      ),
     }),
   };
 
-  GET_Event = {
-    req: z.object({ eventId: z.string().uuid() }).strict(),
+  FieldTypeCode = z.enum(["text", "number", "checkbox", "audio"]);
+  Validator = z.discriminatedUnion("fieldType", [
+    z.object({
+      fieldType: z.literal("text"),
+      code: z.enum(["max", "min"]),
+      name: z.string(),
+      value: z.string(),
+    }),
+    z.object({
+      fieldType: z.literal("number"),
+      code: z.enum(["max", "min"]),
+      name: z.string(),
+      value: z.string(),
+    }),
+    z.object({
+      fieldType: z.literal("checkbox"),
+      code: z.literal("required"),
+      name: z.string(),
+      value: z.string(),
+    }),
+  ]);
+
+  CustomField = z.object({
+    fieldId: z.string().uuid(),
+    title: z.string(),
+    typeCode: this.FieldTypeCode,
+    options: z.array(z.string()),
+    mask: z.string(),
+    validators: z.array(this.Validator),
+  });
+
+  GET_PeCreateTypeData = {
     res: z.object({
       code: z.enum(["success"]),
-      event: z.object({
-        eventId: z.string().uuid(),
-        localName: z.string(),
-        timezone: z.string(),
-        dates: z.array(z.string().datetime()),
+      peType: z.object({
+        peTypeId: z.string().uuid(),
+        code: z.string(),
+        fields: z.array(this.CustomField),
       }),
     }),
   };
 
-  // activity
-  POST_Activity = {
+  GET_PartEntity = {
     req: z.object({
-      eventId: z.string().uuid(),
-      localName: z.string(),
+      peId: z.string().uuid(),
     }),
     res: z.object({
-      code: z.enum(["success"]),
-      activityId: z.string().uuid(),
+      peId: z.string().uuid(),
+      name: z.string(),
+      members: z.array(
+        z.object({
+          memberId: z.string(),
+          userId: z.string().uuid(),
+          email: z.string().email(),
+          firstName: z.string(),
+          lastName: z.string(),
+          patronymic: z.string(),
+        }),
+      ),
     }),
   };
 }
-export const EventsManagementApi = new eventManagementApi();
+export const PartEntitiesApi = new partEntitiesApi();

+ 123 - 102
src/db/db-schema.ts

@@ -1,121 +1,132 @@
 import { z } from "zod";
 
 const DbSchema = {
-  ev: {
-    events: {
-      eventId: z.string().uuid(),
-      localName: z.string(),
-      timezone: z.string(),
-      companyId: z.string().uuid(),
-      eventTypeId: z.string(),
+  usr: {
+    users: {
+      userId: z.string().uuid(),
+      email: z.string().email(),
+      password: z.string(),
+      firstName: z.string(),
+      lastName: z.string(),
+      patronymic: z.string().nullable(),
+      wrongPassTries: z.number().int().default(0),
     },
-    eventTypes: {
-      eventTypeId: z.string(),
+    roles: {
+      roleId: z.string().uuid(),
       name: z.string(),
+      eventId: z.string().uuid().nullable(),
+      eventTypeId: z.string().uuid().nullable(),
+      isSystem: z.boolean().nullable(),
     },
-    eventDates: {
-      eventId: z.string().uuid(),
-      date: z.string().datetime(),
+    groups: {
+      groupId: z.string().uuid(),
+      name: z.string(),
     },
-    eventLocations: {
-      eventId: z.string().uuid(),
-      locationId: z.string().uuid(),
+    roleGroups: {
+      roleId: z.string().uuid(),
+      groupId: z.string().uuid(),
     },
-    locations: {
-      locationId: z.string().uuid(),
+    perms: {
+      permId: z.string().uuid(),
+      code: z.string(),
       name: z.string(),
-      eventId: z.string().uuid(),
+      objId: z.string().uuid(),
     },
-    areas: {
-      areaId: z.string().uuid(),
+    objects: {
+      objId: z.string().uuid(),
+      code: z.string(),
       name: z.string(),
-      locationId: z.string().uuid(),
-      parentId: z.string().uuid().nullable(),
+      description: z.string(),
     },
-    programPoints: {
-      programPointId: z.string().uuid(),
-      name: z.string().min(1),
-      startDate: z.string().datetime(),
-      endDate: z.string().datetime(),
-      eventId: z.string().uuid(),
-      areaId: z.string().uuid().nullable(),
-      blockId: z.string(),
-      isInternal: z.boolean(),
+    groupPerms: {
+      groupId: z.string().uuid(),
+      permId: z.string().uuid(),
+    },
+    userRoles: {
+      roleId: z.string().uuid(),
+      userId: z.string().uuid(),
+      eventId: z.string().uuid().nullable(),
     },
-  },
-
-  usr: {
     confirmPins: {
       transactionId: z.string().uuid(),
       email: z.string().email(),
-      confirmPin: z.number().min(1000).max(9999),
+      confirmPin: z.string(),
       createTime: z.string().datetime(),
-      wrongPinTries: z.number(),
+      wrongPinTries: z.number().int().default(0),
     },
-
     userRefreshTokens: {
       tokenId: z.string().uuid(),
-      refreshToken: z.string(),
       userId: z.string().uuid(),
+      refreshToken: z.string(),
+      rotDate: z.string().datetime(),
     },
-    users: {
-      userId: z.string().uuid(),
-      email: z.string().email(),
-      name: z.string(),
-      password: z.string(),
-      wrongPassTries: z.number(),
-    },
-
-    // roles
-    roles: {
-      roleId: z.string().uuid(),
-      name: z.string(),
+  },
+  ev: {
+    events: {
       eventId: z.string().uuid(),
-      eventType: z.string(),
-      isSystem: z.boolean(),
+      code: z.string(),
+      privateName: z.string(),
+      publicName: z.string(),
+      timezone: z.string(),
+      eventTypeId: z.string().uuid(),
+      ownerId: z.string().uuid(),
     },
-    userRoles: {
-      roleId: z.string().uuid(),
-      userId: z.string().uuid(),
+    eventTypes: {
+      eventTypeId: z.string().uuid(),
+      code: z.string(),
+      name: z.string(),
     },
-    roleGroups: {
-      roleId: z.string().uuid(),
-      groupId: z.string().uuid(),
+    eventDates: {
+      evDateId: z.string().uuid(),
+      eventId: z.string().uuid(),
+      date: z.string().datetime(),
     },
-    groups: {
-      groupId: z.string().uuid(),
+    locations: {
+      locationId: z.string().uuid(),
       name: z.string(),
+      eventId: z.string().uuid(),
     },
-    groupPerms: {
-      groupId: z.string().uuid(),
-      permId: z.string().uuid(),
+    areas: {
+      areaId: z.string().uuid(),
+      name: z.string(),
+      locationId: z.string().uuid(),
+      parentId: z.string().uuid().nullable(),
     },
-    perms: {
-      permId: z.string().uuid(),
+    programBlocks: {
+      blockId: z.string().uuid(),
       name: z.string(),
-      objId: z.string().uuid(),
+      eventId: z.string().uuid(),
     },
-    objects: {
-      objId: z.string().uuid(),
+    programPoints: {
+      pointId: z.string().uuid(),
       name: z.string(),
+      dateStart: z.string().datetime(),
+      dateEnd: z.string().datetime(),
+      eventId: z.string().uuid(),
+      areaId: z.string().uuid().nullable(),
+      blockId: z.string().uuid().nullable(),
+      isInternal: z.boolean().nullable(),
     },
   },
-
   act: {
-    activities: {
-      activityId: z.string().uuid(),
+    activityCategories: {
+      categoryId: z.string().uuid(),
       name: z.string(),
       eventId: z.string().uuid(),
     },
-    activityRegs: {
-      activityRegId: z.string().uuid(),
-      activityId: z.string().uuid(),
-      peId: z.string().uuid(),
-    },
     peTypes: {
       peTypeId: z.string().uuid(),
+      code: z.string(),
       name: z.string(),
     },
+    activities: {
+      activityId: z.string().uuid(),
+      privateName: z.string(),
+      publicName: z.string(),
+      eventId: z.string().uuid(),
+      categoryId: z.string().uuid().nullable(),
+      blockId: z.string().uuid().nullable(),
+    },
     activityPeTypes: {
       activityId: z.string().uuid(),
       peTypeId: z.string().uuid(),
@@ -128,45 +139,55 @@ const DbSchema = {
     },
     peMembers: {
       peMemberId: z.string().uuid(),
-      peId: z.string().uuid(),
       userId: z.string().uuid(),
-    },
-    // fields
-    fieldValidators: {
-      validatorId: z.string(),
-      name: z.string(),
-      fieldTypeId: z.string(),
-    },
-    fieldTypes: {
-      fieldTypeId: z.string(),
-      name: z.string(),
-    },
-    customFieldDefinitions: {
-      fieldId: z.string().uuid(),
-      name: z.string(),
-      fieldTypeId: z.string(),
-      validatorId: z.string().nullable(),
-      validatorValue: z.string().nullable(),
-      options: z.string().nullable(),
-      isRequired: z.boolean(),
+      peId: z.string().uuid(),
     },
     activityRegFormFields: {
       activityId: z.string().uuid(),
-      fieldId: z.string().uuid(),
+      fieldDefinitionId: z.string().uuid(),
+    },
+    activityRegs: {
+      activityRegId: z.string().uuid(),
+      activityId: z.string().uuid(),
+      peId: z.string().uuid(),
     },
     arFieldValues: {
       activityRegId: z.string().uuid(),
-      fieldId: z.string().uuid(),
-      value: z.string(),
+      fieldDefinitionId: z.string().uuid(),
+      value: z.string().nullable(),
     },
-    pe_form_fields: {
+    peFormFields: {
       peTypeId: z.string().uuid(),
-      fieldId: z.string().uuid(),
+      fieldDefinitionId: z.string().uuid(),
     },
     peFieldValues: {
       peId: z.string().uuid(),
+      fieldDefinitionId: z.string().uuid(),
+      value: z.string().nullable(),
+    },
+  },
+  cf: {
+    fieldTypes: {
+      fieldTypeId: z.string().uuid(),
+      code: z.string(),
+    },
+    fieldValidators: {
+      validatorId: z.string().uuid(),
+      code: z.string(),
+      name: z.string(),
+      fieldTypeId: z.string().uuid(),
+    },
+    customFieldDefinitions: {
+      fieldId: z.string().uuid(),
+      fieldTypeId: z.string().uuid(),
+      title: z.string(),
+      mask: z.string().nullable(),
+      options: z.string().nullable(),
+    },
+    customFieldValidators: {
       fieldId: z.string().uuid(),
-      value: z.string(),
+      validatorId: z.string().uuid(),
+      param: z.string().nullable(),
     },
   },
 };

+ 1 - 1
src/db/db-service.ts

@@ -59,7 +59,7 @@ class DbService {
           // если нет столбца
           if (!foundColumn)
             throw Error(
-              `Несоответствие схемы БД: схема ${schema}, таблица ${table}, столбец ${column}`,
+              `Несоответствие схемы БД: схема ${schema}, таблица ${table}, столбец ${column}.`,
             );
         }
       }

+ 3 - 17
src/main.ts

@@ -37,29 +37,15 @@ app.use((req, res, next) => {
 logger.info("Импорт роутеров...");
 
 // роутеры
-import authMiddleware from "./middlewares/auth-middleware.js";
+// import authMiddleware from "./middlewares/auth-middleware.js";
 
 // users-management
 import authRouter from "./modules/users/auth/routers/auth-router.js";
 app.use("/api/auth/", authRouter);
 
 // events-management
-import EventsRouter from "./modules/events-management/events-router.js";
-app.use("/api/events-management/", authMiddleware(), EventsRouter);
-
-// companies-management
-import CompaniesRouter from "./modules/companies-management/companies-router.js";
-app.use("/api/companies-management/", authMiddleware(), CompaniesRouter);
-
-// locations-management
-import LocationsRouter from "./modules/locations-management/locations-router.js";
-app.use("/api/locations-management/", authMiddleware(), LocationsRouter);
-
-// tasks-management
-import TasksRouter from "./modules/tasks-management/tasks-router.js";
-app.use("/api/tasks-management/", authMiddleware(), TasksRouter);
-import TaskBlocksRouter from "./modules/tasks-management/task-blocks-router.js";
-app.use("/api/tasks-management/", authMiddleware(), TaskBlocksRouter);
+// import EventsRouter from "./modules/management/events-router.js";
+// app.use("/api/events-management/", authMiddleware(), EventsRouter);
 
 // import sessionRouter from "./modules/user/routers/session-router.js";
 // app.use("/api/session/", sessionRouter);

+ 142 - 142
src/modules/management/event/event-controller.ts

@@ -1,142 +1,142 @@
-// db
-import { selPool, updPool } from "#db";
-import { DbSchema } from "#db-schema";
-import { sql } from "slonik";
-
-// api
-import { EventsManagementApi } from "#api";
-
-// error
-import { ApiError } from "#exceptions/api-error.js";
-
-// // dayjs
-// import dayjs from "dayjs";
-// import utc from "dayjs/plugin/utc.js";
-// dayjs.extend(utc);
-// import timezone from "dayjs/plugin/timezone.js";
-// dayjs.extend(timezone);
-
-// other
-import { z } from "zod";
-import { Request, Response } from "express";
-
-import { v7 as uuidv7 } from "uuid";
-// import { logger } from "#logger";
-import { UserUtils } from "#utils/user-utils.js";
-import { RouterUtils } from "#utils/router-utils.js";
-import { PermService } from "#modules/users/auth/services/perms-service.js";
-
-class eventController {
-  async createEvent(req: Request, res: Response) {
-    // валидация запроса
-    const { localName, dates, timezone } =
-      EventsManagementApi.POST_Event.req.parse(req.body);
-
-    const userId = UserUtils.getUserFromReq(req).userId;
-
-    await PermService.checkObjPerm(userId, "", "event", "CREATE"); // TODO: Решить что делать с ивентом
-
-    const eventId = uuidv7();
-
-    // создаём ивент
-    await updPool.query(
-      sql.unsafe`
-      insert into ev.events 
-        (event_id, local_name, timezone) 
-      values 
-        (${eventId}, ${localName}, ${timezone})`,
-    );
-
-    // вставляем даты ивента
-    for (const date of dates) {
-      await updPool.query(
-        sql.unsafe`
-        insert into ev.event_dates 
-          (event_id, date) 
-        values 
-          (${eventId}, ${date})`,
-      );
-    }
-
-    RouterUtils.validAndSendResponse(EventsManagementApi.POST_Event.res, res, {
-      code: "success",
-      eventId: eventId,
-    });
-  }
-  async getEvent(req: Request, res: Response) {
-    // валидация запроса
-    const { eventId } = EventsManagementApi.GET_Event.req.parse(req.params);
-    const userId = UserUtils.getUserFromReq(req).userId;
-
-    await PermService.checkObjPerm(userId, eventId, "event", "READ");
-
-    const event = await selPool.maybeOne(
-      sql.type(
-        z.object({
-          eventId: DbSchema.ev.events.eventId,
-          localName: DbSchema.ev.events.localName,
-          timezone: DbSchema.ev.events.timezone,
-          dates: z.array(DbSchema.ev.eventDates.date),
-        }),
-      )`
-            select
-              e.event_id as "eventId",
-              e.local_name as "localName",
-              e.timezone,
-              COALESCE(ARRAY_REMOVE(ARRAY_AGG(ed."date"), NULL), '{}') AS dates
-            from
-              ev.events e
-            left join ev.event_dates ed on
-              e.event_id = ed.event_id
-            where
-              e.event_id = ${eventId}
-            group by
-              e.event_id,
-              e.local_name,
-              e.timezone;
-          `,
-    );
-    if (!event) throw ApiError.BadRequest("EventNotFound", "Ивент не найден");
-
-    RouterUtils.validAndSendResponse(EventsManagementApi.GET_Event.res, res, {
-      code: "success",
-      event: event,
-    });
-  }
-  async updateEvent(req: Request, res: Response) {}
-  async deleteEvent(req: Request, res: Response) {}
-  async createActivity(req: Request, res: Response) {
-    // валидация запроса
-    const { eventId, localName } = EventsManagementApi.POST_Activity.req.parse(
-      req.body,
-    );
-
-    const userId = UserUtils.getUserFromReq(req).userId;
-
-    await PermService.checkObjPerm(userId, eventId, "activity", "CREATE");
-
-    const activityId = uuidv7();
-
-    // создаём активность
-    await updPool.query(
-      sql.unsafe`
-      insert into ev.activities 
-        (activity_id, event_id, local_name) 
-      values 
-        (${activityId}, ${eventId}, ${localName})`,
-    );
-
-    RouterUtils.validAndSendResponse(
-      EventsManagementApi.POST_Activity.res,
-      res,
-      {
-        code: "success",
-        activityId: activityId,
-      },
-    );
-  }
-  async getActivity(req: Request, res: Response) {}
-  async updateActivity(req: Request, res: Response) {}
-  async deleteActivity(req: Request, res: Response) {}
-}
-export const EventController = new eventController();
+// // db
+// import { selPool, updPool } from "#db";
+// import { DbSchema } from "#db-schema";
+// import { sql } from "slonik";
+
+// // api
+// import { EventsManagementApi } from "#api";
+
+// // error
+// import { ApiError } from "#exceptions/api-error.js";
+
+// // // dayjs
+// // import dayjs from "dayjs";
+// // import utc from "dayjs/plugin/utc.js";
+// // dayjs.extend(utc);
+// // import timezone from "dayjs/plugin/timezone.js";
+// // dayjs.extend(timezone);
+
+// // other
+// import { z } from "zod";
+// import { Request, Response } from "express";
+
+// import { v7 as uuidv7 } from "uuid";
+// // import { logger } from "#logger";
+// import { UserUtils } from "#utils/user-utils.js";
+// import { RouterUtils } from "#utils/router-utils.js";
+// import { PermService } from "#modules/users/auth/services/perms-service.js";
+
+// class eventController {
+//   async createEvent(req: Request, res: Response) {
+//     // валидация запроса
+//     const { localName, dates, timezone } =
+//       EventsManagementApi.POST_Event.req.parse(req.body);
+
+//     const userId = UserUtils.getUserFromReq(req).userId;
+
+//     await PermService.checkObjPerm(userId, "", "event", "CREATE"); // TODO: Решить что делать с ивентом
+
+//     const eventId = uuidv7();
+
+//     // создаём ивент
+//     await updPool.query(
+//       sql.unsafe`
+//       insert into ev.events
+//         (event_id, local_name, timezone)
+//       values
+//         (${eventId}, ${localName}, ${timezone})`,
+//     );
+
+//     // вставляем даты ивента
+//     for (const date of dates) {
+//       await updPool.query(
+//         sql.unsafe`
+//         insert into ev.event_dates
+//           (event_id, date)
+//         values
+//           (${eventId}, ${date})`,
+//       );
+//     }
+
+//     RouterUtils.validAndSendResponse(EventsManagementApi.POST_Event.res, res, {
+//       code: "success",
+//       eventId: eventId,
+//     });
+//   }
+//   async getEvent(req: Request, res: Response) {
+//     // валидация запроса
+//     const { eventId } = EventsManagementApi.GET_Event.req.parse(req.params);
+//     const userId = UserUtils.getUserFromReq(req).userId;
+
+//     await PermService.checkObjPerm(userId, eventId, "event", "READ");
+
+//     const event = await selPool.maybeOne(
+//       sql.type(
+//         z.object({
+//           eventId: DbSchema.ev.events.eventId,
+//           localName: DbSchema.ev.events.localName,
+//           timezone: DbSchema.ev.events.timezone,
+//           dates: z.array(DbSchema.ev.eventDates.date),
+//         }),
+//       )`
+//             select
+//               e.event_id as "eventId",
+//               e.local_name as "localName",
+//               e.timezone,
+//               COALESCE(ARRAY_REMOVE(ARRAY_AGG(ed."date"), NULL), '{}') AS dates
+//             from
+//               ev.events e
+//             left join ev.event_dates ed on
+//               e.event_id = ed.event_id
+//             where
+//               e.event_id = ${eventId}
+//             group by
+//               e.event_id,
+//               e.local_name,
+//               e.timezone;
+//           `,
+//     );
+//     if (!event) throw ApiError.BadRequest("EventNotFound", "Ивент не найден");
+
+//     RouterUtils.validAndSendResponse(EventsManagementApi.GET_Event.res, res, {
+//       code: "success",
+//       event: event,
+//     });
+//   }
+//   // async updateEvent(req: Request, res: Response) {}
+//   // async deleteEvent(req: Request, res: Response) {}
+//   async createActivity(req: Request, res: Response) {
+//     // валидация запроса
+//     const { eventId, localName } = EventsManagementApi.POST_Activity.req.parse(
+//       req.body,
+//     );
+
+//     const userId = UserUtils.getUserFromReq(req).userId;
+
+//     await PermService.checkObjPerm(userId, eventId, "activity", "CREATE");
+
+//     const activityId = uuidv7();
+
+//     // создаём активность
+//     await updPool.query(
+//       sql.unsafe`
+//       insert into ev.activities
+//         (activity_id, event_id, local_name)
+//       values
+//         (${activityId}, ${eventId}, ${localName})`,
+//     );
+
+//     RouterUtils.validAndSendResponse(
+//       EventsManagementApi.POST_Activity.res,
+//       res,
+//       {
+//         code: "success",
+//         activityId: activityId,
+//       },
+//     );
+//   }
+//   // async getActivity(req: Request, res: Response) {}
+//   // async updateActivity(req: Request, res: Response) {}
+//   // async deleteActivity(req: Request, res: Response) {}
+// }
+// export const EventController = new eventController();

+ 25 - 25
src/modules/management/event/event-router.ts

@@ -1,34 +1,34 @@
-import { RouterUtils } from "#utils/router-utils.js";
+// import { RouterUtils } from "#utils/router-utils.js";
 
-import express from "express";
-import { EventController } from "./event-controller.js";
-const router = express.Router();
-export default router;
+// import express from "express";
+// import { EventController } from "./event-controller.js";
+// const router = express.Router();
+// export default router;
 
-router.post("/event", RouterUtils.asyncHandler(EventController.createEvent));
+// router.post("/event", RouterUtils.asyncHandler(EventController.createEvent));
 
-router.get(
-  "/event/:eventId",
-  RouterUtils.asyncHandler(EventController.getEvent),
-);
+// router.get(
+//   "/event/:eventId",
+//   RouterUtils.asyncHandler(EventController.getEvent),
+// );
 
-router.patch(
-  "/event/:eventId",
-  RouterUtils.asyncHandler(EventController.updateEvent),
-);
+// router.patch(
+//   "/event/:eventId",
+//   RouterUtils.asyncHandler(EventController.updateEvent),
+// );
 
-router.delete(
-  "/event/:eventId",
-  RouterUtils.asyncHandler(EventController.deleteEvent),
-);
+// router.delete(
+//   "/event/:eventId",
+//   RouterUtils.asyncHandler(EventController.deleteEvent),
+// );
 
-router.post(
-  "/activity",
-  RouterUtils.asyncHandler(EventController.createActivity),
-);
+// router.post(
+//   "/activity",
+//   RouterUtils.asyncHandler(EventController.createActivity),
+// );
 
-router.get("/activity/:activityId", RouterUtils.asyncHandler());
+// router.get("/activity/:activityId", RouterUtils.asyncHandler());
 
-router.patch("/activity/:activityId", RouterUtils.asyncHandler());
+// router.patch("/activity/:activityId", RouterUtils.asyncHandler());
 
-router.delete("/activity/:activityId", RouterUtils.asyncHandler());
+// router.delete("/activity/:activityId", RouterUtils.asyncHandler());

+ 3 - 3
src/modules/users/auth/routers/auth-controller.ts

@@ -67,7 +67,7 @@ class authController {
 
   async confirmRegistration(req: Request, res: Response) {
     // валидация запроса
-    const { password, name, transactionId, confirmPin } =
+    const { password, transactionId, confirmPin } =
       AuthApi.POST_ConfirmRegistration.req.parse(req.body);
 
     // проверка пина
@@ -117,9 +117,9 @@ class authController {
     await updPool.query(
       sql.unsafe`
           insert into usr.users 
-            (user_id, email, name, password) 
+            (user_id, email, password) 
           values 
-            (${userId}, ${email}, ${name}, ${hashPassword})`,
+            (${userId}, ${email}, ${hashPassword})`,
     );
 
     // токены

+ 4 - 2
src/modules/users/auth/services/token-service.ts

@@ -10,6 +10,7 @@ import { sql } from "slonik";
 import { TokenPayload } from "../types/token-playload-type.js";
 import type { Response } from "express";
 import { z } from "zod";
+import { v7 } from "uuid";
 
 const JWT_ACCESS_SECRET = config.JWT_ACCESS_SECRET || "";
 const JWT_REFRESH_SECRET = config.JWT_REFRESH_SECRET || "";
@@ -46,12 +47,13 @@ class TokenService {
    * @param refreshToken - токен, который будет вставлен
    */
   async insertRefreshToken(userId: string, refreshToken: string) {
+    const id = v7();
     await updPool.query(
       sql.unsafe`
       insert into usr.user_refresh_tokens
-        (user_id, refresh_token)
+        (token_id, user_id, refresh_token)
       values
-        (${userId}, ${refreshToken})
+        (${id}, ${userId}, ${refreshToken})
   `,
     );
   }

+ 1 - 1
src/modules/users/confirm-pins/confirm-pins-service.ts

@@ -74,7 +74,7 @@ class confirmPinsService {
 
   async checkConfirmPin(
     transactionId: string,
-    confirmPin: number,
+    confirmPin: string,
   ): Promise<
     | { status: "correct"; email: string }
     | { status: "rotten" }