Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
Grievance
Commits
60af080e
Commit
60af080e
authored
1 year ago
by
shishir suman
Browse files
Options
Download
Patches
Plain Diff
adding code to update mail config if secretary's email is updated
parent
4b094bab
UPHRH_quartz_scheduler
UAT
UPHRH_7903_mobile_otp
1 merge request
!54
Uphrh 7903 mobile otp
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java
+40
-4
.../upsmf/grievance/service/impl/IntegrationServiceImpl.java
with
40 additions
and
4 deletions
+40
-4
src/main/java/org/upsmf/grievance/service/impl/IntegrationServiceImpl.java
+
40
−
4
View file @
60af080e
...
...
@@ -29,10 +29,7 @@ import org.springframework.web.client.RestTemplate;
import
org.springframework.web.server.ResponseStatusException
;
import
org.springframework.web.util.UriComponents
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
org.upsmf.grievance.dto.CreateUserDto
;
import
org.upsmf.grievance.dto.UpdateUserDto
;
import
org.upsmf.grievance.dto.UserCredentials
;
import
org.upsmf.grievance.dto.UserResponseDto
;
import
org.upsmf.grievance.dto.*
;
import
org.upsmf.grievance.enums.Department
;
import
org.upsmf.grievance.exception.*
;
import
org.upsmf.grievance.exception.runtime.InvalidRequestException
;
...
...
@@ -146,6 +143,9 @@ public class IntegrationServiceImpl implements IntegrationService {
@Autowired
private
EmailService
emailService
;
@Autowired
private
SchedulerConfigService
schedulerConfigService
;
@Override
public
User
addUser
(
User
user
)
{
return
userRepository
.
save
(
user
);
...
...
@@ -542,6 +542,8 @@ public class IntegrationServiceImpl implements IntegrationService {
esTicketUpdateService
.
updateEsTicketByUserId
(
userDto
);
esTicketUpdateService
.
updateJunkByEsTicketByUserId
(
userDto
);
// update mail config if user role secretary
updateSecretaryMailAddress
(
userDto
);
return
ResponseEntity
.
ok
().
body
(
"User updated successful"
);
}
catch
(
Exception
e
)
{
...
...
@@ -550,6 +552,40 @@ public class IntegrationServiceImpl implements IntegrationService {
}
}
/**
*
* @param userDto
*/
private
void
updateSecretaryMailAddress
(
UpdateUserDto
userDto
)
{
if
(
userDto
.
getAttributes
()
!=
null
)
{
String
role
=
userDto
.
getAttributes
().
get
(
"Role"
);
if
(
role
!=
null
&&
!
role
.
isBlank
()
&&
role
.
equalsIgnoreCase
(
"SUPERADMIN"
))
{
updateMailConfigEmail
(
userDto
.
getEmail
());
}
}
}
/**
*
* @param email
*/
private
void
updateMailConfigEmail
(
String
email
)
{
List
<
MailConfigDto
>
schedulerConfigServiceAll
=
schedulerConfigService
.
getAll
();
if
(
schedulerConfigServiceAll
!=
null
&&
!
schedulerConfigServiceAll
.
isEmpty
())
{
List
<
MailConfigDto
>
secretary
=
schedulerConfigServiceAll
.
stream
().
filter
(
config
->
config
.
isActive
()
&&
config
.
getAuthorityTitle
().
equalsIgnoreCase
(
"SECRETARY"
)).
collect
(
Collectors
.
toList
());
if
(
secretary
!=
null
&&
!
secretary
.
isEmpty
())
{
secretary
.
stream
().
forEach
(
secConf
->
{
List
<
String
>
emails
=
new
ArrayList
<>();
emails
.
add
(
email
);
secConf
.
setAuthorityEmails
(
emails
);
schedulerConfigService
.
update
(
secConf
);
});
}
}
}
private
void
updateUserData
(
UpdateUserDto
userDto
)
{
Optional
<
User
>
user
=
userRepository
.
findById
(
userDto
.
getId
());
if
(
user
.
isPresent
())
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets