Browse Source

DateAudit class added

JaseG256 6 years ago
parent
commit
9d50f731f1

+ 5
- 5
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/User.java View File

25
     private Long id;
25
     private Long id;
26
 
26
 
27
     @NotBlank
27
     @NotBlank
28
-    private String userName;
28
+    private String username;
29
 
29
 
30
     @NotBlank
30
     @NotBlank
31
     @NaturalId
31
     @NaturalId
58
     }
58
     }
59
 
59
 
60
 
60
 
61
-    public User(String userName, String email, String password) {
62
-        this.userName = userName;
61
+    public User(String username, String email, String password) {
62
+        this.username = username;
63
         this.email = email;
63
         this.email = email;
64
         this.password = password;
64
         this.password = password;
65
     }
65
     }
73
     }
73
     }
74
 
74
 
75
     public String getUserName() {
75
     public String getUserName() {
76
-        return userName;
76
+        return username;
77
     }
77
     }
78
 
78
 
79
     public void setUserName(String userName) {
79
     public void setUserName(String userName) {
80
-        this.userName = userName;
80
+        this.username = userName;
81
     }
81
     }
82
 
82
 
83
     public String getEmail() {
83
     public String getEmail() {

+ 13
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/RoleRepository.java View File

1
+package ZipTeamOrange.Repository;
2
+
3
+import ZipTeamOrange.Model.Role;
4
+import ZipTeamOrange.Model.RoleName;
5
+import org.springframework.data.jpa.repository.JpaRepository;
6
+import org.springframework.stereotype.Repository;
7
+
8
+import java.util.Optional;
9
+
10
+@Repository
11
+public interface RoleRepository extends JpaRepository<Role, Long> {
12
+    Optional<Role> findByName(RoleName roleName);
13
+}

+ 16
- 2
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/UserRepository.java View File

2
 
2
 
3
 import ZipTeamOrange.Model.User;
3
 import ZipTeamOrange.Model.User;
4
 import org.springframework.data.jpa.repository.JpaRepository;
4
 import org.springframework.data.jpa.repository.JpaRepository;
5
+import org.springframework.stereotype.Repository;
5
 
6
 
7
+import java.util.List;
8
+import java.util.Optional;
6
 
9
 
7
-public interface UserRepository extends JpaRepository<User, Long>{
8
 
10
 
9
-}
11
+@Repository
12
+public interface UserRepository extends JpaRepository<User, Long> {
13
+    Optional<User> findByEmail(String email);
14
+
15
+    Optional<User> findByUsernameOrEmail(String username, String email);
16
+
17
+    List<User> findByIdIn(List<Long> userIds);
18
+
19
+    Optional<User> findByUsername(String username);
20
+
21
+    Boolean existsByUsername(String username);
22
+
23
+    Boolean existsByEmail(String email);}

+ 2
- 0
ZipTeamOrange-server/src/main/resources/data.sql View File

1
+--insert into roles(name) values ('Role_Admin');
2
+--insert into roles(name) values ('Role_User');