diff --git a/src/structures/structure-type/structure-type.controller.ts b/src/structures/structure-type/structure-type.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e530a5dd77c3dea93a14ea3e5b3db3abd1b65ed --- /dev/null +++ b/src/structures/structure-type/structure-type.controller.ts @@ -0,0 +1,13 @@ +import { Controller, Get } from '@nestjs/common'; +import { StructureType } from './structure-type.schema'; +import { StructureTypeService } from './structure-type.service'; + +@Controller('structure-type') +export class StructureTypeController { + constructor(private readonly structureTypeService: StructureTypeService) {} + + @Get() + public async findAll(): Promise<StructureType[]> { + return this.structureTypeService.findAll(); + } +} diff --git a/src/structures/structure-type/structure-type.dto.ts b/src/structures/structure-type/structure-type.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..0064714bcd64ca312577d6a549c601c607727d83 --- /dev/null +++ b/src/structures/structure-type/structure-type.dto.ts @@ -0,0 +1,4 @@ +export class CreateStructureType { + name: string; + values: string[]; +} diff --git a/src/structures/structure-type/structure-type.schema.ts b/src/structures/structure-type/structure-type.schema.ts new file mode 100644 index 0000000000000000000000000000000000000000..faa2ecbb6014b6aa176125a686602a4a09fd9957 --- /dev/null +++ b/src/structures/structure-type/structure-type.schema.ts @@ -0,0 +1,15 @@ +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { Document } from 'mongoose'; + +export type StructureTypeDocument = StructureType & Document; + +@Schema({ collection: 'structuretype' }) +export class StructureType { + @Prop() + name: string; + + @Prop() + values: string[]; +} + +export const StructureTypeSchema = SchemaFactory.createForClass(StructureType); diff --git a/src/structures/structure-type/structure-type.service.ts b/src/structures/structure-type/structure-type.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea50e0c79e697e9a07ca28f9ebdbf950608835bf --- /dev/null +++ b/src/structures/structure-type/structure-type.service.ts @@ -0,0 +1,13 @@ +import { Injectable } from '@nestjs/common'; +import { InjectModel } from '@nestjs/mongoose'; +import { Model } from 'mongoose'; +import { StructureType, StructureTypeDocument } from './structure-type.schema'; + +@Injectable() +export class StructureTypeService { + constructor(@InjectModel(StructureType.name) private structureTypeModel: Model<StructureTypeDocument>) {} + + public async findAll(): Promise<StructureType[]> { + return this.structureTypeModel.find().exec(); + } +} diff --git a/src/structures/structures.module.ts b/src/structures/structures.module.ts index 265eb40762fb407b71f72756ae034f1b6555a653..6494ea3a5eed4386ed251679c6e5b45a66e88804 100644 --- a/src/structures/structures.module.ts +++ b/src/structures/structures.module.ts @@ -6,16 +6,22 @@ import { Structure, StructureSchema } from './schemas/structure.schema'; import { StructuresController } from './structures.controller'; import { StructuresService } from './services/structures.service'; import { ApticStructuresService } from './services/aptic-structures.service'; +import { StructureTypeController } from './structure-type/structure-type.controller'; +import { StructureTypeService } from './structure-type/structure-type.service'; +import { StructureType, StructureTypeSchema } from './structure-type/structure-type.schema'; @Module({ imports: [ - MongooseModule.forFeature([{ name: Structure.name, schema: StructureSchema }]), + MongooseModule.forFeature([ + { name: Structure.name, schema: StructureSchema }, + { name: StructureType.name, schema: StructureTypeSchema }, + ]), HttpModule, MailerModule, UsersModule, ], - controllers: [StructuresController], - exports: [StructuresService], - providers: [StructuresService, ApticStructuresService], + controllers: [StructuresController, StructureTypeController], + exports: [StructuresService, StructureTypeService], + providers: [StructuresService, StructureTypeService, ApticStructuresService], }) export class StructuresModule {}