Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
student-personal-details-spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
student-details-microservice
student-personal-details-spring-boot
Commits
678277ca
Commit
678277ca
authored
Apr 05, 2021
by
Darrick Yong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add edit/delete by email
parent
7556ff7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
DetailsController.java
...va/com/student/details/controllers/DetailsController.java
+16
-1
No files found.
src/main/java/com/student/details/controllers/DetailsController.java
View file @
678277ca
...
...
@@ -50,11 +50,26 @@ public class DetailsController {
return
studentService
.
updateStudent
(
studentId
,
student
);
}
@PutMapping
(
"/students/email/{email:.+}"
)
public
Student
updateStudentByEmail
(
@PathVariable
(
value
=
"email"
)
String
email
,
@RequestBody
Student
student
)
throws
ResourceNotFoundException
{
Student
studentToUpdate
=
studentService
.
getStudentByEmail
(
email
)
.
orElseThrow
(()
->
new
ResourceNotFoundException
(
"Student with email"
+
email
+
"not found."
));
return
studentService
.
updateStudent
(
studentToUpdate
.
getId
(),
student
);
}
@DeleteMapping
(
"/students/{id}"
)
public
Map
<
String
,
Boolean
>
delete
Employee
(
@PathVariable
(
value
=
"id"
)
Long
studentId
)
throws
ResourceNotFoundException
{
public
Map
<
String
,
Boolean
>
delete
Student
(
@PathVariable
(
value
=
"id"
)
Long
studentId
)
throws
ResourceNotFoundException
{
Student
student
=
studentService
.
getStudentById
(
studentId
)
.
orElseThrow
(()
->
new
ResourceNotFoundException
(
"Student by Id Not Found"
+
studentId
));
return
studentService
.
deleteStudent
(
studentId
);
}
@DeleteMapping
(
"/students/email/{email:.+}"
)
public
Map
<
String
,
Boolean
>
deleteStudentByEmail
(
@PathVariable
(
value
=
"email"
)
String
email
)
throws
ResourceNotFoundException
{
Student
student
=
studentService
.
getStudentByEmail
(
email
)
.
orElseThrow
(()
->
new
ResourceNotFoundException
(
"Student with email"
+
email
+
"not found."
));
return
studentService
.
deleteStudent
(
student
.
getId
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment