Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
NotificationSVC
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
abdullh.alsoleman
NotificationSVC
Commits
d38482db
Commit
d38482db
authored
Jul 17, 2024
by
Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add some endpoints to notification api
parent
845ffe2e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
NotificationController.java
...i/notificationsvc/controllers/NotificationController.java
+10
-0
INotificationRepository.java
...notificationsvc/repositories/INotificationRepository.java
+7
-2
INotificationService.java
...om/ali/notificationsvc/services/INotificationService.java
+2
-0
NotificationService.java
...com/ali/notificationsvc/services/NotificationService.java
+15
-0
No files found.
src/main/java/com/ali/notificationsvc/controllers/NotificationController.java
View file @
d38482db
...
@@ -47,6 +47,16 @@ public class NotificationController {
...
@@ -47,6 +47,16 @@ public class NotificationController {
boolean
isExist
=
notificationService
.
existById
(
notificationId
);
boolean
isExist
=
notificationService
.
existById
(
notificationId
);
return
ResponseEntity
.
ok
(
isExist
);
return
ResponseEntity
.
ok
(
isExist
);
}
}
@GetMapping
(
"getUnReadNotificationNumForJobseeker/{id}"
)
public
ResponseEntity
<
Integer
>
getUnReadNotificationNumForJobseeker
(
@PathVariable
(
"id"
)
int
jobseekerId
)
{
int
num
=
notificationService
.
getUnReadNotificationsNumberByJobseekerId
(
jobseekerId
);
return
ResponseEntity
.
ok
(
num
);
}
@GetMapping
(
"getUnReadNotificationNumForCompany/{id}"
)
public
ResponseEntity
<
Integer
>
getUnReadNotificationNumForCompany
(
@PathVariable
(
"id"
)
int
companyId
)
{
int
num
=
notificationService
.
getUnReadNotificationsNumberByCompanyId
(
companyId
);
return
ResponseEntity
.
ok
(
num
);
}
@PostMapping
(
"create"
)
@PostMapping
(
"create"
)
public
ResponseEntity
<
RequestStatus
>
createNotification
(
@RequestBody
CreateNotificationDto
createNotificationDto
)
{
public
ResponseEntity
<
RequestStatus
>
createNotification
(
@RequestBody
CreateNotificationDto
createNotificationDto
)
{
...
...
src/main/java/com/ali/notificationsvc/repositories/INotificationRepository.java
View file @
d38482db
...
@@ -10,9 +10,14 @@ import java.util.List;
...
@@ -10,9 +10,14 @@ import java.util.List;
@Repository
@Repository
public
interface
INotificationRepository
extends
JpaRepository
<
Notification
,
Integer
>
{
public
interface
INotificationRepository
extends
JpaRepository
<
Notification
,
Integer
>
{
@Query
(
"SELECT i FROM Notification i WHERE i.companyId = :companyId"
)
@Query
(
"SELECT i FROM Notification i WHERE i.companyId = :companyId
AND i.toCompany = true
"
)
List
<
Notification
>
findNotificationsByCompanyId
(
@Param
(
"companyId"
)
int
companyId
);
List
<
Notification
>
findNotificationsByCompanyId
(
@Param
(
"companyId"
)
int
companyId
);
@Query
(
"SELECT i FROM Notification i WHERE i.jobseekerId = :jobseekerId"
)
@Query
(
"SELECT i FROM Notification i WHERE i.jobseekerId = :jobseekerId
AND i.toCompany = false
"
)
List
<
Notification
>
findNotificationsByJobseekerId
(
@Param
(
"jobseekerId"
)
int
jobseekerId
);
List
<
Notification
>
findNotificationsByJobseekerId
(
@Param
(
"jobseekerId"
)
int
jobseekerId
);
@Query
(
"SELECT i FROM Notification i WHERE i.jobseekerId = :jobseekerId AND i.isRead = false AND i.toCompany = false"
)
List
<
Notification
>
findUnreadNotificationsByJobseekerId
(
@Param
(
"jobseekerId"
)
int
jobseekerId
);
@Query
(
"SELECT i FROM Notification i WHERE i.companyId = :companyId AND i.isRead = false AND i.toCompany = true"
)
List
<
Notification
>
findUnreadNotificationsByCompanyId
(
@Param
(
"companyId"
)
int
companyId
);
}
}
src/main/java/com/ali/notificationsvc/services/INotificationService.java
View file @
d38482db
...
@@ -15,4 +15,6 @@ public interface INotificationService {
...
@@ -15,4 +15,6 @@ public interface INotificationService {
public
RequestStatus
update
(
NotificationDto
notificationDto
);
public
RequestStatus
update
(
NotificationDto
notificationDto
);
public
RequestStatus
delete
(
int
notificationId
);
public
RequestStatus
delete
(
int
notificationId
);
public
boolean
existById
(
int
notificationId
);
public
boolean
existById
(
int
notificationId
);
public
int
getUnReadNotificationsNumberByJobseekerId
(
int
jobseekerId
);
public
int
getUnReadNotificationsNumberByCompanyId
(
int
companyId
);
}
}
src/main/java/com/ali/notificationsvc/services/NotificationService.java
View file @
d38482db
...
@@ -46,9 +46,11 @@ public class NotificationService implements INotificationService {
...
@@ -46,9 +46,11 @@ public class NotificationService implements INotificationService {
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByJobseekerId
(
jobseekerId
);
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByJobseekerId
(
jobseekerId
);
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
for
(
Notification
notification
:
notifications
){
for
(
Notification
notification
:
notifications
){
notification
.
setRead
(
true
);
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
notificationDtos
.
add
(
notificationDto
);
notificationDtos
.
add
(
notificationDto
);
}
}
iNotificationRepository
.
saveAll
(
notifications
);
return
notificationDtos
;
return
notificationDtos
;
}
}
...
@@ -57,9 +59,11 @@ public class NotificationService implements INotificationService {
...
@@ -57,9 +59,11 @@ public class NotificationService implements INotificationService {
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByCompanyId
(
companyId
);
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByCompanyId
(
companyId
);
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
for
(
Notification
notification
:
notifications
){
for
(
Notification
notification
:
notifications
){
notification
.
setRead
(
true
);
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
notificationDtos
.
add
(
notificationDto
);
notificationDtos
.
add
(
notificationDto
);
}
}
iNotificationRepository
.
saveAll
(
notifications
);
return
notificationDtos
;
return
notificationDtos
;
}
}
...
@@ -119,6 +123,17 @@ public class NotificationService implements INotificationService {
...
@@ -119,6 +123,17 @@ public class NotificationService implements INotificationService {
public
boolean
existById
(
int
notificationId
)
{
public
boolean
existById
(
int
notificationId
)
{
return
iNotificationRepository
.
existsById
(
notificationId
);
return
iNotificationRepository
.
existsById
(
notificationId
);
}
}
@Override
public
int
getUnReadNotificationsNumberByJobseekerId
(
int
jobseekerId
)
{
return
iNotificationRepository
.
findUnreadNotificationsByJobseekerId
(
jobseekerId
).
size
();
}
@Override
public
int
getUnReadNotificationsNumberByCompanyId
(
int
companyId
)
{
return
iNotificationRepository
.
findUnreadNotificationsByCompanyId
(
companyId
).
size
();
}
private
void
ignoreIdMapping
(
ModelMapper
modelMapper
){
private
void
ignoreIdMapping
(
ModelMapper
modelMapper
){
modelMapper
.
getConfiguration
()
modelMapper
.
getConfiguration
()
.
setPropertyCondition
(
Conditions
.
isNotNull
())
.
setPropertyCondition
(
Conditions
.
isNotNull
())
...
...
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