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
bd5fdf7a
Commit
bd5fdf7a
authored
Jul 17, 2024
by
Ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add notification service
parent
05353643
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
234 additions
and
0 deletions
+234
-0
pom.xml
pom.xml
+5
-0
CreateNotificationDto.java
...a/com/ali/notificationsvc/dtos/CreateNotificationDto.java
+26
-0
NotificationDto.java
...in/java/com/ali/notificationsvc/dtos/NotificationDto.java
+28
-0
INotificationRepository.java
...notificationsvc/repositories/INotificationRepository.java
+8
-0
INotificationService.java
...om/ali/notificationsvc/services/INotificationService.java
+18
-0
NotificationService.java
...com/ali/notificationsvc/services/NotificationService.java
+118
-0
RequestStatus.java
...in/java/com/ali/notificationsvc/status/RequestStatus.java
+31
-0
No files found.
pom.xml
View file @
bd5fdf7a
...
@@ -69,6 +69,11 @@
...
@@ -69,6 +69,11 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.modelmapper
</groupId>
<artifactId>
modelmapper
</artifactId>
<version>
3.1.0
</version>
</dependency>
</dependencies>
</dependencies>
<dependencyManagement>
<dependencyManagement>
<dependencies>
<dependencies>
...
...
src/main/java/com/ali/notificationsvc/dtos/CreateNotificationDto.java
0 → 100644
View file @
bd5fdf7a
package
com
.
ali
.
notificationsvc
.
dtos
;
import
java.time.LocalDateTime
;
public
class
CreateNotificationDto
{
private
int
jobId
;
private
int
companyId
;
private
int
jobseekerId
;
private
String
details
;
private
boolean
isRead
;
private
boolean
toCompany
;
private
LocalDateTime
createdAt
;
public
CreateNotificationDto
(
int
jobId
,
int
companyId
,
int
jobseekerId
,
String
details
,
boolean
isRead
,
boolean
toCompany
,
LocalDateTime
createdAt
)
{
this
.
jobId
=
jobId
;
this
.
companyId
=
companyId
;
this
.
jobseekerId
=
jobseekerId
;
this
.
details
=
details
;
this
.
isRead
=
isRead
;
this
.
toCompany
=
toCompany
;
this
.
createdAt
=
createdAt
;
}
public
CreateNotificationDto
()
{
}
}
src/main/java/com/ali/notificationsvc/dtos/NotificationDto.java
0 → 100644
View file @
bd5fdf7a
package
com
.
ali
.
notificationsvc
.
dtos
;
import
java.time.LocalDateTime
;
public
class
NotificationDto
{
private
int
id
;
private
int
jobId
;
private
int
companyId
;
private
int
jobseekerId
;
private
String
details
;
private
boolean
isRead
;
private
boolean
toCompany
;
private
LocalDateTime
createdAt
;
public
NotificationDto
(
int
id
,
int
jobId
,
int
companyId
,
int
jobseekerId
,
String
details
,
boolean
isRead
,
boolean
toCompany
,
LocalDateTime
createdAt
)
{
this
.
id
=
id
;
this
.
jobId
=
jobId
;
this
.
companyId
=
companyId
;
this
.
jobseekerId
=
jobseekerId
;
this
.
details
=
details
;
this
.
isRead
=
isRead
;
this
.
toCompany
=
toCompany
;
this
.
createdAt
=
createdAt
;
}
public
NotificationDto
()
{
}
}
src/main/java/com/ali/notificationsvc/repositories/INotificationRepository.java
View file @
bd5fdf7a
...
@@ -2,8 +2,16 @@ package com.ali.notificationsvc.repositories;
...
@@ -2,8 +2,16 @@ package com.ali.notificationsvc.repositories;
import
com.ali.notificationsvc.models.Notification
;
import
com.ali.notificationsvc.models.Notification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
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"
)
List
<
Notification
>
findNotificationsByCompanyId
(
@Param
(
"companyId"
)
int
companyId
);
@Query
(
"SELECT i FROM Notification i WHERE i.jobseekerId = :jobseekerId"
)
List
<
Notification
>
findNotificationsByJobseekerId
(
@Param
(
"jobseekerId"
)
int
jobseekerId
);
}
}
src/main/java/com/ali/notificationsvc/services/INotificationService.java
0 → 100644
View file @
bd5fdf7a
package
com
.
ali
.
notificationsvc
.
services
;
import
com.ali.notificationsvc.dtos.CreateNotificationDto
;
import
com.ali.notificationsvc.dtos.NotificationDto
;
import
com.ali.notificationsvc.status.RequestStatus
;
import
java.util.List
;
public
interface
INotificationService
{
public
NotificationDto
getById
(
int
notificationId
);
public
List
<
NotificationDto
>
getAll
();
public
List
<
NotificationDto
>
getNotificationByJobseekerId
(
int
jobseekerId
);
public
List
<
NotificationDto
>
getNotificationByCompanyId
(
int
companyId
);
public
RequestStatus
create
(
CreateNotificationDto
cNotificationDto
);
public
RequestStatus
update
(
NotificationDto
notificationDto
);
public
RequestStatus
delete
(
int
notificationId
);
public
boolean
existById
(
int
notificationId
);
}
src/main/java/com/ali/notificationsvc/services/NotificationService.java
0 → 100644
View file @
bd5fdf7a
package
com
.
ali
.
notificationsvc
.
services
;
import
com.ali.notificationsvc.dtos.CreateNotificationDto
;
import
com.ali.notificationsvc.dtos.NotificationDto
;
import
com.ali.notificationsvc.models.Notification
;
import
com.ali.notificationsvc.repositories.INotificationRepository
;
import
com.ali.notificationsvc.status.RequestStatus
;
import
org.modelmapper.ModelMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
NotificationService
implements
INotificationService
{
@Autowired
INotificationRepository
iNotificationRepository
;
private
ModelMapper
modelMapper
=
new
ModelMapper
();
NotificationService
(
INotificationRepository
iNotificationRepository
){
this
.
iNotificationRepository
=
iNotificationRepository
;
}
@Override
public
NotificationDto
getById
(
int
notificationId
)
{
NotificationDto
notificationDto
=
new
NotificationDto
();
notificationDto
=
modelMapper
.
map
(
iNotificationRepository
.
getById
(
notificationId
),
NotificationDto
.
class
);
return
notificationDto
;
}
@Override
public
List
<
NotificationDto
>
getAll
()
{
List
<
Notification
>
notifications
=
iNotificationRepository
.
findAll
();
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
for
(
Notification
notification
:
notifications
){
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
notificationDtos
.
add
(
notificationDto
);
}
return
notificationDtos
;
}
@Override
public
List
<
NotificationDto
>
getNotificationByJobseekerId
(
int
jobseekerId
)
{
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByJobseekerId
(
jobseekerId
);
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
for
(
Notification
notification
:
notifications
){
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
notificationDtos
.
add
(
notificationDto
);
}
return
notificationDtos
;
}
@Override
public
List
<
NotificationDto
>
getNotificationByCompanyId
(
int
companyId
)
{
List
<
Notification
>
notifications
=
iNotificationRepository
.
findNotificationsByCompanyId
(
companyId
);
List
<
NotificationDto
>
notificationDtos
=
new
ArrayList
<>();
for
(
Notification
notification
:
notifications
){
NotificationDto
notificationDto
=
modelMapper
.
map
(
notification
,
NotificationDto
.
class
);
notificationDtos
.
add
(
notificationDto
);
}
return
notificationDtos
;
}
@Override
public
RequestStatus
create
(
CreateNotificationDto
cNotificationDto
)
{
RequestStatus
status
=
new
RequestStatus
();
try
{
Notification
notification
=
modelMapper
.
map
(
cNotificationDto
,
Notification
.
class
);
iNotificationRepository
.
save
(
notification
);
status
.
setStatus
(
true
);
status
.
setDescribtion
(
"created successfully"
);
return
status
;
}
catch
(
Exception
e
){
status
.
setStatus
(
false
);
status
.
setDescribtion
(
e
.
getMessage
().
toString
());
return
status
;
}
}
@Override
public
RequestStatus
update
(
NotificationDto
notificationDto
)
{
RequestStatus
status
=
new
RequestStatus
();
try
{
Notification
notification
=
new
Notification
();
notification
=
modelMapper
.
map
(
notificationDto
,
Notification
.
class
);
iNotificationRepository
.
save
(
notification
);
status
.
setStatus
(
true
);
status
.
setDescribtion
(
"updated successfully"
);
return
status
;
}
catch
(
Exception
e
){
status
.
setStatus
(
false
);
status
.
setDescribtion
(
"failed to update"
);
return
status
;
}
}
@Override
public
RequestStatus
delete
(
int
notificationId
)
{
RequestStatus
status
=
new
RequestStatus
();
if
(
iNotificationRepository
.
existsById
(
notificationId
)){
iNotificationRepository
.
deleteById
(
notificationId
);
status
.
setStatus
(
true
);
status
.
setDescribtion
(
"deleted successfully"
);
return
status
;
}
else
{
status
.
setStatus
(
false
);
status
.
setDescribtion
(
"failed to delete, cv does not exist"
);
return
status
;
}
}
@Override
public
boolean
existById
(
int
notificationId
)
{
return
iNotificationRepository
.
existsById
(
notificationId
);
}
}
src/main/java/com/ali/notificationsvc/status/RequestStatus.java
0 → 100644
View file @
bd5fdf7a
package
com
.
ali
.
notificationsvc
.
status
;
public
class
RequestStatus
{
boolean
status
;
String
describtion
;
public
RequestStatus
(
boolean
status
,
String
describtion
)
{
this
.
status
=
status
;
this
.
describtion
=
describtion
;
}
public
RequestStatus
()
{
}
public
boolean
isStatus
()
{
return
status
;
}
public
void
setStatus
(
boolean
status
)
{
this
.
status
=
status
;
}
public
String
getDescribtion
()
{
return
describtion
;
}
public
void
setDescribtion
(
String
describtion
)
{
this
.
describtion
=
describtion
;
}
}
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