именены классы юзеров
This commit is contained in:
parent
e83cce2315
commit
e865488ab5
@ -4,15 +4,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
public class UserDTO {
|
public class UserDTO {
|
||||||
|
|
||||||
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
|
@Size(min = 2, max = 50)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
|
@Size(min = 2, max = 10)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -4,10 +4,21 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import com.example.backend.core.model.BaseEntity;
|
import com.example.backend.core.model.BaseEntity;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "users")
|
||||||
public class UserEntity extends BaseEntity {
|
public class UserEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column(nullable = false, unique = true, length = 15)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
@Column(nullable = false, unique = true, length = 5)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
private boolean isAdmin;
|
private boolean isAdmin;
|
||||||
|
|
||||||
public UserEntity() {
|
public UserEntity() {
|
||||||
@ -15,7 +26,6 @@ public class UserEntity extends BaseEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity(Integer id, String username, String password, boolean isAdmin) {
|
public UserEntity(Integer id, String username, String password, boolean isAdmin) {
|
||||||
super(id);
|
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.isAdmin = isAdmin;
|
this.isAdmin = isAdmin;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.example.backend.users.repository;
|
package com.example.backend.users.repository;
|
||||||
|
|
||||||
import org.springframework.stereotype.Repository;
|
import java.util.Optional;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
import com.example.backend.core.repository.MapRepository;
|
|
||||||
import com.example.backend.users.model.UserEntity;
|
import com.example.backend.users.model.UserEntity;
|
||||||
|
|
||||||
@Repository
|
public interface UserRepository extends CrudRepository<UserEntity, Integer> {
|
||||||
public class UserRepository extends MapRepository<UserEntity> {
|
Optional<UserEntity> findByUsernameIgnoreCase(String username);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user