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
5e9b943d
Commit
5e9b943d
authored
Oct 28, 2024
by
Ishankha K.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
baby wet checker
parent
e6183d6e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
22 deletions
+59
-22
src/main/java/com/kaluwa/enterprises/babycarebackendservice/config/SecurityConfig.java
...rprises/babycarebackendservice/config/SecurityConfig.java
+2
-1
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dao/ActivityLogDao.java
...nterprises/babycarebackendservice/dao/ActivityLogDao.java
+1
-1
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dao/BabyDao.java
...aluwa/enterprises/babycarebackendservice/dao/BabyDao.java
+8
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/BabyDto.java
...aluwa/enterprises/babycarebackendservice/dto/BabyDto.java
+1
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/Baby.java
...kaluwa/enterprises/babycarebackendservice/model/Baby.java
+1
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/rest/BabyController.java
...terprises/babycarebackendservice/rest/BabyController.java
+10
-2
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/BabyService.java
...terprises/babycarebackendservice/service/BabyService.java
+3
-1
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/ActivityLogServiceImpl.java
...rebackendservice/service/impl/ActivityLogServiceImpl.java
+1
-1
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/BabyServiceImpl.java
.../babycarebackendservice/service/impl/BabyServiceImpl.java
+32
-16
No files found.
src/main/java/com/kaluwa/enterprises/babycarebackendservice/config/SecurityConfig.java
View file @
5e9b943d
...
@@ -48,7 +48,8 @@ public class SecurityConfig {
...
@@ -48,7 +48,8 @@ public class SecurityConfig {
"/swagger-ui.html"
,
"/swagger-ui.html"
,
"/emotional/video-process"
,
"/emotional/video-process"
,
"/test/**"
,
"/test/**"
,
"/activity-logs/add"
"/activity-logs/add"
,
"/baby/**"
};
};
@Bean
@Bean
...
...
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dao/ActivityLogDao.java
View file @
5e9b943d
...
@@ -10,5 +10,5 @@ import java.util.List;
...
@@ -10,5 +10,5 @@ import java.util.List;
public
interface
ActivityLogDao
extends
JpaRepository
<
ActivityLog
,
Long
>
{
public
interface
ActivityLogDao
extends
JpaRepository
<
ActivityLog
,
Long
>
{
List
<
ActivityLog
>
findAllByOrderByActivityLogIdDesc
();
List
<
ActivityLog
>
findAllByOrderByActivityLogIdDesc
();
List
<
ActivityLog
>
find
All
ByActivityLogTypeOrderByActivityLogIdDesc
(
String
activityLogType
);
List
<
ActivityLog
>
find
Top5
ByActivityLogTypeOrderByActivityLogIdDesc
(
String
activityLogType
);
}
}
\ No newline at end of file
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dao/BabyDao.java
View file @
5e9b943d
package
com.kaluwa.enterprises.babycarebackendservice.dao
;
package
com.kaluwa.enterprises.babycarebackendservice.dao
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.BabyDto
;
import
com.kaluwa.enterprises.babycarebackendservice.model.Baby
;
import
com.kaluwa.enterprises.babycarebackendservice.model.Baby
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Optional
;
@Repository
@Repository
public
interface
BabyDao
extends
JpaRepository
<
Baby
,
Long
>
{
public
interface
BabyDao
extends
JpaRepository
<
Baby
,
Long
>
{
boolean
existsByDeviceUidAndBabyIdNot
(
String
deviceUid
,
Long
babyId
);
boolean
existsByDeviceUidAndBabyIdNot
(
String
deviceUid
,
Long
babyId
);
boolean
existsByDeviceUid
(
String
deviceUid
);
boolean
existsByDeviceUid
(
String
deviceUid
);
List
<
Baby
>
findByUserUserId
(
Long
userId
);
Optional
<
Baby
>
findByDeviceUid
(
String
deviceId
);
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/BabyDto.java
View file @
5e9b943d
...
@@ -57,6 +57,7 @@ public class BabyDto {
...
@@ -57,6 +57,7 @@ public class BabyDto {
private
String
uniqKey
;
private
String
uniqKey
;
private
UserDto
user
;
private
UserDto
user
;
private
byte
[]
imageData
;
private
byte
[]
imageData
;
private
boolean
wet
;
@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"
)
...
...
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/Baby.java
View file @
5e9b943d
...
@@ -51,6 +51,7 @@ public class Baby {
...
@@ -51,6 +51,7 @@ public class Baby {
private
String
secondaryEmergencyContactNumber
;
private
String
secondaryEmergencyContactNumber
;
private
String
notes
;
private
String
notes
;
private
String
uniqKey
;
private
String
uniqKey
;
private
boolean
wet
;
@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
;
...
...
src/main/java/com/kaluwa/enterprises/babycarebackendservice/rest/BabyController.java
View file @
5e9b943d
...
@@ -28,9 +28,11 @@ public class BabyController {
...
@@ -28,9 +28,11 @@ public class BabyController {
}
}
@GetMapping
()
@GetMapping
()
public
ResponseEntity
<
List
<
BabyDto
>>
getAllbabies
()
{
public
ResponseEntity
<
List
<
BabyDto
>>
getAllbabies
(
@RequestParam
(
value
=
"userId"
,
required
=
false
)
Long
userId
)
{
log
.
info
(
"Inside baby controller getAllbabies method"
);
log
.
info
(
"Inside baby controller getAllbabies method"
);
return
ResponseEntity
.
ok
(
babyService
.
getAllBabies
());
return
ResponseEntity
.
ok
(
babyService
.
getAllBabies
(
userId
));
}
}
@GetMapping
(
"/{babyId}"
)
@GetMapping
(
"/{babyId}"
)
...
@@ -50,4 +52,10 @@ public class BabyController {
...
@@ -50,4 +52,10 @@ public class BabyController {
log
.
info
(
"Inside baby controller deleteBaby method"
);
log
.
info
(
"Inside baby controller deleteBaby method"
);
return
ResponseEntity
.
ok
(
babyService
.
deleteBaby
(
babyId
));
return
ResponseEntity
.
ok
(
babyService
.
deleteBaby
(
babyId
));
}
}
@GetMapping
(
"/byDeviceId/{deviceId}"
)
public
ResponseEntity
<
BabyDto
>
getBabyByDeviceId
(
@PathVariable
String
deviceId
)
{
log
.
info
(
"Inside baby controller getBabyByDeviceId method"
);
return
ResponseEntity
.
ok
(
babyService
.
getBabyByDeviceId
(
deviceId
));
}
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/BabyService.java
View file @
5e9b943d
...
@@ -8,11 +8,13 @@ import java.util.List;
...
@@ -8,11 +8,13 @@ import java.util.List;
public
interface
BabyService
{
public
interface
BabyService
{
BabyDto
createBaby
(
BabyDto
babyDto
);
BabyDto
createBaby
(
BabyDto
babyDto
);
List
<
BabyDto
>
getAllBabies
();
List
<
BabyDto
>
getAllBabies
(
Long
userId
);
BabyDto
getBabyById
(
Long
babyId
);
BabyDto
getBabyById
(
Long
babyId
);
BabyDto
updateBaby
(
Long
babyId
,
BabyDto
babyDto
);
BabyDto
updateBaby
(
Long
babyId
,
BabyDto
babyDto
);
ResponseDto
deleteBaby
(
Long
babyId
);
ResponseDto
deleteBaby
(
Long
babyId
);
BabyDto
getBabyByDeviceId
(
String
deviceId
);
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/ActivityLogServiceImpl.java
View file @
5e9b943d
...
@@ -43,7 +43,7 @@ public class ActivityLogServiceImpl implements ActivityLogService {
...
@@ -43,7 +43,7 @@ public class ActivityLogServiceImpl implements ActivityLogService {
log
.
info
(
"Inside getAllActivityLogs method in ActivityLogServiceImpl"
);
log
.
info
(
"Inside getAllActivityLogs method in ActivityLogServiceImpl"
);
try
{
try
{
if
(
activityLogType
!=
null
&&
!
activityLogType
.
isEmpty
())
{
if
(
activityLogType
!=
null
&&
!
activityLogType
.
isEmpty
())
{
return
ResponseEntity
.
ok
(
activityLogMapper
.
listToDto
(
activityLogDao
.
find
All
ByActivityLogTypeOrderByActivityLogIdDesc
(
activityLogType
)));
return
ResponseEntity
.
ok
(
activityLogMapper
.
listToDto
(
activityLogDao
.
find
Top5
ByActivityLogTypeOrderByActivityLogIdDesc
(
activityLogType
)));
}
else
{
}
else
{
return
ResponseEntity
.
ok
(
activityLogMapper
.
listToDto
(
activityLogDao
.
findAllByOrderByActivityLogIdDesc
()));
return
ResponseEntity
.
ok
(
activityLogMapper
.
listToDto
(
activityLogDao
.
findAllByOrderByActivityLogIdDesc
()));
}
}
...
...
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/BabyServiceImpl.java
View file @
5e9b943d
...
@@ -12,13 +12,8 @@ import com.kaluwa.enterprises.babycarebackendservice.model.Document;
...
@@ -12,13 +12,8 @@ import com.kaluwa.enterprises.babycarebackendservice.model.Document;
import
com.kaluwa.enterprises.babycarebackendservice.service.BabyService
;
import
com.kaluwa.enterprises.babycarebackendservice.service.BabyService
;
import
com.kaluwa.enterprises.babycarebackendservice.service.DocumentService
;
import
com.kaluwa.enterprises.babycarebackendservice.service.DocumentService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -68,6 +63,7 @@ public class BabyServiceImpl implements BabyService {
...
@@ -68,6 +63,7 @@ public class BabyServiceImpl implements BabyService {
if
(
babyDto
.
getUserId
()
==
null
)
{
if
(
babyDto
.
getUserId
()
==
null
)
{
throw
new
BadRequestAlertException
(
"User id is required"
,
"baby"
,
"baby.error"
);
throw
new
BadRequestAlertException
(
"User id is required"
,
"baby"
,
"baby.error"
);
}
}
babyDto
.
setWet
(
false
);
return
babyMapper
.
toDto
(
babyDao
.
save
(
babyMapper
.
toEntity
(
babyDto
)));
return
babyMapper
.
toDto
(
babyDao
.
save
(
babyMapper
.
toEntity
(
babyDto
)));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -76,11 +72,15 @@ public class BabyServiceImpl implements BabyService {
...
@@ -76,11 +72,15 @@ public class BabyServiceImpl implements BabyService {
}
}
@Override
@Override
public
List
<
BabyDto
>
getAllBabies
()
{
public
List
<
BabyDto
>
getAllBabies
(
Long
userId
)
{
log
.
info
(
"Inside baby service getAllBabies method"
);
log
.
info
(
"Inside baby service getAllBabies method"
);
try
{
try
{
List
<
BabyDto
>
babyList
=
babyMapper
.
toDtoList
(
babyDao
.
findAll
());
List
<
BabyDto
>
babyList
;
if
(
userId
!=
null
)
{
babyList
=
babyMapper
.
toDtoList
(
babyDao
.
findByUserUserId
(
userId
));
}
else
{
babyList
=
babyMapper
.
toDtoList
(
babyDao
.
findAll
());
babyList
.
forEach
(
babyDto
->
{
babyList
.
forEach
(
babyDto
->
{
Optional
<
Document
>
documentOp
=
documentDao
.
findByTableNameAndUniqKeyAndDocumentType
(
BABY_TABLE
,
babyDto
.
getUniqKey
(),
IMAGE
);
Optional
<
Document
>
documentOp
=
documentDao
.
findByTableNameAndUniqKeyAndDocumentType
(
BABY_TABLE
,
babyDto
.
getUniqKey
(),
IMAGE
);
documentOp
.
ifPresent
(
document
->
{
documentOp
.
ifPresent
(
document
->
{
...
@@ -90,7 +90,7 @@ public class BabyServiceImpl implements BabyService {
...
@@ -90,7 +90,7 @@ public class BabyServiceImpl implements BabyService {
}
}
});
});
});
});
}
return
babyList
;
return
babyList
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -176,4 +176,20 @@ public class BabyServiceImpl implements BabyService {
...
@@ -176,4 +176,20 @@ public class BabyServiceImpl implements BabyService {
throw
new
BadRequestAlertException
(
e
.
getMessage
(),
"baby"
,
"baby.error"
);
throw
new
BadRequestAlertException
(
e
.
getMessage
(),
"baby"
,
"baby.error"
);
}
}
}
}
@Override
public
BabyDto
getBabyByDeviceId
(
String
deviceId
)
{
log
.
info
(
"Inside baby service getBabyByDeviceId method"
);
try
{
Optional
<
Baby
>
babyOp
=
babyDao
.
findByDeviceUid
(
deviceId
);
if
(
babyOp
.
isEmpty
())
{
throw
new
BadRequestAlertException
(
"Baby not found"
,
"baby"
,
"baby.error"
);
}
else
{
return
babyMapper
.
toDto
(
babyOp
.
get
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BadRequestAlertException
(
e
.
getMessage
(),
"baby"
,
"baby.error"
);
}
}
}
}
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