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
05bd7035
Commit
05bd7035
authored
1 year ago
by
shishir suman
Browse files
Options
Download
Patches
Plain Diff
adding API to get all config
parent
43a729c9
shishir_ticket_statistics_by_user
UAT
UPHRH_7903_mobile_otp
UPHRH_quartz_scheduler
shishir_dynamic_schedular
2 merge requests
!39
Uphrh 7903 mobile otp
,
!37
adding API to get all config
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/main/java/org/upsmf/grievance/controller/SchedulerConfigController.java
+8
-6
...upsmf/grievance/controller/SchedulerConfigController.java
src/main/java/org/upsmf/grievance/dto/MailConfigDto.java
+2
-4
src/main/java/org/upsmf/grievance/dto/MailConfigDto.java
src/main/java/org/upsmf/grievance/model/MailConfig.java
+2
-0
src/main/java/org/upsmf/grievance/model/MailConfig.java
src/main/java/org/upsmf/grievance/service/SchedulerConfigService.java
+4
-2
...a/org/upsmf/grievance/service/SchedulerConfigService.java
src/main/java/org/upsmf/grievance/service/impl/SchedulerConfigServiceImpl.java
+32
-20
...mf/grievance/service/impl/SchedulerConfigServiceImpl.java
with
48 additions
and
32 deletions
+48
-32
src/main/java/org/upsmf/grievance/controller/SchedulerConfigController.java
+
8
−
6
View file @
05bd7035
...
...
@@ -15,6 +15,8 @@ import org.upsmf.grievance.model.reponse.Response;
import
org.upsmf.grievance.service.SchedulerConfigService
;
import
org.upsmf.grievance.util.ErrorCode
;
import
java.util.List
;
@Slf4j
@Controller
@RequestMapping
(
"/api/config/mail"
)
...
...
@@ -65,10 +67,10 @@ public class SchedulerConfigController {
}
}
@PostMapping
(
"/
activate/{id}
"
)
public
ResponseEntity
activateMailConfig
(
@
PathVariable
(
"id"
)
long
id
,
@RequestParam
Long
userId
)
{
@PostMapping
(
"/
status/update
"
)
public
ResponseEntity
activateMailConfig
(
@
RequestParam
Long
id
,
@RequestParam
Boolean
active
,
@RequestParam
Long
userId
)
{
try
{
MailConfigDto
mailConfig
=
schedulerConfigService
.
activateConfigById
(
id
,
userId
);
MailConfigDto
mailConfig
=
schedulerConfigService
.
activateConfigById
(
id
,
active
,
userId
);
return
new
ResponseEntity
(
new
Response
(
HttpStatus
.
OK
.
value
(),
mailConfig
),
HttpStatus
.
OK
);
}
catch
(
CustomException
e
)
{
log
.
error
(
"Error in while creating user - at controller"
);
...
...
@@ -79,10 +81,10 @@ public class SchedulerConfigController {
}
}
@
Pos
tMapping
(
"/
deactivate/{id}
"
)
public
ResponseEntity
deactivate
MailConfig
(
@PathVariable
(
"id"
)
long
id
,
@RequestParam
Long
userId
)
{
@
Ge
tMapping
(
"/
all
"
)
public
ResponseEntity
getAll
MailConfig
()
{
try
{
MailConfigDto
mailConfig
=
schedulerConfigService
.
deactivateConfigById
(
id
,
userId
);
List
<
MailConfigDto
>
mailConfig
=
schedulerConfigService
.
getAll
(
);
return
new
ResponseEntity
(
new
Response
(
HttpStatus
.
OK
.
value
(),
mailConfig
),
HttpStatus
.
OK
);
}
catch
(
CustomException
e
)
{
log
.
error
(
"Error in while creating user - at controller"
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/upsmf/grievance/dto/MailConfigDto.java
+
2
−
4
View file @
05bd7035
package
org.upsmf.grievance.dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.*
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.upsmf.grievance.model.MailConfig
;
...
...
@@ -13,6 +10,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Builder
public
class
MailConfigDto
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/upsmf/grievance/model/MailConfig.java
+
2
−
0
View file @
05bd7035
...
...
@@ -3,6 +3,7 @@ package org.upsmf.grievance.model;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.commons.lang.StringUtils
;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.UpdateTimestamp
;
...
...
@@ -14,6 +15,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Table
(
name
=
"mail_config"
)
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/upsmf/grievance/service/SchedulerConfigService.java
+
4
−
2
View file @
05bd7035
...
...
@@ -4,6 +4,8 @@ import org.upsmf.grievance.dto.MailConfigDto;
import
org.upsmf.grievance.dto.SearchMailConfigDto
;
import
org.upsmf.grievance.dto.SearchMailConfigResponseDto
;
import
java.util.List
;
public
interface
SchedulerConfigService
{
SearchMailConfigResponseDto
searchMailConfig
(
SearchMailConfigDto
searchMailConfigDto
);
...
...
@@ -12,7 +14,7 @@ public interface SchedulerConfigService {
MailConfigDto
update
(
MailConfigDto
mailConfigDto
);
MailConfigDto
activateConfigById
(
Long
id
,
Long
userId
);
MailConfigDto
activateConfigById
(
Long
id
,
Boolean
active
,
Long
userId
);
MailConfigDto
deactivateConfigById
(
Long
id
,
Long
userId
);
List
<
MailConfigDto
>
getAll
(
);
}
This diff is collapsed.
Click to expand it.
src/main/java/org/upsmf/grievance/service/impl/SchedulerConfigServiceImpl.java
+
32
−
20
View file @
05bd7035
...
...
@@ -14,6 +14,9 @@ import org.upsmf.grievance.service.SchedulerConfigService;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Optional
;
@Service
...
...
@@ -44,7 +47,7 @@ public class SchedulerConfigServiceImpl implements SchedulerConfigService {
if
(
mailConfigDto
==
null
)
{
throw
new
InvalidRequestException
(
"Invalid Request"
);
}
if
(
mailConfigDto
.
getId
()
!=
null
||
mailConfigDto
.
getId
()
>
0
)
{
if
(
mailConfigDto
.
getId
()
!=
null
&&
mailConfigDto
.
getId
()
>
0
)
{
throw
new
InvalidRequestException
(
"Invalid Request"
);
}
if
(
mailConfigDto
.
getAuthorityEmails
()
==
null
||
mailConfigDto
.
getAuthorityEmails
().
isEmpty
())
{
...
...
@@ -83,20 +86,38 @@ public class SchedulerConfigServiceImpl implements SchedulerConfigService {
}
private
void
validateUpdatePayload
(
MailConfigDto
mailConfigDto
)
{
if
(
mailConfigDto
==
null
)
{
throw
new
InvalidRequestException
(
"Invalid Request"
);
}
if
(
mailConfigDto
.
getId
()
==
null
||
mailConfigDto
.
getId
()
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid Request"
);
}
if
(
mailConfigDto
.
getAuthorityEmails
()
!=
null
&&
mailConfigDto
.
getAuthorityEmails
().
isEmpty
())
{
throw
new
InvalidRequestException
(
"Missing Authority Emails"
);
}
if
(
mailConfigDto
.
getConfigValue
()
==
null
||
mailConfigDto
.
getConfigValue
()
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid Configuration value"
);
}
if
(
mailConfigDto
.
getUpdatedBy
()
==
null
||
mailConfigDto
.
getUpdatedBy
()
<=
0
)
{
throw
new
InvalidRequestException
(
"Missing user details"
);
}
}
@Override
public
MailConfigDto
activateConfigById
(
Long
id
,
Long
userId
)
{
public
MailConfigDto
activateConfigById
(
Long
id
,
Boolean
active
,
Long
userId
)
{
if
(
id
==
null
||
id
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid request"
);
}
if
(
userId
==
null
||
userId
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid request"
);
}
if
(
active
==
null
)
{
active
=
true
;
}
Optional
<
MailConfig
>
configById
=
mailConfigRepository
.
findById
(
id
);
if
(
configById
.
isPresent
())
{
MailConfig
existingConfig
=
configById
.
get
();
existingConfig
.
setActive
(
true
);
existingConfig
.
setActive
(
active
.
booleanValue
()
);
existingConfig
.
setUpdatedBy
(
userId
);
existingConfig
.
setUpdatedDate
(
Timestamp
.
valueOf
(
LocalDateTime
.
now
()));
existingConfig
=
mailConfigRepository
.
save
(
existingConfig
);
...
...
@@ -107,23 +128,14 @@ public class SchedulerConfigServiceImpl implements SchedulerConfigService {
}
@Override
public
MailConfigDto
deactivateConfigById
(
Long
id
,
Long
userId
)
{
if
(
id
==
null
||
id
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid request"
);
}
if
(
userId
==
null
||
userId
<=
0
)
{
throw
new
InvalidRequestException
(
"Invalid request"
);
}
Optional
<
MailConfig
>
configById
=
mailConfigRepository
.
findById
(
id
);
if
(
configById
.
isPresent
())
{
MailConfig
existingConfig
=
configById
.
get
();
existingConfig
.
setActive
(
false
);
existingConfig
.
setUpdatedBy
(
userId
);
existingConfig
.
setUpdatedDate
(
Timestamp
.
valueOf
(
LocalDateTime
.
now
()));
existingConfig
=
mailConfigRepository
.
save
(
existingConfig
);
// TODO stop scheduledTaskExecutor
return
new
MailConfigDto
(
existingConfig
);
public
List
<
MailConfigDto
>
getAll
()
{
Iterable
<
MailConfig
>
configIterable
=
mailConfigRepository
.
findAll
();
List
<
MailConfigDto
>
configs
=
new
ArrayList
<>();
Iterator
<
MailConfig
>
iterator
=
configIterable
.
iterator
();
while
(
iterator
.
hasNext
())
{
MailConfig
mailConfig
=
iterator
.
next
();
configs
.
add
(
new
MailConfigDto
(
mailConfig
));
}
throw
new
SchedulerConfigException
(
"Unable to deactivate configuration"
)
;
return
configs
;
}
}
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