Начало лаб5

This commit is contained in:
DyCTaTOR 2024-06-03 22:18:58 +04:00
parent 855813a4d5
commit 57875bddcd
20 changed files with 667 additions and 112 deletions

View File

@ -43,6 +43,9 @@ dependencies {
runtimeOnly 'org.webjars.npm:bootstrap-icons:1.11.3'
runtimeOnly 'org.webjars.npm:font-awesome:4.7.0'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Binary file not shown.

View File

@ -29270,3 +29270,247 @@ Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/Study/Interne
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
... 60 more
2024-06-03 21:28:31.369849+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 21:33:19.915269+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 21:33:32.128954+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 21:35:48.326428+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 21:38:04.615892+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 21:57:40.711140+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 22:02:50.958118+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 22:09:38.166530+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"
Data conversion error converting "'user' (ENTRYS_DATA_COPY_3_0: ""ROLE"" TINYINT NOT NULL)"; SQL statement:
INSERT INTO "PUBLIC"."ENTRYS_DATA_COPY_3_0"("DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN") OVERRIDING SYSTEM VALUE SELECT "DEPARTMENT_ID", "ID", "ROLE", "PASSWORD", "LOGIN" FROM "PUBLIC"."ENTRYS_DATA" [22018-224]
2024-06-03 22:11:54.953897+04:00 jdbc[3]: exception
java.sql.SQLClientInfoException: Client info name 'ApplicationName' not supported.
at org.h2.jdbc.JdbcConnection.setClientInfo(JdbcConnection.java:1626)
at org.jkiss.dbeaver.ext.generic.model.GenericDataSource.populateClientAppName(GenericDataSource.java:199)
at org.jkiss.dbeaver.ext.generic.model.GenericDataSource.openConnection(GenericDataSource.java:162)
at org.jkiss.dbeaver.ext.h2.model.H2DataSource.openConnection(H2DataSource.java:74)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.connect(JDBCExecutionContext.java:106)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance.initializeMainContext(JDBCRemoteInstance.java:102)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance.<init>(JDBCRemoteInstance.java:61)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.initializeRemoteInstance(JDBCDataSource.java:119)
at org.jkiss.dbeaver.ext.generic.model.GenericDataSource.<init>(GenericDataSource.java:124)
at org.jkiss.dbeaver.ext.h2.model.H2DataSource.<init>(H2DataSource.java:43)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createDataSourceImpl(H2MetaModel.java:55)
at org.jkiss.dbeaver.ext.generic.GenericDataSourceProvider.openDataSource(GenericDataSourceProvider.java:106)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.openDataSource(DataSourceDescriptor.java:1368)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.connect0(DataSourceDescriptor.java:1245)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.connect(DataSourceDescriptor.java:1035)
at org.jkiss.dbeaver.runtime.jobs.ConnectJob.run(ConnectJob.java:78)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.819070+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:1)
at org.jkiss.dbeaver.model.exec.DBExecUtils.getBestIdentifier(DBExecUtils.java:544)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:886)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.820067+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:1)
at org.jkiss.dbeaver.model.exec.DBExecUtils.getBestIdentifier(DBExecUtils.java:544)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:886)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.821065+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:1)
at org.jkiss.dbeaver.model.exec.DBExecUtils.getBestIdentifier(DBExecUtils.java:544)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:886)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.821065+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:1)
at org.jkiss.dbeaver.model.exec.DBExecUtils.getBestIdentifier(DBExecUtils.java:544)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:886)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.826052+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.ForeignKeysCache.fetchObject(ForeignKeysCache.java:146)
at org.jkiss.dbeaver.ext.generic.model.ForeignKeysCache.fetchObject(ForeignKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:351)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getAssociations(GenericTableBase.java:282)
at org.jkiss.dbeaver.model.virtual.DBVUtils.getAllAssociations(DBVUtils.java:329)
at org.jkiss.dbeaver.model.DBUtils.getAttributeReferrers(DBUtils.java:1062)
at org.jkiss.dbeaver.model.data.DBDAttributeBindingMeta.lateBinding(DBDAttributeBindingMeta.java:267)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:906)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
2024-06-03 22:12:02.827049+04:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Столбец "KEY_SEQ" не найден
Column "KEY_SEQ" not found [42122-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:514)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492)
at org.h2.jdbc.JdbcResultSet.getInt(JdbcResultSet.java:337)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCResultSetImpl.getInt(JDBCResultSetImpl.java:500)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils.safeGetInt(JDBCUtils.java:114)
at org.jkiss.dbeaver.ext.generic.model.GenericUtils.safeGetInt(GenericUtils.java:84)
at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.createConstraintColumnsImpl(GenericMetaModel.java:869)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createConstraintColumnsImpl(H2MetaModel.java:178)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:98)
at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.fetchObjectRow(ConstraintKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:360)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
at org.jkiss.dbeaver.ext.generic.model.ForeignKeysCache.fetchObject(ForeignKeysCache.java:146)
at org.jkiss.dbeaver.ext.generic.model.ForeignKeysCache.fetchObject(ForeignKeysCache.java:1)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:351)
at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:120)
at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getAssociations(GenericTableBase.java:282)
at org.jkiss.dbeaver.model.virtual.DBVUtils.getAllAssociations(DBVUtils.java:329)
at org.jkiss.dbeaver.model.DBUtils.getAttributeReferrers(DBUtils.java:1062)
at org.jkiss.dbeaver.model.data.DBDAttributeBindingMeta.lateBinding(DBDAttributeBindingMeta.java:267)
at org.jkiss.dbeaver.model.exec.DBExecUtils.bindAttributes(DBExecUtils.java:906)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetDataReceiver.fetchEnd(ResultSetDataReceiver.java:166)
at org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable.readData(JDBCTable.java:219)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

View File

@ -9,12 +9,12 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.example.demo.department.model.DepartmentEntity;
import com.example.demo.directions.model.DirectionsEntity;
import com.example.demo.news.model.NewsEntity;
import com.example.demo.entrysData.model.EntrysDataEntity;
import com.example.demo.department.service.DepartmentService;
import com.example.demo.directions.model.DirectionsEntity;
import com.example.demo.directions.service.DirectionsService;
import com.example.demo.entrysData.model.EntrysDataEntity;
import com.example.demo.entrysData.service.EntrysDataService;
import com.example.demo.news.model.NewsEntity;
import com.example.demo.news.service.NewsService;
@SpringBootApplication
@ -47,9 +47,9 @@ public class DemoApplication implements CommandLineRunner {
final var dep3 = departmentService.create(new DepartmentEntity("ИЯ"));
log.info("Create entrysData");
entrysDataService.create(new EntrysDataEntity("login", "password", "user", dep2));
entrysDataService.create(new EntrysDataEntity("login1", "password", "user", dep3));
entrysDataService.create(new EntrysDataEntity("login2", "password", "user", dep1));
entrysDataService.create(new EntrysDataEntity("login", "password", dep2));
entrysDataService.create(new EntrysDataEntity("login1", "password", dep3));
entrysDataService.create(new EntrysDataEntity("login2", "password", dep1));
log.info("Create directions");

View File

@ -0,0 +1,18 @@
package com.example.demo.core.api;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
import jakarta.servlet.http.HttpServletRequest;
@ControllerAdvice
public class GlobalController {
public GlobalController() {
}
@ModelAttribute("servletPath")
String getRequestServletPath(HttpServletRequest request) {
return request.getServletPath();
}
}

View File

@ -11,6 +11,13 @@ public class Constants {
public static final String REDIRECT_VIEW = "redirect:";
public static final String ADMIN_PREFIX = "/admin";
public static final String LOGIN_URL = "/login";
public static final String LOGOUT_URL = "/logout";
public static final String DEFAULT_PASSWORD = "123456";
private Constants() {
}
}

View File

@ -1,13 +1,23 @@
package com.example.demo.core.configuration;
import org.modelmapper.ModelMapper;
import org.modelmapper.PropertyMap;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.example.demo.core.model.BaseEntity;
@Configuration
public class MapperConfiguration {
@Bean
ModelMapper modelMapper() {
return new ModelMapper();
final ModelMapper mapper = new ModelMapper();
mapper.addMappings(new PropertyMap<Object, BaseEntity>() {
@Override
protected void configure() {
skip(destination.getId());
}
});
return mapper;
}
}

View File

@ -1,15 +1,13 @@
package com.example.demo.core.configuration;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE");
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
}
}

