Compare commits
3 Commits
master
...
admin_side
| Author | SHA1 | Date | |
|---|---|---|---|
| e9184963f5 | |||
| 3a356887f7 | |||
| afafad2d4e |
+1
-1
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "source ~/.nvm/nvm.sh && nvm use 20.17.0 && nest start",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
|
||||
@@ -25,6 +25,8 @@ import { ComentariosModule } from './comentarios/comentarios.module';
|
||||
import { ComentarioLineasProgramaticas } from './entities/comentarioLineasProgramaticas.entity';
|
||||
import { ReportesController } from './reportes/reportes.controller';
|
||||
import { ReportesModule } from './reportes/reportes.module';
|
||||
import { Direccion } from './entities/direccion.entity';
|
||||
import { DireccionModule } from './direccion/direccion.module';
|
||||
config({ path: '.env' });
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -35,6 +37,7 @@ config({ path: '.env' });
|
||||
LineasProgramaticasModule,
|
||||
CarreraModule,
|
||||
ReportesModule,
|
||||
DireccionModule,
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
@@ -54,6 +57,7 @@ config({ path: '.env' });
|
||||
LineaProgramatica,
|
||||
TipoUsuarioEntity,
|
||||
UsuarioEntity,
|
||||
Direccion,
|
||||
],
|
||||
}),
|
||||
JwtModule.register({
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Header,
|
||||
HttpCode,
|
||||
Logger,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '../auth/auth.guard';
|
||||
import { DireccionService } from './direccion.service';
|
||||
import { isUndefined } from '@nestjs/common/utils/shared.utils';
|
||||
import { DireccionDTO } from '../dtos/direccionDTO';
|
||||
import { Delete } from '@nestjs/common/decorators/http/request-mapping.decorator';
|
||||
|
||||
@Controller('direccion')
|
||||
export class DireccionController {
|
||||
constructor(private readonly direccionService: DireccionService) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Get('direccion')
|
||||
@HttpCode(200)
|
||||
getDireccion() {
|
||||
Logger.log('Direccion', 'getDireccion');
|
||||
return this.direccionService.findDirecciones();
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Get('direccionById')
|
||||
@HttpCode(200)
|
||||
getDireccionById(@Query('direccionId') direccionId: number) {
|
||||
Logger.log('Direccion', 'getDireccionById');
|
||||
if (!isUndefined(direccionId)) {
|
||||
return this.direccionService.findDireccionById(direccionId);
|
||||
}
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Post('addDireccion')
|
||||
@HttpCode(200)
|
||||
setDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'setDireccion');
|
||||
return this.direccionService.addDireccion(direccion);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Put('updateDireccion')
|
||||
@HttpCode(200)
|
||||
updateDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'updateDireccion');
|
||||
return this.direccionService.updateDireccion(direccion);
|
||||
}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@Header('content-type', 'application/json')
|
||||
@Delete('deleteDireccion')
|
||||
@HttpCode(200)
|
||||
deleteDireccion(@Body() direccion: DireccionDTO) {
|
||||
Logger.log('Direccion', 'deleteDireccion');
|
||||
return this.direccionService.deleteDireccion(direccion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Direccion } from '../entities/direccion.entity';
|
||||
import { DireccionService } from './direccion.service';
|
||||
import { DireccionController } from './direccion.controller';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Direccion])],
|
||||
providers: [DireccionService],
|
||||
controllers: [DireccionController],
|
||||
exports: [TypeOrmModule.forFeature([DireccionService])],
|
||||
})
|
||||
export class DireccionModule {}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { DeleteResult, Repository, UpdateResult } from 'typeorm';
|
||||
import { Direccion } from '../entities/direccion.entity';
|
||||
import { DireccionDTO } from '../dtos/direccionDTO';
|
||||
|
||||
@Injectable()
|
||||
export class DireccionService {
|
||||
constructor(
|
||||
@InjectRepository(Direccion)
|
||||
private direccionRepository: Repository<Direccion>,
|
||||
) {}
|
||||
|
||||
findDirecciones(): Promise<Direccion[]> {
|
||||
return this.direccionRepository.find({});
|
||||
}
|
||||
|
||||
findDireccionById(direccionId: number): Promise<Direccion[]> {
|
||||
return this.direccionRepository.findBy({ id: direccionId });
|
||||
|
||||
}
|
||||
|
||||
addDireccion(direccion: DireccionDTO): Promise<Direccion> {
|
||||
return this.direccionRepository.save(direccion);
|
||||
}
|
||||
|
||||
updateDireccion(direccion: DireccionDTO): Promise<UpdateResult> {
|
||||
return this.direccionRepository.update({ direccion });
|
||||
}
|
||||
|
||||
deleteDireccion(direccion: Direccion): Promise<DeleteResult> {
|
||||
return this.direccionRepository.delete({
|
||||
id: direccion.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { IsDefined, IsInt, IsNotEmpty, IsString } from "@nestjs/class-validator";
|
||||
|
||||
export class DireccionDTO {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly primer_nombre: string;
|
||||
|
||||
@IsString()
|
||||
readonly segundo_nombre: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly apellido_paterno: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly apellido_materno: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly inicio_periodo: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly fin_periodo: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly inicio_periodo_encuesta: Date;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsDefined()
|
||||
readonly fin_periodo_encuesta: Date;
|
||||
|
||||
@IsInt()
|
||||
readonly id: number;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity('direccion')
|
||||
export class Direccion {
|
||||
|
||||
@PrimaryGeneratedColumn('increment', { type: 'int' })
|
||||
id: number;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
primer_nombre: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
segundo_nombre: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
apellido_paterno: string;
|
||||
|
||||
@Column('varchar', { length: 100 })
|
||||
apellido_materno: string;
|
||||
|
||||
@Column('date')
|
||||
inicio_periodo: Date;
|
||||
|
||||
@Column('date')
|
||||
fin_periodo: Date;
|
||||
|
||||
@Column('date')
|
||||
inicio_periodo_encuesta: Date;
|
||||
|
||||
@Column('date')
|
||||
fin_periodo_encuesta: Date;
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
PrimaryGeneratedColumn,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
} from 'typeorm';
|
||||
import { LineaProgramatica } from './LineaProgramatica.entity';
|
||||
import { Direccion } from './direccion.entity';
|
||||
|
||||
@Entity('ejes_estrategicos')
|
||||
export class EjeEstrategico {
|
||||
@@ -17,4 +24,7 @@ export class EjeEstrategico {
|
||||
(lineaProgramatica) => lineaProgramatica.ejeEstrategico,
|
||||
)
|
||||
lineasProgramaticas: LineaProgramatica[];
|
||||
|
||||
@ManyToOne(() => Direccion, (direccion) => direccion.id)
|
||||
direccion: Direccion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user