generated from HenriqueAmorim20/GEROcuidadoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from fga-eps-mds/feature/#186-CRUD-rotina
[#186] CRUD rotina
- Loading branch information
Showing
20 changed files
with
650 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AlterTableIdoso1699572747760 implements MigrationInterface { | ||
name = 'AlterTableIdoso1699572747760' | ||
name = 'AlterTableIdoso1699572747760'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" ALTER COLUMN "tipoSanguineo" DROP NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "idoso" ALTER COLUMN "descricao" DROP NOT NULL`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" ALTER COLUMN "descricao" SET NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "idoso" ALTER COLUMN "tipoSanguineo" SET NOT NULL`); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "idoso" ALTER COLUMN "tipoSanguineo" DROP NOT NULL`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "idoso" ALTER COLUMN "descricao" DROP NOT NULL`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "idoso" ALTER COLUMN "descricao" SET NOT NULL`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "idoso" ALTER COLUMN "tipoSanguineo" SET NOT NULL`, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddDataHoraTableIdoso1699904482169 implements MigrationInterface { | ||
name = 'AddDataHoraTableIdoso1699904482169' | ||
name = 'AddDataHoraTableIdoso1699904482169'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" ADD "dataHora" TIMESTAMP`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" DROP COLUMN "dataHora"`); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" ADD "dataHora" TIMESTAMP`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "idoso" DROP COLUMN "dataHora"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CreateTableRotina1700415713319 implements MigrationInterface { | ||
name = 'CreateTableRotina1700415713319'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."rotina_categoria_enum" AS ENUM('Geral', 'Alimentação', 'Exercícios', 'Medicamentos', 'Água', 'Compromissos')`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "rotina" ("id" SERIAL NOT NULL, "idPaciente" integer NOT NULL, "categoria" "public"."rotina_categoria_enum" NOT NULL, "dataHora" TIMESTAMP NOT NULL, "titulo" character varying(100) NOT NULL, "descricao" character varying(100) NOT NULL, CONSTRAINT "PK_dda374a9512c52ad46707571b57" PRIMARY KEY ("id"))`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "rotina"`); | ||
await queryRunner.query(`DROP TYPE "public"."rotina_categoria_enum"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class UpdateDescricaoRotina1700418953821 implements MigrationInterface { | ||
name = 'UpdateDescricaoRotina1700418953821'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ALTER COLUMN "descricao" DROP NOT NULL`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ALTER COLUMN "descricao" SET NOT NULL`, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AlterTableRotina1700794599958 implements MigrationInterface { | ||
name = 'AlterTableRotina1700794599958'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD "dias" integer array NOT NULL DEFAULT '{}'`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD "concluido" boolean NOT NULL DEFAULT false`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "concluido"`); | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "dias"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AlterTableIdosoAndrotina1700863027631 | ||
implements MigrationInterface | ||
{ | ||
name = 'AlterTableIdosoAndrotina1700863027631'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "idPaciente"`); | ||
await queryRunner.query(`ALTER TABLE "rotina" ADD "idIdoso" integer`); | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "dias"`); | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."rotina_dias_enum" AS ENUM('0', '1', '2', '3', '4', '5', '6')`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD "dias" "public"."rotina_dias_enum" array NOT NULL DEFAULT '{}'`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD CONSTRAINT "FK_2d6a9e702b76cd983428672bdb0" FOREIGN KEY ("idIdoso") REFERENCES "idoso"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" DROP CONSTRAINT "FK_2d6a9e702b76cd983428672bdb0"`, | ||
); | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "dias"`); | ||
await queryRunner.query(`DROP TYPE "public"."rotina_dias_enum"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD "dias" integer array NOT NULL DEFAULT '{}'`, | ||
); | ||
await queryRunner.query(`ALTER TABLE "rotina" DROP COLUMN "idIdoso"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "rotina" ADD "idPaciente" integer NOT NULL`, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export enum ECategoriaRotina { | ||
GERAL = 'Geral', | ||
ALIMENTACAO = 'Alimentação', | ||
EXERCICIOS = 'Exercícios', | ||
MEDICAMENTOS = 'Medicamentos', | ||
AGUA = 'Água', | ||
COMPROMISSOS = 'Compromissos', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export enum EDiasSemana { | ||
Domingo = 0, | ||
Segunda = 1, | ||
Terca = 2, | ||
Quarta = 3, | ||
Quinta = 4, | ||
Sexta = 5, | ||
Sabado = 6, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
IsArray, | ||
IsBoolean, | ||
IsDateString, | ||
IsEnum, | ||
IsNotEmpty, | ||
IsNumber, | ||
IsOptional, | ||
IsString, | ||
MaxLength, | ||
} from 'class-validator'; | ||
import { ECategoriaRotina } from '../classes/categoria-rotina.enum'; | ||
import { EDiasSemana } from '../classes/dias-semana.enum'; | ||
export class CreateRotinaDto { | ||
@IsNotEmpty() | ||
@IsNumber() | ||
idIdoso!: number; | ||
|
||
@IsString() | ||
@MaxLength(100) | ||
@IsNotEmpty() | ||
titulo?: string; | ||
|
||
@IsNotEmpty() | ||
@IsEnum(ECategoriaRotina) | ||
categoria?: ECategoriaRotina; | ||
|
||
@IsDateString() | ||
@IsNotEmpty() | ||
dataHora!: Date; | ||
|
||
@IsString() | ||
@IsOptional() | ||
@MaxLength(100) | ||
descricao?: string; | ||
|
||
@IsOptional() | ||
@IsBoolean() | ||
concluido?: boolean; | ||
|
||
@IsArray() | ||
@IsEnum(EDiasSemana, { each: true }) | ||
dias?: EDiasSemana[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateRotinaDto } from './create-rotina.dto'; | ||
|
||
export class UpdateRotinaDto extends PartialType(CreateRotinaDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
PrimaryGeneratedColumn, | ||
} from 'typeorm'; | ||
import { Idoso } from '../../idoso/entities/idoso.entity'; | ||
import { ECategoriaRotina } from '../classes/categoria-rotina.enum'; | ||
import { EDiasSemana } from '../classes/dias-semana.enum'; | ||
import { CreateRotinaDto } from '../dto/create-rotina.dto'; | ||
import { UpdateRotinaDto } from '../dto/update-rotina.dto'; | ||
|
||
@Entity({ name: 'rotina' }) | ||
export class Rotina { | ||
@PrimaryGeneratedColumn() | ||
id!: number; | ||
|
||
@Column('varchar', { length: 100 }) | ||
titulo!: string; | ||
|
||
@Column('enum', { enum: ECategoriaRotina }) | ||
categoria!: ECategoriaRotina; | ||
|
||
@Column('enum', { enum: EDiasSemana, array: true, default: [] }) | ||
dias!: EDiasSemana[]; | ||
|
||
@Column('timestamp') | ||
dataHora!: Date; | ||
|
||
@Column('varchar', { length: 100, nullable: true }) | ||
descricao!: string; | ||
|
||
@Column({ type: 'boolean', default: false }) | ||
concluido!: boolean; | ||
|
||
@ManyToOne(() => Idoso) | ||
@JoinColumn({ name: 'idIdoso' }) | ||
idIdoso!: number; | ||
|
||
constructor(createRotinaDto: CreateRotinaDto | UpdateRotinaDto) { | ||
Object.assign(this, createRotinaDto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IRotinaFilter { | ||
id?: number; | ||
idIdoso?: number; | ||
} |
Oops, something went wrong.