Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
awa-w5d5-microservices
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
StudentAddressDetails
awa-w5d5-microservices
Commits
4c2305c0
Commit
4c2305c0
authored
Apr 02, 2021
by
dbhuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds create, update methods to service
parent
0c8dcb6b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
StudentAddressService.java
.../studentaddressservice/service/StudentAddressService.java
+19
-0
No files found.
student-address-service/src/main/java/service/student/studentaddressservice/service/StudentAddressService.java
View file @
4c2305c0
package
service
.
student
.
studentaddressservice
.
service
;
import
org.apache.catalina.valves.StuckThreadDetectionValve
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Example
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Service
;
import
service.student.studentaddressservice.StudentAddressServiceApplication
;
import
service.student.studentaddressservice.model.StudentAddress
;
import
service.student.studentaddressservice.repository.StudentAddressRepository
;
...
...
@@ -22,4 +24,21 @@ public class StudentAddressService {
public
Optional
<
StudentAddress
>
getStudentAddressByEmail
(
String
email
){
return
Optional
.
ofNullable
(
studentAddressRepository
.
findByEmail
(
email
));
}
public
StudentAddress
createStudentAddress
(
StudentAddress
studentAddressDetails
)
{
return
studentAddressRepository
.
save
(
studentAddressDetails
);
}
public
StudentAddress
updateStudentAddress
(
StudentAddress
studentAddressDetails
,
String
email
)
{
StudentAddress
studentAddressToUpdate
=
getStudentAddressByEmail
(
email
).
orElseThrow
(()
->
new
NullPointerException
(
"Email not found: "
+
email
));
//TEMPORARY FIX
studentAddressToUpdate
.
setStreetAddress
(
studentAddressDetails
.
getStreetAddress
());
studentAddressToUpdate
.
setState
(
studentAddressDetails
.
getState
());
studentAddressToUpdate
.
setCity
(
studentAddressDetails
.
getCity
());
studentAddressToUpdate
.
setZip
(
studentAddressDetails
.
getZip
());
if
(
studentAddressDetails
.
getAptNum
()
!=
null
)
{
studentAddressToUpdate
.
setAptNum
(
studentAddressDetails
.
getAptNum
());
}
return
studentAddressRepository
.
save
(
studentAddressToUpdate
);
}
}
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