View File

@ -0,0 +1,63 @@
package com.example.demo.core.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer.FrameOptionsConfig;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import com.example.demo.core.configuration.Constants;
import com.example.demo.entrysData.api.EntrysDataSignupController;
import com.example.demo.entrysData.model.EntrysDataRole;
@Configuration
@EnableWebSecurity
public class SecurityConfiguration {
@Bean
SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
httpSecurity.headers(headers -> headers.frameOptions(FrameOptionsConfig::sameOrigin));
httpSecurity.csrf(AbstractHttpConfigurer::disable);
httpSecurity.cors(Customizer.withDefaults());
httpSecurity.authorizeHttpRequests(requests -> requests
.requestMatchers("/css/**", "/webjars/**", "/*.svg")
.permitAll());
httpSecurity.authorizeHttpRequests(requests -> requests
.requestMatchers(Constants.ADMIN_PREFIX + "/**").hasRole(EntrysDataRole.ADMIN.name())
.requestMatchers("/h2-console/**").hasRole(EntrysDataRole.ADMIN.name())
.requestMatchers(EntrysDataSignupController.URL).anonymous()
.requestMatchers(Constants.LOGIN_URL).anonymous()
.anyRequest().authenticated());
httpSecurity.formLogin(formLogin -> formLogin
.loginPage(Constants.LOGIN_URL));
httpSecurity.rememberMe(rememberMe -> rememberMe.key("uniqueAndSecret"));
httpSecurity.logout(logout -> logout
.deleteCookies("JSESSIONID"));
return httpSecurity.build();
}
@Bean
DaoAuthenticationProvider authenticationProvider(UserDetailsService userDetailsService) {
final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Bean
PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}

View File

@ -0,0 +1,64 @@
package com.example.demo.core.security;
import java.util.Collection;
import java.util.Set;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.example.demo.entrysData.model.EntrysDataEntity;
public class UserPrincipal implements UserDetails {
private final long id;
private final String username;
private final String password;
private final Set<? extends GrantedAuthority> roles;
private final boolean active;
public UserPrincipal(EntrysDataEntity user) {
this.id = user.getId();
this.username = user.getLogin();
this.password = user.getPassword();
this.roles = Set.of(user.getRole());
this.active = true;
}
public Long getId() {
return id;
}
@Override
public String getUsername() {
return username;
}
@Override
public String getPassword() {
return password;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return roles;
}
@Override
public boolean isEnabled() {
return active;
}
@Override
public boolean isAccountNonExpired() {
return isEnabled();
}
@Override
public boolean isAccountNonLocked() {
return isEnabled();
}
@Override
public boolean isCredentialsNonExpired() {
return isEnabled();
}
}

View File

