seperated backend and frontend
This commit is contained in:
49
backend/src/models/base.model.ts
Normal file
49
backend/src/models/base.model.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Prop } from '@nestjs/mongoose';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
export class Base {
|
||||
@Prop({ default: randomUUID, unique: true })
|
||||
uuid: string;
|
||||
|
||||
@Prop({ default: () => new Date(Date.now()) })
|
||||
expiryStarts: Date;
|
||||
|
||||
@Prop({ default: () => new Date('2099-12-31') })
|
||||
expiryEnds: Date;
|
||||
|
||||
@Prop({ default: false })
|
||||
isConfirmed: boolean;
|
||||
|
||||
@Prop({ default: false })
|
||||
deleted: boolean;
|
||||
|
||||
@Prop({ default: true })
|
||||
active: boolean;
|
||||
|
||||
@Prop({ default: randomUUID })
|
||||
crypUuId: string;
|
||||
|
||||
@Prop({ default: randomUUID })
|
||||
createdCredentialsToken: string;
|
||||
|
||||
@Prop({ default: randomUUID })
|
||||
updatedCredentialsToken: string;
|
||||
|
||||
@Prop({ default: randomUUID })
|
||||
confirmedCredentialsToken: string;
|
||||
|
||||
@Prop({ default: false })
|
||||
isNotificationSend: boolean;
|
||||
|
||||
@Prop({ default: false })
|
||||
isEmailSend: boolean;
|
||||
|
||||
@Prop({ default: 0 })
|
||||
refInt: number;
|
||||
|
||||
@Prop({ default: randomUUID })
|
||||
refId: string;
|
||||
|
||||
@Prop({ default: 0 })
|
||||
replicationId: number;
|
||||
}
|
||||
47
backend/src/models/build-address.model.ts
Normal file
47
backend/src/models/build-address.model.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { ObjectType, Field, ID, Float } from '@nestjs/graphql';
|
||||
import { Base } from '@/models/base.model';
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class BuildAddress extends Base {
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
buildNumber: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
doorNumber: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
floorNumber: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
commentAddress: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
letterAddress: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
shortLetterAddress: string;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
latitude: number;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
longitude: number;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'Street', required: true })
|
||||
street: Types.ObjectId;
|
||||
}
|
||||
|
||||
export type BuildAddressDocument = BuildAddress & Document;
|
||||
export const BuildAddressSchema = SchemaFactory.createForClass(BuildAddress);
|
||||
36
backend/src/models/build-area.model.ts
Normal file
36
backend/src/models/build-area.model.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { ObjectType, Field, ID, Float } from '@nestjs/graphql';
|
||||
import { Base } from '@/models/base.model';
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class BuildArea extends Base {
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'Build', required: true })
|
||||
build: Types.ObjectId;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
area: number;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
size: number;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
type: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
typeToken: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
description: string;
|
||||
}
|
||||
|
||||
export type BuildAreaDocument = BuildArea & Document;
|
||||
export const BuildAreaSchema = SchemaFactory.createForClass(BuildArea);
|
||||
60
backend/src/models/build-parts.model.ts
Normal file
60
backend/src/models/build-parts.model.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { ObjectType, Field, ID, Float } from '@nestjs/graphql';
|
||||
import { Base } from '@/models/base.model';
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class BuildParts extends Base {
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'Build', required: true })
|
||||
buildId: Types.ObjectId;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
addressGovCode: string;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
no: number;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
level: number;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
code: string;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
grossSize: number;
|
||||
|
||||
@Field(() => Float)
|
||||
@Prop({ required: true })
|
||||
netSize: number;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
defaultAccessory: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
humanLivability: boolean;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
key: string;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'ApiEnumDropdown', required: true })
|
||||
directionId: Types.ObjectId;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'ApiEnumDropdown', required: true })
|
||||
typeId: Types.ObjectId;
|
||||
}
|
||||
|
||||
export type BuildPartsDocument = BuildParts & Document;
|
||||
export const BuildPartsSchema = SchemaFactory.createForClass(BuildParts);
|
||||
146
backend/src/models/build.model.ts
Normal file
146
backend/src/models/build.model.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { ObjectType, Field, ID, Int } from '@nestjs/graphql';
|
||||
import { Base } from '@/models/base.model';
|
||||
import { Person } from '@/models/person.model';
|
||||
import { Company } from '@/models/company.model';
|
||||
|
||||
@ObjectType()
|
||||
export class BuildIban {
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
iban: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
startDate: Date;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, default: new Date('2900-01-01T03:00:00+03:00') })
|
||||
stopDate: Date;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, default: 'TR0000000000000' })
|
||||
bankCode: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, default: '????' })
|
||||
xcomment: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class BuildResponsible {
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: Company.name, required: true })
|
||||
company: Types.ObjectId;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: Person.name, required: true })
|
||||
person: Types.ObjectId;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class BuildInfo {
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
govAddressCode: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
buildName: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
buildNo: string;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
maxFloor: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
undergroundFloor: number;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
buildDate: Date;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
decisionPeriodDate: Date;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
taxNo: string;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
liftCount: number;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
heatingSystem: boolean;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
coolingSystem: boolean;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
hotWaterSystem: boolean;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
blockServiceManCount: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
securityServiceManCount: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
garageCount: number;
|
||||
|
||||
@Field(() => Int)
|
||||
@Prop({ required: true })
|
||||
managementRoomId: number;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class Build extends Base {
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: 'BuildType', required: true })
|
||||
buildType: Types.ObjectId;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, unique: true })
|
||||
collectionToken: string;
|
||||
|
||||
@Field(() => BuildInfo)
|
||||
@Prop({ type: BuildInfo, required: true })
|
||||
info: BuildInfo;
|
||||
|
||||
@Field(() => ID, { nullable: true })
|
||||
@Prop({ type: Types.ObjectId, ref: 'Site' })
|
||||
site?: Types.ObjectId;
|
||||
|
||||
@Field(() => ID, { nullable: true })
|
||||
@Prop({ type: Types.ObjectId, ref: 'BuildAddress' })
|
||||
address?: Types.ObjectId;
|
||||
|
||||
@Field(() => [ID], { nullable: true })
|
||||
@Prop({ type: [{ type: Types.ObjectId, ref: 'BuildArea' }] })
|
||||
areas?: Types.ObjectId[];
|
||||
|
||||
@Field(() => [BuildIban], { nullable: true })
|
||||
@Prop({ type: [BuildIban] })
|
||||
ibans?: BuildIban[];
|
||||
|
||||
@Field(() => [BuildResponsible], { nullable: true })
|
||||
@Prop({ type: [BuildResponsible] })
|
||||
responsibles?: BuildResponsible[];
|
||||
}
|
||||
|
||||
export type BuildDocument = Build & Document;
|
||||
export const BuildSchema = SchemaFactory.createForClass(Build);
|
||||
16
backend/src/models/company.model.ts
Normal file
16
backend/src/models/company.model.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ObjectType, Field, ID } from '@nestjs/graphql';
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { Base } from '@/models/base.model';
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class Company extends Base {
|
||||
@Field(() => ID)
|
||||
@Prop({ required: true })
|
||||
name: string;
|
||||
|
||||
}
|
||||
|
||||
export type CompanyDocument = Company & Document;
|
||||
export const CompanySchema = SchemaFactory.createForClass(Company);
|
||||
41
backend/src/models/living-spaces.model.ts
Normal file
41
backend/src/models/living-spaces.model.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Document, Model, Types, Connection, connection as defaultConnection } from 'mongoose';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
||||
import { Base } from '@/models/base.model';
|
||||
import { BuildParts } from '@/models/build-parts.model';
|
||||
import { Person } from '@/models/person.model';
|
||||
import { Company } from '@/models/company.model';
|
||||
import { UserType } from '@/models/user-type.model';
|
||||
|
||||
@ObjectType()
|
||||
export class LivingSpaces extends Base {
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: BuildParts.name, required: true })
|
||||
part: Types.ObjectId;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: Company.name, required: true })
|
||||
company: Types.ObjectId;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: Person.name, required: true })
|
||||
person: Types.ObjectId;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: UserType.name, required: true })
|
||||
userType: Types.ObjectId;
|
||||
}
|
||||
|
||||
|
||||
export type LivingSpacesDocument = LivingSpaces & Document;
|
||||
export const LivingSpacesSchema = SchemaFactory.createForClass(LivingSpaces);
|
||||
|
||||
export function getDynamicLivingSpaceModel(collectionToken: string, conn?: Connection): Model<LivingSpacesDocument> {
|
||||
const connection = conn || defaultConnection;
|
||||
const collectionName = `LivingSpaces${collectionToken}`;
|
||||
if (connection.models[collectionName]) { return connection.models[collectionName] as Model<LivingSpacesDocument> }
|
||||
const schema = SchemaFactory.createForClass(LivingSpaces);
|
||||
schema.add({ uuid: { type: String, required: false, unique: true, default: () => randomUUID() } });
|
||||
return connection.model(collectionName, schema, collectionName) as unknown as Model<LivingSpacesDocument>;
|
||||
}
|
||||
51
backend/src/models/person.model.ts
Normal file
51
backend/src/models/person.model.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document } from 'mongoose';
|
||||
import { Base } from '@/models/base.model';
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
export class Person extends Base {
|
||||
@Prop({ required: true })
|
||||
firstName: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
surname: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
middleName: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
sexCode: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
personRef: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
personTag: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
fatherName: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
motherName: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
countryCode: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
nationalIdentityId: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
birthPlace: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
birthDate: Date;
|
||||
|
||||
@Prop({ required: true })
|
||||
taxNo: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
birthname: string;
|
||||
}
|
||||
|
||||
export type PersonDocument = Person & Document;
|
||||
export const PersonSchema = SchemaFactory.createForClass(Person);
|
||||
26
backend/src/models/user-type.model.ts
Normal file
26
backend/src/models/user-type.model.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document } from 'mongoose';
|
||||
import { ObjectType, Field, ID } from '@nestjs/graphql';
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class UserType {
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
type: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
token: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
typeToken: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
description: string;
|
||||
}
|
||||
|
||||
export type UserTypeDocument = UserType & Document;
|
||||
export const UserTypeSchema = SchemaFactory.createForClass(UserType);
|
||||
81
backend/src/models/user.model.ts
Normal file
81
backend/src/models/user.model.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { ObjectType, Field, ID } from '@nestjs/graphql';
|
||||
import { Document, Types } from 'mongoose';
|
||||
import { Base } from '@/models/base.model';
|
||||
import { Person } from '@/models/person.model';
|
||||
import { UserType } from '@/models/user-type.model';
|
||||
|
||||
@ObjectType()
|
||||
export class CollectionTokenItem {
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
prefix: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
token: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class CollectionToken {
|
||||
|
||||
@Field(() => [CollectionTokenItem])
|
||||
@Prop({ type: [CollectionTokenItem], default: [] })
|
||||
tokens: CollectionTokenItem[];
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, default: '' })
|
||||
default: string;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
@Schema({ timestamps: true })
|
||||
export class User extends Base {
|
||||
|
||||
@Field(() => ID)
|
||||
_id: string;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Prop({ default: () => new Date(Date.now() + 30 * 24 * 60 * 60 * 1000) })
|
||||
expiresAt?: Date;
|
||||
|
||||
@Field({ nullable: true })
|
||||
@Prop()
|
||||
resetToken?: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
password: string;
|
||||
|
||||
@Field(() => [String], { nullable: 'itemsAndList' })
|
||||
@Prop({ type: [String], default: [], validate: [(val: string[]) => val.length <= 3, 'History can have max 3 items'] })
|
||||
history?: string[];
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true })
|
||||
tag: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, unique: true })
|
||||
email: string;
|
||||
|
||||
@Field()
|
||||
@Prop({ required: true, unique: true })
|
||||
phone: string;
|
||||
|
||||
@Field(() => CollectionToken)
|
||||
@Prop({ type: CollectionToken, default: () => ({ tokens: [], default: '' }) })
|
||||
collectionTokens: CollectionToken;
|
||||
|
||||
@Field(() => ID)
|
||||
@Prop({ type: Types.ObjectId, ref: Person.name, required: true })
|
||||
person: Types.ObjectId;
|
||||
|
||||
@Field(() => ID, { nullable: true })
|
||||
@Prop({ type: Types.ObjectId, ref: UserType.name })
|
||||
type?: Types.ObjectId;
|
||||
}
|
||||
|
||||
export type UserDocument = User & Document;
|
||||
export const UserSchema = SchemaFactory.createForClass(User);
|
||||
Reference in New Issue
Block a user