瀏覽代碼

DateAudit class added

JaseG256 6 年之前
父節點
當前提交
9d50f731f1

+ 5
- 5
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Model/User.java 查看文件

@@ -25,7 +25,7 @@ public class User extends DateAudit{
25 25
     private Long id;
26 26
 
27 27
     @NotBlank
28
-    private String userName;
28
+    private String username;
29 29
 
30 30
     @NotBlank
31 31
     @NaturalId
@@ -58,8 +58,8 @@ public class User extends DateAudit{
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 63
         this.email = email;
64 64
         this.password = password;
65 65
     }
@@ -73,11 +73,11 @@ public class User extends DateAudit{
73 73
     }
74 74
 
75 75
     public String getUserName() {
76
-        return userName;
76
+        return username;
77 77
     }
78 78
 
79 79
     public void setUserName(String userName) {
80
-        this.userName = userName;
80
+        this.username = userName;
81 81
     }
82 82
 
83 83
     public String getEmail() {

+ 13
- 0
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Repository/RoleRepository.java 查看文件

@@ -0,0 +1,13 @@
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 查看文件

@@ -2,8 +2,22 @@ package ZipTeamOrange.Repository;
2 2
 
3 3
 import ZipTeamOrange.Model.User;
4 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 查看文件

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