@ -9,9 +9,6 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -23,8 +20,6 @@ import com.example.demo.entrysData.model.EntrysDataGrouped;
import com.example.demo.entrysData.model.EntrysDataGroupedDepartment;
import com.example.demo.entrysData.service.EntrysDataService;
import jakarta.validation.Valid;
@Controller
@RequestMapping(EntrysDataController.URL)
public class EntrysDataController {
@ -56,18 +51,10 @@ public class EntrysDataController {
return modelMapper.map(entity, EntrysDataGroupedDepartmentDto.class);
}
private EntrysDataEntity toEntity(EntrysDataDto dto) {
final EntrysDataEntity entity = modelMapper.map(dto, EntrysDataEntity.class);
entity.setDepartment(departmentService.get(dto.getDepartmentId()));
return entity;
}
// @GetMapping
// public PageDto<EntrysDataDto> getAll(
// @RequestParam(name = "departmentId", defaultValue = "0") Long departmentId,
// @RequestParam(name = "page", defaultValue = "0") int page,
// @RequestParam(name = "size", defaultValue = Constants.DEFAULT_PAGE_SIZE) int size) {
// return PageDtoMapper.toDto(entrysDataService.getAll(departmentId, page, size), this::toDto);
// private EntrysDataEntity toEntity(EntrysDataDto dto) {
// final EntrysDataEntity entity = modelMapper.map(dto, EntrysDataEntity.class);
// entity.setDepartment(departmentService.get(dto.getDepartmentId()));
// return entity;
// }
@GetMapping
@ -88,28 +75,21 @@ public class EntrysDataController {
return toDto(entrysDataService.get(id));
}
@PostMapping
public EntrysDataDto create(@RequestBody @Valid EntrysDataDto dto) {
return toDto(entrysDataService.create(toEntity(dto)));
}
// @PostMapping
// public EntrysDataDto create(@RequestBody @Valid EntrysDataDto dto) {
// return toDto(entrysDataService.create(toEntity(dto)));
// }
@PutMapping("/{id}")
public EntrysDataDto update(@PathVariable(name = "id") Long id, @RequestBody EntrysDataDto dto) {
return toDto(entrysDataService.update(id, toEntity(dto)));
}
// @PutMapping("/{id}")
// public EntrysDataDto update(@PathVariable(name = "id") Long id, @RequestBody EntrysDataDto dto) {
// return toDto(entrysDataService.update(id, toEntity(dto)));
// }
@DeleteMapping("/{id}")
public EntrysDataDto delete(@PathVariable(name = "id") Long id) {
return toDto(entrysDataService.delete(id));
}
@PutMapping("/{id}/password")
public EntrysDataDto updatePassword(@PathVariable(name = "id") Long id,
@RequestParam(name = "newPassword") String newPas,
@RequestParam(name = "oldPassword") String oldPas) {
return toDto(entrysDataService.updatePassword(id, newPas, oldPas));
}
@GetMapping("/count")
public List<EntrysDataGroupedDto> getCount() {
return entrysDataService.getCount().stream().map(this::toDto).toList();

View File

@ -1,24 +1,15 @@
package com.example.demo.entrysData.api;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
public class EntrysDataDto {
private Long id;
@NotBlank
@Size(min = 3, max = 20)
private String login;
@NotNull
private String role = "user";
@NotBlank
private String password;
@NotNull
@Min(1)
private Long departmentId;
private String role;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Long getId() {
return id;
}
@ -35,25 +26,7 @@ public class EntrysDataDto {
this.login = login;
}
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public String getRole() {
return role;
}
public String getPassword() {
return password;
}
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
public void setPassword(String password) {
this.password = password;
}
public Long getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Long departmentId) {
this.departmentId = departmentId;
}
}

View File

@ -0,0 +1,65 @@
package com.example.demo.entrysData.api;
import java.util.Objects;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.demo.core.configuration.Constants;
import com.example.demo.entrysData.model.EntrysDataEntity;
import com.example.demo.entrysData.service.EntrysDataService;
import jakarta.validation.Valid;
@Controller
@RequestMapping(EntrysDataSignupController.URL)
public class EntrysDataSignupController {
public static final String URL = "/signup";
private static final String SIGNUP_VIEW = "signup";
private static final String USER_ATTRIBUTE = "user";
private final EntrysDataService userService;
private final ModelMapper modelMapper;
public EntrysDataSignupController(
EntrysDataService userService,
ModelMapper modelMapper) {
this.userService = userService;
this.modelMapper = modelMapper;
}
private EntrysDataEntity toEntity(EntrysDataSignupDto dto) {
return modelMapper.map(dto, EntrysDataEntity.class);
}
@GetMapping
public String getSignup(Model model) {
model.addAttribute(USER_ATTRIBUTE, new EntrysDataSignupDto());
return SIGNUP_VIEW;
}
@PostMapping
public String signup(
@ModelAttribute(name = USER_ATTRIBUTE) @Valid EntrysDataSignupDto user,
BindingResult bindingResult,
Model model) {
if (bindingResult.hasErrors()) {
return SIGNUP_VIEW;
}
if (!Objects.equals(user.getPassword(), user.getPasswordConfirm())) {
bindingResult.rejectValue("password", "signup:passwords", "Пароли не совпадают.");
model.addAttribute(USER_ATTRIBUTE, user);
return SIGNUP_VIEW;
}
userService.create(toEntity(user));
return Constants.REDIRECT_VIEW + Constants.LOGIN_URL + "?signup";
}
}

View File

@ -0,0 +1,40 @@
package com.example.demo.entrysData.api;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public class EntrysDataSignupDto {
@NotBlank
@Size(min = 3, max = 20)
private String login;
@NotBlank
@Size(min = 3, max = 20)
private String password;
@NotBlank
@Size(min = 3, max = 20)
private String passwordConfirm;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPasswordConfirm() {
return passwordConfirm;
}
public void setPasswordConfirm(String passwordConfirm) {
this.passwordConfirm = passwordConfirm;
}
}

View File

@ -16,10 +16,9 @@ import jakarta.persistence.Table;
public class EntrysDataEntity extends BaseEntity {
@Column(nullable = false, unique = true, length = 30)
private String login;
@Column(nullable = false, unique = false, length = 25)
@Column(nullable = false, length = 25)
private String password;
@Column(nullable = false, unique = false, length = 10)
private String role;
private EntrysDataRole role;
@ManyToOne
@JoinColumn(name = "departmentId", nullable = false)
private DepartmentEntity department;
@ -27,10 +26,10 @@ public class EntrysDataEntity extends BaseEntity {
public EntrysDataEntity() {
}
public EntrysDataEntity(String login, String password, String role, DepartmentEntity department) {
public EntrysDataEntity(String login, String password, DepartmentEntity department) {
this.login = login;
this.password = password;
this.role = role;
this.role = EntrysDataRole.USER;
this.department = department;
}
@ -50,10 +49,11 @@ public class EntrysDataEntity extends BaseEntity {
this.password = password;
}
public String getRole() {
public EntrysDataRole getRole() {
return role;
}
public void setRole(String role){
public void setRole(EntrysDataRole role){
this.role = role;
}
@ -67,7 +67,7 @@ public class EntrysDataEntity extends BaseEntity {
@Override
public int hashCode() {
return Objects.hash(id, login);
return Objects.hash(id, login, password, role, department);
}
@Override

View File

@ -0,0 +1,15 @@
package com.example.demo.entrysData.model;
import org.springframework.security.core.GrantedAuthority;
public enum EntrysDataRole implements GrantedAuthority {
ADMIN,
USER;
private static final String PREFIX = "ROLE_";
@Override
public String getAuthority() {
return PREFIX + this.name();
}
}

View File

@ -1,32 +1,40 @@
package com.example.demo.entrysData.service;
import java.util.List;
import java.util.Optional;
import java.util.stream.StreamSupport;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.example.demo.core.configuration.Constants;
import com.example.demo.core.error.NotFoundException;
import com.example.demo.entrysData.model.EntrysDataEntity;
import com.example.demo.entrysData.model.EntrysDataGrouped;
import com.example.demo.entrysData.model.EntrysDataGroupedDepartment;
import com.example.demo.entrysData.model.EntrysDataRole;
import com.example.demo.entrysData.repository.EntrysDataRepository;
@Service
public class EntrysDataService {
private final EntrysDataRepository repository;
private final PasswordEncoder passwordEncoder;
public EntrysDataService(EntrysDataRepository repository) {
public EntrysDataService(EntrysDataRepository repository, PasswordEncoder passwordEncoder) {
this.repository = repository;
this.passwordEncoder = passwordEncoder;
}
private void checklogin(String name) {
if (repository.findByloginIgnoreCase(name).isPresent()) {
private void checklogin(Long id, String login) {
final Optional<EntrysDataEntity> existsUser = repository.findByloginIgnoreCase(login);
if (existsUser.isPresent() && !existsUser.get().getId().equals(id)) {
throw new IllegalArgumentException(
String.format("Type with name %s is already exists", name));
String.format("User with login %s is already exists", login));
}
}
@ -60,17 +68,22 @@ public class EntrysDataService {
if (entity == null) {
throw new IllegalArgumentException("Entity is null");
}
checklogin(entity.getLogin());
checklogin(null, entity.getLogin());
final String password = Optional.ofNullable(entity.getPassword()).orElse("");
entity.setPassword(
passwordEncoder.encode(
StringUtils.hasText(password.strip()) ? password : Constants.DEFAULT_PASSWORD));
entity.setRole(Optional.ofNullable(entity.getRole()).orElse(EntrysDataRole.USER));
repository.save(entity);
return repository.save(entity);
}
@Transactional
public EntrysDataEntity update(Long id, EntrysDataEntity entity) {
final EntrysDataEntity existsEntity = get(id);
checklogin(entity.getLogin());
checklogin(id, entity.getLogin());
existsEntity.setLogin(entity.getLogin());
existsEntity.setPassword(entity.getPassword());
existsEntity.setDepartment(entity.getDepartment());
repository.save(existsEntity);
return repository.save(existsEntity);
}
@ -81,26 +94,6 @@ public class EntrysDataService {
return existsEntity;
}
@Transactional
public Boolean AuthPassword(Long id, String pas) {
final EntrysDataEntity existsEntity = get(id);
String truePas = existsEntity.getPassword();
if (truePas.equals(pas)) {
return true;
}
return false;
}
@Transactional
public EntrysDataEntity updatePassword(Long id, String newPas, String oldPas) {
final EntrysDataEntity existsEntity = get(id);
String truePas = existsEntity.getPassword();
if (truePas.equals(oldPas) && !oldPas.equals(newPas)) {
existsEntity.setPassword(newPas);
}
return repository.save(existsEntity);
}
@Transactional
public List<EntrysDataGrouped> getCount() {
return repository.getCountEntrysInDepartment();

View File

@ -68,7 +68,7 @@ public class NewsEntity extends BaseEntity {
@Override
public int hashCode() {
return Objects.hash(id, name);
return Objects.hash(id, name, description, date, department);
}
@Override
@ -81,6 +81,7 @@ public class NewsEntity extends BaseEntity {
return Objects.equals(other.getId(), id)
&& Objects.equals(other.getDate(), date)
&& Objects.equals(other.getName(), name)
&& Objects.equals(other.getDescription(), description);
&& Objects.equals(other.getDescription(), description)
&& Objects.equals(other.getDepartment(), department);
}
}

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">
<head>
<title>Вход</title>
</head>
<body>
<main layout:fragment="content">
<form action="#" th:action="@{/login}" method="post">
<div th:if="${param.error}" class="alert alert-danger">
Неверный логин или пароль
</div>
<div th:if="${param.logout}" class="alert alert-success">
Выход успешно произведен
</div>
<div th:if="${param.signup}" class="alert alert-success">
Пользователь успешно создан
</div>
<div class="mb-3">
<label for="username" class="form-label">Имя пользователя</label>
<input type="text" id="username" name="username" class="form-control" required minlength="3"
maxlength="20">
</div>
<div class="mb-3">
<label for="password" class="form-label">Пароль</label>
<input type="password" id="password" name="password" class="form-control" required minlength="3"
maxlength="20">
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="remember-me" name="remember-me" checked>
<label class="form-check-label" for="remember-me">Запомнить меня</label>
</div>
<div class="mb-3 d-flex flex-row">
<button class="btn btn-primary me-2 button-fixed-width" type="submit">Войти</button>
<a class="btn btn-secondary button-fixed-width" href="/signup">Регистрация</a>
</div>
</form>
</main>
</body>
</html>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{default}">
<head>
<title>Вход</title>
</head>
<body>
<main layout:fragment="content">
<form action="#" th:action="@{/signup}" th:object="${user}" method="post">
<div class="mb-3">
<label for="login" class="form-label">Имя пользователя</label>
<input type="text" th:field="*{login}" id="login" class="form-control">
<div th:if="${#fields.hasErrors('login')}" th:errors="*{login}" class="invalid-feedback"></div>
</div>
<div class="mb-3">
<label for="password" class="form-label">Пароль</label>
<input type="password" th:field="*{password}" id="password" class="form-control">
<div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="invalid-feedback"></div>
</div>
<div class="mb-3">
<label for="passwordConfirm" class="form-label">Пароль (подтверждение)</label>
<input type="password" th:field="*{passwordConfirm}" id="passwordConfirm" class="form-control">
<div th:if="${#fields.hasErrors('passwordConfirm')}" th:errors="*{passwordConfirm}"
class="invalid-feedback"></div>
</div>
<div class="mb-3 d-flex flex-row">
<button class="btn btn-primary me-2 button-fixed-width" type="submit">Регистрация</button>
<a class="btn btn-secondary button-fixed-width" href="/">Отмена</a>
</div>
</form>
</main>
</body>
</html>
</html>