- Добавил миграции Flyway.

- Добавил профиль пользователя и возможность его редактирования.
https://www.youtube.com/watch?v=ArM7nCys4hY&list=PLU2ftbIeotGpAYRP9Iv2KLIwK36-o_qYk&index=12
This commit is contained in:
Leonid
2025-02-16 14:46:28 +03:00
parent 2736f3ddf6
commit 9a41c4caae
10 changed files with 179 additions and 25 deletions

View File

@@ -1,4 +1,5 @@
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/sweater_db
spring.datasource.username=user
spring.datasource.password=123456

View File

@@ -0,0 +1,48 @@
create table message
(
id bigint not null,
user_id bigint,
filename varchar(255),
tag varchar(255),
text varchar(2048) not null,
primary key (id)
) engine = InnoDB;
create table message_seq
(
next_val bigint
) engine = InnoDB;
insert into message_seq
values (1);
create table user_role
(
user_id bigint not null,
roles enum ('ADMIN','USER')
) engine = InnoDB;
create table usr
(
enabled bit not null,
id bigint not null,
activation_code varchar(255),
email varchar(255),
password varchar(255) not null,
username varchar(255) not null,
primary key (id)
) engine = InnoDB;
create table usr_seq
(
next_val bigint
) engine = InnoDB;
insert into usr_seq
values (1);
alter table message
add constraint message_user_fk foreign key (user_id) references usr (id);
alter table user_role
add constraint user_role_user_fk foreign key (user_id) references usr (id);

View File

@@ -0,0 +1,5 @@
insert into usr (id, username, password, enabled)
values (1, 'admin', '{noop}admin', true);
insert into user_role (user_id, roles)
values (1, 'USER'), (1, 'ADMIN');

View File

@@ -22,6 +22,11 @@
<a class="nav-link" aria-current="page" href="/users">Users</a>
</li>
</#if>
<#if user??>
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/users/profile">Profile</a>
</li>
</#if>
</ul>
</div>
<div class="navbar-text mr-3" >${name}</div>

View File

@@ -0,0 +1,24 @@
<#import "parts/common.ftl" as com>
<@com.page>
<h5>${username}</h5>
<#if message??>
<div class="mb-3"> ${message} </div>
</#if>
<form method="post" xmlns="http://www.w3.org/1999/html">
<div class="row mb-3">
<label for="inputPassword3" class="col-sm-2 col-form-label"> Password: </label>
<div class="col-sm-6">
<input type="password" class="form-control" name="password" value="${password}">
</div>
</div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label"> E-mail:</label>
<div class="col-sm-6">
<input type="email" class="form-control" name="email" value="${email!''}"/>
</div>
</div>
<input class="btn btn-primary" type="submit" value="Save"/>
<input type="hidden" name="_csrf" value="${_csrf.token}"/>
</form>
</@com.page>