Browse Source

teacher fully integrated

rjsmall90 6 years ago
parent
commit
104c3a593c

+ 2
- 2
src/main/java/com/passionproject/project_spitball20/controller/TeacherController.java View File

15
 
15
 
16
 @CrossOrigin
16
 @CrossOrigin
17
 @RestController
17
 @RestController
18
-@RequestMapping("profile")
18
+@RequestMapping("teacher_profile")
19
 public class TeacherController {
19
 public class TeacherController {
20
 
20
 
21
     @Autowired
21
     @Autowired
28
     public ResponseEntity<Teacher> registerUser(@RequestBody Teacher newTeacher) {
28
     public ResponseEntity<Teacher> registerUser(@RequestBody Teacher newTeacher) {
29
         Teacher teacher = new Teacher();
29
         Teacher teacher = new Teacher();
30
         HttpStatus status = HttpStatus.CONFLICT;
30
         HttpStatus status = HttpStatus.CONFLICT;
31
-        if(teacherService.findEmail(newTeacher.getEmail()).equals(null) && teacherService.findName(newTeacher.getFullName()).equals(null)) {
31
+        if(teacherService.findEmail(newTeacher.getEmail()).equals(null)){ //&& teacherService.findName(newTeacher.getFullName()).equals(null)) {
32
             teacher = teacherService.save(newTeacher);
32
             teacher = teacherService.save(newTeacher);
33
             status  = HttpStatus.CREATED;
33
             status  = HttpStatus.CREATED;
34
         }
34
         }

+ 2
- 2
src/main/java/com/passionproject/project_spitball20/controller/UserController.java View File

12
 
12
 
13
 @CrossOrigin
13
 @CrossOrigin
14
 @RestController
14
 @RestController
15
-@RequestMapping("profile")
15
+@RequestMapping("user_profile")
16
 public class UserController {
16
 public class UserController {
17
 
17
 
18
     @Autowired
18
     @Autowired
25
     public ResponseEntity<User> registerUser(@RequestBody User newUser) {
25
     public ResponseEntity<User> registerUser(@RequestBody User newUser) {
26
         User user = new User();
26
         User user = new User();
27
         HttpStatus status = HttpStatus.CONFLICT;
27
         HttpStatus status = HttpStatus.CONFLICT;
28
-        if(userService.findEmail(newUser.getEmail()).equals(null) && userService.findName(newUser.getDisplayName()).equals(null)) {
28
+        if(userService.findEmail(newUser.getEmail()).equals(null)) { //&& userService.findName(newUser.getDisplayName()).equals(null)) {
29
             user = userService.save(newUser);
29
             user = userService.save(newUser);
30
             status  = HttpStatus.CREATED;
30
             status  = HttpStatus.CREATED;
31
         }
31
         }

+ 4
- 0
src/main/java/com/passionproject/project_spitball20/model/Teacher.java View File

54
     public void setPassword(String password) {
54
     public void setPassword(String password) {
55
         this.password = password;
55
         this.password = password;
56
     }
56
     }
57
+
58
+    public String getFullName() {
59
+        return firstName + lastName;
60
+    }
57
 }
61
 }

+ 2
- 2
src/main/java/com/passionproject/project_spitball20/repositories/TeacherRepository.java View File

7
 @Repository
7
 @Repository
8
 public interface TeacherRepository extends JpaRepository<Teacher, Long> {
8
 public interface TeacherRepository extends JpaRepository<Teacher, Long> {
9
 
9
 
10
-     Teacher findByEmail(String email);
10
+    Teacher findByEmail(String email);
11
 
11
 
12
-    Teacher findByName(String fullName);
12
+    //Teacher findByName(String fullName);
13
 }
13
 }

+ 1
- 1
src/main/java/com/passionproject/project_spitball20/repositories/UserRepository.java View File

9
 
9
 
10
    User findByEmail(String email);
10
    User findByEmail(String email);
11
 
11
 
12
-   User findByName(String fullName);
12
+   //User findByName(String fullName);
13
 
13
 
14
 }
14
 }

+ 3
- 3
src/main/java/com/passionproject/project_spitball20/service/TeacherService.java View File

23
         return teacherRepository.findById(id).get();
23
         return teacherRepository.findById(id).get();
24
     }
24
     }
25
 
25
 
26
-    public Teacher findName(String fullName) {
27
-        return teacherRepository.findByName(fullName);
28
-    }
26
+//    public Teacher findName(String fullName) {
27
+//        return teacherRepository.findByName(fullName);
28
+//    }
29
 
29
 
30
     public Teacher findEmail(String email) {
30
     public Teacher findEmail(String email) {
31
         return teacherRepository.findByEmail(email);
31
         return teacherRepository.findByEmail(email);

+ 3
- 3
src/main/java/com/passionproject/project_spitball20/service/UserService.java View File

24
         return userRepository.findByEmail(email);
24
         return userRepository.findByEmail(email);
25
     }
25
     }
26
 
26
 
27
-    public User findName(String displayName) {
28
-        return userRepository.findByName(displayName);
29
-    }
27
+//    public User findName(String displayName) {
28
+//        return userRepository.findByName(displayName);
29
+//    }
30
 
30
 
31
     public User find(Long id) {
31
     public User find(Long id) {
32
         return userRepository.findById(id).get();
32
         return userRepository.findById(id).get();