Tabla de inventario agregada

This commit is contained in:
2025-06-20 14:43:35 -04:00
parent 0a65946a8a
commit ed2a1da038
33 changed files with 3272 additions and 10 deletions

View File

@@ -18,7 +18,7 @@ import { MailModule } from './features/mail/mail.module';
import { RolesModule } from './features/roles/roles.module';
import { UserRolesModule } from './features/user-roles/user-roles.module';
import { SurveysModule } from './features/surveys/surveys.module';
import {InventoryModule} from './features/inventory/inventory.module'
@Module({
providers: [
@@ -58,7 +58,8 @@ import { SurveysModule } from './features/surveys/surveys.module';
UserRolesModule,
ConfigurationsModule,
SurveysModule,
LocationModule
LocationModule,
InventoryModule
],
})
export class AppModule {}

View File

@@ -0,0 +1,13 @@
CREATE TABLE "products" (
"id" serial PRIMARY KEY NOT NULL,
"title" text NOT NULL,
"description" text NOT NULL,
"price" numeric NOT NULL,
"stock" integer NOT NULL,
"url_img" text NOT NULL,
"user_id" integer,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp (3)
);
--> statement-breakpoint
ALTER TABLE "products" ADD CONSTRAINT "products_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE cascade ON UPDATE no action;

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,13 @@
"when": 1747665408016,
"tag": "0001_massive_kylun",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1750442271575,
"tag": "0002_polite_franklin_richards",
"breakpoints": true
}
]
}

View File

@@ -1,13 +1,11 @@
import { DRIZZLE_PROVIDER } from 'src/database/drizzle-provider';
import { Env, validateString } from '@/common/utils';
import { Inject, Injectable, HttpException, HttpStatus, NotFoundException, UnauthorizedException } from '@nestjs/common';
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
import * as schema from 'src/database/index';
import { products } from 'src/database/index';
import { eq, like, or, SQL, sql, and, not } from 'drizzle-orm';
import * as bcrypt from 'bcryptjs';
import { CreateProductDto } from './dto/create-product.dto';
import { UpdateUserDto } from './dto/update-product.dto';
import { UpdateProductDto } from './dto/update-product.dto';
import { Product } from './entities/inventory.entity';
import { PaginationDto } from '../../common/dto/pagination.dto';
@@ -53,8 +51,9 @@ export class InventoryService {
id: products.id,
title: products.title,
description: products.description,
valuePerUnit: products.valuePerUnit,
price: products.price,
urlImg: products.urlImg,
stock: products.stock,
// price: products.price,
// quantity: products.quantity,
// isActive: products.isActive
@@ -79,7 +78,7 @@ export class InventoryService {
previousPage: page > 1 ? page - 1 : null,
};
// console.log(data);
console.log(data);
return { data, meta };
}
@@ -90,8 +89,9 @@ export class InventoryService {
id: products.id,
title: products.title,
description: products.description,
valuePerUnit: products.valuePerUnit,
price: products.price,
urlImg: products.urlImg,
stock: products.stock
})
.from(products)
// .leftJoin(usersRole, eq(usersRole.userId, users.id))
@@ -124,8 +124,9 @@ export class InventoryService {
.values({
title: createProductDto.title,
description: createProductDto.description,
valuePerUnit: createProductDto.valuePerUnit,
price: createProductDto.price,
urlImg: createProductDto.urlImg,
stock: createProductDto.stock
})
.returning();