builds backend initated

This commit is contained in:
2025-11-20 18:52:38 +03:00
parent 44f209ae1f
commit a5a7a7e7b5
83 changed files with 3950 additions and 222 deletions

View File

@@ -1,75 +1,75 @@
import { Prop } from '@nestjs/mongoose';
import { randomUUID } from 'crypto';
import { ObjectType, InputType, Field, ID } from '@nestjs/graphql';
import { ObjectType, InputType, Field } from '@nestjs/graphql';
@ObjectType({ isAbstract: true })
export class Base {
@Field()
@Prop({ default: randomUUID, unique: true })
@Field({ nullable: true })
@Prop({ default: () => randomUUID(), unique: true })
uuid: string;
@Field()
@Field({ nullable: true })
@Prop({ default: () => new Date(Date.now()) })
createdAt: Date;
@Field()
@Field({ nullable: true })
@Prop({ default: () => new Date(Date.now()) })
updatedAt: Date;
@Field()
@Field({ nullable: true })
@Prop({ default: false, required: false })
isConfirmed?: boolean;
@Field()
@Field({ nullable: true })
@Prop({ default: false, required: false })
deleted?: boolean;
@Field()
@Field({ nullable: true })
@Prop({ default: true, required: false })
active?: boolean;
@Field()
@Field({ nullable: true })
@Prop({ default: randomUUID })
crypUuId: string;
@Field()
@Field({ nullable: true })
@Prop({ default: randomUUID })
createdCredentialsToken: string;
@Field()
@Field({ nullable: true })
@Prop({ default: randomUUID })
updatedCredentialsToken: string;
@Field()
@Field({ nullable: true })
@Prop({ default: randomUUID })
confirmedCredentialsToken: string;
@Field()
@Field({ nullable: true })
@Prop({ default: false, required: false })
isNotificationSend?: boolean;
@Field()
@Field({ nullable: true })
@Prop({ default: false, required: false })
isEmailSend?: boolean;
@Field()
@Field({ nullable: true })
@Prop({ default: 0 })
refInt: number;
@Field()
@Field({ nullable: true })
@Prop({ default: randomUUID })
refId: string;
@Field()
@Field({ nullable: true })
@Prop({ default: 0 })
replicationId: number;
@Field()
@Field({ nullable: true })
@Prop({ default: () => new Date(Date.now()), required: false })
expiryStarts?: Date;
@Field()
@Field({ nullable: true })
@Prop({ default: () => new Date('2099-12-31'), required: false })
expiryEnds?: Date;

View File

@@ -1,13 +1,13 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import { ObjectType, Field, ID, Int } from '@nestjs/graphql';
import { Base, ChangableBase } from '@/models/base.model';
import { Base } from '@/models/base.model';
import { Person } from '@/models/person.model';
import { Company } from '@/models/company.model';
@ObjectType()
@Schema({ timestamps: true })
export class BuildIban extends ChangableBase {
export class BuildIban extends Base {
@Field(() => ID)
readonly _id: string;
@@ -37,13 +37,13 @@ export class BuildIban extends ChangableBase {
@ObjectType()
export class BuildResponsible {
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: Company.name, required: true })
company: Types.ObjectId;
@Field(() => [String], { nullable: true, defaultValue: [] })
@Prop({ type: [String], default: [] })
company?: string[];
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: Person.name, required: true })
person: Types.ObjectId;
@Field(() => [String], { nullable: true, defaultValue: [] })
@Prop({ type: [String], default: [] })
person?: string[];
}
@@ -118,38 +118,45 @@ export class BuildInfo {
@ObjectType()
@Schema({ timestamps: true })
export class Build extends Base {
@Field(() => ID)
@Prop({ type: Types.ObjectId, ref: 'BuildType', required: true })
buildType: Types.ObjectId;
export class Build {
@Field()
@Prop({ required: true, unique: true })
readonly _id: string;
// @Field(() => ID)
// @Prop({ type: Types.ObjectId, ref: 'BuildType', required: true })
// buildType: Types.ObjectId;
@Field(() => String, { nullable: true })
@Prop({ required: true })
buildType: string;
@Field(() => String, { nullable: true })
@Prop({ required: true })
collectionToken: string;
@Field(() => BuildInfo)
@Field(() => BuildInfo, { nullable: true })
@Prop({ type: BuildInfo, required: true })
info: BuildInfo;
@Field(() => ID, { nullable: true })
@Prop({ type: Types.ObjectId, ref: 'BuildSites' })
site?: Types.ObjectId;
@Field(() => String, { nullable: true })
@Prop({ type: String })
site?: string;
@Field(() => ID, { nullable: true })
@Prop({ type: Types.ObjectId, ref: 'BuildAddress' })
address?: Types.ObjectId;
@Field(() => String, { nullable: true })
@Prop({ type: String })
address?: string;
@Field(() => [ID], { nullable: true })
@Prop({ type: [{ type: Types.ObjectId, ref: 'BuildArea' }] })
areas?: Types.ObjectId[];
@Field(() => [String], { nullable: true, defaultValue: [] })
@Prop({ type: [String], default: [] })
areas?: string[];
@Field(() => [BuildIban], { nullable: true })
@Prop({ type: [BuildIban] })
ibans?: BuildIban[];
@Field(() => [String], { nullable: true, defaultValue: [] })
@Prop({ type: [String], default: [] })
ibans?: string[];
@Field(() => [BuildResponsible], { nullable: true })
@Prop({ type: [BuildResponsible] })
@Field(() => [BuildResponsible], { nullable: true, defaultValue: [] })
@Prop({ type: [BuildResponsible], default: [] })
responsibles?: BuildResponsible[];
}