diff --git a/.idea/encodings.xml b/.idea/encodings.xml index ab03429..2a244de 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -3,13 +3,11 @@ - - - - - - + + + + \ No newline at end of file diff --git a/logs/app.log b/logs/app.log index 8ceffbf..c2e6d43 100644 --- a/logs/app.log +++ b/logs/app.log @@ -4,7 +4,7 @@ 2024-08-27 00:52:23 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 00:52:23 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 00:52:24 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -15,7 +15,7 @@ 2024-08-27 00:52:56 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 00:52:56 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 00:52:56 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -26,7 +26,7 @@ 2024-08-27 00:54:30 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 00:54:30 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 00:54:31 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -38,7 +38,7 @@ 2024-08-27 00:58:17 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 00:58:17 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 00:58:17 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -50,7 +50,7 @@ 2024-08-27 01:02:48 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 01:02:48 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 01:02:48 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -62,7 +62,7 @@ 2024-08-27 08:49:52 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 08:49:52 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 08:49:52 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -74,7 +74,7 @@ 2024-08-27 09:00:04 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 09:00:04 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 09:00:04 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -86,7 +86,7 @@ 2024-08-27 09:00:45 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-27 09:00:45 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-27 09:00:45 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -98,7 +98,7 @@ 2024-08-29 17:09:39 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-29 17:09:39 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -111,7 +111,7 @@ 2024-08-29 17:17:33 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-29 17:17:33 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) @@ -123,9 +123,94 @@ 2024-08-29 17:19:43 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) 2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver 2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] -2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq} +2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} 2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false 2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) 2024-08-29 17:19:43 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) 2024-08-29 17:19:44 INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration) 2024-08-29 17:19:44 INFO o.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@1d91bfa] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. +2024-08-30 11:19:09 INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: JFXSGPU] +2024-08-30 11:19:09 INFO org.hibernate.Version - HHH000412: Hibernate ORM core version [WORKING] +2024-08-30 11:19:09 INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled +2024-08-30 11:19:09 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use) +2024-08-30 11:19:09 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver +2024-08-30 11:19:09 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app] +2024-08-30 11:19:09 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, userDTO=lcaohoanq} +2024-08-30 11:19:09 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false +2024-08-30 11:19:09 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1) +2024-08-30 11:19:09 WARN o.h.e.j.e.i.JdbcEnvironmentInitiator - HHH000342: Could not obtain connection to query metadata +java.lang.IllegalStateException: Cannot get a connection as the driver manager is not properly initialized + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:260) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:437) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.resource.transaction.backend.jdbc.internal.JdbcIsolationDelegate.delegateWork(JdbcIsolationDelegate.java:61) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:290) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:123) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:77) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:52) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:133) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:43) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:61) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.addConnections(DriverManagerConnectionProviderImpl.java:500) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections.(DriverManagerConnectionProviderImpl.java:373) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections$Builder.build(DriverManagerConnectionProviderImpl.java:551) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildPool(DriverManagerConnectionProviderImpl.java:102) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:82) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:136) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:247) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.ServiceRegistry.requireService(ServiceRegistry.java:68) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:404) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.getJdbcEnvironmentUsingJdbcMetadata(JdbcEnvironmentInitiator.java:276) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:123) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:77) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:130) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:238) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:215) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.model.relational.Database.(Database.java:45) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:221) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.internal.InFlightMetadataCollectorImpl.(InFlightMetadataCollectorImpl.java:189) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:171) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1431) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1502) + at org.hibernate.orm.core@6.5.2.Final/org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:55) + at jakarta.persistence@3.1.0/jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80) + at jakarta.persistence@3.1.0/jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.modules.userDTO.UserDAO.(UserDAO.java:20) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.modules.userDTO.UserDAO.getInstance(UserDAO.java:27) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.controllers.ScoreController.(ScoreController.java:20) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.ScoreView.(ScoreView.java:27) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.base.MyFrame.doAction(MyFrame.java:184) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.SwingLoginView.doAction(SwingLoginView.java:143) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.base.MyFrame.initUI(MyFrame.java:39) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.base.MyFrame.(MyFrame.java:34) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.SwingLoginView.(SwingLoginView.java:33) + at com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.views.MenuView$LogOut.lambda$actionPerformed$0(MenuView.java:253) + at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) + at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) + at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720) + at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714) + at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) + at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) + at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) + at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) + at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) + at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) + at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) + at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) + at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) +2024-08-30 11:19:09 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default) +2024-08-30 11:19:09 WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 08S01 +2024-08-30 11:19:09 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Communications link failure + +The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. +2024-08-30 15:10:15 INFO c.l.fxsnakegame.views.base.Board - Update score successfully +2024-08-30 15:14:20 INFO c.l.fxsnakegame.views.base.Board - Update score successfully diff --git a/mvnw.cmd b/mvnw.cmd index 1d8ab01..67e6de0 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -43,7 +43,7 @@ title %0 @REM set %HOME% to equivalent of $HOME if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") -@REM Execute a user defined script before this one +@REM Execute a userDTO 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" %* diff --git a/pom.xml b/pom.xml index 7d6f928..bccea83 100644 --- a/pom.xml +++ b/pom.xml @@ -41,12 +41,6 @@ ${junit.version} test - - - com.mysql - mysql-connector-j - 8.0.33 - org.swinglabs @@ -144,15 +138,15 @@ - src/main/resources/com/lcaohoanq/formhandling/ + src/main/resources/com/lcaohoanq/fxsnakegame/ false **.fxml - ${project.build.outputDirectory}/com/lcaohoanq/formhandling + ${project.build.outputDirectory}/com/lcaohoanq/fxsnakegame - src/main/resources/com/lcaohoanq/formhandling/assets/img + src/main/resources/com/lcaohoanq/fxsnakegame/assets/img false **.png @@ -160,7 +154,7 @@ ${project.build.outputDirectory}/assets/img - src/main/resources/com/lcaohoanq/formhandling/assets/sound + src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound false **.wav @@ -168,7 +162,7 @@ ${project.build.outputDirectory}/assets/sound - src/main/resources/com/lcaohoanq/formhandling/templates/email + src/main/resources/com/lcaohoanq/fxsnakegame/templates/email false **.html @@ -176,20 +170,12 @@ ${project.build.outputDirectory}/templates/email - src/main/resources/com/lcaohoanq/formhandling + src/main/resources/com/lcaohoanq/fxsnakegame false logback.xml - - src/main/resources/com/lcaohoanq/formhandling/META-INF - false - - persistence.xml - - META-INF - @@ -200,7 +186,7 @@ - com.lcaohoanq.formhandling.Main + com.lcaohoanq.fxsnakegame.Main @@ -251,15 +237,6 @@ ${basedir}/src/main/webapp - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - 18 - 18 - - org.openjfx javafx-maven-plugin @@ -269,7 +246,7 @@ default-cli - com.lcaohoanq.formhandling/com.lcaohoanq.formhandling.Main + com.lcaohoanq.fxsnakegame/com.lcaohoanq.fxsnakegame.Main app app diff --git a/src/main/java/com/lcaohoanq/formhandling/exceptions/DBException.java b/src/main/java/com/lcaohoanq/formhandling/exceptions/DBException.java deleted file mode 100644 index 0370dd4..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/exceptions/DBException.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.lcaohoanq.formhandling.exceptions; - -import java.sql.SQLException; - -public class DBException extends SQLException { - public DBException(String message) { - super(message); - } -} diff --git a/src/main/java/com/lcaohoanq/formhandling/exceptions/DataException.java b/src/main/java/com/lcaohoanq/formhandling/exceptions/DataException.java deleted file mode 100644 index ba65e3a..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/exceptions/DataException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.lcaohoanq.formhandling.exceptions; - -public class DataException extends Exception { - public DataException(String message) { - super(message); - } -} diff --git a/src/main/java/com/lcaohoanq/formhandling/exceptions/FileException.java b/src/main/java/com/lcaohoanq/formhandling/exceptions/FileException.java deleted file mode 100644 index 72b9cc2..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/exceptions/FileException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.lcaohoanq.formhandling.exceptions; - -public class FileException extends Exception { - public FileException(String message) { - super(message); - } -} diff --git a/src/main/java/com/lcaohoanq/formhandling/models/LoginModel.java b/src/main/java/com/lcaohoanq/formhandling/models/LoginModel.java deleted file mode 100644 index 1aa48ba..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/models/LoginModel.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.lcaohoanq.formhandling.models; - -import com.lcaohoanq.formhandling.exceptions.DataException; -import com.lcaohoanq.formhandling.modules.user.UserDAO; -import com.lcaohoanq.formhandling.modules.user.UserEntity; -import com.lcaohoanq.formhandling.utils.PBKDF2; - -public record LoginModel(String username, String password) { - public LoginModel() { - this("", ""); - } - - public boolean isAdmin(String username, String password) { - return username.equals("admin") && password.equals("admin"); - } - - public boolean isMatching(String username, String password) { - UserEntity db; - UserDAO executeQuery = UserDAO.getInstance(); - try { - db = executeQuery.selectEmailAndPasswordByEmail(username); - if (db != null) { - return new PBKDF2().authenticate(password.toCharArray(), db.getPassword()); - } else { - throw new DataException("Error authenticate, password do not match"); - } - } catch (Exception e) { - System.out.println(e.getMessage()); - } - return false; - } - - public boolean isEmpty(String username, String password) { - return username.isEmpty() || password.isEmpty(); - } -} diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/phone/PhoneUtils.java b/src/main/java/com/lcaohoanq/formhandling/modules/phone/PhoneUtils.java deleted file mode 100644 index 52d4c5e..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/modules/phone/PhoneUtils.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.lcaohoanq.formhandling.modules.phone; - -public class PhoneUtils { - -} diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/user/UserDAO.java b/src/main/java/com/lcaohoanq/formhandling/modules/user/UserDAO.java deleted file mode 100644 index ec03ba5..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/modules/user/UserDAO.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.lcaohoanq.formhandling.modules.user; - -import com.lcaohoanq.formhandling.constants.ErrorMessages; -import com.lcaohoanq.formhandling.utils.PBKDF2; -import jakarta.persistence.EntityManager; -import jakarta.persistence.EntityManagerFactory; -import jakarta.persistence.ParameterMode; -import jakarta.persistence.Persistence; -import jakarta.persistence.StoredProcedureQuery; -import java.util.ArrayList; -import java.util.List; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.query.Query; - -@Deprecated -public class UserDAO { - - private static UserDAO instance; - private final EntityManagerFactory emf = Persistence.createEntityManagerFactory("JFXSGPU"); - - private UserDAO() { - } - - public static UserDAO getInstance() { - if (instance == null) { - instance = new UserDAO(); - } - return instance; - } - - private EntityManager getEntityManager() { - return emf.createEntityManager(); - } - - public List selectFirstNameAndScore() { - List resultList = new ArrayList<>(); - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - - try { - transaction = session.beginTransaction(); - StoredProcedureQuery query = session.createStoredProcedureQuery( - "proc_select_first_name_score"); - List results = query.getResultList(); - for (Object[] result : results) { - resultList.add(result[0] + " " + result[1]); - } - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(ErrorMessages.ERROR_SELECT_FIRST_NAME_AND_SCORE + e.getMessage()); - } finally { - session.close(); - } - return resultList; - } - - public UserEntity selectEmailAndPasswordByEmail(String email) { - UserEntity user = null; - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - - try { - transaction = session.beginTransaction(); - Query query = session.createQuery( - "FROM UserEntity WHERE email = :email", UserEntity.class); - - query.setParameter("email", email); - query.setMaxResults(1); - List results = query.getResultList(); // Get directly as UserEntity - if (!results.isEmpty()) { - user = results.get(0); // No need for manual mapping - } - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(ErrorMessages.ERROR_SELECT_EMAIL_AND_PASSWORD + e.getMessage()); - } finally { - session.close(); - } - return user; - } - - public UserEntity selectEmailAndScoreByEmail(String email) { - UserEntity user = null; - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - - try { - transaction = session.beginTransaction(); - StoredProcedureQuery query = session.createStoredProcedureQuery( - "proc_select_email_score_by_email") - .registerStoredProcedureParameter(1, String.class, ParameterMode.IN); - - query.setParameter(1, email); - query.setMaxResults(1); - List results = query.getResultList(); - if (!results.isEmpty()) { - Object[] result = results.get(0); - user = new UserEntity((String) result[0], (Integer) result[1]); - } - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(ErrorMessages.ERROR_SELECT_USERNAME_AND_SCORE + e.getMessage()); - } finally { - session.close(); - } - return user; - } - - public int setSafeUpdate() { - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - int rowsAffected = 0; - try { - transaction = session.beginTransaction(); - StoredProcedureQuery query = session.createStoredProcedureQuery("proc_set_safe_update"); - - rowsAffected = query.executeUpdate(); - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(e.getMessage()); - } finally { - session.close(); - } - return rowsAffected; - } - - public int updateEmailScore(String email, String score) { - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - int rowsAffected = 0; - try { - transaction = session.beginTransaction(); - StoredProcedureQuery query = session.createStoredProcedureQuery( - "proc_update_score_by_email") - .registerStoredProcedureParameter(1, String.class, ParameterMode.IN) - .registerStoredProcedureParameter(2, Integer.class, ParameterMode.IN); - - query.setParameter(1, email); - query.setParameter(2, score); - rowsAffected = query.executeUpdate(); - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(e.getMessage()); - } finally { - session.close(); - } - return rowsAffected; - } - - public int updatePassword(String email, String newPassword) { - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - int rowsAffected = 0; - - try { - transaction = session.beginTransaction(); - - // Find the user by email - UserEntity user = (UserEntity) session.createQuery("FROM UserEntity WHERE email = :email") - .setParameter("email", email) - .uniqueResult(); - - if (user != null) { - // Update the password - user.setPassword(newPassword); - - // Save the changes - session.update(user); - rowsAffected = 1; - } - - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - e.printStackTrace(); - } finally { - session.close(); - } - - return rowsAffected; - } - - public int insertMail(String email, String phoneNumber, String firstName, String lastName, - String password) { - EntityManager entityManager = getEntityManager(); - Session session = entityManager.unwrap(Session.class); - Transaction transaction = null; - int rowsAffected = 0; - try { - transaction = session.beginTransaction(); - StoredProcedureQuery query = session.createStoredProcedureQuery( - "proc_insert_user_new") - .registerStoredProcedureParameter(1, String.class, ParameterMode.IN) - .registerStoredProcedureParameter(2, String.class, ParameterMode.IN) - .registerStoredProcedureParameter(3, String.class, ParameterMode.IN) - .registerStoredProcedureParameter(4, String.class, ParameterMode.IN) - .registerStoredProcedureParameter(5, String.class, ParameterMode.IN); - - query.setParameter(1, email); - query.setParameter(2, phoneNumber); - query.setParameter(3, firstName); - query.setParameter(4, lastName); - query.setParameter(5, password); - rowsAffected = query.executeUpdate(); - transaction.commit(); - } catch (Exception e) { - if (transaction != null) { - transaction.rollback(); - } - System.out.println(e.getMessage()); - } finally { - session.close(); - } - return rowsAffected; - } - - public static void main(String[] args) { -// UserDAO.getInstance().insertMail("hoangclw@gmail.com", "", "Hoang", "Luu", "123456"); -// UserDAO.getInstance().selectFirstNameAndScore().forEach(System.out::println); - System.out.println( - UserDAO.getInstance().selectEmailAndPasswordByEmail("hoanglcse181513@fpt.edu.vn").getPassword()); - -// PasswordHandler pwd = new PasswordHandler(); -// String data = pwd.hash("12345"); -// System.out.println(UserDAO.getInstance().updatePassword("hoanglcse181513@fpt.edu.vn", data));; - - System.out.println(new PBKDF2().authenticate("12345".toCharArray(), UserDAO.getInstance().selectEmailAndPasswordByEmail("hoanglcse181513@fpt.edu.vn").getPassword())); - } -} diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/user/UserEntity.java b/src/main/java/com/lcaohoanq/formhandling/modules/user/UserEntity.java deleted file mode 100644 index 34887a6..0000000 --- a/src/main/java/com/lcaohoanq/formhandling/modules/user/UserEntity.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.lcaohoanq.formhandling.modules.user; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import jakarta.persistence.Transient; -import java.time.LocalDateTime; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -@Entity -@Table(name = "users") -@Getter -@Setter -@ToString -@NoArgsConstructor -@AllArgsConstructor -public class UserEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "user_id", nullable = false) - private Integer userId; - - @Column(name = "email", unique = true, length = 45) - private String email; - - @Column(name = "phone_number", unique = true, length = 15) - private String phoneNumber; - - @Column(name = "first_name", nullable = false, length = 45) - private String firstName; - - @Column(name = "last_name", nullable = false, length = 45) - private String lastName; - - @Column(name = "password", nullable = false, length = 50) - private String password; - - @Transient - private String confirmPassword; - - @Column(name = "score", nullable = false) - private Integer score = 0; - - @Column(name = "created", nullable = false) - private LocalDateTime created = LocalDateTime.now(); - - public UserEntity(String email, String firstName, String lastName, String password, - String confirmPassword) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - this.password = password; - this.confirmPassword = confirmPassword; - } - - public UserEntity(String email, String password) { - this.email = email; - this.password = password; - } - - public UserEntity(String email, Integer score) { - this.email = email; - this.score = score; - } - -} diff --git a/src/main/java/com/lcaohoanq/formhandling/Main.java b/src/main/java/com/lcaohoanq/fxsnakegame/Main.java similarity index 77% rename from src/main/java/com/lcaohoanq/formhandling/Main.java rename to src/main/java/com/lcaohoanq/fxsnakegame/Main.java index 36c1506..140e86c 100644 --- a/src/main/java/com/lcaohoanq/formhandling/Main.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/Main.java @@ -1,8 +1,7 @@ -package com.lcaohoanq.formhandling; +package com.lcaohoanq.fxsnakegame; -import com.lcaohoanq.formhandling.utils.LogsUtils; -import com.lcaohoanq.formhandling.views.OTPVerificationView; -import com.lcaohoanq.formhandling.views.SwingLoginView; +import com.lcaohoanq.fxsnakegame.utils.LogsUtils; +import com.lcaohoanq.fxsnakegame.views.SwingLoginView; import java.awt.EventQueue; import javafx.application.Application; import javafx.fxml.FXMLLoader; diff --git a/src/main/java/com/lcaohoanq/formhandling/constants/APIConstants.java b/src/main/java/com/lcaohoanq/fxsnakegame/constants/APIConstants.java similarity index 78% rename from src/main/java/com/lcaohoanq/formhandling/constants/APIConstants.java rename to src/main/java/com/lcaohoanq/fxsnakegame/constants/APIConstants.java index 4e95b97..0830b45 100644 --- a/src/main/java/com/lcaohoanq/formhandling/constants/APIConstants.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/constants/APIConstants.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.constants; +package com.lcaohoanq.fxsnakegame.constants; public class APIConstants { public static final String API_PREFIX = "/api/v1"; diff --git a/src/main/java/com/lcaohoanq/formhandling/constants/ErrorMessages.java b/src/main/java/com/lcaohoanq/fxsnakegame/constants/ErrorMessages.java similarity index 90% rename from src/main/java/com/lcaohoanq/formhandling/constants/ErrorMessages.java rename to src/main/java/com/lcaohoanq/fxsnakegame/constants/ErrorMessages.java index 0b99a56..4464b3c 100644 --- a/src/main/java/com/lcaohoanq/formhandling/constants/ErrorMessages.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/constants/ErrorMessages.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.constants; +package com.lcaohoanq.fxsnakegame.constants; public class ErrorMessages { public static final String ERROR_READ_FILE_ENV = "Error read file .env: "; diff --git a/src/main/java/com/lcaohoanq/formhandling/constants/Regex.java b/src/main/java/com/lcaohoanq/fxsnakegame/constants/Regex.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/constants/Regex.java rename to src/main/java/com/lcaohoanq/fxsnakegame/constants/Regex.java index ce06f56..7305862 100644 --- a/src/main/java/com/lcaohoanq/formhandling/constants/Regex.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/constants/Regex.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.constants; +package com.lcaohoanq.fxsnakegame.constants; public class Regex { public static final String NAME = "^[a-zA-Z]{1,20}$"; diff --git a/src/main/java/com/lcaohoanq/formhandling/constants/ResourcePaths.java b/src/main/java/com/lcaohoanq/fxsnakegame/constants/ResourcePaths.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/constants/ResourcePaths.java rename to src/main/java/com/lcaohoanq/fxsnakegame/constants/ResourcePaths.java index 1f49722..5466927 100644 --- a/src/main/java/com/lcaohoanq/formhandling/constants/ResourcePaths.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/constants/ResourcePaths.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.constants; +package com.lcaohoanq.fxsnakegame.constants; public class ResourcePaths { // img diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/EventSwitchSelected.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/EventSwitchSelected.java similarity index 63% rename from src/main/java/com/lcaohoanq/formhandling/controllers/EventSwitchSelected.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/EventSwitchSelected.java index 943a3c8..a4738c8 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/EventSwitchSelected.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/EventSwitchSelected.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; public interface EventSwitchSelected { diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/ForgotPasswordController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ForgotPasswordController.java similarity index 86% rename from src/main/java/com/lcaohoanq/formhandling/controllers/ForgotPasswordController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/ForgotPasswordController.java index 370d3cd..28b5fa8 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/ForgotPasswordController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ForgotPasswordController.java @@ -1,11 +1,11 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; import java.awt.Desktop; import java.awt.event.ActionListener; import java.net.URI; import lombok.extern.slf4j.Slf4j; -import com.lcaohoanq.formhandling.views.SwingLoginView; -import com.lcaohoanq.formhandling.views.OTPVerificationView; +import com.lcaohoanq.fxsnakegame.views.SwingLoginView; +import com.lcaohoanq.fxsnakegame.views.OTPVerificationView; @Slf4j public class ForgotPasswordController implements ActionListener { diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/LoginController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/LoginController.java similarity index 77% rename from src/main/java/com/lcaohoanq/formhandling/controllers/LoginController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/LoginController.java index f543ce8..9d0328c 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/LoginController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/LoginController.java @@ -1,13 +1,11 @@ -package com.lcaohoanq.formhandling.controllers; - -import com.lcaohoanq.formhandling.constants.APIConstants; -import com.lcaohoanq.formhandling.utils.ApiUtils; -import com.lcaohoanq.formhandling.utils.EnvUtils; -import com.lcaohoanq.formhandling.views.MenuView; -import com.lcaohoanq.formhandling.views.UIPrompts; -import com.lcaohoanq.formhandling.views.base.BaseResources; -import java.awt.EventQueue; -import java.awt.event.ActionListener; +package com.lcaohoanq.fxsnakegame.controllers; + +import com.lcaohoanq.fxsnakegame.constants.APIConstants; +import com.lcaohoanq.fxsnakegame.utils.ApiUtils; +import com.lcaohoanq.fxsnakegame.utils.EnvUtils; +import com.lcaohoanq.fxsnakegame.views.MenuView; +import com.lcaohoanq.fxsnakegame.views.UIPrompts; +import com.lcaohoanq.fxsnakegame.views.base.BaseResources; import java.net.http.HttpResponse; import java.util.Map; import javafx.application.Platform; @@ -39,7 +37,7 @@ public class LoginController extends BaseResources { private PasswordField enterPasswordField; @FXML private Button loginButton; - private String email = ""; + public static String email = ""; private String password = ""; @FXML @@ -73,6 +71,12 @@ public void validateLogin() { password = enterPasswordField.getText(); if (email.equals("admin") && password.equals("admin")) { UIPrompts.IS_LOGIN_SUCCESS(); + Platform.runLater(() -> { + new MenuView().setVisible(true); + Stage stage = (Stage) loginButton.getScene().getWindow(); + stage.close(); + }); + } else { login(email, password); } @@ -154,4 +158,23 @@ public void signupHereAction(ActionEvent actionEvent) { System.out.println("Error: " + ex.getMessage()); } } + + public void forgotPasswordAction(ActionEvent actionEvent) { + String api = "http://localhost:3000/forgot-password"; + Platform.runLater(() -> { + try { + // Specify the URL of the website + URI uri = new URI(api); + // Open the website in the default browser + if (Desktop.isDesktopSupported() && Desktop.getDesktop() + .isSupported(Desktop.Action.BROWSE)) { + Desktop.getDesktop().browse(uri); + } + } catch (Exception ex) { + System.out.println("Error when open frontend forgot password: " + ex.getMessage()); + } + }); + } + + } \ No newline at end of file diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/MenuController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/MenuController.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/controllers/MenuController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/MenuController.java index add4597..010f473 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/MenuController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/MenuController.java @@ -1,7 +1,7 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; -import com.lcaohoanq.formhandling.constants.ResourcePaths; -import com.lcaohoanq.formhandling.enums.Hover; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.enums.Hover; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -11,12 +11,12 @@ import java.util.Arrays; import java.util.List; import javax.swing.JButton; -import com.lcaohoanq.formhandling.modules.sound.AudioHandler; -import com.lcaohoanq.formhandling.styles.UIHovers; -import com.lcaohoanq.formhandling.views.MenuView; -import com.lcaohoanq.formhandling.views.UIPrompts; -import com.lcaohoanq.formhandling.views.base.AppComponent; -import com.lcaohoanq.formhandling.views.game.Snake; +import com.lcaohoanq.fxsnakegame.modules.sound.AudioHandler; +import com.lcaohoanq.fxsnakegame.styles.UIHovers; +import com.lcaohoanq.fxsnakegame.views.MenuView; +import com.lcaohoanq.fxsnakegame.views.UIPrompts; +import com.lcaohoanq.fxsnakegame.views.base.AppComponent; +import com.lcaohoanq.fxsnakegame.views.game.Snake; public class MenuController implements MouseListener, ActionListener { diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/OTPVerificationListener.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/OTPVerificationListener.java similarity index 83% rename from src/main/java/com/lcaohoanq/formhandling/controllers/OTPVerificationListener.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/OTPVerificationListener.java index 3ee8600..633b232 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/OTPVerificationListener.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/OTPVerificationListener.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; import java.io.IOException; diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/PlayController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/PlayController.java similarity index 83% rename from src/main/java/com/lcaohoanq/formhandling/controllers/PlayController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/PlayController.java index 04898cc..c0fc188 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/PlayController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/PlayController.java @@ -1,11 +1,11 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import com.lcaohoanq.formhandling.views.SwingLoginView; -import com.lcaohoanq.formhandling.views.MenuView; -import com.lcaohoanq.formhandling.views.game.Snake; +import com.lcaohoanq.fxsnakegame.views.SwingLoginView; +import com.lcaohoanq.fxsnakegame.views.MenuView; +import com.lcaohoanq.fxsnakegame.views.game.Snake; public class PlayController implements ActionListener { public static MenuView menuView; diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/RegisterController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/RegisterController.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/controllers/RegisterController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/RegisterController.java index 1200483..19e700a 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/RegisterController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/RegisterController.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; -import com.lcaohoanq.formhandling.enums.Hover; +import com.lcaohoanq.fxsnakegame.enums.Hover; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -10,12 +10,12 @@ import javax.swing.JButton; import javax.swing.JTextField; import lombok.extern.slf4j.Slf4j; -import com.lcaohoanq.formhandling.modules.email.EmailUtils; -import com.lcaohoanq.formhandling.modules.otp.OTPUtils; -import com.lcaohoanq.formhandling.styles.UIHovers; -import com.lcaohoanq.formhandling.views.OTPVerificationView; -import com.lcaohoanq.formhandling.views.SwingRegisterView; -import com.lcaohoanq.formhandling.views.UIPrompts; +import com.lcaohoanq.fxsnakegame.modules.email.EmailUtils; +import com.lcaohoanq.fxsnakegame.modules.otp.OTPUtils; +import com.lcaohoanq.fxsnakegame.styles.UIHovers; +import com.lcaohoanq.fxsnakegame.views.OTPVerificationView; +import com.lcaohoanq.fxsnakegame.views.SwingRegisterView; +import com.lcaohoanq.fxsnakegame.views.UIPrompts; @Slf4j public class RegisterController implements ActionListener, MouseListener { diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/ScoreController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ScoreController.java similarity index 89% rename from src/main/java/com/lcaohoanq/formhandling/controllers/ScoreController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/ScoreController.java index de9dff7..93167c2 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/ScoreController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ScoreController.java @@ -1,12 +1,12 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.lcaohoanq.formhandling.modules.user.UserDAO; -import com.lcaohoanq.formhandling.utils.ApiUtils; -import com.lcaohoanq.formhandling.views.ScoreView; +//import com.lcaohoanq.fxsnakegame.modules.user.UserDAO; +import com.lcaohoanq.fxsnakegame.utils.ApiUtils; +import com.lcaohoanq.fxsnakegame.views.ScoreView; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; @@ -17,7 +17,7 @@ public class ScoreController implements ActionListener { private final ScoreView scoreView; - private final UserDAO executeQuery = UserDAO.getInstance(); +// private final UserDAO executeQuery = UserDAO.getInstance(); private ObjectMapper objectMapper; public ScoreController(ScoreView scoreView) { this.scoreView = scoreView; diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/SwingLoginController.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/SwingLoginController.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/controllers/SwingLoginController.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/SwingLoginController.java index 10c6dcc..43acaf6 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/SwingLoginController.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/SwingLoginController.java @@ -1,9 +1,9 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.lcaohoanq.formhandling.enums.Hover; +import com.lcaohoanq.fxsnakegame.enums.Hover; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -15,10 +15,10 @@ import javax.swing.JButton; import javax.swing.JOptionPane; import lombok.extern.slf4j.Slf4j; -import com.lcaohoanq.formhandling.styles.UIHovers; -import com.lcaohoanq.formhandling.utils.ApiUtils; -import com.lcaohoanq.formhandling.views.SwingLoginView; -import com.lcaohoanq.formhandling.views.UIPrompts; +import com.lcaohoanq.fxsnakegame.styles.UIHovers; +import com.lcaohoanq.fxsnakegame.utils.ApiUtils; +import com.lcaohoanq.fxsnakegame.views.SwingLoginView; +import com.lcaohoanq.fxsnakegame.views.UIPrompts; @Slf4j public final class SwingLoginController implements ActionListener, MouseListener { diff --git a/src/main/java/com/lcaohoanq/formhandling/controllers/ToggleHandler.java b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ToggleHandler.java similarity index 67% rename from src/main/java/com/lcaohoanq/formhandling/controllers/ToggleHandler.java rename to src/main/java/com/lcaohoanq/fxsnakegame/controllers/ToggleHandler.java index 4baabcf..734b20b 100644 --- a/src/main/java/com/lcaohoanq/formhandling/controllers/ToggleHandler.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/controllers/ToggleHandler.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.controllers; +package com.lcaohoanq.fxsnakegame.controllers; -import com.lcaohoanq.formhandling.views.Toggle; +import com.lcaohoanq.fxsnakegame.views.Toggle; public interface ToggleHandler { Toggle toggleButton = new Toggle(); diff --git a/src/main/java/com/lcaohoanq/formhandling/dto/AbstractRequest.java b/src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractRequest.java similarity index 52% rename from src/main/java/com/lcaohoanq/formhandling/dto/AbstractRequest.java rename to src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractRequest.java index fb5ea89..ccd1dcf 100644 --- a/src/main/java/com/lcaohoanq/formhandling/dto/AbstractRequest.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractRequest.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.dto; +package com.lcaohoanq.fxsnakegame.dto; public abstract class AbstractRequest { diff --git a/src/main/java/com/lcaohoanq/formhandling/dto/AbstractResponse.java b/src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractResponse.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/dto/AbstractResponse.java rename to src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractResponse.java index ca33f9d..91e89a0 100644 --- a/src/main/java/com/lcaohoanq/formhandling/dto/AbstractResponse.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/dto/AbstractResponse.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.dto; +package com.lcaohoanq.fxsnakegame.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/lcaohoanq/formhandling/dto/MailResponse.java b/src/main/java/com/lcaohoanq/fxsnakegame/dto/MailResponse.java similarity index 92% rename from src/main/java/com/lcaohoanq/formhandling/dto/MailResponse.java rename to src/main/java/com/lcaohoanq/fxsnakegame/dto/MailResponse.java index 023ea3f..97f0b0d 100644 --- a/src/main/java/com/lcaohoanq/formhandling/dto/MailResponse.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/dto/MailResponse.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.dto; +package com.lcaohoanq.fxsnakegame.dto; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/lcaohoanq/formhandling/enums/Hover.java b/src/main/java/com/lcaohoanq/fxsnakegame/enums/Hover.java similarity index 81% rename from src/main/java/com/lcaohoanq/formhandling/enums/Hover.java rename to src/main/java/com/lcaohoanq/fxsnakegame/enums/Hover.java index 9303e86..d50ad9a 100644 --- a/src/main/java/com/lcaohoanq/formhandling/enums/Hover.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/enums/Hover.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.enums; +package com.lcaohoanq.fxsnakegame.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/lcaohoanq/fxsnakegame/exceptions/BadCredentialsException.java b/src/main/java/com/lcaohoanq/fxsnakegame/exceptions/BadCredentialsException.java new file mode 100644 index 0000000..a12d3a5 --- /dev/null +++ b/src/main/java/com/lcaohoanq/fxsnakegame/exceptions/BadCredentialsException.java @@ -0,0 +1,7 @@ +package com.lcaohoanq.fxsnakegame.exceptions; + +public class BadCredentialsException extends Exception { + public BadCredentialsException(String message) { + super(message); + } +} diff --git a/src/main/java/com/lcaohoanq/fxsnakegame/models/LoginModel.java b/src/main/java/com/lcaohoanq/fxsnakegame/models/LoginModel.java new file mode 100644 index 0000000..7dcf61b --- /dev/null +++ b/src/main/java/com/lcaohoanq/fxsnakegame/models/LoginModel.java @@ -0,0 +1,15 @@ +package com.lcaohoanq.fxsnakegame.models; + +public record LoginModel(String username, String password) { + public LoginModel() { + this("", ""); + } + + public boolean isAdmin(String username, String password) { + return username.equals("admin") && password.equals("admin"); + } + + public boolean isEmpty(String username, String password) { + return username.isEmpty() || password.isEmpty(); + } +} diff --git a/src/main/java/com/lcaohoanq/formhandling/models/MenuModel.java b/src/main/java/com/lcaohoanq/fxsnakegame/models/MenuModel.java similarity index 87% rename from src/main/java/com/lcaohoanq/formhandling/models/MenuModel.java rename to src/main/java/com/lcaohoanq/fxsnakegame/models/MenuModel.java index 1dd0f76..74f38af 100644 --- a/src/main/java/com/lcaohoanq/formhandling/models/MenuModel.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/models/MenuModel.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.models; +package com.lcaohoanq.fxsnakegame.models; public record MenuModel(String tittle, String btn_1, String btn_2, String btn_3, String btn_4, String btn_5, String btn_6, String btn_7, String btn_8, String btn_9) { diff --git a/src/main/java/com/lcaohoanq/formhandling/models/RegisterModel.java b/src/main/java/com/lcaohoanq/fxsnakegame/models/RegisterModel.java similarity index 74% rename from src/main/java/com/lcaohoanq/formhandling/models/RegisterModel.java rename to src/main/java/com/lcaohoanq/fxsnakegame/models/RegisterModel.java index b903655..fbb8039 100644 --- a/src/main/java/com/lcaohoanq/formhandling/models/RegisterModel.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/models/RegisterModel.java @@ -1,9 +1,10 @@ -package com.lcaohoanq.formhandling.models; +package com.lcaohoanq.fxsnakegame.models; -import com.lcaohoanq.formhandling.constants.Regex; -import com.lcaohoanq.formhandling.modules.user.UserDAO; -import com.lcaohoanq.formhandling.modules.user.UserEntity; -import com.lcaohoanq.formhandling.utils.PBKDF2; +import com.lcaohoanq.fxsnakegame.constants.Regex; +//import com.lcaohoanq.fxsnakegame.modules.user.UserDAO; +import com.lcaohoanq.fxsnakegame.modules.user.UserDAO; +import com.lcaohoanq.fxsnakegame.modules.user.UserDTO; +import com.lcaohoanq.fxsnakegame.utils.PBKDF2; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -37,11 +38,11 @@ public boolean isMatching(String password, String confirmPassword) { } public boolean isDuplicateEmail(String username) { - UserEntity db; - UserDAO executeQuery = UserDAO.getInstance(); + UserDTO db; +// UserDAO executeQuery = UserDAO.getInstance(); try { - db = executeQuery.selectEmailAndPasswordByEmail(username); - return db == null ? false : true; +// db = executeQuery.selectEmailAndPasswordByEmail(username); +// return db == null ? false : true; } catch (Exception e) { log.error("Error while checking if email exists", e); } diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/email/EmailCategories.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailCategories.java similarity index 83% rename from src/main/java/com/lcaohoanq/formhandling/modules/email/EmailCategories.java rename to src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailCategories.java index 7022a9a..471e3d6 100644 --- a/src/main/java/com/lcaohoanq/formhandling/modules/email/EmailCategories.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailCategories.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.modules.email; +package com.lcaohoanq.fxsnakegame.modules.email; import lombok.Getter; diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/email/EmailUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailUtils.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/modules/email/EmailUtils.java rename to src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailUtils.java index d434084..eb26197 100644 --- a/src/main/java/com/lcaohoanq/formhandling/modules/email/EmailUtils.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/email/EmailUtils.java @@ -1,7 +1,7 @@ -package com.lcaohoanq.formhandling.modules.email; +package com.lcaohoanq.fxsnakegame.modules.email; -import com.lcaohoanq.formhandling.modules.otp.OTPUtils; -import com.lcaohoanq.formhandling.utils.EnvUtils; +import com.lcaohoanq.fxsnakegame.modules.otp.OTPUtils; +import com.lcaohoanq.fxsnakegame.utils.EnvUtils; import java.util.Properties; import java.util.regex.Pattern; import javax.mail.Authenticator; diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/otp/OTPUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/otp/OTPUtils.java similarity index 89% rename from src/main/java/com/lcaohoanq/formhandling/modules/otp/OTPUtils.java rename to src/main/java/com/lcaohoanq/fxsnakegame/modules/otp/OTPUtils.java index 933f7c0..e1ca3ee 100644 --- a/src/main/java/com/lcaohoanq/formhandling/modules/otp/OTPUtils.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/otp/OTPUtils.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.modules.otp; +package com.lcaohoanq.fxsnakegame.modules.otp; import javax.swing.JOptionPane; diff --git a/src/main/java/com/lcaohoanq/fxsnakegame/modules/phone/PhoneUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/phone/PhoneUtils.java new file mode 100644 index 0000000..fbfd23f --- /dev/null +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/phone/PhoneUtils.java @@ -0,0 +1,5 @@ +package com.lcaohoanq.fxsnakegame.modules.phone; + +public class PhoneUtils { + +} diff --git a/src/main/java/com/lcaohoanq/formhandling/modules/sound/AudioHandler.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/sound/AudioHandler.java similarity index 86% rename from src/main/java/com/lcaohoanq/formhandling/modules/sound/AudioHandler.java rename to src/main/java/com/lcaohoanq/fxsnakegame/modules/sound/AudioHandler.java index e5f7239..0c25094 100644 --- a/src/main/java/com/lcaohoanq/formhandling/modules/sound/AudioHandler.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/sound/AudioHandler.java @@ -1,7 +1,7 @@ -package com.lcaohoanq.formhandling.modules.sound; +package com.lcaohoanq.fxsnakegame.modules.sound; -import com.lcaohoanq.formhandling.exceptions.FileException; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.InputStream; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -20,7 +20,7 @@ public boolean isEmptyPath() { public void playAudio(InputStream inputStream) { try { if (inputStreamCurrent != null) { - throw new FileException("Audio file is missing"); + throw new IOException("Audio file is missing"); } // Create a byte array to store the audio data byte[] audioData = inputStream.readAllBytes(); diff --git a/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDAO.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDAO.java new file mode 100644 index 0000000..c09ac13 --- /dev/null +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDAO.java @@ -0,0 +1,68 @@ +package com.lcaohoanq.fxsnakegame.modules.user; + +import com.lcaohoanq.fxsnakegame.constants.ErrorMessages; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.ParameterMode; +import jakarta.persistence.Persistence; +import jakarta.persistence.StoredProcedureQuery; +import java.util.ArrayList; +import java.util.List; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.query.Query; + +@Deprecated +public class UserDAO { + + private static UserDAO instance; + private final EntityManagerFactory emf = Persistence.createEntityManagerFactory("JFXSGPU"); + + private UserDAO() { + } + + public static UserDAO getInstance() { + if (instance == null) { + instance = new UserDAO(); + } + return instance; + } + + private EntityManager getEntityManager() { + return emf.createEntityManager(); + } + + public int insertMail(String email, String phoneNumber, String firstName, String lastName, + String password) { + EntityManager entityManager = getEntityManager(); + Session session = entityManager.unwrap(Session.class); + Transaction transaction = null; + int rowsAffected = 0; + try { + transaction = session.beginTransaction(); + StoredProcedureQuery query = session.createStoredProcedureQuery( + "proc_insert_user_new") + .registerStoredProcedureParameter(1, String.class, ParameterMode.IN) + .registerStoredProcedureParameter(2, String.class, ParameterMode.IN) + .registerStoredProcedureParameter(3, String.class, ParameterMode.IN) + .registerStoredProcedureParameter(4, String.class, ParameterMode.IN) + .registerStoredProcedureParameter(5, String.class, ParameterMode.IN); + + query.setParameter(1, email); + query.setParameter(2, phoneNumber); + query.setParameter(3, firstName); + query.setParameter(4, lastName); + query.setParameter(5, password); + rowsAffected = query.executeUpdate(); + transaction.commit(); + } catch (Exception e) { + if (transaction != null) { + transaction.rollback(); + } + System.out.println(e.getMessage()); + } finally { + session.close(); + } + return rowsAffected; + } +} diff --git a/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDTO.java b/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDTO.java new file mode 100644 index 0000000..6775bb6 --- /dev/null +++ b/src/main/java/com/lcaohoanq/fxsnakegame/modules/user/UserDTO.java @@ -0,0 +1,49 @@ +package com.lcaohoanq.fxsnakegame.modules.user; + +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +public class UserDTO { + + private Integer userId; + private String email; + private String phoneNumber; + private String firstName; + private String lastName; + private String password; + private String confirmPassword; + private Integer score = 0; + private LocalDateTime created = LocalDateTime.now(); + + public UserDTO(String email, String firstName, String lastName, String password, + String confirmPassword) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + this.password = password; + this.confirmPassword = confirmPassword; + } + + public UserDTO(String email, String password) { + this.email = email; + this.password = password; + } + + public UserDTO(String email, Integer score) { + this.email = email; + this.score = score; + } + +} diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UIBorders.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIBorders.java similarity index 97% rename from src/main/java/com/lcaohoanq/formhandling/styles/UIBorders.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UIBorders.java index 0ba7875..c5d538b 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UIBorders.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIBorders.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; import java.awt.Color; import javax.swing.BorderFactory; diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UIColors.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIColors.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/styles/UIColors.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UIColors.java index aaebd13..79f0bef 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UIColors.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIColors.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; import java.awt.Color; diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UIFonts.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIFonts.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/styles/UIFonts.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UIFonts.java index 5d2fb4f..eb063c3 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UIFonts.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIFonts.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; import java.awt.Font; diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UIHovers.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIHovers.java similarity index 97% rename from src/main/java/com/lcaohoanq/formhandling/styles/UIHovers.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UIHovers.java index 7d5398d..c861925 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UIHovers.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIHovers.java @@ -1,11 +1,11 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; import java.awt.Color; import java.awt.Font; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JTextField; -import com.lcaohoanq.formhandling.views.base.AppComponent; +import com.lcaohoanq.fxsnakegame.views.base.AppComponent; public record UIHovers(T frame) { diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UIImages.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIImages.java similarity index 78% rename from src/main/java/com/lcaohoanq/formhandling/styles/UIImages.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UIImages.java index 9d79e87..49035c2 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UIImages.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UIImages.java @@ -1,11 +1,11 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Image; import java.awt.Toolkit; import java.net.URL; import javax.swing.ImageIcon; -import com.lcaohoanq.formhandling.views.base.MyFrame; +import com.lcaohoanq.fxsnakegame.views.base.MyFrame; public class UIImages { public static final URL iconURL = MyFrame.class.getResource(ResourcePaths.URL_KEY_ICON); diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UILabels.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UILabels.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/styles/UILabels.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UILabels.java index 37c44c5..48e168f 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UILabels.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UILabels.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; public class UILabels { public static final String WINDOW = "Snake Game"; diff --git a/src/main/java/com/lcaohoanq/formhandling/styles/UISizes.java b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UISizes.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/styles/UISizes.java rename to src/main/java/com/lcaohoanq/fxsnakegame/styles/UISizes.java index df854ba..dc89bd5 100644 --- a/src/main/java/com/lcaohoanq/formhandling/styles/UISizes.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/styles/UISizes.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.styles; +package com.lcaohoanq.fxsnakegame.styles; import java.awt.Dimension; diff --git a/src/main/java/com/lcaohoanq/formhandling/utils/ApiUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/utils/ApiUtils.java similarity index 58% rename from src/main/java/com/lcaohoanq/formhandling/utils/ApiUtils.java rename to src/main/java/com/lcaohoanq/fxsnakegame/utils/ApiUtils.java index e8fd3a7..8d003cf 100644 --- a/src/main/java/com/lcaohoanq/formhandling/utils/ApiUtils.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/utils/ApiUtils.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.utils; +package com.lcaohoanq.fxsnakegame.utils; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -16,6 +16,15 @@ public class ApiUtils { private static final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule()).enable( SerializationFeature.INDENT_OUTPUT); + public static HttpResponse getRequest(String url) throws IOException, InterruptedException { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .GET() + .build(); + + return httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + } + public static HttpResponse postRequest(String url, Map payload) throws IOException, InterruptedException { String jsonPayload = objectMapper.writeValueAsString(payload); @@ -28,14 +37,29 @@ public static HttpResponse postRequest(String url, Map p return httpClient.send(request, HttpResponse.BodyHandlers.ofString()); } - public static HttpResponse getRequest(String url) throws IOException, InterruptedException { + //{{API_PREFIX}}/scores/users/email?email=ashly.jones@gmail.com&newScore=10 + public static HttpResponse putRequest(String url) throws IOException, InterruptedException { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) - .GET() + .header("Content-Type", "application/json") + .PUT(HttpRequest.BodyPublishers.noBody()) .build(); return httpClient.send(request, HttpResponse.BodyHandlers.ofString()); } + public static HttpResponse putRequest(String url, Map payload) throws IOException, InterruptedException { + String jsonPayload = objectMapper.writeValueAsString(payload); + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .header("Content-Type", "application/json") + .PUT(HttpRequest.BodyPublishers.ofString(jsonPayload)) + .build(); + + return httpClient.send(request, HttpResponse.BodyHandlers.ofString()); + } + + } diff --git a/src/main/java/com/lcaohoanq/formhandling/utils/EnvUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/utils/EnvUtils.java similarity index 89% rename from src/main/java/com/lcaohoanq/formhandling/utils/EnvUtils.java rename to src/main/java/com/lcaohoanq/fxsnakegame/utils/EnvUtils.java index ed9a5cb..111e381 100644 --- a/src/main/java/com/lcaohoanq/formhandling/utils/EnvUtils.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/utils/EnvUtils.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.utils; +package com.lcaohoanq.fxsnakegame.utils; import io.github.cdimascio.dotenv.Dotenv; @@ -10,7 +10,6 @@ public class EnvUtils { dotenv = Dotenv.configure().load(); } catch (Exception e) { System.err.println("Error initializing EnvUtils: " + e.getMessage()); - e.printStackTrace(); } } diff --git a/src/main/java/com/lcaohoanq/formhandling/utils/LogsUtils.java b/src/main/java/com/lcaohoanq/fxsnakegame/utils/LogsUtils.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/utils/LogsUtils.java rename to src/main/java/com/lcaohoanq/fxsnakegame/utils/LogsUtils.java index 646280e..3f64714 100644 --- a/src/main/java/com/lcaohoanq/formhandling/utils/LogsUtils.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/utils/LogsUtils.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.utils; +package com.lcaohoanq.fxsnakegame.utils; import java.io.File; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/lcaohoanq/formhandling/utils/PBKDF2.java b/src/main/java/com/lcaohoanq/fxsnakegame/utils/PBKDF2.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/utils/PBKDF2.java rename to src/main/java/com/lcaohoanq/fxsnakegame/utils/PBKDF2.java index c0dbdae..06e5bad 100644 --- a/src/main/java/com/lcaohoanq/formhandling/utils/PBKDF2.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/utils/PBKDF2.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.utils; +package com.lcaohoanq.fxsnakegame.utils; -import com.lcaohoanq.formhandling.constants.Regex; +import com.lcaohoanq.fxsnakegame.constants.Regex; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.spec.InvalidKeySpecException; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/AlertHandler.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/AlertHandler.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/views/AlertHandler.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/AlertHandler.java index 5fbf430..c63a384 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/AlertHandler.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/AlertHandler.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; import javafx.scene.control.Alert; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/ChangePasswordView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/ChangePasswordView.java similarity index 66% rename from src/main/java/com/lcaohoanq/formhandling/views/ChangePasswordView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/ChangePasswordView.java index 793f0b3..5443f74 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/ChangePasswordView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/ChangePasswordView.java @@ -1,16 +1,22 @@ -package com.lcaohoanq.formhandling.views; - -import com.lcaohoanq.formhandling.models.RegisterModel; -import com.lcaohoanq.formhandling.modules.user.UserDAO; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.utils.PBKDF2; +package com.lcaohoanq.fxsnakegame.views; + +import com.lcaohoanq.fxsnakegame.constants.APIConstants; +import com.lcaohoanq.fxsnakegame.models.RegisterModel; +//import com.lcaohoanq.fxsnakegame.modules.user.UserDAO; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.utils.ApiUtils; +import com.lcaohoanq.fxsnakegame.utils.PBKDF2; import java.awt.Cursor; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.http.HttpResponse; +import java.util.Map; +import java.util.Objects; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JFrame; @@ -98,9 +104,31 @@ public void actionPerformed(ActionEvent e) { if (newPassword.equals(confirmNewPassword)) { if (new RegisterModel().isPasswordFormat(newPassword)) { // update password in database - UserDAO.getInstance().updatePassword(email, new PBKDF2().hash(newPassword.toCharArray())); - UIPrompts.IS_CHANGE_PASSWORD_SUCCESS(); - log.info("Updated password for user: {}", email); +// UserDAO.getInstance().updatePassword(email, new PBKDF2().hash(newPassword.toCharArray())); + + String endPoint = APIConstants.BASE_URL + "/users/updatePassword"; + + Map payload = Map.of( + "identifier", email, + "newPassword", newPassword + ); + + try { + HttpResponse response = ApiUtils.putRequest(endPoint, payload); + switch (response.statusCode()) { + case 200: + UIPrompts.IS_CHANGE_PASSWORD_SUCCESS(); + log.info("Updated password for user: {}", email); + break; + case 400: + UIPrompts.IS_WRONG_FORMAT_PASSWORD(); + break; + default: + break; + } + } catch (IOException | InterruptedException ex) { + throw new RuntimeException(ex); + } } else { UIPrompts.IS_WRONG_FORMAT_PASSWORD(); } @@ -111,17 +139,4 @@ public void actionPerformed(ActionEvent e) { } } - public static void main(String[] args) { -// new ChangePasswordView("hoanglcse181513@fpt.edu.vn").setVisible(true); - - System.out.println(UserDAO.getInstance().selectEmailAndPasswordByEmail("hoangdz1604@gmail.com").getPassword()); - - UserDAO.getInstance().updatePassword("hoangdz1604@gmail.com", "12345"); - - System.out.println(UserDAO.getInstance().selectEmailAndPasswordByEmail("hoangdz1604@gmail.com").getPassword()); - -// System.out.println(new PasswordHandler().authenticate("Luucaohoang0612^^".toCharArray(), UserDAO.getInstance().selectEmailAndPasswordByEmail("hoangdz1604@gmail.com").getPassword())); - - } - } diff --git a/src/main/java/com/lcaohoanq/formhandling/constants/Info.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/Info.java similarity index 70% rename from src/main/java/com/lcaohoanq/formhandling/constants/Info.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/Info.java index 79b907d..6007eef 100644 --- a/src/main/java/com/lcaohoanq/formhandling/constants/Info.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/Info.java @@ -1,6 +1,5 @@ -package com.lcaohoanq.formhandling.constants; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.views.UIPrompts; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/MenuView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/MenuView.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/views/MenuView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/MenuView.java index 21e5dfb..d413814 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/MenuView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/MenuView.java @@ -1,7 +1,7 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.controllers.MenuController; -import com.lcaohoanq.formhandling.controllers.ToggleHandler; +import com.lcaohoanq.fxsnakegame.controllers.MenuController; +import com.lcaohoanq.fxsnakegame.controllers.ToggleHandler; import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.FlowLayout; @@ -10,13 +10,13 @@ import java.util.Objects; import javax.swing.JFrame; import javax.swing.JMenuBar; -import com.lcaohoanq.formhandling.modules.sound.AudioHandler; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIHovers; -import com.lcaohoanq.formhandling.styles.UIImages; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.AppComponent; +import com.lcaohoanq.fxsnakegame.modules.sound.AudioHandler; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIHovers; +import com.lcaohoanq.fxsnakegame.styles.UIImages; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.AppComponent; public class MenuView extends AppComponent implements ToggleHandler { boolean isActive; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/OTPVerificationView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/OTPVerificationView.java similarity index 97% rename from src/main/java/com/lcaohoanq/formhandling/views/OTPVerificationView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/OTPVerificationView.java index 83d0247..08c8dca 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/OTPVerificationView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/OTPVerificationView.java @@ -1,8 +1,8 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.controllers.OTPVerificationListener; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.controllers.OTPVerificationListener; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; import java.awt.Cursor; import java.awt.FlowLayout; import java.awt.GridLayout; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/ScoreView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/ScoreView.java similarity index 86% rename from src/main/java/com/lcaohoanq/formhandling/views/ScoreView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/ScoreView.java index cfd56de..0e76cff 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/ScoreView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/ScoreView.java @@ -1,10 +1,10 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.controllers.ScoreController; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.styles.UISizes; +import com.lcaohoanq.fxsnakegame.controllers.ScoreController; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.styles.UISizes; import java.awt.BorderLayout; import javax.swing.JFrame; import javax.swing.JLabel; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/SwingLoginView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/SwingLoginView.java similarity index 85% rename from src/main/java/com/lcaohoanq/formhandling/views/SwingLoginView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/SwingLoginView.java index fc96653..676a8fb 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/SwingLoginView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/SwingLoginView.java @@ -1,11 +1,10 @@ -package com.lcaohoanq.formhandling.views; - -import com.lcaohoanq.formhandling.controllers.SwingLoginController; -import com.lcaohoanq.formhandling.constants.ResourcePaths; -import com.lcaohoanq.formhandling.controllers.ForgotPasswordController; -import com.lcaohoanq.formhandling.controllers.LoginController; -import com.lcaohoanq.formhandling.controllers.PlayController; -import com.lcaohoanq.formhandling.controllers.ToggleHandler; +package com.lcaohoanq.fxsnakegame.views; + +import com.lcaohoanq.fxsnakegame.controllers.SwingLoginController; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.controllers.ForgotPasswordController; +import com.lcaohoanq.fxsnakegame.controllers.PlayController; +import com.lcaohoanq.fxsnakegame.controllers.ToggleHandler; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.GridLayout; @@ -14,13 +13,13 @@ import javax.swing.JLabel; import javax.swing.JPanel; import lombok.Getter; -import com.lcaohoanq.formhandling.models.LoginModel; -import com.lcaohoanq.formhandling.modules.user.UserEntity; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.styles.UILabels; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.MyFrame; +import com.lcaohoanq.fxsnakegame.models.LoginModel; +import com.lcaohoanq.fxsnakegame.modules.user.UserDTO; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.styles.UILabels; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.MyFrame; @Getter public class SwingLoginView extends MyFrame implements ToggleHandler{ @@ -158,8 +157,8 @@ public void doAction() { } //xu li cac ham o day - public UserEntity getDataWhenLogin() { - return new UserEntity(jTextField_Right_Middle_Email.getText(), String.valueOf(jPasswordField_Right_Middle_Password.getPassword())); + public UserDTO getDataWhenLogin() { + return new UserDTO(jTextField_Right_Middle_Email.getText(), String.valueOf(jPasswordField_Right_Middle_Password.getPassword())); } public boolean isEmpty() { @@ -170,10 +169,6 @@ public boolean isAdmin() { return this.loginModel.isAdmin(this.getDataWhenLogin().getEmail(), this.getDataWhenLogin().getPassword()); } - public boolean isMatching() { - return this.loginModel.isMatching(this.getDataWhenLogin().getEmail(), this.getDataWhenLogin().getPassword()); - } - public void handleSuccess() { UIPrompts.IS_LOGIN_SUCCESS(); // Switch to the play button card diff --git a/src/main/java/com/lcaohoanq/formhandling/views/SwingRegisterView.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/SwingRegisterView.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/views/SwingRegisterView.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/SwingRegisterView.java index 55a8240..cb7dccf 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/SwingRegisterView.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/SwingRegisterView.java @@ -1,7 +1,7 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.controllers.RegisterController; -import com.lcaohoanq.formhandling.controllers.ToggleHandler; +import com.lcaohoanq.fxsnakegame.controllers.RegisterController; +import com.lcaohoanq.fxsnakegame.controllers.ToggleHandler; import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.BoxLayout; @@ -9,13 +9,13 @@ import javax.swing.JLabel; import javax.swing.JPanel; import lombok.Getter; -import com.lcaohoanq.formhandling.models.RegisterModel; -import com.lcaohoanq.formhandling.modules.user.UserEntity; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.styles.UILabels; -import com.lcaohoanq.formhandling.views.base.MyFrame; +import com.lcaohoanq.fxsnakegame.models.RegisterModel; +import com.lcaohoanq.fxsnakegame.modules.user.UserDTO; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.styles.UILabels; +import com.lcaohoanq.fxsnakegame.views.base.MyFrame; @Deprecated @Getter @@ -218,8 +218,8 @@ public boolean isEmpty() { } //xu li cac ham o day - public UserEntity getDataWhenRegister() { - return new UserEntity(jTextField_Right_Middle_Email.getText(), + public UserDTO getDataWhenRegister() { + return new UserDTO(jTextField_Right_Middle_Email.getText(), jTextField_Right_Middle_FirstName.getText(), jTextField_Right_Middle_LastName.getText(), String.valueOf(jPasswordField_Right_Middle_Password.getPassword()), diff --git a/src/main/java/com/lcaohoanq/formhandling/views/Toggle.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/Toggle.java similarity index 97% rename from src/main/java/com/lcaohoanq/formhandling/views/Toggle.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/Toggle.java index dce96d5..b1d1c41 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/Toggle.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/Toggle.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; -import com.lcaohoanq.formhandling.controllers.EventSwitchSelected; +import com.lcaohoanq.fxsnakegame.controllers.EventSwitchSelected; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Component; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/UIPrompts.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/UIPrompts.java similarity index 98% rename from src/main/java/com/lcaohoanq/formhandling/views/UIPrompts.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/UIPrompts.java index 8eb5083..77ffee3 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/UIPrompts.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/UIPrompts.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.views; +package com.lcaohoanq.fxsnakegame.views; import javax.swing.JOptionPane; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/base/AppComponent.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/AppComponent.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/views/base/AppComponent.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/base/AppComponent.java index aba3eff..a78e3ad 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/base/AppComponent.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/AppComponent.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.views.base; +package com.lcaohoanq.fxsnakegame.views.base; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.BorderLayout; import java.awt.Cursor; import java.awt.Dimension; @@ -20,12 +20,12 @@ import javax.swing.JTextField; import javax.swing.SwingConstants; import lombok.Getter; -import com.lcaohoanq.formhandling.modules.sound.AudioHandler; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.styles.UILabels; -import com.lcaohoanq.formhandling.styles.UISizes; +import com.lcaohoanq.fxsnakegame.modules.sound.AudioHandler; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.styles.UILabels; +import com.lcaohoanq.fxsnakegame.styles.UISizes; @Getter public abstract class AppComponent extends JFrame { diff --git a/src/main/java/com/lcaohoanq/formhandling/views/base/BaseResources.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/BaseResources.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/views/base/BaseResources.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/base/BaseResources.java index 0a99f20..1aeeef6 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/base/BaseResources.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/BaseResources.java @@ -1,4 +1,4 @@ -package com.lcaohoanq.formhandling.views.base; +package com.lcaohoanq.fxsnakegame.views.base; import java.net.URL; import java.util.ResourceBundle; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/base/Board.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/Board.java similarity index 91% rename from src/main/java/com/lcaohoanq/formhandling/views/base/Board.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/base/Board.java index ebc03e2..bf9e591 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/base/Board.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/Board.java @@ -1,7 +1,10 @@ -package com.lcaohoanq.formhandling.views.base; +package com.lcaohoanq.fxsnakegame.views.base; -import com.lcaohoanq.formhandling.constants.ResourcePaths; -import com.lcaohoanq.formhandling.controllers.SwingLoginController; +import com.lcaohoanq.fxsnakegame.constants.APIConstants; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.controllers.LoginController; +import com.lcaohoanq.fxsnakegame.controllers.SwingLoginController; +import com.lcaohoanq.fxsnakegame.utils.ApiUtils; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; @@ -13,6 +16,8 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.InputStream; +import java.net.http.HttpClient; +import java.net.http.HttpResponse; import java.util.Objects; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -22,16 +27,18 @@ import javax.swing.JProgressBar; import javax.swing.SwingUtilities; import javax.swing.Timer; -import com.lcaohoanq.formhandling.modules.sound.AudioHandler; -import com.lcaohoanq.formhandling.modules.user.UserDAO; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIFonts; -import com.lcaohoanq.formhandling.styles.UILabels; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.MenuView; -import com.lcaohoanq.formhandling.views.UIPrompts; - +import com.lcaohoanq.fxsnakegame.modules.sound.AudioHandler; +//import com.lcaohoanq.fxsnakegame.modules.user.UserDAO; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIFonts; +import com.lcaohoanq.fxsnakegame.styles.UILabels; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.MenuView; +import com.lcaohoanq.fxsnakegame.views.UIPrompts; +import lombok.extern.slf4j.Slf4j; + +@Slf4j public abstract class Board extends JPanel implements ActionListener { // Board dimensions and settings @@ -293,25 +300,28 @@ public int compareDatabaseAndCurrentScore(int dbScore, int currentScore) { return dbScore - currentScore; } - public int handleScore(String username) { - UserDAO executeQuery = UserDAO.getInstance(); - int currentScore = this.score; - int dbScore = Objects.requireNonNull(executeQuery.selectEmailAndScoreByEmail(username)) - .getScore(); - return compareDatabaseAndCurrentScore(dbScore, currentScore); - } - public void updateScore() { - UserDAO executeQuery = UserDAO.getInstance(); - String username = SwingLoginController.email; + String username = LoginController.email; if (username.isEmpty()) { return; } - // if the current score > db score, update the score in the database - if (handleScore(username) < 0) { - if (executeQuery.setSafeUpdate() == 0) { - executeQuery.updateEmailScore(username, String.valueOf(this.score)); + String endPoint = String.format( + APIConstants.BASE_URL + "/scores/users/email?" + "email=%s&newScore=%d", username, + this.score); + try { + HttpResponse response = ApiUtils.putRequest(endPoint); + switch (response.statusCode()) { + case 200: + log.info("Update score successfully"); + break; + case 400: + log.error("Update score failed"); + break; + default: + break; } + } catch (Exception e) { + System.out.println("Error when update user's score: " + e.getMessage()); } } diff --git a/src/main/java/com/lcaohoanq/formhandling/views/base/MyFrame.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/MyFrame.java similarity index 94% rename from src/main/java/com/lcaohoanq/formhandling/views/base/MyFrame.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/base/MyFrame.java index c07a29a..890fbc8 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/base/MyFrame.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/base/MyFrame.java @@ -1,8 +1,8 @@ -package com.lcaohoanq.formhandling.views.base; +package com.lcaohoanq.fxsnakegame.views.base; -import com.lcaohoanq.formhandling.constants.Info; -import com.lcaohoanq.formhandling.controllers.ScoreController; -import com.lcaohoanq.formhandling.controllers.ToggleHandler; +import com.lcaohoanq.fxsnakegame.views.Info; +import com.lcaohoanq.fxsnakegame.controllers.ScoreController; +import com.lcaohoanq.fxsnakegame.controllers.ToggleHandler; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Desktop; @@ -14,13 +14,13 @@ import java.util.Map; import javax.swing.JComponent; import javax.swing.JFrame; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIColors; -import com.lcaohoanq.formhandling.styles.UIImages; -import com.lcaohoanq.formhandling.styles.UILabels; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.MenuView; -import com.lcaohoanq.formhandling.views.ScoreView; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIColors; +import com.lcaohoanq.fxsnakegame.styles.UIImages; +import com.lcaohoanq.fxsnakegame.styles.UILabels; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.MenuView; +import com.lcaohoanq.fxsnakegame.views.ScoreView; public abstract class MyFrame extends AppComponent implements ToggleHandler{ diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Apartment.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Apartment.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Apartment.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Apartment.java index 579ed20..ccf9bfc 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Apartment.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Apartment.java @@ -1,12 +1,12 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.swing.ImageIcon; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Apartment extends Board { protected int wallThickness = 20; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Box.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Box.java similarity index 93% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Box.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Box.java index 3dc0181..656afdb 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Box.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Box.java @@ -1,12 +1,12 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.swing.ImageIcon; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Box extends Board { protected int wallThickness = 20; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Campaign.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Campaign.java similarity index 68% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Campaign.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Campaign.java index 0b118ae..7b91da2 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Campaign.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Campaign.java @@ -1,6 +1,6 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Campaign extends Board { @Override diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Mill.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Mill.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Mill.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Mill.java index ae3b523..0f530db 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Mill.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Mill.java @@ -1,12 +1,12 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.swing.ImageIcon; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Mill extends Board { protected int wallThickness = 20; diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/NoMaze.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/NoMaze.java similarity index 91% rename from src/main/java/com/lcaohoanq/formhandling/views/game/NoMaze.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/NoMaze.java index 8a691ea..b428ce4 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/NoMaze.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/NoMaze.java @@ -1,9 +1,9 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.io.InputStream; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class NoMaze extends Board { diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Rails.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Rails.java similarity index 95% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Rails.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Rails.java index 8ed5704..cf44c9e 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Rails.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Rails.java @@ -1,12 +1,12 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.swing.ImageIcon; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Rails extends Board { diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Snake.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Snake.java similarity index 88% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Snake.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Snake.java index 570d8fb..ed32447 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Snake.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Snake.java @@ -1,14 +1,14 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.controllers.MenuController; -import com.lcaohoanq.formhandling.controllers.PlayController; +import com.lcaohoanq.fxsnakegame.controllers.MenuController; +import com.lcaohoanq.fxsnakegame.controllers.PlayController; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; -import com.lcaohoanq.formhandling.styles.UIBorders; -import com.lcaohoanq.formhandling.styles.UIImages; +import com.lcaohoanq.fxsnakegame.styles.UIBorders; +import com.lcaohoanq.fxsnakegame.styles.UIImages; public class Snake extends JFrame { private final JMenuBar jMenuBar = new JMenuBar(); diff --git a/src/main/java/com/lcaohoanq/formhandling/views/game/Tunnel.java b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Tunnel.java similarity index 96% rename from src/main/java/com/lcaohoanq/formhandling/views/game/Tunnel.java rename to src/main/java/com/lcaohoanq/fxsnakegame/views/game/Tunnel.java index 61a6db7..601bb47 100644 --- a/src/main/java/com/lcaohoanq/formhandling/views/game/Tunnel.java +++ b/src/main/java/com/lcaohoanq/fxsnakegame/views/game/Tunnel.java @@ -1,13 +1,13 @@ -package com.lcaohoanq.formhandling.views.game; +package com.lcaohoanq.fxsnakegame.views.game; -import com.lcaohoanq.formhandling.constants.ResourcePaths; +import com.lcaohoanq.fxsnakegame.constants.ResourcePaths; import java.awt.Graphics; import java.awt.Image; import java.io.InputStream; import javax.swing.ImageIcon; import javax.swing.JFrame; -import com.lcaohoanq.formhandling.styles.UISizes; -import com.lcaohoanq.formhandling.views.base.Board; +import com.lcaohoanq.fxsnakegame.styles.UISizes; +import com.lcaohoanq.fxsnakegame.views.base.Board; public class Tunnel extends Board { protected int wallThickness = 20; diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 343ce10..ae5104b 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,4 +1,4 @@ -module com.lcaohoanq.formhandling { +module com.lcaohoanq.fxsnakegame { requires javafx.controls; requires javafx.fxml; requires javafx.graphics; @@ -17,12 +17,11 @@ requires javax.mail.api; requires swingx; - opens com.lcaohoanq.formhandling to javafx.fxml; - opens com.lcaohoanq.formhandling.modules.user to org.hibernate.orm.core; - opens com.lcaohoanq.formhandling.views.base to javafx.fxml; - exports com.lcaohoanq.formhandling; - exports com.lcaohoanq.formhandling.views; - opens com.lcaohoanq.formhandling.views to javafx.fxml; - exports com.lcaohoanq.formhandling.controllers; - opens com.lcaohoanq.formhandling.controllers to javafx.fxml; + opens com.lcaohoanq.fxsnakegame to javafx.fxml; + opens com.lcaohoanq.fxsnakegame.views.base to javafx.fxml; + exports com.lcaohoanq.fxsnakegame; + exports com.lcaohoanq.fxsnakegame.views; + opens com.lcaohoanq.fxsnakegame.views to javafx.fxml; + exports com.lcaohoanq.fxsnakegame.controllers; + opens com.lcaohoanq.fxsnakegame.controllers to javafx.fxml; } \ No newline at end of file diff --git a/src/main/resources/com/lcaohoanq/formhandling/META-INF/persistence.xml b/src/main/resources/com/lcaohoanq/formhandling/META-INF/persistence.xml deleted file mode 100644 index f301d0b..0000000 --- a/src/main/resources/com/lcaohoanq/formhandling/META-INF/persistence.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - org.hibernate.jpa.HibernatePersistenceProvider - com.lcaohoanq.formhandling.modules.user.UserEntity - - - - - - - - - - - diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/apple.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/apple.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/apple.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/apple.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/big_apple.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/big_apple.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/big_apple.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/big_apple.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/blue_apple.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/blue_apple.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/blue_apple.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/blue_apple.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/branding.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/branding.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/branding.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/branding.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/dot.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/dot.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/dot.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/dot.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/facebook.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/facebook.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/facebook.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/facebook.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/fpt.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/fpt.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/fpt.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/fpt.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/google.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/google.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/google.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/google.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/head.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/head.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/head.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/head.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/key.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/key.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/key.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/key.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/lcaohoanq.branding.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/lcaohoanq.branding.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/lcaohoanq.branding.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/lcaohoanq.branding.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/snake.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/snake.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/snake.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/snake.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/twitter.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/twitter.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/twitter.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/twitter.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/img/wall.png b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/wall.png similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/img/wall.png rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/img/wall.png diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/bigAppleApp.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/bigAppleApp.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/bigAppleApp.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/bigAppleApp.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/bigAppleDis.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/bigAppleDis.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/bigAppleDis.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/bigAppleDis.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/eating.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/eating.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/eating.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/eating.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/eating2.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/eating2.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/eating2.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/eating2.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/gameover.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/gameover.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/gameover.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/gameover.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/assets/sound/intro.wav b/src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/intro.wav similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/assets/sound/intro.wav rename to src/main/resources/com/lcaohoanq/fxsnakegame/assets/sound/intro.wav diff --git a/src/main/resources/com/lcaohoanq/formhandling/css/style.css b/src/main/resources/com/lcaohoanq/fxsnakegame/css/style.css similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/css/style.css rename to src/main/resources/com/lcaohoanq/fxsnakegame/css/style.css diff --git a/src/main/resources/com/lcaohoanq/formhandling/logback.xml b/src/main/resources/com/lcaohoanq/fxsnakegame/logback.xml similarity index 100% rename from src/main/resources/com/lcaohoanq/formhandling/logback.xml rename to src/main/resources/com/lcaohoanq/fxsnakegame/logback.xml diff --git a/src/main/resources/com/lcaohoanq/formhandling/login.fxml b/src/main/resources/com/lcaohoanq/fxsnakegame/login.fxml similarity index 64% rename from src/main/resources/com/lcaohoanq/formhandling/login.fxml rename to src/main/resources/com/lcaohoanq/fxsnakegame/login.fxml index f801c47..8aa5948 100644 --- a/src/main/resources/com/lcaohoanq/formhandling/login.fxml +++ b/src/main/resources/com/lcaohoanq/fxsnakegame/login.fxml @@ -14,8 +14,7 @@ - - + @@ -35,15 +34,15 @@
- + - + - - + + - + @@ -104,12 +118,12 @@ -