diff --git a/angular/src/app/app-routing.module.ts b/angular/src/app/app-routing.module.ts new file mode 100644 index 0000000..0297262 --- /dev/null +++ b/angular/src/app/app-routing.module.ts @@ -0,0 +1,10 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +const routes: Routes = []; + +@NgModule({ + imports: [RouterModule.forRoot(routes)], + exports: [RouterModule] +}) +export class AppRoutingModule { } diff --git a/beta/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/angular/src/app/app.component.css similarity index 100% rename from beta/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst rename to angular/src/app/app.component.css diff --git a/angular/src/app/app.component.html b/angular/src/app/app.component.html new file mode 100644 index 0000000..452aa9d --- /dev/null +++ b/angular/src/app/app.component.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/angular/src/app/app.component.spec.ts b/angular/src/app/app.component.spec.ts new file mode 100644 index 0000000..0170394 --- /dev/null +++ b/angular/src/app/app.component.spec.ts @@ -0,0 +1,29 @@ +import { TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(() => TestBed.configureTestingModule({ + imports: [RouterTestingModule], + declarations: [AppComponent] + })); + + it('should create the app', () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app).toBeTruthy(); + }); + + it(`should have as title 'control_stock'`, () => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.componentInstance; + expect(app.title).toEqual('control_stock'); + }); + + it('should render title', () => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.nativeElement as HTMLElement; + expect(compiled.querySelector('.content span')?.textContent).toContain('control_stock app is running!'); + }); +}); diff --git a/angular/src/app/app.component.ts b/angular/src/app/app.component.ts new file mode 100644 index 0000000..495992e --- /dev/null +++ b/angular/src/app/app.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + title = 'control_stock'; +} diff --git a/angular/src/app/app.module.ts b/angular/src/app/app.module.ts new file mode 100644 index 0000000..9751f00 --- /dev/null +++ b/angular/src/app/app.module.ts @@ -0,0 +1,27 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent } from './app.component'; +import { MovimientoComponent } from './movimiento/movimiento.component'; +import { HttpClientModule } from '@angular/common/http'; +import { MovimientoService } from './service/movimiento.service'; +import { FormComponent } from './form/form.component'; +import { FormsModule } from '@angular/forms'; +import { ProductoDepositoComponent } from './producto-deposito/producto-deposito.component'; +@NgModule({ + declarations: [ + AppComponent, + MovimientoComponent, + FormComponent, + ProductoDepositoComponent + ], + imports: [ + BrowserModule, + AppRoutingModule, + HttpClientModule, + FormsModule + ], + providers: [MovimientoService], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/angular/src/app/datos-formulario.ts b/angular/src/app/datos-formulario.ts new file mode 100644 index 0000000..cef5c8e --- /dev/null +++ b/angular/src/app/datos-formulario.ts @@ -0,0 +1,6 @@ +export interface DatosFormulario { + cantidad: number; + productoId: number; + movimientoTipoId: number; + depositoId: number; +} diff --git a/angular/src/app/form/form.component.css b/angular/src/app/form/form.component.css new file mode 100644 index 0000000..67b436a --- /dev/null +++ b/angular/src/app/form/form.component.css @@ -0,0 +1,70 @@ +/* Center the form and make inputs smaller */ +.my-form { + text-align: center; + max-width: 400px; + margin: 0 auto; + } + + /* Custom input style */ + .custom-input { + border: 1px solid #3498db; + border-radius: 5px; + padding: 5px; + width: 100%; + margin-bottom: 10px; + } + + /* Custom select style */ + .custom-select { + border: 1px solid #e74c3c; + border-radius: 5px; + padding: 5px; + width: 100%; + margin-bottom: 10px; + } + + /* Custom button style */ + .custom-button { + background-color: #27ae60; + border: none; + color: white; + padding: 10px 20px; + border-radius: 5px; + cursor: pointer; + width: 100%; + } + .page-header { + font-size: 24px; + text-align: center; + margin-bottom: 20px; + color: #333; /* Color de texto deseado */ + } + .error-message { + background-color: #f44336; /* Color de fondo rojo */ + color: white; /* Color de texto blanco */ + padding: 10px; /* Espaciado interior */ + border: 1px solid #d32f2f; /* Borde rojo */ + border-radius: 4px; /* Bordes redondeados */ + margin-top: 10px; /* Margen superior para separar de otros elementos */ + text-align: center; + } + .producto-cantidad { + font-size: 18px; + font-weight: bold; + margin-bottom: 10px; + } + + .lista-depositos { + list-style: none; + padding: 0; + } + + .deposito-item { + background-color: #f5f5f5; + border: 1px solid #ccc; + margin: 5px 0; + padding: 10px; + font-size: 16px; + } + + \ No newline at end of file diff --git a/angular/src/app/form/form.component.html b/angular/src/app/form/form.component.html new file mode 100644 index 0000000..9fb5aaf --- /dev/null +++ b/angular/src/app/form/form.component.html @@ -0,0 +1,44 @@ + + +
+ {{ errorMensaje }} +
+ +
+
+ + +
+
+ + +
+

Cantidad total del producto: {{ cantidadProducto }}

+ + + +
+ + +
+
+ + +
+ +
+ + + diff --git a/angular/src/app/form/form.component.spec.ts b/angular/src/app/form/form.component.spec.ts new file mode 100644 index 0000000..de45613 --- /dev/null +++ b/angular/src/app/form/form.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { FormComponent } from './form.component'; + +describe('FormComponent', () => { + let component: FormComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [FormComponent] + }); + fixture = TestBed.createComponent(FormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/src/app/form/form.component.ts b/angular/src/app/form/form.component.ts new file mode 100644 index 0000000..95c066a --- /dev/null +++ b/angular/src/app/form/form.component.ts @@ -0,0 +1,111 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { ProductoService } from '../service/producto.service'; +import { MovimientoTipoService } from '../service/movimiento-tipo.service'; +import { DepositoService } from '../service/deposito.service'; +import { ProductoDepositoService } from '../service/producto-deposito.service'; +import { MovimientoService } from '../service/movimiento.service'; +import { DatosFormulario } from '../datos-formulario'; +@Component({ + selector: 'app-form', + templateUrl: './form.component.html', + styleUrls: ['./form.component.css'] +}) +export class FormComponent implements OnInit { + formularioData: DatosFormulario = { cantidad: 0, productoId: 0, movimientoTipoId: 0, depositoId: 0 }; + productos: any[] = []; + tiposMovimiento: any[] = []; + depositos: any[] = []; + errorMensaje: string = ''; + cantidadProducto: number = 0; + cantidadDeposito: any[] = []; + + constructor(private http: HttpClient, private productoService: ProductoService, private movimientoTipoService: MovimientoTipoService, + private depositoService: DepositoService, private productoDepositoService: ProductoDepositoService, private movimientoService: MovimientoService) {} + + ngOnInit() { + this.cargarProductos(); + this.cargarTiposMovimiento(); + this.cargarDepositos(); + this.cargarCantidadProducto(); + } + + cargarProductos() { + this.productoService.cargarProductos().subscribe( + (response: any) => { + this.productos = response; + }, + (error) => { + this.errorMensaje = 'Error al cargar opciones de productos: ' + error; + } + ); + } + + cargarTiposMovimiento() { + this.movimientoTipoService.cargarTiposMovimiento().subscribe( + (response: any) => { + this.tiposMovimiento = response; + }, + (error) => { + this.errorMensaje = 'Error al cargar opciones de tipos de movimiento: ' + error; + } + ); + } + + cargarDepositos() { + this.depositoService.cargarDeposito().subscribe( + (response: any) => { + this.depositos = response; + }, + (error) => { + this.errorMensaje = 'Error al cargar opciones de depósitos: ' + error; + } + ); + } + + cargarCantidadProducto() { + const productoId = this.formularioData.productoId; + this.productoService.cargarProductoId(productoId).subscribe( + (response: any) => { + this.cantidadProducto = response.cantidad; + }, + (error) => { + console.error('Error al cargar la cantidad del producto', error); + } + ); + + // Obtener la lista de depósitos y sus cantidades respectivas + this.productoDepositoService.cargarProductoDeposito(productoId).subscribe( + (response: any) => { + this.cantidadDeposito = response; + }, + (error) => { + console.error('Error al cargar la lista de depósitos', error); + } + ); + } + + enviarDatos() { + const requestData = { + producto: { id: this.formularioData['productoId'] }, + deposito: { id: this.formularioData['depositoId'] }, + movimientoTipo: { id: this.formularioData['movimientoTipoId'] }, + cantidad: this.formularioData['cantidad'] + }; + + this.movimientoService.enviarDatos(requestData).subscribe( + (response) => { + this.errorMensaje = 'Datos enviados con éxito'; + }, + (error) => { + this.errorMensaje = 'Error al enviar los datos'; + }); + console.log('Datos a enviar:', requestData); + console.log(this.cantidadDeposito); + + setTimeout(() => { + window.location.reload(); + }, 1000); + } + +} diff --git a/angular/src/app/model/model.spec.ts b/angular/src/app/model/model.spec.ts new file mode 100644 index 0000000..b6d43bf --- /dev/null +++ b/angular/src/app/model/model.spec.ts @@ -0,0 +1,7 @@ +import { Model } from './model'; + +describe('Model', () => { + it('should create an instance', () => { + expect(new Model()).toBeTruthy(); + }); +}); diff --git a/angular/src/app/model/model.ts b/angular/src/app/model/model.ts new file mode 100644 index 0000000..215c2dd --- /dev/null +++ b/angular/src/app/model/model.ts @@ -0,0 +1,7 @@ +export class Model { + id?: any; + cantidad?: any; + producto_id?: any; + deposito_id?: any; + movimiento_tipo_id?: any; + } \ No newline at end of file diff --git a/beta/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/angular/src/app/movimiento/movimiento.component.css similarity index 100% rename from beta/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst rename to angular/src/app/movimiento/movimiento.component.css diff --git a/angular/src/app/movimiento/movimiento.component.html b/angular/src/app/movimiento/movimiento.component.html new file mode 100644 index 0000000..f22e425 --- /dev/null +++ b/angular/src/app/movimiento/movimiento.component.html @@ -0,0 +1,16 @@ +
+
+
+
+
+
{{ card.cantidad}}
+
{{ card.movimientoTipo.nombre}}
+

{{ card.deposito.nombre}}

+
{{ card.producto.nombre }}
+
{{ card.producto.descripcion}}
+

{{ card.precio }}

+
+
+
+
+
diff --git a/angular/src/app/movimiento/movimiento.component.spec.ts b/angular/src/app/movimiento/movimiento.component.spec.ts new file mode 100644 index 0000000..bf58b22 --- /dev/null +++ b/angular/src/app/movimiento/movimiento.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MovimientoComponent } from './movimiento.component'; + +describe('MovimientoComponent', () => { + let component: MovimientoComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [MovimientoComponent] + }); + fixture = TestBed.createComponent(MovimientoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/src/app/movimiento/movimiento.component.ts b/angular/src/app/movimiento/movimiento.component.ts new file mode 100644 index 0000000..4c65c55 --- /dev/null +++ b/angular/src/app/movimiento/movimiento.component.ts @@ -0,0 +1,31 @@ +import { Component, OnInit } from '@angular/core'; +import { MovimientoService } from '../service/movimiento.service'; +@Component({ + selector: 'app-movimiento', + templateUrl: './movimiento.component.html', + styleUrls: ['./movimiento.component.css'] +}) +export class MovimientoComponent implements OnInit { + public listaCard:any[] = []; + + constructor(private MovimientoService: MovimientoService) {} + + ngOnInit(): void { + this.cargarDato(); + + } + + public cargarDato() { + this.MovimientoService.get("http://localhost:8080/api/v1/movimientos") + .subscribe( + respuesta => { + console.log(respuesta); + this.listaCard = respuesta; + }, + error => { + console.error("Error en la solicitud:", error); + } + ); + + } +} \ No newline at end of file diff --git a/angular/src/app/producto-deposito/producto-deposito.component.css b/angular/src/app/producto-deposito/producto-deposito.component.css new file mode 100644 index 0000000..e69de29 diff --git a/angular/src/app/producto-deposito/producto-deposito.component.html b/angular/src/app/producto-deposito/producto-deposito.component.html new file mode 100644 index 0000000..a844ed7 --- /dev/null +++ b/angular/src/app/producto-deposito/producto-deposito.component.html @@ -0,0 +1,21 @@ +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + diff --git a/angular/src/app/producto-deposito/producto-deposito.component.spec.ts b/angular/src/app/producto-deposito/producto-deposito.component.spec.ts new file mode 100644 index 0000000..8316e67 --- /dev/null +++ b/angular/src/app/producto-deposito/producto-deposito.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProductoDepositoComponent } from './producto-deposito.component'; + +describe('ProductoDepositoComponent', () => { + let component: ProductoDepositoComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [ProductoDepositoComponent] + }); + fixture = TestBed.createComponent(ProductoDepositoComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/src/app/producto-deposito/producto-deposito.component.ts b/angular/src/app/producto-deposito/producto-deposito.component.ts new file mode 100644 index 0000000..eee9e37 --- /dev/null +++ b/angular/src/app/producto-deposito/producto-deposito.component.ts @@ -0,0 +1,65 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; + +interface DatosFormulario { + cantidad: number; + productoId: number; + depositoId: number; +} + +@Component({ + selector: 'app-form2', + templateUrl: './producto-deposito.component.html', +}) +export class ProductoDepositoComponent implements OnInit { + formularioData: DatosFormulario = { cantidad: 0, productoId: 0, depositoId: 0 }; + productos: any[] = []; // Array para almacenar opciones de productos + depositos: any[] = []; // Array para almacenar opciones de depósitos + + constructor(private http: HttpClient) {} + + ngOnInit() { + // Carga las opciones de productos, tipos de movimiento y depósitos desde tu backend. + this.cargarProductos(); + this.cargarDepositos(); + } + + cargarProductos() { + this.http.get('http://localhost:8080/api/v1/productos').subscribe( + (response: any) => { + this.productos = response; // Asigna la respuesta a this.productos + }, + (error) => { + console.error('Error al cargar opciones de productos', error); + } + ); + } + cargarDepositos() { + this.http.get('http://localhost:8080/api/v1/depositos').subscribe( + (response: any) => { + this.depositos = response; // Asigna la respuesta a this.depositos + }, + (error) => { + console.error('Error al cargar opciones de depósitos', error); + } + ); + } + + enviarDatos() { + const requestData = { + producto: { id: this.formularioData.productoId }, + deposito: { id: this.formularioData.depositoId } + }; + const url = 'http://localhost:8080/api/v1/productos_depositos'; + + this.http.post(url, requestData).subscribe( + (response) => { + console.log('Datos enviados con éxito', response); + }, + (error) => { + console.error('Error al enviar los datos', error); + } + ); + console.log('Datos a enviar:', requestData); + } +} diff --git a/angular/src/app/service/deposito.service.spec.ts b/angular/src/app/service/deposito.service.spec.ts new file mode 100644 index 0000000..b3647f8 --- /dev/null +++ b/angular/src/app/service/deposito.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { DepositoService } from './deposito.service'; + +describe('DepositoService', () => { + let service: DepositoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(DepositoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/angular/src/app/service/deposito.service.ts b/angular/src/app/service/deposito.service.ts new file mode 100644 index 0000000..d32ac4f --- /dev/null +++ b/angular/src/app/service/deposito.service.ts @@ -0,0 +1,13 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DepositoService { + constructor(private http: HttpClient) { } + + cargarDeposito() { + return this.http.get('http://localhost:8080/api/v1/depositos'); + } +} diff --git a/angular/src/app/service/movimiento-tipo.service.spec.ts b/angular/src/app/service/movimiento-tipo.service.spec.ts new file mode 100644 index 0000000..0ee786e --- /dev/null +++ b/angular/src/app/service/movimiento-tipo.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { MovimientoTipoService } from './movimiento-tipo.service'; + +describe('MovimientoTipoService', () => { + let service: MovimientoTipoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(MovimientoTipoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/angular/src/app/service/movimiento-tipo.service.ts b/angular/src/app/service/movimiento-tipo.service.ts new file mode 100644 index 0000000..c05b25d --- /dev/null +++ b/angular/src/app/service/movimiento-tipo.service.ts @@ -0,0 +1,13 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class MovimientoTipoService { + constructor(private http: HttpClient) { } + + cargarTiposMovimiento() { + return this.http.get('http://localhost:8080/api/v1/movimientos_tipos'); + } +} diff --git a/angular/src/app/service/movimiento.service.spec.ts b/angular/src/app/service/movimiento.service.spec.ts new file mode 100644 index 0000000..bb8f95a --- /dev/null +++ b/angular/src/app/service/movimiento.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { MovimientoService } from './movimiento.service'; + +describe('MovimientoService', () => { + let service: MovimientoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(MovimientoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/angular/src/app/service/movimiento.service.ts b/angular/src/app/service/movimiento.service.ts new file mode 100644 index 0000000..51b6d9f --- /dev/null +++ b/angular/src/app/service/movimiento.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class MovimientoService { + private baseUrl = 'http://localhost:8080/api/v1/movimientos'; + + public get(url: string): Observable { + return this.http.get(url); // GET + } + constructor(private http: HttpClient) { } + + enviarDatos(data: any): Observable { + const url = this.baseUrl; + return this.http.post(url, data); + } + +} \ No newline at end of file diff --git a/angular/src/app/service/producto-deposito.service.spec.ts b/angular/src/app/service/producto-deposito.service.spec.ts new file mode 100644 index 0000000..3846384 --- /dev/null +++ b/angular/src/app/service/producto-deposito.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProductoDepositoService } from './producto-deposito.service'; + +describe('ProductoDepositoService', () => { + let service: ProductoDepositoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ProductoDepositoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/angular/src/app/service/producto-deposito.service.ts b/angular/src/app/service/producto-deposito.service.ts new file mode 100644 index 0000000..f92254c --- /dev/null +++ b/angular/src/app/service/producto-deposito.service.ts @@ -0,0 +1,12 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +@Injectable({ + providedIn: 'root' +}) +export class ProductoDepositoService { + constructor(private http: HttpClient) { } + + cargarProductoDeposito(productoId: number) { + return this.http.get(`http://localhost:8080/api/v1/productos_depositos/producto/${productoId}`); + } +} diff --git a/angular/src/app/service/producto.service.spec.ts b/angular/src/app/service/producto.service.spec.ts new file mode 100644 index 0000000..14326d5 --- /dev/null +++ b/angular/src/app/service/producto.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProductoService } from './producto.service'; + +describe('ProductoService', () => { + let service: ProductoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(ProductoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/angular/src/app/service/producto.service.ts b/angular/src/app/service/producto.service.ts new file mode 100644 index 0000000..b5ad786 --- /dev/null +++ b/angular/src/app/service/producto.service.ts @@ -0,0 +1,18 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) + +export class ProductoService { + constructor(private http: HttpClient) { } + + cargarProductos() { + return this.http.get('http://localhost:8080/api/v1/productos'); + } + cargarProductoId(productoId: number){ + return this.http.get(`http://localhost:8080/api/v1/productos/${productoId}`) + } +} + diff --git a/angular/src/favicon.ico b/angular/src/favicon.ico new file mode 100644 index 0000000..997406a Binary files /dev/null and b/angular/src/favicon.ico differ diff --git a/angular/src/index.html b/angular/src/index.html new file mode 100644 index 0000000..9623120 --- /dev/null +++ b/angular/src/index.html @@ -0,0 +1,13 @@ + + + + + ControlStock + + + + + + + + diff --git a/angular/src/main.ts b/angular/src/main.ts new file mode 100644 index 0000000..c58dc05 --- /dev/null +++ b/angular/src/main.ts @@ -0,0 +1,7 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; + + +platformBrowserDynamic().bootstrapModule(AppModule) + .catch(err => console.error(err)); diff --git a/angular/src/styles.css b/angular/src/styles.css new file mode 100644 index 0000000..2ea47c4 --- /dev/null +++ b/angular/src/styles.css @@ -0,0 +1,2 @@ +/* You can add global styles to this file, and also import other style files */ +@import 'bootstrap/dist/css/bootstrap.min.css'; diff --git a/api/HELP.md b/api/HELP.md new file mode 100644 index 0000000..d401127 --- /dev/null +++ b/api/HELP.md @@ -0,0 +1,20 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.4/maven-plugin/reference/html/) +* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.4/maven-plugin/reference/html/#build-image) +* [Spring Web](https://docs.spring.io/spring-boot/docs/3.1.4/reference/htmlsingle/index.html#web) +* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.1.4/reference/htmlsingle/index.html#data.sql.jpa-and-spring-data) + +### Guides +The following guides illustrate how to use some features concretely: + +* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) +* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) +* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) +* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/) +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) + diff --git a/beta/bin/mvnw b/api/mvnw similarity index 100% rename from beta/bin/mvnw rename to api/mvnw diff --git a/beta/bin/mvnw.cmd b/api/mvnw.cmd similarity index 100% rename from beta/bin/mvnw.cmd rename to api/mvnw.cmd diff --git a/beta/bin/pom.xml b/api/pom.xml similarity index 63% rename from beta/bin/pom.xml rename to api/pom.xml index 5d2aecf..4a2eaf9 100644 --- a/beta/bin/pom.xml +++ b/api/pom.xml @@ -8,30 +8,15 @@ 3.1.4 - com.mobeats.control_stock - beta + com.mobeats + api 0.0.1-SNAPSHOT - beta + depositos Demo project for Spring Boot 17 - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-actuator - org.springframework.boot spring-boot-starter-data-jpa @@ -42,13 +27,28 @@ - org.springframework.boot - spring-boot-devtools - runtime - + javax.validation + validation-api + 2.0.1.Final + + + + + org.hibernate.validator + hibernate-validator + 6.2.0.Final + + - mysql - mysql-connector-java + mysql + mysql-connector-java + 8.0.28 + + + + + com.mysql + mysql-connector-j runtime @@ -56,6 +56,8 @@ spring-boot-starter-test test + + diff --git a/beta/src/main/java/com/mobeats/Application.java b/api/src/main/java/com/mobeats/api/Application.java similarity index 91% rename from beta/src/main/java/com/mobeats/Application.java rename to api/src/main/java/com/mobeats/api/Application.java index 8e157c7..cba98c1 100644 --- a/beta/src/main/java/com/mobeats/Application.java +++ b/api/src/main/java/com/mobeats/api/Application.java @@ -1,4 +1,4 @@ -package com.mobeats; +package com.mobeats.api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -9,4 +9,4 @@ public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } -} +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/controller/DepositoController.java b/api/src/main/java/com/mobeats/api/controller/DepositoController.java new file mode 100644 index 0000000..b0bd009 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/controller/DepositoController.java @@ -0,0 +1,86 @@ +package com.mobeats.api.controller; +import com.mobeats.api.model.Deposito; +import com.mobeats.api.repository.DepositoRepository; +import com.mobeats.api.exception.ResourceNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * The type User controller. + * + * @author Givantha Kalansuriya + */ +@RestController +@RequestMapping("/api/v1") +@CrossOrigin(origins = "http://localhost:4200") +public class DepositoController { + + @Autowired + private DepositoRepository depositoRepository; + + /** + * Get all users list. + * + * @return the list + */ + @GetMapping("/depositos") + public List getAllDepositos() { + return depositoRepository.findAll(); + } + + /** + * Gets users by id. + * + * @param depositoId the user id + * @return the users by id + * @throws ResourceNotFoundException the resource not found exception + */ + @GetMapping("/depositos/{id}") + public ResponseEntity getDepositoById(@PathVariable(value = "id") Long depositoId) + throws ResourceNotFoundException { + Deposito deposito = + depositoRepository + .findById(depositoId) + .orElseThrow(() -> new ResourceNotFoundException("Deposito not found on :: " + depositoId)); + return ResponseEntity.ok().body(deposito); + } + + /** + * Create user user. + * + * @param deposito the user + * @return the user + */ + @PostMapping("/depositos") + public Deposito createDeposito(@Valid @RequestBody Deposito deposito) { + return depositoRepository.save(deposito); + } + + /** + * Update user response entity. + * + * @param depositoId the user id + * @param depositoDetails the user details + * @return the response entity + * @throws ResourceNotFoundException the resource not found exception + */ + @PutMapping("/depositos/{id}") +public ResponseEntity updateDeposito( + @PathVariable(value = "id") Long depositoId, @Valid @RequestBody Deposito depositoDetails) + throws ResourceNotFoundException { + + Deposito deposito = + depositoRepository + .findById(depositoId) + .orElseThrow(() -> new ResourceNotFoundException("product not found on :: " + depositoId)); + + deposito.setNombre(depositoDetails.getNombre()); + final Deposito updateDeposito = depositoRepository.save(deposito); // Cambio de variable a updatedProducto + return ResponseEntity.ok(updateDeposito); // Cambio de variable a updatedProducto +} + +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/controller/MovimientoController.java b/api/src/main/java/com/mobeats/api/controller/MovimientoController.java new file mode 100644 index 0000000..7eb8091 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/controller/MovimientoController.java @@ -0,0 +1,44 @@ +package com.mobeats.api.controller; + +import com.mobeats.api.model.Movimiento; +import com.mobeats.api.service.MovimientoService; +import com.mobeats.api.exception.ResourceNotFoundException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + + +/** + * The type User controller. + * + * @author Givantha Kalansuriya + */ +@RestController +@RequestMapping("/api/v1") +@CrossOrigin(origins = "http://localhost:4200") +public class MovimientoController { + + @Autowired + private MovimientoService movimientoService; + + @GetMapping("/movimientos") + public List getAllMovimientos() { + return movimientoService.getAllMovimientos(); + } + + @GetMapping("/movimientos/{id}") + public ResponseEntity getMovimientoById(@PathVariable(value = "id") Long movimientoId) + throws ResourceNotFoundException { + Movimiento movimiento = movimientoService.getMovimientoById(movimientoId); + return ResponseEntity.ok().body(movimiento); + } + + @PostMapping("/movimientos") + public Movimiento createMovimiento(@Valid @RequestBody Movimiento movimiento) { + return movimientoService.createMovimiento(movimiento); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/controller/MovimientoTipoController.java b/api/src/main/java/com/mobeats/api/controller/MovimientoTipoController.java new file mode 100644 index 0000000..3d12ec5 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/controller/MovimientoTipoController.java @@ -0,0 +1,46 @@ +package com.mobeats.api.controller; +import com.mobeats.api.model.MovimientoTipo; +import com.mobeats.api.service.MovimientoTipoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * The type User controller. + * + * @author Givantha Kalansuriya + */ +@RestController +@RequestMapping("/api/v1") +@CrossOrigin(origins = "http://localhost:4200") +public class MovimientoTipoController { + + @Autowired + private MovimientoTipoService movimientoTipoService; + + @GetMapping("/movimientos_tipos") + public List getAllMovimientoTipos() { + return movimientoTipoService.getAllMovimientoTipos(); + } + + @GetMapping("/movimientos_tipos/{id}") + public ResponseEntity getMovimientoTipoById(@PathVariable(value = "id") Long movimientoTipoId) { + MovimientoTipo movimientoTipo = movimientoTipoService.getMovimientoTipoById(movimientoTipoId); + return ResponseEntity.ok().body(movimientoTipo); + } + + @PostMapping("/movimientos_tipos") + public MovimientoTipo createMovimientoTipo(@Valid @RequestBody MovimientoTipo movimientoTipo) { + return movimientoTipoService.createMovimientoTipo(movimientoTipo); + } + + @PutMapping("/movimientos_tipos/{id}") + public ResponseEntity updateMovimientoTipo( + @PathVariable(value = "id") Long movimientoTipoId, @Valid @RequestBody MovimientoTipo movimientoTipoDetails) { + MovimientoTipo updatedMovimientoTipo = movimientoTipoService.updateMovimientoTipo(movimientoTipoId, movimientoTipoDetails); + return ResponseEntity.ok(updatedMovimientoTipo); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/controller/ProductoController.java b/api/src/main/java/com/mobeats/api/controller/ProductoController.java new file mode 100644 index 0000000..19e0ee9 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/controller/ProductoController.java @@ -0,0 +1,51 @@ +package com.mobeats.api.controller; +import com.mobeats.api.model.Producto; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.service.ProductoService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * The type User controller. + * + * @author Givantha Kalansuriya + */ +@RestController +@RequestMapping("/api/v1") +@CrossOrigin(origins = "http://localhost:4200") +public class ProductoController { + + @Autowired + private ProductoService productoService; + + @GetMapping("/productos") + public List getAllProductos() { + return productoService.getAllProductos(); + } + + @GetMapping("/productos/{id}") + public ResponseEntity getProductoById(@PathVariable(value = "id") Long productoId) + throws ResourceNotFoundException { + Producto producto = productoService.getProductoById(productoId); + return ResponseEntity.ok().body(producto); + } + + @PostMapping("/productos") + public Producto createProducto(@Valid @RequestBody Producto producto) { + return productoService.createProducto(producto); + } + + @PutMapping("/productos/{id}") + public ResponseEntity updateProducto( + @PathVariable(value = "id") Long productoId, + @Valid @RequestBody Producto productoDetails) + throws ResourceNotFoundException { + Producto updatedProducto = productoService.updateProducto(productoId, productoDetails); + return ResponseEntity.ok(updatedProducto); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/controller/ProductoDepositoController.java b/api/src/main/java/com/mobeats/api/controller/ProductoDepositoController.java new file mode 100644 index 0000000..b8ccafd --- /dev/null +++ b/api/src/main/java/com/mobeats/api/controller/ProductoDepositoController.java @@ -0,0 +1,51 @@ +package com.mobeats.api.controller; + +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.ProductoDeposito; +import com.mobeats.api.service.ProductoDepositoService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/api/v1") +@CrossOrigin(origins = "http://localhost:4200") +public class ProductoDepositoController { + + @Autowired + private ProductoDepositoService productoDepositoService; + + @GetMapping("/productos_depositos") + public List getAllProductosDepositos() { + return productoDepositoService.getAllProductosDepositos(); + } + + @GetMapping("/productos_depositos/{id}") + public ResponseEntity getProductoDepositoById(@PathVariable(value = "id") Long productoDepositoId) + throws ResourceNotFoundException { + ProductoDeposito productoDeposito = productoDepositoService.getProductoDepositoById(productoDepositoId); + return ResponseEntity.ok().body(productoDeposito); + } + @GetMapping("/productos_depositos/producto/{id_producto}") + public List getProductosDepositosByProductoId(@PathVariable(value = "id_producto") Long productoId) { + return productoDepositoService.getProductosDepositosByProductoId(productoId); + } + + @PostMapping("/productos_depositos") + public ProductoDeposito createProductoDeposito(@Valid @RequestBody ProductoDeposito productoDeposito) { + return productoDepositoService.createProductoDeposito(productoDeposito); + } + + @PutMapping("/productos_depositos/{id}") + public ResponseEntity updateProductoDeposito( + @PathVariable(value = "id") Long productoDepositoId, + @Valid @RequestBody ProductoDeposito productoDepositoDetails) + throws ResourceNotFoundException { + ProductoDeposito updatedProductoDeposito = productoDepositoService.updateProductoDeposito(productoDepositoId, productoDepositoDetails); + return ResponseEntity.ok(updatedProductoDeposito); + } +} diff --git a/beta/src/main/java/com/mobeats/exception/ResourceNotFoundException.java b/api/src/main/java/com/mobeats/api/exception/ResourceNotFoundException.java similarity index 73% rename from beta/src/main/java/com/mobeats/exception/ResourceNotFoundException.java rename to api/src/main/java/com/mobeats/api/exception/ResourceNotFoundException.java index 3ab0e34..d976499 100644 --- a/beta/src/main/java/com/mobeats/exception/ResourceNotFoundException.java +++ b/api/src/main/java/com/mobeats/api/exception/ResourceNotFoundException.java @@ -1,4 +1,4 @@ -package com.mobeats.exception; +package com.mobeats.api.exception; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; @@ -9,8 +9,8 @@ * @author Givantha Kalansuriya */ @ResponseStatus(value = HttpStatus.NOT_FOUND) -public class ResourceNotFoundException extends Exception { - +public class ResourceNotFoundException extends RuntimeException{ + private static final long serialVersionUID = 1L; /** * Instantiates a new Resource not found exception. * diff --git a/api/src/main/java/com/mobeats/api/model/Deposito.java b/api/src/main/java/com/mobeats/api/model/Deposito.java new file mode 100644 index 0000000..223b82e --- /dev/null +++ b/api/src/main/java/com/mobeats/api/model/Deposito.java @@ -0,0 +1,78 @@ +package com.mobeats.api.model; + +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.*; +import java.util.Objects; + +@Entity +@Table(name = "depositos") +@EntityListeners(AuditingEntityListener.class) +public class Deposito { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = "nombre", nullable = false) + private String nombre; + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets nombre + * + * @return the nombre + */ + public String getNombre() { + return nombre; + } + + /** + * Sets nombre. + * + * @param nombre the nombre + */ + public void setNombre(String nombre) { + this.nombre = nombre; + } + + @Override + public String toString() { + return "Depositos{" + + "id=" + id + + ", nombre='" + nombre + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Deposito deposito = (Deposito) o; + return Objects.equals(id, deposito.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/model/Movimiento.java b/api/src/main/java/com/mobeats/api/model/Movimiento.java new file mode 100644 index 0000000..a76c663 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/model/Movimiento.java @@ -0,0 +1,96 @@ +package com.mobeats.api.model; + +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.*; +import java.util.Date; + + +@Entity +@Table(name = "movimientos") +@EntityListeners(AuditingEntityListener.class) +public class Movimiento { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = "cantidad", nullable = false) + private Integer cantidad; + + @ManyToOne + @JoinColumn(name = "id_producto", referencedColumnName = "id") + private Producto producto; + + @ManyToOne + @JoinColumn(name = "id_movimiento_tipo", referencedColumnName = "id") + private MovimientoTipo movimientoTipo; + + @ManyToOne + @JoinColumn(name = "id_deposito", referencedColumnName = "id") + private Deposito deposito; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha", nullable = false, updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + private Date fecha = new Date(); + +public long getId() { + return id; +} + +public void setId(long id) { + this.id = id; +} + +public Integer getCantidad() { + return cantidad; +} + +public void setCantidad(Integer cantidad) { + this.cantidad = cantidad; +} + +public Producto getProducto() { + return producto; +} + +public void setProducto(Producto producto) { + this.producto = producto; +} + +public MovimientoTipo getMovimientoTipo() { + return movimientoTipo; +} + +public void setMovimientoTipo(MovimientoTipo movimientoTipo) { + this.movimientoTipo = movimientoTipo; +} + +public Deposito getDeposito() { + return deposito; +} + +public void setDeposito(Deposito deposito) { + this.deposito = deposito; +} + +public Date getFecha() { + return fecha; +} + +public void setFecha(Date fecha) { + this.fecha = fecha; +} + + @Override + public String toString() { + return "Movimiento{" + + "id=" + id + + ", cantidad=" + cantidad + + ", producto=" + producto + + ", movimientoTipo=" + movimientoTipo + + ", deposito=" + deposito + + ", fecha=" + fecha + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/model/MovimientoTipo.java b/api/src/main/java/com/mobeats/api/model/MovimientoTipo.java new file mode 100644 index 0000000..8530e20 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/model/MovimientoTipo.java @@ -0,0 +1,110 @@ +package com.mobeats.api.model; + +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.*; + +@Entity +@Table(name = "movimientos_tipos") +@EntityListeners(AuditingEntityListener.class) +public class MovimientoTipo { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = "nombre", nullable = false) + private String nombre; + + @Column(name = "descripcion", nullable = false) + private String descripcion; + + @Column(name = "saldo", nullable = false) + @Enumerated(EnumType.STRING) + private SaldoEnum saldo; + public enum SaldoEnum { + ACREEDOR, + DEUDOR + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets nombre + * + * @return the nombre + */ + public String getNombre() { + return nombre; + } + + /** + * Sets nombre. + * + * @param nombre the nombre + */ + public void setNombre(String nombre) { + this.nombre = nombre; + } + + /** + * Gets descripcion. + * + * @return the descripcion + */ + public String getDescripcion() { + return descripcion; + } + + /** + * Sets descripcion. + * + * @param descripcion the descripcion + */ + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + /** + * Gets saldo. + * + * @return the saldo + */ + public SaldoEnum getSaldo() { + return saldo; + } + + /** + * Sets saldo. + * + * @param saldo the saldo + */ + public void setSaldo(SaldoEnum saldo) { + this.saldo = saldo; + } + + @Override + public String toString() { + return "Productos{" + + "id=" + id + + ", nombre='" + nombre + '\'' + + ", descripcion='" + descripcion + '\'' + + ", saldo='" + saldo + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/model/Producto.java b/api/src/main/java/com/mobeats/api/model/Producto.java new file mode 100644 index 0000000..d9fa54f --- /dev/null +++ b/api/src/main/java/com/mobeats/api/model/Producto.java @@ -0,0 +1,193 @@ +package com.mobeats.api.model; + +import org.hibernate.annotations.UpdateTimestamp; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.*; +import java.util.Date; +import java.util.Objects; + +@Entity +@Table(name = "productos") +@EntityListeners(AuditingEntityListener.class) +public class Producto { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = "nombre", nullable = false) + private String nombre; + + @Column(name = "descripcion", nullable = false) + private String descripcion; + + @Column(name = "precio", nullable = false) + private Float precio; + + @Column(name = "cantidad", nullable = false) + private int cantidad; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha_creacion", nullable = false, updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + private Date fecha_creacion = new Date(); + + @UpdateTimestamp + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha_actualizacion", nullable = false) + private Date fecha_actualizacion; + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets nombre + * + * @return the nombre + */ + public String getNombre() { + return nombre; + } + + /** + * Sets nombre. + * + * @param nombre the nombre + */ + public void setNombre(String nombre) { + this.nombre = nombre; + } + + /** + * Gets descripcion. + * + * @return the descripcion + */ + public String getDescripcion() { + return descripcion; + } + + /** + * Sets descripcion. + * + * @param descripcion the descripcion + */ + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + /** + * Gets precio. + * + * @return the precio + */ + public Float getPrecio() { + return precio; + } + + /** + * Sets precio. + * + * @param precio the precio + */ + public void setPrecio(Float precio) { + this.precio = precio; + } + + /** + * Gets cantidad. + * + * @return the cantidad + */ + public Integer getCantidad() { + return cantidad; + } + + /** + * Sets cantidad. + * + * @param cantidad the cantidad + */ + public void setCantidad(Integer cantidad) { + this.cantidad = cantidad; + } + + /** + * Gets fecha_creacion. + * + * @return the fecha_creacion + */ + public Date getFechaCreacion() { + return fecha_creacion; + } + + /** + * Sets fecha_creacion. + * + * @param fecha_creacion the fecha_creacion + */ + public void setFechaCreacion(Date fecha_creacion) { + this.fecha_creacion = fecha_creacion; + } + + /** + * Gets fecha_actualizacion. + * + * @return the fecha_actualizacion + */ + public Date getFechaActualizacion() { + return fecha_actualizacion; + } + + /** + * Sets fecha_actualizacion. + * + * @param fecha_actualizacion the fecha_actualizacion + */ + public void setFechaActualizacion(Date fecha_actualizacion) { + this.fecha_actualizacion = fecha_actualizacion; + } + + @Override + public String toString() { + return "Productos{" + + "id=" + id + + ", nombre='" + nombre + '\'' + + ", descripcion='" + descripcion + '\'' + + ", precio='" + precio + '\'' + + ", cantidad=" + cantidad + + ", fecha_creacion='" + fecha_creacion + '\'' + + ", fecha_actualizacion=" + fecha_actualizacion + '\'' + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Producto producto = (Producto) o; + return Objects.equals(id, producto.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/model/ProductoDeposito.java b/api/src/main/java/com/mobeats/api/model/ProductoDeposito.java new file mode 100644 index 0000000..780da9a --- /dev/null +++ b/api/src/main/java/com/mobeats/api/model/ProductoDeposito.java @@ -0,0 +1,116 @@ +package com.mobeats.api.model; + +import org.hibernate.annotations.UpdateTimestamp; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +@Table(name = "productos_depositos") +@EntityListeners(AuditingEntityListener.class) +public class ProductoDeposito { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = "cantidad", nullable = false) + private int cantidad; + + @UpdateTimestamp + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "fecha_actualizacion", nullable = false) + private Date fecha_actualizacion; + + @ManyToOne + @JoinColumn(name = "id_producto", referencedColumnName = "id") + private Producto producto; + + @ManyToOne + @JoinColumn(name = "id_deposito", referencedColumnName = "id") + private Deposito deposito; + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + + /** + * Gets cantidad. + * + * @return the cantidad + */ + public Integer getCantidad() { + return cantidad; + } + + /** + * Sets cantidad. + * + * @param cantidad the cantidad + */ + public void setCantidad(Integer cantidad) { + this.cantidad = cantidad; + } + + /** + * Gets fecha_actualizacion. + * + * @return the fecha_actualizacion + */ + public Date getFechaActualizacion() { + return fecha_actualizacion; + } + + /** + * Sets fecha_actualizacion. + * + * @param fecha_actualizacion the fecha_actualizacion + */ + public void setFechaActualizacion(Date fecha_actualizacion) { + this.fecha_actualizacion = fecha_actualizacion; + } + + public Producto getProducto() { + return producto; + } + + public void setProducto(Producto producto) { + this.producto = producto; + } + + public Deposito getDeposito() { + return deposito; + } + + public void setDeposito(Deposito deposito) { + this.deposito = deposito; + } + + @Override + public String toString() { + return "Productos{" + + "id=" + id + + ", cantidad=" + cantidad + + ", fecha_actualizacion=" + fecha_actualizacion + '\'' + + ", producto=" + producto + + ", deposito=" + deposito + + '}'; + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/repository/DepositoRepository.java b/api/src/main/java/com/mobeats/api/repository/DepositoRepository.java new file mode 100644 index 0000000..e889840 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/repository/DepositoRepository.java @@ -0,0 +1,9 @@ +package com.mobeats.api.repository; + +import com.mobeats.api.model.Deposito; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface DepositoRepository extends JpaRepository {} diff --git a/api/src/main/java/com/mobeats/api/repository/MovimientoRepository.java b/api/src/main/java/com/mobeats/api/repository/MovimientoRepository.java new file mode 100644 index 0000000..3f890c2 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/repository/MovimientoRepository.java @@ -0,0 +1,11 @@ +package com.mobeats.api.repository; + +import com.mobeats.api.model.Movimiento; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface MovimientoRepository extends JpaRepository {} + diff --git a/api/src/main/java/com/mobeats/api/repository/MovimientoTipoRepository.java b/api/src/main/java/com/mobeats/api/repository/MovimientoTipoRepository.java new file mode 100644 index 0000000..97f0dd3 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/repository/MovimientoTipoRepository.java @@ -0,0 +1,11 @@ +package com.mobeats.api.repository; + +import com.mobeats.api.model.MovimientoTipo; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface MovimientoTipoRepository extends JpaRepository {} + diff --git a/api/src/main/java/com/mobeats/api/repository/ProductoDepositoRepository.java b/api/src/main/java/com/mobeats/api/repository/ProductoDepositoRepository.java new file mode 100644 index 0000000..605361b --- /dev/null +++ b/api/src/main/java/com/mobeats/api/repository/ProductoDepositoRepository.java @@ -0,0 +1,14 @@ +package com.mobeats.api.repository; + +import com.mobeats.api.model.ProductoDeposito; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import com.mobeats.api.model.Producto; +import com.mobeats.api.model.Deposito; +import java.util.List; + +@Repository +public interface ProductoDepositoRepository extends JpaRepository { + List findByProductoId(Long productoId); + ProductoDeposito findByProductoAndDeposito(Producto producto, Deposito deposito); +} \ No newline at end of file diff --git a/beta/src/main/java/com/mobeats/repository/ProductoRepository.java b/api/src/main/java/com/mobeats/api/repository/ProductoRepository.java similarity index 58% rename from beta/src/main/java/com/mobeats/repository/ProductoRepository.java rename to api/src/main/java/com/mobeats/api/repository/ProductoRepository.java index 4eb58ed..87d8e82 100644 --- a/beta/src/main/java/com/mobeats/repository/ProductoRepository.java +++ b/api/src/main/java/com/mobeats/api/repository/ProductoRepository.java @@ -1,9 +1,11 @@ -package com.mobeats.repository; +package com.mobeats.api.repository; -import com.mobeats.model.Producto; +import com.mobeats.api.model.Producto; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface ProductoRepository extends JpaRepository {} \ No newline at end of file +public interface ProductoRepository extends JpaRepository { + Producto findById(Producto producto); +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/service/DepositoService.java b/api/src/main/java/com/mobeats/api/service/DepositoService.java new file mode 100644 index 0000000..bac2f31 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/service/DepositoService.java @@ -0,0 +1,36 @@ +package com.mobeats.api.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.Deposito; +import com.mobeats.api.repository.DepositoRepository; + +@Service +public class DepositoService { + + @Autowired + private DepositoRepository depositoRepository; + + public List getAllDepositos() { + return depositoRepository.findAll(); + } + + public Deposito getDepositoById(Long depositoId) { + return depositoRepository.findById(depositoId) + .orElseThrow(() -> new ResourceNotFoundException("Deposito not found on :: " + depositoId)); + } + + public Deposito createDeposito(Deposito deposito) { + return depositoRepository.save(deposito); + } + + public Deposito updateDeposito(Long depositoId, Deposito depositoDetails) { + Deposito deposito = getDepositoById(depositoId); + deposito.setNombre(depositoDetails.getNombre()); + return depositoRepository.save(deposito); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/service/MovimientoService.java b/api/src/main/java/com/mobeats/api/service/MovimientoService.java new file mode 100644 index 0000000..f3988a0 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/service/MovimientoService.java @@ -0,0 +1,84 @@ +package com.mobeats.api.service; + +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.Movimiento; +import com.mobeats.api.model.MovimientoTipo; +import com.mobeats.api.model.ProductoDeposito; +import com.mobeats.api.model.Producto; +import com.mobeats.api.repository.MovimientoRepository; +import com.mobeats.api.repository.MovimientoTipoRepository; +import com.mobeats.api.repository.ProductoDepositoRepository; +import com.mobeats.api.repository.ProductoRepository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; // Agrega la importación de List + +@Service +public class MovimientoService { + + @Autowired + private MovimientoRepository movimientoRepository; + + @Autowired + private MovimientoTipoRepository movimientoTipoRepository; + + @Autowired + private ProductoDepositoRepository productoDepositoRepository; + + @Autowired + private ProductoRepository productoRepository; + + @Autowired + private ProductoDepositoService productoDepositoService; + + @Autowired + private ProductoService productoService; + + public List getAllMovimientos() { + return movimientoRepository.findAll(); + } + + public Movimiento getMovimientoById(Long movimientoId) { + return movimientoRepository + .findById(movimientoId) + .orElseThrow(() -> new ResourceNotFoundException("Movimiento not found with ID: " + movimientoId)); + } + + @Transactional + public Movimiento createMovimiento(Movimiento movimiento) { + Producto producto = productoRepository.findById(movimiento.getProducto().getId()) + .orElseThrow(() -> new ResourceNotFoundException( + "Producto not found with ID: " + movimiento.getProducto().getId())); + + ProductoDeposito productoDeposito = productoDepositoRepository.findByProductoAndDeposito(producto, + movimiento.getDeposito()); + MovimientoTipo movimientoTipo = movimientoTipoRepository.findById(movimiento.getMovimientoTipo().getId()) + .orElseThrow(() -> new ResourceNotFoundException( + "MovimientoTipo not found with ID: " + movimiento.getMovimientoTipo().getId())); + + Integer nuevaCantidad = movimiento.getCantidad(); + Integer nuevaCantidadProducto = nuevaCantidad; + + if ("ACREEDOR".equals(movimientoTipo.getSaldo().toString())) { + nuevaCantidad += productoDeposito.getCantidad(); + nuevaCantidadProducto += producto.getCantidad(); + } else { + if (productoDeposito.getCantidad() >= nuevaCantidad) { + nuevaCantidad = productoDeposito.getCantidad() - nuevaCantidad; + nuevaCantidadProducto = producto.getCantidad() - nuevaCantidadProducto; + } else { + throw new RuntimeException("Estás queriendo sacar " + nuevaCantidad + + " y en el depósito hay " + productoDeposito.getCantidad()); + } + } + + productoDepositoService.updateCantidadProductoDeposito(productoDeposito.getId(), nuevaCantidad); + productoService.updateCantidadProducto(movimiento.getProducto().getId(), nuevaCantidadProducto); + + return movimientoRepository.save(movimiento); + } +} diff --git a/api/src/main/java/com/mobeats/api/service/MovimientoTipoService.java b/api/src/main/java/com/mobeats/api/service/MovimientoTipoService.java new file mode 100644 index 0000000..6f08745 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/service/MovimientoTipoService.java @@ -0,0 +1,37 @@ +package com.mobeats.api.service; + +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.MovimientoTipo; +import com.mobeats.api.repository.MovimientoTipoRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class MovimientoTipoService { + + @Autowired + private MovimientoTipoRepository movimientoTipoRepository; + + public List getAllMovimientoTipos() { + return movimientoTipoRepository.findAll(); + } + + public MovimientoTipo getMovimientoTipoById(Long movimientoTipoId) { + return movimientoTipoRepository.findById(movimientoTipoId) + .orElseThrow(() -> new ResourceNotFoundException("MovimientoTipo not found on :: " + movimientoTipoId)); + } + + public MovimientoTipo createMovimientoTipo(MovimientoTipo movimientoTipo) { + return movimientoTipoRepository.save(movimientoTipo); + } + + public MovimientoTipo updateMovimientoTipo(Long movimientoTipoId, MovimientoTipo movimientoTipoDetails) { + MovimientoTipo movimientoTipo = getMovimientoTipoById(movimientoTipoId); + movimientoTipo.setNombre(movimientoTipoDetails.getNombre()); + movimientoTipo.setDescripcion(movimientoTipoDetails.getDescripcion()); + movimientoTipo.setSaldo(movimientoTipoDetails.getSaldo()); + return movimientoTipoRepository.save(movimientoTipo); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/service/ProductoDepositoService.java b/api/src/main/java/com/mobeats/api/service/ProductoDepositoService.java new file mode 100644 index 0000000..6d81b91 --- /dev/null +++ b/api/src/main/java/com/mobeats/api/service/ProductoDepositoService.java @@ -0,0 +1,49 @@ +package com.mobeats.api.service; + +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.ProductoDeposito; +import com.mobeats.api.repository.ProductoDepositoRepository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +public class ProductoDepositoService { + + @Autowired + private ProductoDepositoRepository productoDepositoRepository; + + public List getAllProductosDepositos() { + return productoDepositoRepository.findAll(); + } + public List getProductosDepositosByProductoId(Long productoId) { + return productoDepositoRepository.findByProductoId(productoId); + } + + public ProductoDeposito getProductoDepositoById(Long productoDepositoId) { + return productoDepositoRepository + .findById(productoDepositoId) + .orElseThrow(() -> new ResourceNotFoundException("producto not found on :: " + productoDepositoId)); + } + + public ProductoDeposito createProductoDeposito(ProductoDeposito productoDeposito) { + return productoDepositoRepository.save(productoDeposito); + } + + public ProductoDeposito updateProductoDeposito(Long productoDepositoId, ProductoDeposito productoDepositoDetails) { + ProductoDeposito productoDeposito = getProductoDepositoById(productoDepositoId); + productoDeposito.setCantidad(productoDepositoDetails.getCantidad()); + productoDeposito.setProducto(productoDepositoDetails.getProducto()); + productoDeposito.setDeposito(productoDepositoDetails.getDeposito()); + return productoDepositoRepository.save(productoDeposito); + } + + public ProductoDeposito updateCantidadProductoDeposito(Long productoDepositoId, Integer nuevaCantidad) { + ProductoDeposito productoDeposito = productoDepositoRepository.findById(productoDepositoId) + .orElseThrow(() -> new ResourceNotFoundException("ProductoDeposito not found on :: " + productoDepositoId)); + + productoDeposito.setCantidad(nuevaCantidad); + return productoDepositoRepository.save(productoDeposito); + } +} \ No newline at end of file diff --git a/api/src/main/java/com/mobeats/api/service/ProductoService.java b/api/src/main/java/com/mobeats/api/service/ProductoService.java new file mode 100644 index 0000000..1b64bca --- /dev/null +++ b/api/src/main/java/com/mobeats/api/service/ProductoService.java @@ -0,0 +1,47 @@ +package com.mobeats.api.service; + +import java.util.List; +import com.mobeats.api.exception.ResourceNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.mobeats.api.model.Producto; +import com.mobeats.api.repository.ProductoRepository; + +@Service +public class ProductoService { + + @Autowired + private ProductoRepository productoRepository; + + public List getAllProductos() { + return productoRepository.findAll(); + } + + public Producto getProductoById(Long productoId) { + return productoRepository + .findById(productoId) + .orElseThrow(() -> new ResourceNotFoundException("producto not found on :: " + productoId)); + } + + public Producto createProducto(Producto producto) { + return productoRepository.save(producto); + } + + public Producto updateProducto(Long productoId, Producto productoDetails) { + Producto producto = getProductoById(productoId); + producto.setNombre(productoDetails.getNombre()); + producto.setDescripcion(productoDetails.getDescripcion()); + producto.setPrecio(productoDetails.getPrecio()); + producto.setCantidad(productoDetails.getCantidad()); + return productoRepository.save(producto); + } + + public Producto updateCantidadProducto(Long productoId, Integer nuevaCantidad) { + Producto producto = productoRepository.findById(productoId) + .orElseThrow( + () -> new ResourceNotFoundException("Producto not found on :: " + productoId)); + producto.setCantidad(nuevaCantidad); + return productoRepository.save(producto); + } +} diff --git a/api/src/main/resources/application.properties b/api/src/main/resources/application.properties new file mode 100644 index 0000000..0c65050 --- /dev/null +++ b/api/src/main/resources/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:mysql://localhost:3306/control_stock +spring.datasource.username=root +spring.datasource.password= +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/api/src/test/java/com/mobeats/api/DepositoServiceTest.java b/api/src/test/java/com/mobeats/api/DepositoServiceTest.java new file mode 100644 index 0000000..791a7d2 --- /dev/null +++ b/api/src/test/java/com/mobeats/api/DepositoServiceTest.java @@ -0,0 +1,76 @@ +package com.mobeats.api; + +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import com.mobeats.api.service.DepositoService; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.Deposito; +import com.mobeats.api.repository.DepositoRepository; + +public class DepositoServiceTest { + + @Mock + private DepositoRepository depositoRepositoryMock; + + @InjectMocks + private DepositoService depositoService; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetAllDepositos() { + // Create a list of mock Depositos + List mockDepositos = new ArrayList<>(); + mockDepositos.add(new Deposito(1L, "Deposito 1")); + mockDepositos.add(new Deposito(2L, "Deposito 2")); + + // Set up the behavior of the mock repository + when(depositoRepositoryMock.findAll()).thenReturn(mockDepositos); + + // Perform the test + List result = depositoService.getAllDepositos(); + + // Verify the result + assertEquals(mockDepositos, result); + } + + @Test + public void testGetDepositoById() { + // Create a mock Deposito + Deposito mockDeposito = new Deposito(1L, "Deposito 1"); + + // Set up the behavior of the mock repository + when(depositoRepositoryMock.findById(1L)).thenReturn(Optional.of(mockDeposito)); + + // Perform the test + Deposito result = depositoService.getDepositoById(1L); + + // Verify the result + assertEquals(mockDeposito, result); + } + + @Test + public void testGetDepositoById_NotFound() { + // Set up the behavior of the mock repository to return an empty Optional + when(depositoRepositoryMock.findById(1L)).thenReturn(Optional.empty()); + + // Perform the test and expect a ResourceNotFoundException + assertThrows(ResourceNotFoundException.class, () -> depositoService.getDepositoById(1L)); + } + +} + diff --git a/beta/src/test/java/com/mobeats/ApplicationTests.java b/api/src/test/java/com/mobeats/api/DepositosApplicationTests.java similarity index 71% rename from beta/src/test/java/com/mobeats/ApplicationTests.java rename to api/src/test/java/com/mobeats/api/DepositosApplicationTests.java index 6746bf4..7e53852 100644 --- a/beta/src/test/java/com/mobeats/ApplicationTests.java +++ b/api/src/test/java/com/mobeats/api/DepositosApplicationTests.java @@ -1,10 +1,10 @@ -package com.mobeats; +package com.mobeats.api; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class ApplicationTests { +class DepositosApplicationTests { @Test void contextLoads() { diff --git a/api/src/test/java/com/mobeats/api/MovimientoServiceTest.java b/api/src/test/java/com/mobeats/api/MovimientoServiceTest.java new file mode 100644 index 0000000..cbf261e --- /dev/null +++ b/api/src/test/java/com/mobeats/api/MovimientoServiceTest.java @@ -0,0 +1,80 @@ +package com.mobeats.api; + +import com.mobeats.api.service.MovimientoService; +import com.mobeats.api.service.ProductoService; +import com.mobeats.api.service.ProductoDepositoService; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.Movimiento; +import com.mobeats.api.model.MovimientoTipo; +import com.mobeats.api.model.Producto; +import com.mobeats.api.model.ProductoDeposito; +import com.mobeats.api.repository.MovimientoRepository; +import com.mobeats.api.repository.MovimientoTipoRepository; +import com.mobeats.api.repository.ProductoDepositoRepository; +import com.mobeats.api.repository.ProductoRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; + +public class MovimientoServiceTest { + + @Mock + private MovimientoRepository movimientoRepositoryMock; + + @Mock + private MovimientoTipoRepository movimientoTipoRepositoryMock; + + @Mock + private ProductoDepositoRepository productoDepositoRepositoryMock; + + @Mock + private ProductoRepository productoRepositoryMock; + + @Mock + private ProductoDepositoService productoDepositoServiceMock; + + @Mock + private ProductoService productoServiceMock; + + @InjectMocks + private MovimientoService movimientoService; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testCreateMovimiento() { + // Create a mock + Movimiento mockMovimiento = new Movimiento(); + + // Set up the behavior of the mock repositories + when(productoRepositoryMock.findById(anyLong())).thenReturn(Optional.of(new Producto())); + when(productoDepositoRepositoryMock.findByProductoAndDeposito(any(), any())).thenReturn(new ProductoDeposito()); + when(movimientoTipoRepositoryMock.findById(anyLong())).thenReturn(Optional.of(new MovimientoTipo())); + when(productoDepositoServiceMock.updateCantidadProductoDeposito(anyLong(), anyInt())).thenReturn(new ProductoDeposito()); + when(productoServiceMock.updateCantidadProducto(anyLong(), anyInt())).thenReturn(new Producto()); + when(movimientoRepositoryMock.save(any())).thenReturn(mockMovimiento); + + // Perform the test + Movimiento result = movimientoService.createMovimiento(mockMovimiento); + + // Verify the result + assertEquals(mockMovimiento, result); + + // Verify that the methods were called + verify(productoDepositoServiceMock, times(1)).updateCantidadProductoDeposito(anyLong(), anyInt()); + verify(productoServiceMock, times(1)).updateCantidadProducto(anyLong(), anyInt()); + verify(movimientoRepositoryMock, times(1)).save(any()); + } + + // Add more tests for other methods as needed +} diff --git a/api/src/test/java/com/mobeats/api/MovimientoTipoServiceTest.java b/api/src/test/java/com/mobeats/api/MovimientoTipoServiceTest.java new file mode 100644 index 0000000..19d7ee0 --- /dev/null +++ b/api/src/test/java/com/mobeats/api/MovimientoTipoServiceTest.java @@ -0,0 +1,77 @@ +package com.mobeats.api; + +import com.mobeats.api.service.MovimientoTipoService; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.MovimientoTipo; +import com.mobeats.api.repository.MovimientoTipoRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.*; + +public class MovimientoTipoServiceTest { + + @Mock + private MovimientoTipoRepository movimientoTipoRepositoryMock; + + @InjectMocks + private MovimientoTipoService movimientoTipoService; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetAllMovimientoTipos() { + // Create a list of mock MovimientoTipos + List mockMovimientoTipos = new ArrayList<>(); + mockMovimientoTipos.add(new MovimientoTipo()); + mockMovimientoTipos.add(new MovimientoTipo()); + + // Set up the behavior of the mock repository + when(movimientoTipoRepositoryMock.findAll()).thenReturn(mockMovimientoTipos); + + // Perform the test + List result = movimientoTipoService.getAllMovimientoTipos(); + + // Verify the result + assertEquals(mockMovimientoTipos, result); + } + + @Test + public void testGetMovimientoTipoById() { + // Create a mock MovimientoTipo + MovimientoTipo mockMovimientoTipo = new MovimientoTipo(); + + // Set up the behavior of the mock repository + when(movimientoTipoRepositoryMock.findById(1L)).thenReturn(Optional.of(mockMovimientoTipo)); + + // Perform the test + MovimientoTipo result = movimientoTipoService.getMovimientoTipoById(1L); + + // Verify the result + assertEquals(mockMovimientoTipo, result); + } + + @Test + public void testGetMovimientoTipoById_NotFound() { + // Set up the behavior of the mock repository to return an empty Optional + when(movimientoTipoRepositoryMock.findById(1L)).thenReturn(Optional.empty()); + + // Perform the test and expect a ResourceNotFoundException + assertThrows(ResourceNotFoundException.class, () -> movimientoTipoService.getMovimientoTipoById(1L)); + } + + // Similarly, you can write tests for other methods like createMovimientoTipo and updateMovimientoTipo + // Remember to mock the repository's behavior accordingly +} diff --git a/api/src/test/java/com/mobeats/api/ProductoDepositoServiceTest.java b/api/src/test/java/com/mobeats/api/ProductoDepositoServiceTest.java new file mode 100644 index 0000000..1ee27bf --- /dev/null +++ b/api/src/test/java/com/mobeats/api/ProductoDepositoServiceTest.java @@ -0,0 +1,76 @@ +package com.mobeats.api; +import com.mobeats.api.service.ProductoDepositoService; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.ProductoDeposito; +import com.mobeats.api.repository.ProductoDepositoRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.*; + +public class ProductoDepositoServiceTest { + + @Mock + private ProductoDepositoRepository productoDepositoRepositoryMock; + + @InjectMocks + private ProductoDepositoService productoDepositoService; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetAllProductosDepositos() { + // Create a list of mock ProductoDepositos + List mockProductosDepositos = new ArrayList<>(); + mockProductosDepositos.add(new ProductoDeposito()); + mockProductosDepositos.add(new ProductoDeposito()); + + // Set up the behavior of the mock repository + when(productoDepositoRepositoryMock.findAll()).thenReturn(mockProductosDepositos); + + // Perform the test + List result = productoDepositoService.getAllProductosDepositos(); + + // Verify the result + assertEquals(mockProductosDepositos, result); + } + + @Test + public void testGetProductoDepositoById() { + // Create a mock ProductoDeposito + ProductoDeposito mockProductoDeposito = new ProductoDeposito(); + + // Set up the behavior of the mock repository + when(productoDepositoRepositoryMock.findById(1L)).thenReturn(Optional.of(mockProductoDeposito)); + + // Perform the test + ProductoDeposito result = productoDepositoService.getProductoDepositoById(1L); + + // Verify the result + assertEquals(mockProductoDeposito, result); + } + + @Test + public void testGetProductoDepositoById_NotFound() { + // Set up the behavior of the mock repository to return an empty Optional + when(productoDepositoRepositoryMock.findById(1L)).thenReturn(Optional.empty()); + + // Perform the test and expect a ResourceNotFoundException + assertThrows(ResourceNotFoundException.class, () -> productoDepositoService.getProductoDepositoById(1L)); + } + + // Similarly, you can write tests for other methods like createProductoDeposito and updateProductoDeposito + // Remember to mock the repository's behavior accordingly +} diff --git a/api/src/test/java/com/mobeats/api/ProductoServiceTest.java b/api/src/test/java/com/mobeats/api/ProductoServiceTest.java new file mode 100644 index 0000000..ab8d8d0 --- /dev/null +++ b/api/src/test/java/com/mobeats/api/ProductoServiceTest.java @@ -0,0 +1,74 @@ +package com.mobeats.api; + +import com.mobeats.api.service.ProductoService; +import com.mobeats.api.exception.ResourceNotFoundException; +import com.mobeats.api.model.Producto; +import com.mobeats.api.repository.ProductoRepository; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.*; + +public class ProductoServiceTest { + + @Mock + private ProductoRepository productoRepositoryMock; + + @InjectMocks + private ProductoService productoService; + + @BeforeEach + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testGetAllProductos() { + // Create a list of mock Productos + List mockProductos = new ArrayList<>(); + mockProductos.add(new Producto()); + mockProductos.add(new Producto()); + + // Set up the behavior of the mock repository + when(productoRepositoryMock.findAll()).thenReturn(mockProductos); + + // Perform the test + List result = productoService.getAllProductos(); + + // Verify the result + assertEquals(mockProductos, result); + } + + @Test + public void testGetProductoById() { + // Create a mock Producto + Producto mockProducto = new Producto(); + + // Set up the behavior of the mock repository + when(productoRepositoryMock.findById(1L)).thenReturn(Optional.of(mockProducto)); + + // Perform the test + Producto result = productoService.getProductoById(1L); + + // Verify the result + assertEquals(mockProducto, result); + } + + @Test + public void testGetProductoById_NotFound() { + // Set up the behavior of the mock repository to return an empty Optional + when(productoRepositoryMock.findById(1L)).thenReturn(Optional.empty()); + + // Perform the test and expect a ResourceNotFoundException + assertThrows(ResourceNotFoundException.class, () -> productoService.getProductoById(1L)); + } +} diff --git a/api/target/classes/application.properties b/api/target/classes/application.properties new file mode 100644 index 0000000..0c65050 --- /dev/null +++ b/api/target/classes/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:mysql://localhost:3306/control_stock +spring.datasource.username=root +spring.datasource.password= +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/api/target/classes/com/mobeats/api/Application.class b/api/target/classes/com/mobeats/api/Application.class new file mode 100644 index 0000000..16d8266 Binary files /dev/null and b/api/target/classes/com/mobeats/api/Application.class differ diff --git a/api/target/classes/com/mobeats/api/controller/DepositoController.class b/api/target/classes/com/mobeats/api/controller/DepositoController.class new file mode 100644 index 0000000..636e8a6 Binary files /dev/null and b/api/target/classes/com/mobeats/api/controller/DepositoController.class differ diff --git a/api/target/classes/com/mobeats/api/controller/MovimientoController.class b/api/target/classes/com/mobeats/api/controller/MovimientoController.class new file mode 100644 index 0000000..ace62b8 Binary files /dev/null and b/api/target/classes/com/mobeats/api/controller/MovimientoController.class differ diff --git a/api/target/classes/com/mobeats/api/controller/MovimientoTipoController.class b/api/target/classes/com/mobeats/api/controller/MovimientoTipoController.class new file mode 100644 index 0000000..8f54c02 Binary files /dev/null and b/api/target/classes/com/mobeats/api/controller/MovimientoTipoController.class differ diff --git a/api/target/classes/com/mobeats/api/controller/ProductoController.class b/api/target/classes/com/mobeats/api/controller/ProductoController.class new file mode 100644 index 0000000..0d25a9a Binary files /dev/null and b/api/target/classes/com/mobeats/api/controller/ProductoController.class differ diff --git a/api/target/classes/com/mobeats/api/controller/ProductoDepositoController.class b/api/target/classes/com/mobeats/api/controller/ProductoDepositoController.class new file mode 100644 index 0000000..4edb350 Binary files /dev/null and b/api/target/classes/com/mobeats/api/controller/ProductoDepositoController.class differ diff --git a/api/target/classes/com/mobeats/api/exception/ResourceNotFoundException.class b/api/target/classes/com/mobeats/api/exception/ResourceNotFoundException.class new file mode 100644 index 0000000..201bc2f Binary files /dev/null and b/api/target/classes/com/mobeats/api/exception/ResourceNotFoundException.class differ diff --git a/api/target/classes/com/mobeats/api/model/Deposito.class b/api/target/classes/com/mobeats/api/model/Deposito.class new file mode 100644 index 0000000..4c8d281 Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/Deposito.class differ diff --git a/api/target/classes/com/mobeats/api/model/Movimiento.class b/api/target/classes/com/mobeats/api/model/Movimiento.class new file mode 100644 index 0000000..9a6ce7c Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/Movimiento.class differ diff --git a/api/target/classes/com/mobeats/api/model/MovimientoTipo$SaldoEnum.class b/api/target/classes/com/mobeats/api/model/MovimientoTipo$SaldoEnum.class new file mode 100644 index 0000000..176015e Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/MovimientoTipo$SaldoEnum.class differ diff --git a/api/target/classes/com/mobeats/api/model/MovimientoTipo.class b/api/target/classes/com/mobeats/api/model/MovimientoTipo.class new file mode 100644 index 0000000..fe9925b Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/MovimientoTipo.class differ diff --git a/api/target/classes/com/mobeats/api/model/Producto.class b/api/target/classes/com/mobeats/api/model/Producto.class new file mode 100644 index 0000000..7e94af6 Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/Producto.class differ diff --git a/api/target/classes/com/mobeats/api/model/ProductoDeposito.class b/api/target/classes/com/mobeats/api/model/ProductoDeposito.class new file mode 100644 index 0000000..c2ce78a Binary files /dev/null and b/api/target/classes/com/mobeats/api/model/ProductoDeposito.class differ diff --git a/api/target/classes/com/mobeats/api/repository/DepositoRepository.class b/api/target/classes/com/mobeats/api/repository/DepositoRepository.class new file mode 100644 index 0000000..ad00f30 Binary files /dev/null and b/api/target/classes/com/mobeats/api/repository/DepositoRepository.class differ diff --git a/api/target/classes/com/mobeats/api/repository/MovimientoRepository.class b/api/target/classes/com/mobeats/api/repository/MovimientoRepository.class new file mode 100644 index 0000000..78a0dde Binary files /dev/null and b/api/target/classes/com/mobeats/api/repository/MovimientoRepository.class differ diff --git a/api/target/classes/com/mobeats/api/repository/MovimientoTipoRepository.class b/api/target/classes/com/mobeats/api/repository/MovimientoTipoRepository.class new file mode 100644 index 0000000..7444262 Binary files /dev/null and b/api/target/classes/com/mobeats/api/repository/MovimientoTipoRepository.class differ diff --git a/api/target/classes/com/mobeats/api/repository/ProductoDepositoRepository.class b/api/target/classes/com/mobeats/api/repository/ProductoDepositoRepository.class new file mode 100644 index 0000000..3f4a066 Binary files /dev/null and b/api/target/classes/com/mobeats/api/repository/ProductoDepositoRepository.class differ diff --git a/api/target/classes/com/mobeats/api/repository/ProductoRepository.class b/api/target/classes/com/mobeats/api/repository/ProductoRepository.class new file mode 100644 index 0000000..2868f0f Binary files /dev/null and b/api/target/classes/com/mobeats/api/repository/ProductoRepository.class differ diff --git a/api/target/classes/com/mobeats/api/service/DepositoService.class b/api/target/classes/com/mobeats/api/service/DepositoService.class new file mode 100644 index 0000000..d2cbf42 Binary files /dev/null and b/api/target/classes/com/mobeats/api/service/DepositoService.class differ diff --git a/api/target/classes/com/mobeats/api/service/MovimientoService.class b/api/target/classes/com/mobeats/api/service/MovimientoService.class new file mode 100644 index 0000000..1994118 Binary files /dev/null and b/api/target/classes/com/mobeats/api/service/MovimientoService.class differ diff --git a/api/target/classes/com/mobeats/api/service/MovimientoTipoService.class b/api/target/classes/com/mobeats/api/service/MovimientoTipoService.class new file mode 100644 index 0000000..afb5159 Binary files /dev/null and b/api/target/classes/com/mobeats/api/service/MovimientoTipoService.class differ diff --git a/api/target/classes/com/mobeats/api/service/ProductoDepositoService.class b/api/target/classes/com/mobeats/api/service/ProductoDepositoService.class new file mode 100644 index 0000000..5bda648 Binary files /dev/null and b/api/target/classes/com/mobeats/api/service/ProductoDepositoService.class differ diff --git a/api/target/classes/com/mobeats/api/service/ProductoService.class b/api/target/classes/com/mobeats/api/service/ProductoService.class new file mode 100644 index 0000000..03005ba Binary files /dev/null and b/api/target/classes/com/mobeats/api/service/ProductoService.class differ diff --git a/api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/api/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..8f9a9a3 --- /dev/null +++ b/api/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,22 @@ +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/controller/DepositoController.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/repository/MovimientoRepository.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/controller/MovimientoController.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/repository/DepositoRepository.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/repository/MovimientoTipoRepository.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/model/Movimiento.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/model/Producto.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/service/DepositoService.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/model/ProductoDeposito.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/model/MovimientoTipo.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/service/ProductoDepositoService.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/controller/MovimientoTipoController.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/service/MovimientoService.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/repository/ProductoDepositoRepository.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/controller/ProductoController.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/exception/ResourceNotFoundException.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/Application.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/model/Deposito.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/service/ProductoService.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/repository/ProductoRepository.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/controller/ProductoDepositoController.java +/home/pc-1/Descargas/api/src/main/java/com/mobeats/api/service/MovimientoTipoService.java diff --git a/api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..be85f5f --- /dev/null +++ b/api/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/pc-1/Descargas/api/src/test/java/com/mobeats/api/DepositosApplicationTests.java diff --git a/api/target/test-classes/com/mobeats/api/DepositosApplicationTests.class b/api/target/test-classes/com/mobeats/api/DepositosApplicationTests.class new file mode 100644 index 0000000..935b40b Binary files /dev/null and b/api/target/test-classes/com/mobeats/api/DepositosApplicationTests.class differ diff --git a/beta/HELP.md b/beta/HELP.md deleted file mode 100644 index b105e64..0000000 --- a/beta/HELP.md +++ /dev/null @@ -1,14 +0,0 @@ -# Read Me First -The following was discovered as part of building this project: - -* The original package name 'com.mobeats.' is invalid and this project uses 'com.mobeats' instead. - -# Getting Started - -### Reference Documentation -For further reference, please consider the following sections: - -* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) -* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.1.4/maven-plugin/reference/html/) -* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.1.4/maven-plugin/reference/html/#build-image) - diff --git a/beta/LICENSE b/beta/LICENSE deleted file mode 100644 index e2795e0..0000000 --- a/beta/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 progmatt1 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/beta/README.md b/beta/README.md deleted file mode 100644 index e031089..0000000 --- a/beta/README.md +++ /dev/null @@ -1,184 +0,0 @@ -# control_stock -Proyecto usando Java 17+ en Spring Boot para crear una API. Se trata de un control de stock -# Inicio -Este es el inicio basico para empezar. -## Modelo ER -Este es el modelo que estariamos utilizando -![alt text](https://raw.githubusercontent.com/progmatt1/control_stock/main/er-model.png?token=GHSAT0AAAAAACGO5MURR57A4EOBQ5KV6GWEZIRSXHQ) -## Crea estas tablas en MySql -La logica aqui es crear distintas tablas en orden y configurar sus respectivas relaciones. Despues en el codigo del proyecto en Java -se da la logica. -### productos -``` -CREATE TABLE `productos` ( - `id` int NOT NULL AUTO_INCREMENT, - `nombre` text NOT NULL, - `descripcion` text NOT NULL, - `precio` float NOT NULL, - `cantidad` text NOT NULL, - `fecha_creacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `fecha_actualizacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -``` -### movimientos_tipo -``` -CREATE TABLE `control_stock`.`movimientos_tipo` ( - `id` INT NOT NULL AUTO_INCREMENT, - `nombre` TEXT NOT NULL, - `descripcion` TEXT NOT NULL, - PRIMARY KEY (`id`)); -``` -### depositos -``` -CREATE TABLE `control_stock`.`depositos` ( - `id` INT NOT NULL AUTO_INCREMENT, - `nombre` TEXT NOT NULL, - PRIMARY KEY (`id`)); -``` -### movimientos -``` -CREATE TABLE `control_stock`.`movimientos` ( - `id` INT NOT NULL AUTO_INCREMENT, - `cantidad` INT NOT NULL, - `fecha` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - `id_movimiento_tipo` INT NOT NULL, - `id_producto` INT NOT NULL, - `id_deposito` INT NOT NULL, - PRIMARY KEY (`id`), - INDEX `id_movimiento_tipo_idx` (`id_movimiento_tipo` ASC) VISIBLE, - INDEX `id_producto_idx` (`id_producto` ASC) VISIBLE, - INDEX `id_deposito_idx` (`id_deposito` ASC) VISIBLE, - CONSTRAINT `id_movimiento_tipo` - FOREIGN KEY (`id_movimiento_tipo`) - REFERENCES `control_stock`.`movimientos_tipo` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `id_producto` - FOREIGN KEY (`id_producto`) - REFERENCES `control_stock`.`productos` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `id_deposito` - FOREIGN KEY (`id_deposito`) - REFERENCES `control_stock`.`depositos` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION); -``` - -### productos_deposito -``` -CREATE TABLE `productos_deposito` ( - `id` int NOT NULL AUTO_INCREMENT, - `id_deposito` int NOT NULL, - `id_producto` int NOT NULL, - `cantidad` int NOT NULL, - `fecha_actualizacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `id_deposito_idx` (`id_deposito`), - KEY `id_producto_idx` (`id_producto`), - CONSTRAINT `id_deposito_foreign` FOREIGN KEY (`id_deposito`) REFERENCES `depositos` (`id`), - CONSTRAINT `id_producto_foreign` FOREIGN KEY (`id_producto`) REFERENCES `productos` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -``` -## Inserta estos datos de ejemplo -Estos datos nos va a servir de ejemplo para empezar a tener algo y empezar a trabajar con sus respectivas relaciones y un pequeño bug en productos_deposito para mayor entendimiento (cantidad: -6) - -``` --- Inserta datos en la tabla deposito -INSERT INTO depositos(nombre) VALUES ('Deposito A'); -INSERT INTO depositos(nombre) VALUES ('Deposito B'); -INSERT INTO depositos(nombre) VALUES ('Deposito C'); -INSERT INTO depositos(nombre) VALUES ('Deposito D'); - --- Inserta datos en la tabla productos. La cantidad es la cantidad general que hay en todos los depositos -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto A', -'Esta es la descripcion para el Producto A', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto B', -'Esta es la descripcion para el Producto B', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto C', -'Esta es la descripcion para el Producto B', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto D', -'Esta es la descripcion para el Producto B', -999.99, -15 -); - --- Los tipos de movimiento que se pueden realizar. Despues en el proyecto de Java segun el tipo de movimiento se crea la logica -INSERT INTO movimientos_tipo(nombre, descripcion) VALUES( -'Baja', -'Esta es la descripcion de Baja.' -); - -INSERT INTO movimientos_tipo(nombre, descripcion) VALUES( -'Subida', -'Esta es la descripcion de Subida.' -); - --- Insertamos algunos datos en la tabla movimientos - --- En el primer ejemplo estamos añadiendo 10 productos 'Producto A' en el deposito 'Deposito B' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -10, -2, -1, -2 -); --- En el primer ejemplo estamos añadiendo 14 productos 'Producto A' en el deposito 'Deposito A' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -14, -2, -1, -1 -); --- En el primer ejemplo estamos añadiendo 12 productos 'Producto C' en el deposito 'Deposito C' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -12, -2, -3, -3 -); --- En el primer ejemplo estamos quitando 6 productos 'Producto D' en el deposito 'Deposito A' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -6, -1, -4, -1 -); - --- Aqui insertamos de modo de ejemplo como quedaria la cantidad de un producto en un deposito --- Aqui se añade la logica despues en el codigo de Java -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -2, -1, -10 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -1, -1, -14 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -3, -3, -12 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -1, -4, --6 -); -``` diff --git a/beta/bin/LICENSE b/beta/bin/LICENSE deleted file mode 100644 index e2795e0..0000000 --- a/beta/bin/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 progmatt1 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/beta/bin/README.md b/beta/bin/README.md deleted file mode 100644 index e031089..0000000 --- a/beta/bin/README.md +++ /dev/null @@ -1,184 +0,0 @@ -# control_stock -Proyecto usando Java 17+ en Spring Boot para crear una API. Se trata de un control de stock -# Inicio -Este es el inicio basico para empezar. -## Modelo ER -Este es el modelo que estariamos utilizando -![alt text](https://raw.githubusercontent.com/progmatt1/control_stock/main/er-model.png?token=GHSAT0AAAAAACGO5MURR57A4EOBQ5KV6GWEZIRSXHQ) -## Crea estas tablas en MySql -La logica aqui es crear distintas tablas en orden y configurar sus respectivas relaciones. Despues en el codigo del proyecto en Java -se da la logica. -### productos -``` -CREATE TABLE `productos` ( - `id` int NOT NULL AUTO_INCREMENT, - `nombre` text NOT NULL, - `descripcion` text NOT NULL, - `precio` float NOT NULL, - `cantidad` text NOT NULL, - `fecha_creacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `fecha_actualizacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -``` -### movimientos_tipo -``` -CREATE TABLE `control_stock`.`movimientos_tipo` ( - `id` INT NOT NULL AUTO_INCREMENT, - `nombre` TEXT NOT NULL, - `descripcion` TEXT NOT NULL, - PRIMARY KEY (`id`)); -``` -### depositos -``` -CREATE TABLE `control_stock`.`depositos` ( - `id` INT NOT NULL AUTO_INCREMENT, - `nombre` TEXT NOT NULL, - PRIMARY KEY (`id`)); -``` -### movimientos -``` -CREATE TABLE `control_stock`.`movimientos` ( - `id` INT NOT NULL AUTO_INCREMENT, - `cantidad` INT NOT NULL, - `fecha` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - `id_movimiento_tipo` INT NOT NULL, - `id_producto` INT NOT NULL, - `id_deposito` INT NOT NULL, - PRIMARY KEY (`id`), - INDEX `id_movimiento_tipo_idx` (`id_movimiento_tipo` ASC) VISIBLE, - INDEX `id_producto_idx` (`id_producto` ASC) VISIBLE, - INDEX `id_deposito_idx` (`id_deposito` ASC) VISIBLE, - CONSTRAINT `id_movimiento_tipo` - FOREIGN KEY (`id_movimiento_tipo`) - REFERENCES `control_stock`.`movimientos_tipo` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `id_producto` - FOREIGN KEY (`id_producto`) - REFERENCES `control_stock`.`productos` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT `id_deposito` - FOREIGN KEY (`id_deposito`) - REFERENCES `control_stock`.`depositos` (`id`) - ON DELETE NO ACTION - ON UPDATE NO ACTION); -``` - -### productos_deposito -``` -CREATE TABLE `productos_deposito` ( - `id` int NOT NULL AUTO_INCREMENT, - `id_deposito` int NOT NULL, - `id_producto` int NOT NULL, - `cantidad` int NOT NULL, - `fecha_actualizacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `id_deposito_idx` (`id_deposito`), - KEY `id_producto_idx` (`id_producto`), - CONSTRAINT `id_deposito_foreign` FOREIGN KEY (`id_deposito`) REFERENCES `depositos` (`id`), - CONSTRAINT `id_producto_foreign` FOREIGN KEY (`id_producto`) REFERENCES `productos` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; -``` -## Inserta estos datos de ejemplo -Estos datos nos va a servir de ejemplo para empezar a tener algo y empezar a trabajar con sus respectivas relaciones y un pequeño bug en productos_deposito para mayor entendimiento (cantidad: -6) - -``` --- Inserta datos en la tabla deposito -INSERT INTO depositos(nombre) VALUES ('Deposito A'); -INSERT INTO depositos(nombre) VALUES ('Deposito B'); -INSERT INTO depositos(nombre) VALUES ('Deposito C'); -INSERT INTO depositos(nombre) VALUES ('Deposito D'); - --- Inserta datos en la tabla productos. La cantidad es la cantidad general que hay en todos los depositos -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto A', -'Esta es la descripcion para el Producto A', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto B', -'Esta es la descripcion para el Producto B', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto C', -'Esta es la descripcion para el Producto B', -999.99, -15 -); -INSERT INTO productos(nombre, descripcion, precio, cantidad) VALUES ( -'Producto D', -'Esta es la descripcion para el Producto B', -999.99, -15 -); - --- Los tipos de movimiento que se pueden realizar. Despues en el proyecto de Java segun el tipo de movimiento se crea la logica -INSERT INTO movimientos_tipo(nombre, descripcion) VALUES( -'Baja', -'Esta es la descripcion de Baja.' -); - -INSERT INTO movimientos_tipo(nombre, descripcion) VALUES( -'Subida', -'Esta es la descripcion de Subida.' -); - --- Insertamos algunos datos en la tabla movimientos - --- En el primer ejemplo estamos añadiendo 10 productos 'Producto A' en el deposito 'Deposito B' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -10, -2, -1, -2 -); --- En el primer ejemplo estamos añadiendo 14 productos 'Producto A' en el deposito 'Deposito A' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -14, -2, -1, -1 -); --- En el primer ejemplo estamos añadiendo 12 productos 'Producto C' en el deposito 'Deposito C' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -12, -2, -3, -3 -); --- En el primer ejemplo estamos quitando 6 productos 'Producto D' en el deposito 'Deposito A' -INSERT INTO movimientos(cantidad, id_movimiento_tipo, id_producto, id_deposito) VALUES ( -6, -1, -4, -1 -); - --- Aqui insertamos de modo de ejemplo como quedaria la cantidad de un producto en un deposito --- Aqui se añade la logica despues en el codigo de Java -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -2, -1, -10 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -1, -1, -14 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -3, -3, -12 -); -INSERT INTO productos_deposito(id_deposito, id_producto, cantidad) VALUES ( -1, -4, --6 -); -``` diff --git a/beta/bin/er-model.png b/beta/bin/er-model.png deleted file mode 100644 index c2e557b..0000000 Binary files a/beta/bin/er-model.png and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/Application.class b/beta/bin/src/main/java/com/mobeats/beta/Application.class deleted file mode 100644 index 3a5ace4..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/Application.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/controller/UserController.class b/beta/bin/src/main/java/com/mobeats/beta/controller/UserController.class deleted file mode 100644 index 4619243..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/controller/UserController.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/exception/ErrorResponse.class b/beta/bin/src/main/java/com/mobeats/beta/exception/ErrorResponse.class deleted file mode 100644 index 1e3e1df..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/exception/ErrorResponse.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/exception/GlobalExceptionHandler.class b/beta/bin/src/main/java/com/mobeats/beta/exception/GlobalExceptionHandler.class deleted file mode 100644 index 0ce3cb9..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/exception/GlobalExceptionHandler.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/exception/ResourceNotFoundException.class b/beta/bin/src/main/java/com/mobeats/beta/exception/ResourceNotFoundException.class deleted file mode 100644 index 8806623..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/exception/ResourceNotFoundException.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/model/User.class b/beta/bin/src/main/java/com/mobeats/beta/model/User.class deleted file mode 100644 index 071c225..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/model/User.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/repository/UserRepository.class b/beta/bin/src/main/java/com/mobeats/beta/repository/UserRepository.class deleted file mode 100644 index b15a885..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/repository/UserRepository.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/beta/service/UserService.class b/beta/bin/src/main/java/com/mobeats/beta/service/UserService.class deleted file mode 100644 index a2a7c06..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/beta/service/UserService.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/Application.class b/beta/bin/src/main/java/com/mobeats/control_stock/Application.class deleted file mode 100644 index 17cf525..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/Application.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/controller/UserController.class b/beta/bin/src/main/java/com/mobeats/control_stock/controller/UserController.class deleted file mode 100644 index 563da3b..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/controller/UserController.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/exception/ErrorResponse.class b/beta/bin/src/main/java/com/mobeats/control_stock/exception/ErrorResponse.class deleted file mode 100644 index 111b0ab..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/exception/ErrorResponse.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/exception/GlobalExceptionHandler.class b/beta/bin/src/main/java/com/mobeats/control_stock/exception/GlobalExceptionHandler.class deleted file mode 100644 index 2432778..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/exception/GlobalExceptionHandler.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/exception/ResourceNotFoundException.class b/beta/bin/src/main/java/com/mobeats/control_stock/exception/ResourceNotFoundException.class deleted file mode 100644 index 07d9905..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/exception/ResourceNotFoundException.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/model/User.class b/beta/bin/src/main/java/com/mobeats/control_stock/model/User.class deleted file mode 100644 index e5d774b..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/model/User.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/repository/UserRepository.class b/beta/bin/src/main/java/com/mobeats/control_stock/repository/UserRepository.class deleted file mode 100644 index e67316d..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/repository/UserRepository.class and /dev/null differ diff --git a/beta/bin/src/main/java/com/mobeats/control_stock/service/UserService.class b/beta/bin/src/main/java/com/mobeats/control_stock/service/UserService.class deleted file mode 100644 index ab35fbd..0000000 Binary files a/beta/bin/src/main/java/com/mobeats/control_stock/service/UserService.class and /dev/null differ diff --git a/beta/bin/src/main/resources/application.properties b/beta/bin/src/main/resources/application.properties deleted file mode 100644 index 518cb11..0000000 --- a/beta/bin/src/main/resources/application.properties +++ /dev/null @@ -1,12 +0,0 @@ -## Database Properties -spring.datasource.url = jdbc:mysql://localhost:3306/user_database?useSSL=false -spring.datasource.username = root -spring.datasource.password = - - -## Hibernate Properties -# The SQL dialect makes Hibernate generate better SQL for the chosen database -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect - -# Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/beta/bin/target/classes/META-INF/MANIFEST.MF b/beta/bin/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index 5e9e7d9..0000000 --- a/beta/bin/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -Build-Jdk-Spec: 17 -Implementation-Title: beta -Implementation-Version: 0.0.1-SNAPSHOT -Created-By: Maven Integration for Eclipse - diff --git a/beta/bin/target/classes/application.properties b/beta/bin/target/classes/application.properties deleted file mode 100644 index 518cb11..0000000 --- a/beta/bin/target/classes/application.properties +++ /dev/null @@ -1,12 +0,0 @@ -## Database Properties -spring.datasource.url = jdbc:mysql://localhost:3306/user_database?useSSL=false -spring.datasource.username = root -spring.datasource.password = - - -## Hibernate Properties -# The SQL dialect makes Hibernate generate better SQL for the chosen database -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect - -# Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update \ No newline at end of file diff --git a/beta/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/beta/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 739ad22..0000000 --- a/beta/bin/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,17 +0,0 @@ -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/repository/UserRepository.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/ResourceNotFoundException.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/model/User.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/repository/UserRepository.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/ResourceNotFoundException.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/Application.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/service/UserService.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/GlobalExceptionHandler.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/GlobalExceptionHandler.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/ErrorResponse.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/service/UserService.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/controller/UserController.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/ErrorResponse.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/Application.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/model/User.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/controller/MovimientosController.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/controller/UserController.java diff --git a/beta/er-model.png b/beta/er-model.png deleted file mode 100644 index c2e557b..0000000 Binary files a/beta/er-model.png and /dev/null differ diff --git a/beta/mvnw b/beta/mvnw deleted file mode 100644 index 66df285..0000000 --- a/beta/mvnw +++ /dev/null @@ -1,308 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.2.0 -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /usr/local/etc/mavenrc ] ; then - . /usr/local/etc/mavenrc - fi - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "$(uname)" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME - else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=$(java-config --jre-home) - fi -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && - JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then - if $darwin ; then - javaHome="$(dirname "\"$javaExecutable\"")" - javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" - else - javaExecutable="$(readlink -f "\"$javaExecutable\"")" - fi - javaHome="$(dirname "\"$javaExecutable\"")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=$(cd "$wdir/.." || exit 1; pwd) - fi - # end of workaround - done - printf '%s' "$(cd "$basedir" || exit 1; pwd)" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - # Remove \r in case we run on Windows within Git Bash - # and check out the repository with auto CRLF management - # enabled. Otherwise, we may read lines that are delimited with - # \r\n and produce $'-Xarg\r' rather than -Xarg due to word - # splitting rules. - tr -s '\r\n' ' ' < "$1" - fi -} - -log() { - if [ "$MVNW_VERBOSE" = true ]; then - printf '%s\n' "$1" - fi -} - -BASE_DIR=$(find_maven_basedir "$(dirname "$0")") -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR -log "$MAVEN_PROJECTBASEDIR" - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" -else - log "Couldn't find $wrapperJarPath, downloading it ..." - - if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; - esac - done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - - if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") - fi - - if command -v wget > /dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - fi - else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") - fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") - fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -# If specified, validate the SHA-256 sum of the Maven wrapper jar file -wrapperSha256Sum="" -while IFS="=" read -r key value; do - case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; - esac -done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" -if [ -n "$wrapperSha256Sum" ]; then - wrapperSha256Result=false - if command -v sha256sum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - elif command -v shasum > /dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then - wrapperSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." - exit 1 - fi - if [ $wrapperSha256Result = false ]; then - echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 - echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 - echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 - exit 1 - fi -fi - -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -# shellcheck disable=SC2086 # safe args -exec "$JAVACMD" \ - $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/beta/mvnw.cmd b/beta/mvnw.cmd deleted file mode 100644 index 95ba6f5..0000000 --- a/beta/mvnw.cmd +++ /dev/null @@ -1,205 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.2.0 -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %WRAPPER_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file -SET WRAPPER_SHA_256_SUM="" -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B -) -IF NOT %WRAPPER_SHA_256_SUM%=="" ( - powershell -Command "&{"^ - "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ - "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ - " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ - " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ - " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ - " exit 1;"^ - "}"^ - "}" - if ERRORLEVEL 1 goto error -) - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% ^ - %JVM_CONFIG_MAVEN_PROPS% ^ - %MAVEN_OPTS% ^ - %MAVEN_DEBUG_OPTS% ^ - -classpath %WRAPPER_JAR% ^ - "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause - -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% diff --git a/beta/pom.xml b/beta/pom.xml deleted file mode 100644 index 6e6c08f..0000000 --- a/beta/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.1.4 - - - com.mobeats - demo - 0.0.1-SNAPSHOT - demo - demo proyect for a control stock - - 17 - - - - org.springframework.boot - spring-boot-starter - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-web - - - javax.validation - validation-api - 2.0.1.Final - - - - org.springframework.boot - spring-boot-starter-validation - - - - org.hibernate - hibernate-core - 5.5.7.Final - - - - - org.hibernate - hibernate-entitymanager - 5.5.7.Final - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/beta/src/main/java/com/mobeats/controller/ProductoController.java b/beta/src/main/java/com/mobeats/controller/ProductoController.java deleted file mode 100644 index 01926a5..0000000 --- a/beta/src/main/java/com/mobeats/controller/ProductoController.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.mobeats.controller; -import com.mobeats.model.Producto; -import com.mobeats.repository.ProductoRepository; -import com.mobeats.exception.ResourceNotFoundException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * The type User controller. - * - * @author Givantha Kalansuriya - */ -@RestController -@RequestMapping("/api/v1") -public class ProductoController { - - @Autowired - private ProductoRepository productoRepository; - - /** - * Get all users list. - * - * @return the list - */ - @GetMapping("/users") - public List getAllUsers() { - return productoRepository.findAll(); - } - - /** - * Gets users by id. - * - * @param productoId the user id - * @return the users by id - * @throws ResourceNotFoundException the resource not found exception - */ - @GetMapping("/productos/{id}") - public ResponseEntity getUsersById(@PathVariable(value = "id") Long productoId) - throws ResourceNotFoundException { - Producto producto = - productoRepository - .findById(productoId) - .orElseThrow(() -> new ResourceNotFoundException("User not found on :: " + productoId)); - return ResponseEntity.ok().body(producto); - } - - /** - * Create user user. - * - * @param producto the user - * @return the user - */ - @PostMapping("/productos") - public Producto createUser(@Valid @RequestBody Producto producto) { - return productoRepository.save(producto); - } - - /** - * Update user response entity. - * - * @param productoId the user id - * @param productoDetails the user details - * @return the response entity - * @throws ResourceNotFoundException the resource not found exception - */ - @PutMapping("/productos/{id}") - public ResponseEntity updateUser( - @PathVariable(value = "id") Long productoId, @Valid @RequestBody Producto productoDetails) - throws ResourceNotFoundException { - - Producto producto = - productoRepository - .findById(productoId) - .orElseThrow(() -> new ResourceNotFoundException("product not found on :: " + productoId)); - - producto.setDescription(productoDetails.getDescription()); - producto.setName(productoDetails.getName()); - producto.setUpdatedAt(new Date()); - final Producto updatedUser = productoRepository.save(producto); - return ResponseEntity.ok(updatedUser); - } - - /** - * Delete user map. - * - * @param productoId the user id - * @return the map - * @throws Exception the exception - */ - @DeleteMapping("/productos/{id}") - public Map deleteUser(@PathVariable(value = "id") Long productoId) throws Exception { - Producto producto = - productoRepository - .findById(productoId) - .orElseThrow(() -> new ResourceNotFoundException("Product not found on :: " + productoId)); - - productoRepository.delete(producto); - Map response = new HashMap<>(); - response.put("deleted", Boolean.TRUE); - return response; - } -} \ No newline at end of file diff --git a/beta/src/main/java/com/mobeats/model/Producto.java b/beta/src/main/java/com/mobeats/model/Producto.java deleted file mode 100644 index 8828733..0000000 --- a/beta/src/main/java/com/mobeats/model/Producto.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.mobeats.model; - -import org.hibernate.annotations.UpdateTimestamp; -import org.springframework.data.annotation.LastModifiedBy; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - -import javax.persistence.*; -import java.util.Date; - -@Entity -@Table(name = "productos") -@EntityListeners(AuditingEntityListener.class) -public class Producto { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - @Column(name = "name", nullable = false) - private String name; - - @Column(name = "description", nullable = false) - private String description; - - @UpdateTimestamp - @Temporal(TemporalType.TIMESTAMP) - @Column(name = "updated_at", nullable = false) - private Date updatedAt; - - @Column(name = "updated_by", nullable = false) - @LastModifiedBy - private String updatedBy; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - @Override - public String toString() { - return "Producto{" + - "id=" + id + - ", name='" + name + '\'' + - ", description='" + description + '\'' + - ", updatedAt=" + updatedAt + - ", updatedBy='" + updatedBy + '\'' + - '}'; - } -} diff --git a/beta/src/main/java/com/mobeats/service/ProductoService.java b/beta/src/main/java/com/mobeats/service/ProductoService.java deleted file mode 100644 index 5c02996..0000000 --- a/beta/src/main/java/com/mobeats/service/ProductoService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mobeats.service; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.mobeats.model.Producto; -import com.mobeats.repository.ProductoRepository; - -@Service -public class ProductoService { - - @Autowired - private ProductoRepository productoRepository; - - public List findAll() { - return productoRepository.findAll(); - } - -} \ No newline at end of file diff --git a/beta/src/main/resources/application.properties b/beta/src/main/resources/application.properties deleted file mode 100644 index 51da45d..0000000 --- a/beta/src/main/resources/application.properties +++ /dev/null @@ -1,12 +0,0 @@ -## Database Properties -spring.datasource.url = jdbc:mysql://localhost:3306/control_stock?useSSL=false -spring.datasource.username = root -spring.datasource.password = - - -## Hibernate Properties -# The SQL dialect makes Hibernate generate better SQL for the chosen database -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect - -# Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update diff --git a/beta/target/classes/application.properties b/beta/target/classes/application.properties deleted file mode 100644 index 51da45d..0000000 --- a/beta/target/classes/application.properties +++ /dev/null @@ -1,12 +0,0 @@ -## Database Properties -spring.datasource.url = jdbc:mysql://localhost:3306/control_stock?useSSL=false -spring.datasource.username = root -spring.datasource.password = - - -## Hibernate Properties -# The SQL dialect makes Hibernate generate better SQL for the chosen database -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect - -# Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto = update diff --git a/beta/target/classes/com/mobeats/Application.class b/beta/target/classes/com/mobeats/Application.class deleted file mode 100644 index d6343cb..0000000 Binary files a/beta/target/classes/com/mobeats/Application.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/controller/ProductoController.class b/beta/target/classes/com/mobeats/controller/ProductoController.class deleted file mode 100644 index 787a5c4..0000000 Binary files a/beta/target/classes/com/mobeats/controller/ProductoController.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/controller/UserController.class b/beta/target/classes/com/mobeats/controller/UserController.class deleted file mode 100644 index 5f73174..0000000 Binary files a/beta/target/classes/com/mobeats/controller/UserController.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/exception/ResourceNotFoundException.class b/beta/target/classes/com/mobeats/exception/ResourceNotFoundException.class deleted file mode 100644 index 054fa26..0000000 Binary files a/beta/target/classes/com/mobeats/exception/ResourceNotFoundException.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/model/Producto$Productos.class b/beta/target/classes/com/mobeats/model/Producto$Productos.class deleted file mode 100644 index abf1896..0000000 Binary files a/beta/target/classes/com/mobeats/model/Producto$Productos.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/model/Producto$User.class b/beta/target/classes/com/mobeats/model/Producto$User.class deleted file mode 100644 index ed3923e..0000000 Binary files a/beta/target/classes/com/mobeats/model/Producto$User.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/model/Producto.class b/beta/target/classes/com/mobeats/model/Producto.class deleted file mode 100644 index d61ddf3..0000000 Binary files a/beta/target/classes/com/mobeats/model/Producto.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/repository/ProductoRepository.class b/beta/target/classes/com/mobeats/repository/ProductoRepository.class deleted file mode 100644 index 6ad392f..0000000 Binary files a/beta/target/classes/com/mobeats/repository/ProductoRepository.class and /dev/null differ diff --git a/beta/target/classes/com/mobeats/service/ProductoService.class b/beta/target/classes/com/mobeats/service/ProductoService.class deleted file mode 100644 index 3fe1d3d..0000000 Binary files a/beta/target/classes/com/mobeats/service/ProductoService.class and /dev/null differ diff --git a/beta/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/beta/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 739ad22..0000000 --- a/beta/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,17 +0,0 @@ -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/repository/UserRepository.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/ResourceNotFoundException.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/model/User.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/repository/UserRepository.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/ResourceNotFoundException.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/Application.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/service/UserService.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/GlobalExceptionHandler.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/GlobalExceptionHandler.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/exception/ErrorResponse.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/service/UserService.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/controller/UserController.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/exception/ErrorResponse.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/control_stock/Application.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/model/User.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/controller/MovimientosController.java -/home/pc-1/Documentos/beta/src/main/java/com/mobeats/beta/controller/UserController.java diff --git a/beta/target/test-classes/com/mobeats/ApplicationTests.class b/beta/target/test-classes/com/mobeats/ApplicationTests.class deleted file mode 100644 index 265a8d2..0000000 Binary files a/beta/target/test-classes/com/mobeats/ApplicationTests.class and /dev/null differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..796a8f6 --- /dev/null +++ b/index.html @@ -0,0 +1,124 @@ + + + + + + + Control de Stock + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID Product Name Stock Deposito
+ + + + + + + + + + + diff --git a/productPop.js b/productPop.js new file mode 100644 index 0000000..4a2301e --- /dev/null +++ b/productPop.js @@ -0,0 +1,31 @@ +const openModalButton = document.getElementById("openModalButton"); +const openModalButton2 = document.getElementById("openModalButton2"); +const closeModal = document.getElementById("closeModal"); +const closeModal2 = document.getElementById("closeModal2"); +const modal = document.getElementById("myModal"); +const modal2 = document.getElementById("myModal2"); + +openModalButton.addEventListener("click", function() { + modal.style.display = "block"; +}); + +openModalButton2.addEventListener("click", function() { + modal2.style.display = "block"; +}); + +closeModal.addEventListener("click", function() { + modal.style.display = "none"; +}); + +closeModal2.addEventListener("click", function() { + modal2.style.display = "none"; +}); + +window.addEventListener("click", function(event) { + if (event.target === modal) { + modal.style.display = "none"; + } + if (event.target === modal2) { + modal2.style.display = "none"; + } +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..9ef8997 --- /dev/null +++ b/style.css @@ -0,0 +1,245 @@ +/* Estilo del header */ +header { + background-color: #007bff; + color: #fff; + text-align: center; + padding: 30px; +} + +/* Estilos de etiquetas */ +label { + color: #000000; + margin-right: 10px; +} + +/* Estilos de select */ +select { + padding: 10px; + border: none; + border-radius: 5px; +} + +/* Estilos de botones */ +button { + background-color: #0056b3; + color: #fff; + border: none; + border-radius: 5px; + padding: 10px 20px; + cursor: pointer; + margin: 10px; +} + +button:hover { + background-color: #004799; +} + +/* Estilos para el botón "Movement" */ +#openModalButton { + float: right; +} + +/* Estilos para el botón "Product add" */ +#openModalButton2 { + float: left; +} + +/* Estilo de la lista de alumnos */ +h2 { + font-size: 20px; + margin-top: 20px; +} + +/* Estilos de la tabla */ +table { + border-collapse: collapse; + width: 100%; + margin-top: 20px; +} + +table, th, td { + border: 1px solid #ccc; +} + +th, td { + padding: 10px; + text-align: left; + text-align: center; +} + +/* Estilos de la ventana emergente (modal) */ +.modal { + display: none; + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.4); +} + +/* Estilos para el botón "Cerrar" (la "X") en la ventana emergente */ +.close { + float: right; + cursor: pointer; + font-size: 24px; +} + +.close:hover { + color: red; +} + +/* Estilos para el contenido de la ventana emergente */ +.modal-content { + background-color: #fff; + margin: auto; + margin-top: 60px; + padding: 20px; + border: 1px solid #888; + width: 30%; /* Ajusta el ancho de la ventana emergente */ + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); + text-align: center; +} + +/* Estilos para etiquetas y campos de entrada en la ventana emergente */ +.modal-content select, +.modal-content textarea, +.modal-content input { + width: 100%; + padding: 10px; + margin: 10px 0; + border: 1px solid #ccc; + border-radius: 3px; + box-sizing: border-box; /* Evita que el input sobresalga por la derecha del fondo */ +} + +.modal-content select { + height: 40px; +} + +/* Ajusta el tamaño del textarea en la ventana emergente */ +.modal-content textarea { + width: 100%; + height: 200px; /* Ajusta la altura del textarea */ + padding: 10px; + margin: 10px 0; + border: 1px solid #ccc; + border-radius: 3px; + box-sizing: border-box; /* Evita que el textarea sobresalga por la derecha del fondo */ +} + +/* Estilos para las etiquetas de los elementos en la ventana emergente */ +.modal-content label { + display: block; /* Para que cada etiqueta aparezca en una línea nueva */ + font-weight: bold; /* Texto en negrita para las etiquetas */ +} + +/* Estilos para el botón "Cerrar" (la "X") en la ventana emergente */ +.close { + float: right; + cursor: pointer; + font-size: 24px; +} + +.close:hover { + color: red; +} + +/* Estilos para la ventana emergente "Add Product" */ +#myModal2 { + display: none; + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.4); +} + +.modal-content2 { + background-color: #fff; + margin: 15% auto; + padding: 20px; + border: 1px solid #888; + width: 30%; + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); + text-align: center; +} + +.close2 { + float: right; + +} + +/* Estilos para el modal 2 */ +#myModal2 { + display: none; + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.4); +} + +/* Estilos para el contenido del modal 2 */ +.modal-content2 { + background-color: #fff; + margin: auto; + margin-top: 60px; + padding: 20px; + border: 1px solid #888; + width: 30%; /* Ajusta el ancho de la ventana emergente */ + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); + text-align: center; +} + +/* Estilos para el botón "Cerrar" (la "X") en el modal 2 */ +.close2 { + float: right; + cursor: pointer; + font-size: 24px; +} + +.close2:hover { + color: red; +} + +/* Estilos para el título del modal 2 */ +.modal-content2 h2 { + font-size: 24px; +} + +/* Estilos para etiquetas y campos de entrada en el modal 2 */ +.modal-content2 label { + display: block; + font-weight: bold; + margin: 10px 0; +} + +.modal-content2 input { + width: 100%; + padding: 10px; + margin: 10px 0; + border: 1px solid #ccc; + border-radius: 3px; + box-sizing: border-box; /* Evita que el input sobresalga por la derecha del fondo */ +} + +/* Estilos para el botón en el modal 2 */ +.modal-content2 button { + background-color: #007bff; + color: #fff; + border: none; + border-radius: 5px; + padding: 10px 20px; + cursor: pointer; + margin: 10px; +} + +.modal-content2 button:hover { + background-color: #0056b3; +}