Update role

This commit is contained in:
Velixeor 2024-10-19 22:13:50 +03:00 committed by Maksim Skobaro
parent 9191e6bf16
commit d4f61438eb
8 changed files with 18 additions and 19 deletions

View File

@ -35,8 +35,8 @@ public record UserDTO(
.fullName(user.getFullName()) .fullName(user.getFullName())
.email(user.getMail()) .email(user.getMail())
.phoneNumber(user.getNumberPhone()) .phoneNumber(user.getNumberPhone())
.createdAt(user.getCreateAt()) .createdAt(user.getCreatedAt())
.updatedAt(user.getUpdateAt()) .updatedAt(user.getUpdatedAt())
.authorities(user.getRoles().stream().map(Role::getAuthority).toList()) .authorities(user.getRoles().stream().map(Role::getAuthority).toList())
.build(); .build();
} }

View File

@ -9,6 +9,7 @@ import lombok.Setter;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@ -22,9 +23,6 @@ public class Role implements GrantedAuthority {
private Integer id; private Integer id;
@Column(name = "name", nullable = false) @Column(name = "name", nullable = false)
private String name; private String name;
@Column(name = "authority", nullable = false)
@Override private String authority;
public String getAuthority() {
return name;
}
} }

View File

@ -36,10 +36,10 @@ public class User implements UserDetails {
private String mail; private String mail;
@Column(name = "number_phone", nullable = false, unique = true) @Column(name = "number_phone", nullable = false, unique = true)
private String numberPhone; private String numberPhone;
@Column(name = "create_at", nullable = false) @Column(name = "created_at", nullable = false)
private ZonedDateTime createAt; private ZonedDateTime createdAt;
@Column(name = "update_at") @Column(name = "updated_at")
private ZonedDateTime updateAt; private ZonedDateTime updatedAt;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "user_role",schema = "vkr", @JoinTable(name = "user_role",schema = "vkr",
joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"),

View File

@ -8,10 +8,10 @@ spring:
out-of-order: true out-of-order: true
web: web:
resources: resources:
static-locations: file://${user.dir}/web/dist/ static-locations: file:///${user.dir}/web/dist/
chain: chain:
cache: false cache: false
compressed: false compressed: false
server: server:
compression: compression:
enabled: false enabled: false

View File

@ -1,5 +1,6 @@
create table vkr.role create table vkr.role
( (
id integer primary key generated by default as identity, id integer primary key generated by default as identity,
name text not null unique name text not null unique,
authority text not null unique
) )

View File

@ -6,7 +6,7 @@ create table vkr.user
full_name text not null, full_name text not null,
mail text not null unique, mail text not null unique,
number_phone text not null unique, number_phone text not null unique,
create_at timestamp(6) with time zone not null, created_at timestamp(6) with time zone not null,
update_at timestamp(6) with time zone updated_at timestamp(6) with time zone
) )

View File

@ -1,4 +1,4 @@
INSERT INTO vkr.user (login, password, full_name, mail, number_phone, create_at, update_at) INSERT INTO vkr.user (login, password, full_name, mail, number_phone, created_at, updated_at)
VALUES ('akulenko_mikhail', 'password123', 'Акуленко Михаил Вячеславович', 'akulenko.mikhail@example.com', VALUES ('akulenko_mikhail', 'password123', 'Акуленко Михаил Вячеславович', 'akulenko.mikhail@example.com',
'+79110000001', NOW(), NOW()), '+79110000001', NOW(), NOW()),
('borovikov_artem', 'password123', 'Боровиков Артём Викторович', 'borovikov.artem@example.com', '+79110000002', ('borovikov_artem', 'password123', 'Боровиков Артём Викторович', 'borovikov.artem@example.com', '+79110000002',

View File

@ -1,2 +1,2 @@
INSERT INTO vkr.role (name) INSERT INTO vkr.role (name,authority)
VALUES('Руководитель'),('Куратор'),('Студент'); VALUES('Руководитель','ROLE_DIRECTOR'),('Куратор','ROLE_TUTOR'),('Студент','ROLE_STUDENT');