Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
baby-monitoring-spring-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
R24-145
baby-monitoring-spring-backend
Commits
4d8d4bc8
Commit
4d8d4bc8
authored
May 21, 2024
by
Chamod Ishankha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
baby dto updated
parent
98eae013
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
13 deletions
+84
-13
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/BabyDto.java
...aluwa/enterprises/babycarebackendservice/dto/BabyDto.java
+40
-6
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/Baby.java
...kaluwa/enterprises/babycarebackendservice/model/Baby.java
+32
-4
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/BabyServiceImpl.java
.../babycarebackendservice/service/impl/BabyServiceImpl.java
+12
-3
No files found.
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/BabyDto.java
View file @
4d8d4bc8
...
@@ -8,20 +8,54 @@ import lombok.NoArgsConstructor;
...
@@ -8,20 +8,54 @@ import lombok.NoArgsConstructor;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
static
com
.
kaluwa
.
enterprises
.
babycarebackendservice
.
constants
.
Status
.
STATUS_NEW
;
@Data
@Data
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
public
class
BabyDto
{
public
class
BabyDto
{
private
Long
babyId
;
private
Long
babyId
;
@NotNull
(
message
=
"Baby name is required"
)
@NotNull
(
message
=
"Baby's first name is required"
)
@NotEmpty
(
message
=
"Baby name is required"
)
@NotEmpty
(
message
=
"Baby's first name is required"
)
private
String
babyName
;
private
String
firstName
;
private
String
babyGender
;
private
String
lastName
;
private
LocalDate
babyDob
;
@NotNull
(
message
=
"Baby's date of birth is required"
)
private
String
babyWeight
;
@NotEmpty
(
message
=
"Baby's date of birth is required"
)
private
LocalDate
dob
;
@NotNull
(
message
=
"Baby's gender is required"
)
@NotEmpty
(
message
=
"Baby's gender is required"
)
private
String
sex
;
private
String
status
=
STATUS_NEW
;
private
boolean
isActive
;
private
float
weight
;
private
float
height
;
private
String
bloodType
;
private
String
eyeColor
;
private
String
hairColor
;
private
String
allergies
;
private
String
medicalConditions
;
private
String
medications
;
private
String
vaccinateRecords
;
private
String
docName
;
private
String
docContactNumber
;
private
String
healthInsuranceInfo
;
private
LocalDate
firstSmileDate
;
private
LocalDate
firstToothDate
;
private
LocalDate
firstWordDate
;
private
LocalDate
firstStepDate
;
private
String
favFoods
;
private
String
foodsDislikes
;
private
String
primaryEmergencyContactName
;
private
String
primaryEmergencyRelationship
;
private
String
primaryEmergencyContactNumber
;
private
String
secondaryEmergencyContactName
;
private
String
secondaryEmergencyRelationship
;
private
String
secondaryEmergencyContactNumber
;
private
String
notes
;
private
UserDto
user
;
private
UserDto
user
;
@NotNull
(
message
=
"Logged user id is required"
)
@NotNull
(
message
=
"Logged user id is required"
)
@NotEmpty
(
message
=
"Logged user id is required"
)
@NotEmpty
(
message
=
"Logged user id is required"
)
private
Long
userId
;
private
Long
userId
;
private
Long
documentId
;
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/Baby.java
View file @
4d8d4bc8
...
@@ -18,11 +18,39 @@ public class Baby {
...
@@ -18,11 +18,39 @@ public class Baby {
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
private
Long
babyId
;
private
Long
babyId
;
private
String
babyName
;
private
String
firstName
;
private
String
babyGender
;
private
String
lastName
;
private
LocalDate
babyDob
;
private
LocalDate
dob
;
private
String
babyWeight
;
private
String
sex
;
private
String
status
;
private
boolean
isActive
;
private
float
weight
;
private
float
height
;
private
String
bloodType
;
private
String
eyeColor
;
private
String
hairColor
;
private
String
allergies
;
private
String
medicalConditions
;
private
String
medications
;
private
String
vaccinateRecords
;
private
String
docName
;
private
String
docContactNumber
;
private
String
healthInsuranceInfo
;
private
LocalDate
firstSmileDate
;
private
LocalDate
firstToothDate
;
private
LocalDate
firstWordDate
;
private
LocalDate
firstStepDate
;
private
String
favFoods
;
private
String
foodsDislikes
;
private
String
primaryEmergencyContactName
;
private
String
primaryEmergencyRelationship
;
private
String
primaryEmergencyContactNumber
;
private
String
secondaryEmergencyContactName
;
private
String
secondaryEmergencyRelationship
;
private
String
secondaryEmergencyContactNumber
;
private
String
notes
;
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JoinColumn
(
name
=
"userId"
,
referencedColumnName
=
"userId"
,
nullable
=
false
)
@JoinColumn
(
name
=
"userId"
,
referencedColumnName
=
"userId"
,
nullable
=
false
)
private
User
user
;
private
User
user
;
private
Long
documentId
;
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/BabyServiceImpl.java
View file @
4d8d4bc8
package
com.kaluwa.enterprises.babycarebackendservice.service.impl
;
package
com.kaluwa.enterprises.babycarebackendservice.service.impl
;
import
com.kaluwa.enterprises.babycarebackendservice.dao.BabyDao
;
import
com.kaluwa.enterprises.babycarebackendservice.dao.BabyDao
;
import
com.kaluwa.enterprises.babycarebackendservice.dao.DocumentDao
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.BabyDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.BabyDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ResponseDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ResponseDto
;
import
com.kaluwa.enterprises.babycarebackendservice.error.BadRequestAlertException
;
import
com.kaluwa.enterprises.babycarebackendservice.error.BadRequestAlertException
;
import
com.kaluwa.enterprises.babycarebackendservice.mappers.BabyMapper
;
import
com.kaluwa.enterprises.babycarebackendservice.mappers.BabyMapper
;
import
com.kaluwa.enterprises.babycarebackendservice.model.Baby
;
import
com.kaluwa.enterprises.babycarebackendservice.model.Baby
;
import
com.kaluwa.enterprises.babycarebackendservice.model.Document
;
import
com.kaluwa.enterprises.babycarebackendservice.service.BabyService
;
import
com.kaluwa.enterprises.babycarebackendservice.service.BabyService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -15,15 +18,17 @@ import java.util.List;
...
@@ -15,15 +18,17 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.Optional
;
@Service
@Service
@Slf4j
public
class
BabyServiceImpl
implements
BabyService
{
public
class
BabyServiceImpl
implements
BabyService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BabyServiceImpl
.
class
);
private
final
BabyDao
babyDao
;
private
final
BabyDao
babyDao
;
private
final
BabyMapper
babyMapper
;
private
final
BabyMapper
babyMapper
;
private
final
DocumentDao
documentDao
;
public
BabyServiceImpl
(
BabyDao
babyDao
,
BabyMapper
babyMapper
)
{
public
BabyServiceImpl
(
BabyDao
babyDao
,
BabyMapper
babyMapper
,
DocumentDao
documentDao
)
{
this
.
babyDao
=
babyDao
;
this
.
babyDao
=
babyDao
;
this
.
babyMapper
=
babyMapper
;
this
.
babyMapper
=
babyMapper
;
this
.
documentDao
=
documentDao
;
}
}
@Override
@Override
...
@@ -92,6 +97,10 @@ public class BabyServiceImpl implements BabyService {
...
@@ -92,6 +97,10 @@ public class BabyServiceImpl implements BabyService {
if
(
babyOp
.
isEmpty
())
{
if
(
babyOp
.
isEmpty
())
{
throw
new
BadRequestAlertException
(
"Baby not found"
,
"baby"
,
"baby.error"
);
throw
new
BadRequestAlertException
(
"Baby not found"
,
"baby"
,
"baby.error"
);
}
else
{
}
else
{
Optional
<
Document
>
documentOp
=
documentDao
.
findById
(
babyOp
.
get
().
getDocumentId
());
if
(
documentOp
.
isPresent
())
{
documentDao
.
deleteById
(
babyOp
.
get
().
getDocumentId
());
}
babyDao
.
deleteById
(
babyId
);
babyDao
.
deleteById
(
babyId
);
ResponseDto
responseDto
=
new
ResponseDto
();
ResponseDto
responseDto
=
new
ResponseDto
();
responseDto
.
setId
(
babyId
);
responseDto
.
setId
(
babyId
);
...
...
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