diff --git a/M01-SISTEMAS/docker-mongo/Dockerfile b/M01-SISTEMAS/docker-mongo/Dockerfile new file mode 100644 index 0000000..e0cc9a2 --- /dev/null +++ b/M01-SISTEMAS/docker-mongo/Dockerfile @@ -0,0 +1,11 @@ +# Usa la imagen base desde Docker Hub +FROM jgusgonza/my-mongo + +# Exponemos el puerto 3306 para que se pueda acceder a MySQL desde fuera del contenedor +EXPOSE 27017 + +# Establecemos las variables de entorno para MySQL +ENV MYSQL_ROOT_PASSWORD=Sabores1234 + +# Copia el archivo SQL al directorio de inicialización de MySQL +#COPY ../../M02-BBDD/script/script_inicial.sql /docker-entrypoint-initdb.d/ diff --git a/M01-SISTEMAS/docker-mongo/docker-compose.yml b/M01-SISTEMAS/docker-mongo/docker-compose.yml new file mode 100644 index 0000000..e36e2af --- /dev/null +++ b/M01-SISTEMAS/docker-mongo/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3.8' + +services: + mongo: + image: gusgonza/mymongo + container_name: mymongo + ports: + - "27017:27017" + environment: + ME_CONFIG_MONGODB_ADMINUSERNAME: root + ME_CONFIG_MONGODB_ADMINPASSWORD: root + ME_CONFIG_MONGODB_URL: mongodb://root:root@mongo:27017/ + ME_CONFIG_BASICAUTH: "false" + volumes: + - mongo_data:/data/db + restart: always + +volumes: + mongo_data: diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnection.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnection.java index 2e6666e..7425e9d 100644 --- a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnection.java +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnection.java @@ -27,14 +27,18 @@ public class DataBaseConnection { public ArrayList platos_productos; - public void init() throws SQLException { - //Conectamos - conectar(); - //Cargamos datos - cargaDeDatosCSV(); - System.out.println("CARGA DE DATOS COMPLETADA :)!"); - //Desconectamos - desconectar(); + public void init() throws CheckError { + try { + //Conectamos + conectar(); + //Cargamos datos + cargaDeDatosCSV(); + System.out.println("CARGA DE DATOS COMPLETADA :)!"); + //Desconectamos + desconectar(); + }catch (SQLException e) { + throw new CheckError(CheckError.ERROR_CONNECT_BBDD); + } } public static Connection getConnection()throws CheckError { diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnectionMongo.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnectionMongo.java index 81b6ccb..5bc0ddb 100644 --- a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnectionMongo.java +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/database/DataBaseConnectionMongo.java @@ -1,5 +1,29 @@ package abp.project.mesapp.database; +import abp.project.mesapp.util.CheckError; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + +import java.util.logging.Level; +import java.util.logging.Logger; + public class DataBaseConnectionMongo { + public MongoClient connectDB(String uri) throws CheckError{ + // Reduce logging level from MongoDB driver + Logger.getLogger("org.mongodb.driver").setLevel(Level.SEVERE); + MongoClient mongoClient = null; + try { + mongoClient = MongoClients.create(uri); + System.out.println("Connected"); + } catch (Exception e) { + System.out.println("Error connecting"); + throw new CheckError(CheckError.ERROR_CONNECT_BBDD); + } + return mongoClient; + } + public void disconnectDB(MongoClient mongoClient) { + System.out.println("Disconnected"); + mongoClient.close(); + } } diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Producto.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Producto.java index 0e4950f..8b2558b 100644 --- a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Producto.java +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Producto.java @@ -6,6 +6,7 @@ public class Producto { private int stock; private String proveedor; + public Producto(int id_producto, String nombre, int stock, String proveedor) { setIdproducto(id_producto); setNombre(nombre); @@ -13,6 +14,7 @@ public Producto(int id_producto, String nombre, int stock, String proveedor) { setProveedor(proveedor); } + public int getIdproducto() { return id_producto; } diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Proveedores.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Proveedores.java new file mode 100644 index 0000000..69d4d6b --- /dev/null +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Proveedores.java @@ -0,0 +1,114 @@ +package abp.project.mesapp.model; + +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import org.bson.Document; + +import java.util.List; + +public class Proveedores { + private int id; + private String nombre; + private String direccion; + private String telefono; + private String email; + private List productos; + + + public Proveedores(int id, String nombre, String direccion, String telefono, String email) { + this.id = id; + this.nombre = nombre; + this.direccion = direccion; + this.telefono = telefono; + this.email = email; + this.productos = productos; + } + + public int getId() { + return id; + } + + public String getNombre() { + return nombre; + } + + public String getDireccion() { + return direccion; + } + + public String getTelefono() { + return telefono; + } + + public String getEmail() { + return email; + } + + public void setId(int id) { + this.id = id; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public void setDireccion(String direccion) { + this.direccion = direccion; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getProductos() { + return productos; + } + + public void setProductos(List productos) { + this.productos = productos; + } + + @Override + public String toString() { + return "Proveedores{" + + "id=" + id + + ", nombre='" + nombre + '\'' + + ", direccion='" + direccion + '\'' + + ", telefono='" + telefono + '\'' + + ", email='" + email + '\'' + + '}'; + } + public static void saveProveedorToMongoDB(MongoClient mongoClient, String databaseName, String collectionName, Proveedores proveedor) { + MongoDatabase database = mongoClient.getDatabase(databaseName); + MongoCollection collection = database.getCollection(collectionName); + + Document proveedorDocument = new Document(); + proveedorDocument.append("id", proveedor.getId()) + .append("nombre", proveedor.getNombre()) + .append("direccion", proveedor.getDireccion()) + .append("telefono", proveedor.getTelefono()) + .append("email", proveedor.getEmail()); + + // Convertir lista de productos a documentos BSON + List productos = proveedor.getProductos(); + for (Producto producto : productos) { + Document productoDocument = new Document(); + productoDocument.append("id_producto", producto.getIdproducto()) + .append("nombre", producto.getNombre()) + .append("stock", producto.getStock()) + .append("proveedor", proveedor.getNombre()); // El nombre del proveedor se asocia con cada producto + + proveedorDocument.append("productos", productoDocument); + } + + // Insertar documento del proveedor en la colección + collection.insertOne(proveedorDocument); + } + + +} diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Tickets.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Tickets.java new file mode 100644 index 0000000..5d325e7 --- /dev/null +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/model/Tickets.java @@ -0,0 +1,62 @@ +package abp.project.mesapp.model; + +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoCollection; +import lombok.Getter; +import org.bson.Document; + +import java.util.Date; + + +public class Tickets { + int order; + int table; + int waiter; + Date date; + int num_diners; + + public Tickets(int order, int table, int waiter, Date date, int num_diners) { + setOrder(order); + setTable(table); + setWaiter(waiter); + setDate(date); + setNumDinners(num_diners); + } + + public void setOrder(int order) { + this.order = order; + } + + public void setTable(int table) { + this.table = table; + } + + public void setWaiter(int waiter) { + this.waiter = waiter; + } + + public void setDate(Date date) { + this.date = date; + } + + public void setNumDinners(int num_diners) { + this.num_diners = num_diners; + } + + public String toString() { + return "Order: " + order + ", Table: " + table + ", Waiter: " + waiter + ", Date: " + date + ", Number of diners: " + num_diners; + } + + public void saveTicket(MongoClient mongoClient, String databaseName, String collectionName) { + MongoCollection collection = mongoClient.getDatabase(databaseName).getCollection(collectionName); + + Document ticketDocument = new Document(); + ticketDocument.append("order", this.order) + .append("table", this.table) + .append("waiter", this.waiter) + .append("date", this.date) + .append("num_diners", this.num_diners); + + collection.insertOne(ticketDocument); + } +} \ No newline at end of file diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Constantes.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Constantes.java index aa648f4..c8de38e 100644 --- a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Constantes.java +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Constantes.java @@ -6,6 +6,7 @@ public class Constantes { public static final String PASS = "Sabores1234"; public static final String SCHEMA = "vialacteadesabores"; public static final String BBDD = "jdbc:mysql://localhost:3307/"; + public static final String uri = "mongodb://root:root@localhost:27017"; //RUTAS DE ARCHIVO public static final String PATH = "src/main/java/abp/project/mesapp/data/"; //RUTAS DE ARCHIVO ESPECÍFICO diff --git a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Main.java b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Main.java index 0114ac0..7941adb 100644 --- a/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Main.java +++ b/M03-PROG/vialacteadesabores_back/src/main/java/abp/project/mesapp/util/Main.java @@ -1,18 +1,38 @@ package abp.project.mesapp.util; import abp.project.mesapp.database.DataBaseConnection; +import abp.project.mesapp.database.DataBaseConnectionMongo; import abp.project.mesapp.model.MenuFunciones; +import abp.project.mesapp.model.Producto; +import abp.project.mesapp.model.Proveedores; +import abp.project.mesapp.model.Tickets; +import com.mongodb.client.MongoClient; import java.sql.SQLException; +import java.util.Date; public class Main { - public static void main(String[] args) throws SQLException { - DataBaseConnection db = new DataBaseConnection(); - db.init(); - MenuFunciones menu = new MenuFunciones(); - menu.menuFunciones(db); - // DESCONECTAR - db.desconectar(); + public static void main(String[] args) throws CheckError { + try{ + DataBaseConnection db = new DataBaseConnection(); + db.init(); + DataBaseConnectionMongo dbMongo = new DataBaseConnectionMongo(); + System.out.println("Conexión establecida"); + MongoClient mongoClient = dbMongo.connectDB(Constantes.uri); + System.out.println("Disconnected"); + dbMongo.disconnectDB(mongoClient); + Tickets ticket = new Tickets(1, 1, 1, new Date(), 1); + ticket.saveTicket(mongoClient, "vialacteadesabores", "tickets"); + Proveedores proveedor = new Proveedores(1, "Proveedor A", "Calle 123", "123456789", "proveedor@example.com"); + Producto producto1 = new Producto(1, "Producto 1", 10, "Proveedor A"); + Producto producto2 = new Producto(2, "Producto 2", 20, "Proveedor A"); + proveedor.getProductos().add(producto1); + proveedor.getProductos().add(producto2); + Proveedores.saveProveedorToMongoDB(mongoClient, "vialacteadesabores", "proveedores", proveedor); + db.desconectar(); + }catch (SQLException e){ + throw new CheckError(CheckError.ERROR_CONNECT_BBDD); + } } } diff --git a/M04-LENGUAJES/via-lactea-fronted/src/App.vue b/M04-LENGUAJES/via-lactea-fronted/src/App.vue index c458c89..7405464 100644 --- a/M04-LENGUAJES/via-lactea-fronted/src/App.vue +++ b/M04-LENGUAJES/via-lactea-fronted/src/App.vue @@ -1,6 +1,9 @@ diff --git a/M04-LENGUAJES/via-lactea-fronted/src/assets/css/registro.css b/M04-LENGUAJES/via-lactea-fronted/src/assets/css/registro.css index c6b2d33..5445979 100644 --- a/M04-LENGUAJES/via-lactea-fronted/src/assets/css/registro.css +++ b/M04-LENGUAJES/via-lactea-fronted/src/assets/css/registro.css @@ -7,9 +7,9 @@ body, html { } .registro-container { - position: relative; + position: fixed; text-align: center; - padding: 20px; + padding: 7.5%; width: 100%; height: 100vh; overflow-y: auto; diff --git a/M04-LENGUAJES/via-lactea-fronted/src/components/HomeView.vue b/M04-LENGUAJES/via-lactea-fronted/src/components/HomeView.vue index 0a15e20..00a08be 100644 --- a/M04-LENGUAJES/via-lactea-fronted/src/components/HomeView.vue +++ b/M04-LENGUAJES/via-lactea-fronted/src/components/HomeView.vue @@ -1,7 +1,7 @@