From 6516087085dbb8e38ec124c40ed3519a74cdff4f Mon Sep 17 00:00:00 2001
From: Nabilsenko <96882497+Nabilsenko@users.noreply.github.com>
Date: Fri, 10 Feb 2023 10:55:09 +0100
Subject: [PATCH] fix: added INE to people

---
 src/people/dto/create-people.dto.ts  |  50 ++++++-----
 src/people/dto/update-people.dto.ts  |  51 ++++++-----
 src/people/entities/people.entity.ts |  29 +++----
 src/people/schemas/people.schema.ts  | 121 ++++++++++++++-------------
 4 files changed, 133 insertions(+), 118 deletions(-)

diff --git a/src/people/dto/create-people.dto.ts b/src/people/dto/create-people.dto.ts
index c26bd35..2dc4098 100644
--- a/src/people/dto/create-people.dto.ts
+++ b/src/people/dto/create-people.dto.ts
@@ -1,23 +1,27 @@
-import { IsBoolean, IsString, IsNotEmpty, IsOptional } from 'class-validator';
-
-export class CreatePeopleDto {
-
-  @IsString()
-  @IsNotEmpty()
-  firstname: string;
-
-  @IsString()
-  @IsNotEmpty()
-  lastname: string;
-
-  @IsOptional()
-  passwordHash: string;
-
-  @IsString()
-  @IsNotEmpty()
-  email: string;
-  
-  @IsNotEmpty()
-  role: number;
-
-}
\ No newline at end of file
+import { IsBoolean, IsString, IsNotEmpty, IsOptional, IsNumber } from 'class-validator';
+
+export class CreatePeopleDto {
+
+  @IsNumber()
+  @IsNotEmpty()
+  ine: number;
+
+  @IsString()
+  @IsNotEmpty()
+  firstname: string;
+
+  @IsString()
+  @IsNotEmpty()
+  lastname: string;
+
+  @IsOptional()
+  passwordHash: string;
+
+  @IsString()
+  @IsNotEmpty()
+  email: string;
+  
+  @IsNotEmpty()
+  role: number;
+
+}
diff --git a/src/people/dto/update-people.dto.ts b/src/people/dto/update-people.dto.ts
index 4097f1e..71aa9c1 100644
--- a/src/people/dto/update-people.dto.ts
+++ b/src/people/dto/update-people.dto.ts
@@ -1,23 +1,28 @@
-import { IsOptional, IsString, IsNotEmpty } from 'class-validator';
-
-export class UpdatePeopleDto {
-  @IsString()
-  @IsOptional()
-  firstname: string;
-
-  @IsString()
-  @IsOptional()
-  lastname: string;
-
-  @IsString()
-  @IsOptional()
-  email: string;
-
-  @IsString()
-  @IsOptional()
-  passwordHash: string;
-  
-  @IsOptional()
-  role: number;
-
-}
\ No newline at end of file
+import { IsOptional, IsString, IsNotEmpty, IsNumber } from 'class-validator';
+
+export class UpdatePeopleDto {
+  
+  @IsNumber()
+  @IsNotEmpty()
+  ine: number;
+  
+  @IsString()
+  @IsOptional()
+  firstname: string;
+
+  @IsString()
+  @IsOptional()
+  lastname: string;
+
+  @IsString()
+  @IsOptional()
+  email: string;
+
+  @IsString()
+  @IsOptional()
+  passwordHash: string;
+  
+  @IsOptional()
+  role: number;
+
+}
diff --git a/src/people/entities/people.entity.ts b/src/people/entities/people.entity.ts
index 7f8bf24..5a2829e 100644
--- a/src/people/entities/people.entity.ts
+++ b/src/people/entities/people.entity.ts
@@ -1,14 +1,15 @@
-import { People } from '../schemas/people.schema';
-
-export class PeopleEntity {
-  _id: string;
-  firstname: string;
-  lastname: string;
-  email: string;
-  passwordHash: string;
-  role: number;
-
-  constructor(partial: Partial<People>) {
-    Object.assign(this, partial);
-  }
-}
\ No newline at end of file
+import { People } from '../schemas/people.schema';
+
+export class PeopleEntity {
+  _id: string;
+  ine: number;
+  firstname: string;
+  lastname: string;
+  email: string;
+  passwordHash: string;
+  role: number;
+
+  constructor(partial: Partial<People>) {
+    Object.assign(this, partial);
+  }
+}
diff --git a/src/people/schemas/people.schema.ts b/src/people/schemas/people.schema.ts
index 09d9a5f..98f636e 100644
--- a/src/people/schemas/people.schema.ts
+++ b/src/people/schemas/people.schema.ts
@@ -1,58 +1,63 @@
-import * as mongoose from 'mongoose';
-import { Document } from 'mongoose';
-import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
-
-export type PeopleDocument = People & Document;
-
-@Schema({
-  toJSON: {
-    virtuals: true,
-    transform: (doc: any, ret: any) => {
-      delete ret._id;
-    },
-  },
-})
-export class People {
-    @Prop({
-        type: mongoose.Schema.Types.ObjectId,
-        auto: true,
-      })
-      _id: any;
-    
-    @Prop({
-        type: String,
-        required: true,
-        trim: true,
-        minlength: 2,
-    }) firstname: string;
-
-    @Prop({
-        type: String,
-        required: true,
-        trim: true,
-        minlength: 2,
-    }) lastname: string;
-
-    @Prop({
-        type: String,
-        required: true,
-        trim: true,
-        minlength: 2,
-    }) email: string;
-
-    @Prop({
-        type: String,
-        trim: true,
-        minlength: 2,
-    }) passwordHash: string;
-
-    @Prop({
-        type: Number,
-        required: true,
-    }) role: number;
-
-}
-
-export const PeopleSchema = SchemaFactory.createForClass(People);
-
-PeopleSchema.index({});
\ No newline at end of file
+import * as mongoose from 'mongoose';
+import { Document } from 'mongoose';
+import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
+
+export type PeopleDocument = People & Document;
+
+@Schema({
+  toJSON: {
+    virtuals: true,
+    transform: (doc: any, ret: any) => {
+      delete ret._id;
+    },
+  },
+})
+export class People {
+    @Prop({
+        type: mongoose.Schema.Types.ObjectId,
+        auto: true,
+      })
+      _id: any;
+    
+      @Prop({
+        type: Number,
+        required: true,
+    }) ine: number;
+
+    @Prop({
+        type: String,
+        required: true,
+        trim: true,
+        minlength: 2,
+    }) firstname: string;
+
+    @Prop({
+        type: String,
+        required: true,
+        trim: true,
+        minlength: 2,
+    }) lastname: string;
+
+    @Prop({
+        type: String,
+        required: true,
+        trim: true,
+        minlength: 2,
+    }) email: string;
+
+    @Prop({
+        type: String,
+        trim: true,
+        minlength: 2,
+    }) passwordHash: string;
+
+    @Prop({
+        type: Number,
+        required: true,
+    }) role: number;
+
+}
+
+export const PeopleSchema = SchemaFactory.createForClass(People);
+
+PeopleSchema.index({});
-- 
GitLab