From bdcff2461c76b6f7c0aa5106cd70258f58ff1ccd Mon Sep 17 00:00:00 2001 From: filippo-ferrari Date: Fri, 6 Sep 2024 19:14:26 +0200 Subject: [PATCH] feat: created user entity --- .../com/application/munera/data/User.java | 41 +++++++++++++++++++ .../munera/repositories/UserRepository.java | 11 +++++ 2 files changed, 52 insertions(+) create mode 100644 src/main/java/com/application/munera/data/User.java create mode 100644 src/main/java/com/application/munera/repositories/UserRepository.java diff --git a/src/main/java/com/application/munera/data/User.java b/src/main/java/com/application/munera/data/User.java new file mode 100644 index 0000000..71eb624 --- /dev/null +++ b/src/main/java/com/application/munera/data/User.java @@ -0,0 +1,41 @@ +package com.application.munera.data; + +import jakarta.persistence.*; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Entity +@Data +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "Id", unique = true, nullable = false) + private Long id; + + @Size(max = 100) + @Column(name = "FirstName", nullable = false) + private String firstName; + + @Size(max = 100) + @Column(name = "LastName", nullable = false) + private String lastName; + + @Size(max = 100) + @Column(name = "username", nullable = false) + private String username; + + @Size(max = 100) + @Column(name = "password", nullable = false) + private String password; + + @Column(name = "roles", nullable = false) + private String roles; + + @Email + @Size(max = 100) + @Column(name = "email") + private String email; +} diff --git a/src/main/java/com/application/munera/repositories/UserRepository.java b/src/main/java/com/application/munera/repositories/UserRepository.java new file mode 100644 index 0000000..3c0daac --- /dev/null +++ b/src/main/java/com/application/munera/repositories/UserRepository.java @@ -0,0 +1,11 @@ +package com.application.munera.repositories; + +import com.application.munera.data.User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends JpaRepository { + + User findByUsername(final String username); +}