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
0a605754
Commit
0a605754
authored
Oct 25, 2024
by
Ishankha K.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear notification api
logTime to notification api
parent
404837a9
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
2 deletions
+34
-2
src/main/java/com/kaluwa/enterprises/babycarebackendservice/config/WebSocketClient.java
...prises/babycarebackendservice/config/WebSocketClient.java
+1
-1
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/ActivityLogDto.java
...nterprises/babycarebackendservice/dto/ActivityLogDto.java
+2
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/ActivityLog.java
...enterprises/babycarebackendservice/model/ActivityLog.java
+3
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/rest/ActivityLogController.java
...es/babycarebackendservice/rest/ActivityLogController.java
+8
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/ActivityLogService.java
...es/babycarebackendservice/service/ActivityLogService.java
+3
-0
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/ActivityLogServiceImpl.java
...rebackendservice/service/impl/ActivityLogServiceImpl.java
+16
-0
src/main/resources/application.yaml
src/main/resources/application.yaml
+1
-1
No files found.
src/main/java/com/kaluwa/enterprises/babycarebackendservice/config/WebSocketClient.java
View file @
0a605754
...
...
@@ -56,7 +56,7 @@ public class WebSocketClient {
scheduler
.
schedule
(
this
::
connectToWebSocket
,
2
,
TimeUnit
.
MINUTES
);
}
@Scheduled
(
fixedDelay
=
120000
)
// Check every 5
minutes
@Scheduled
(
fixedDelay
=
60000
)
// Check every 1
minutes
private
void
checkConnection
()
{
if
(
session
==
null
||
!
session
.
isOpen
())
{
System
.
out
.
println
(
"WebSocket connection is closed. Reconnecting..."
);
...
...
src/main/java/com/kaluwa/enterprises/babycarebackendservice/dto/ActivityLogDto.java
View file @
0a605754
...
...
@@ -3,6 +3,7 @@ package com.kaluwa.enterprises.babycarebackendservice.dto;
import
lombok.*
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* DTO for {@link com.kaluwa.enterprises.babycarebackendservice.model.ActivityLog}
...
...
@@ -14,4 +15,5 @@ public class ActivityLogDto implements Serializable {
private
Long
activityLogId
;
private
String
activityLogType
;
private
String
activityLogDescription
;
private
LocalDateTime
logTime
;
}
\ No newline at end of file
src/main/java/com/kaluwa/enterprises/babycarebackendservice/model/ActivityLog.java
View file @
0a605754
...
...
@@ -5,6 +5,8 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.time.LocalDateTime
;
import
static
com
.
kaluwa
.
enterprises
.
babycarebackendservice
.
constants
.
TableNames
.
ACTIVITY_LOG_TABLE
;
@Data
...
...
@@ -18,4 +20,5 @@ public class ActivityLog {
private
Long
activityLogId
;
private
String
activityLogType
;
private
String
activityLogDescription
;
private
LocalDateTime
logTime
;
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/rest/ActivityLogController.java
View file @
0a605754
package
com.kaluwa.enterprises.babycarebackendservice.rest
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ActivityLogDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ResponseDto
;
import
com.kaluwa.enterprises.babycarebackendservice.service.ActivityLogService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -27,4 +29,10 @@ public class ActivityLogController {
return
activityLogService
.
getAllActivityLogs
();
}
@DeleteMapping
public
ResponseEntity
<
ResponseDto
>
clearNotifications
()
{
log
.
info
(
"Inside activity log controller clearNotifications method"
);
return
activityLogService
.
clearNotifications
();
}
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/ActivityLogService.java
View file @
0a605754
package
com.kaluwa.enterprises.babycarebackendservice.service
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ActivityLogDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ResponseDto
;
import
org.springframework.http.ResponseEntity
;
import
java.util.List
;
...
...
@@ -10,4 +11,6 @@ public interface ActivityLogService {
ActivityLogDto
saveActivityLog
(
ActivityLogDto
activityLogDto
);
ResponseEntity
<
List
<
ActivityLogDto
>>
getAllActivityLogs
();
ResponseEntity
<
ResponseDto
>
clearNotifications
();
}
src/main/java/com/kaluwa/enterprises/babycarebackendservice/service/impl/ActivityLogServiceImpl.java
View file @
0a605754
...
...
@@ -2,6 +2,7 @@ package com.kaluwa.enterprises.babycarebackendservice.service.impl;
import
com.kaluwa.enterprises.babycarebackendservice.dao.ActivityLogDao
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ActivityLogDto
;
import
com.kaluwa.enterprises.babycarebackendservice.dto.ResponseDto
;
import
com.kaluwa.enterprises.babycarebackendservice.error.BadRequestAlertException
;
import
com.kaluwa.enterprises.babycarebackendservice.mappers.ActivityLogMapper
;
import
com.kaluwa.enterprises.babycarebackendservice.service.ActivityLogService
;
...
...
@@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.util.List
;
@Service
...
...
@@ -27,6 +29,7 @@ public class ActivityLogServiceImpl implements ActivityLogService {
public
ActivityLogDto
saveActivityLog
(
ActivityLogDto
activityLogDto
)
{
log
.
info
(
"Inside saveActivityLog method in ActivityLogServiceImpl"
);
try
{
activityLogDto
.
setLogTime
(
LocalDateTime
.
now
());
return
activityLogMapper
.
toDto
(
activityLogDao
.
save
(
activityLogMapper
.
toEntity
(
activityLogDto
)));
}
catch
(
Exception
e
)
{
log
.
error
(
"Error occurred while saving activity log: {}"
,
e
.
getMessage
());
...
...
@@ -46,4 +49,17 @@ public class ActivityLogServiceImpl implements ActivityLogService {
throw
new
BadRequestAlertException
(
e
.
getMessage
(),
"ActivityLog"
,
"errorFetchingActivityLogs"
);
}
}
@Override
public
ResponseEntity
<
ResponseDto
>
clearNotifications
()
{
log
.
info
(
"Inside clearNotifications method in ActivityLogServiceImpl"
);
try
{
activityLogDao
.
deleteAll
();
return
ResponseEntity
.
ok
(
new
ResponseDto
(
Long
.
parseLong
(
"200"
),
"Notifications cleared successfully"
));
}
catch
(
Exception
e
)
{
log
.
error
(
"Error occurred while clearing notifications: {}"
,
e
.
getMessage
());
e
.
printStackTrace
();
throw
new
BadRequestAlertException
(
e
.
getMessage
(),
"ActivityLog"
,
"errorClearingNotifications"
);
}
}
}
src/main/resources/application.yaml
View file @
0a605754
...
...
@@ -6,7 +6,7 @@ spring:
name
:
user
password
:
password
datasource
:
url
:
jdbc:mysql://192.168.1.8:30306/baby_care_db?useSSL=false&serverTimezone=UTC
url
:
jdbc:mysql://192.168.1.8:30306/baby_care_db?useSSL=false&
allowPublicKeyRetrieval=true&
serverTimezone=UTC
username
:
root
password
:
password
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
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