Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OTSWithFeign
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
Siva Naga Someswara Jatla
OTSWithFeign
Commits
75ce3730
Commit
75ce3730
authored
Apr 22, 2020
by
Kali Padhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sonar issue resolved
parent
10d431e4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
28 deletions
+39
-28
OfferTransactionController.java
...sactionservice/controller/OfferTransactionController.java
+1
-1
OfferConvertion.java
...um/offertransactionservice/converter/OfferConvertion.java
+1
-2
GlobalApiGenericException.java
...onservice/genericexception/GlobalApiGenericException.java
+26
-17
OfferCallingPEService.java
...ffertransactionservice/service/OfferCallingPEService.java
+7
-4
ExceptionUtil.java
...com/nisum/offertransactionservice/util/ExceptionUtil.java
+1
-1
application.properties
src/main/resources/application.properties
+3
-3
No files found.
src/main/java/com/nisum/offertransactionservice/controller/OfferTransactionController.java
View file @
75ce3730
...
...
@@ -31,7 +31,7 @@ public class OfferTransactionController {
private
EndOfTransactionService
endOfTransactionService
;
@PostMapping
(
"offerTransactionCall"
)
public
OfferTransactionResponse
getOfferTransactionResponse
(
@Valid
@RequestBody
OfferTransactionRequest
offerTransactionRequest
)
throws
InterruptedException
{
public
OfferTransactionResponse
getOfferTransactionResponse
(
@Valid
@RequestBody
OfferTransactionRequest
offerTransactionRequest
)
{
MDC
.
put
(
SWY_RES_UNIQUE_UUID
,
String
.
valueOf
(
offerTransactionRequest
.
getHhId
()));
MDC
.
put
(
USER_ID
,
String
.
valueOf
(
offerTransactionRequest
.
getHhId
()));
return
offerCallingPEService
.
getDiscountedItemList
(
offerTransactionRequest
);
...
...
src/main/java/com/nisum/offertransactionservice/converter/OfferConvertion.java
View file @
75ce3730
...
...
@@ -4,12 +4,11 @@ import com.nisum.offertransactionservice.dto.*;
import
com.nisum.offertransactionservice.model.OfferLookup
;
import
com.nisum.offertransactionservice.model.OfferMeta
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
OfferConvertion
{
OfferConvertion
INSTANCE
=
Mappers
.
getMapper
(
OfferConvertion
.
class
);
OfferTransactionResponse
map
(
PEResponse
peResponse
);
...
...
src/main/java/com/nisum/offertransactionservice/genericexception/GlobalApiGenericException.java
View file @
75ce3730
...
...
@@ -7,53 +7,62 @@ public class GlobalApiGenericException extends RuntimeException {
private
static
final
long
serialVersionUID
=
-
3841677326659278730L
;
private
String
statusCode
;
private
final
String
statusCode
;
private
boolean
isHttpError
;
private
final
boolean
isHttpError
;
private
Response
response
;
private
final
Response
response
;
public
GlobalApiGenericException
(
String
statusCode
,
boolean
isHttpError
,
Response
response
)
{
this
.
statusCode
=
statusCode
;
this
.
isHttpError
=
isHttpError
;
this
.
response
=
response
;
}
public
GlobalApiGenericException
()
{
this
.
statusCode
=
""
;
this
.
isHttpError
=
false
;
this
.
response
=
null
;
}
public
GlobalApiGenericException
(
final
Response
response
,
final
String
statusCode
){
this
.
response
=
response
;
this
.
statusCode
=
statusCode
;
this
.
isHttpError
=
false
;
}
public
GlobalApiGenericException
(
Response
response
,
String
statusCode
){
public
GlobalApiGenericException
(
final
Response
response
,
final
String
statusCode
,
final
boolean
isHttpError
){
this
.
response
=
response
;
this
.
statusCode
=
statusCode
;
this
.
isHttpError
=
isHttpError
;
}
public
GlobalApiGenericException
(
String
debugMessage
){
public
GlobalApiGenericException
(
final
String
debugMessage
,
boolean
isHttpError
){
this
.
statusCode
=
debugMessage
;
this
.
isHttpError
=
isHttpError
;
this
.
response
=
null
;
}
public
GlobalApiGenericException
(
String
debugMessage
,
Throwable
ex
,
String
statuCode
,
boolean
isHttpError
)
{
public
GlobalApiGenericException
(
final
String
debugMessage
,
final
Throwable
ex
,
final
String
statuCode
,
final
boolean
isHttpError
)
{
super
(
debugMessage
,
ex
);
this
.
statusCode
=
statuCode
;
this
.
isHttpError
=
isHttpError
;
this
.
response
=
null
;
}
public
String
getStatusCode
()
{
return
statusCode
;
}
public
void
setStatusCode
(
String
statusCode
)
{
this
.
statusCode
=
statusCode
;
}
public
boolean
isHttpError
()
{
return
isHttpError
;
}
public
void
setHttpError
(
boolean
httpError
)
{
isHttpError
=
httpError
;
}
public
Response
getResponse
()
{
return
response
;
}
public
void
setResponse
(
Response
response
)
{
this
.
response
=
response
;
}
}
src/main/java/com/nisum/offertransactionservice/service/OfferCallingPEService.java
View file @
75ce3730
...
...
@@ -9,6 +9,7 @@ import com.nisum.offertransactionservice.dto.*;
import
com.nisum.offertransactionservice.genericexception.GlobalApiGenericException
;
import
com.nisum.offertransactionservice.model.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.mapstruct.factory.Mappers
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Service
;
...
...
@@ -22,6 +23,8 @@ import java.util.stream.Collectors;
@Slf4j
public
class
OfferCallingPEService
{
OfferConvertion
INSTANCE
=
Mappers
.
getMapper
(
OfferConvertion
.
class
);
@Autowired
private
OfferLookupRepo
offerLookupRepo
;
...
...
@@ -44,12 +47,12 @@ public class OfferCallingPEService {
}
log
.
debug
(
"Offer lookup Object {}"
,
offerLookupRepo
);
OfferTransactionResponse
offerTransactionResponse
;
PERequest
peRequest
=
OfferConvertion
.
INSTANCE
.
map
(
offerTransactionRequest
);
PERequest
peRequest
=
INSTANCE
.
map
(
offerTransactionRequest
);
peRequest
.
setEligibleOffers
(
offerLookupDTOList
);
log
.
info
(
"Promotional Engine WebClient call Start"
);
PEResponse
peResponseFlux
=
clientService
.
getPeResponseFlux
(
peRequest
);
log
.
debug
(
"Promotional Engine WebClient call End"
);
offerTransactionResponse
=
OfferConvertion
.
INSTANCE
.
map
(
peResponseFlux
);
offerTransactionResponse
=
INSTANCE
.
map
(
peResponseFlux
);
offerTransactionResponse
.
setTransactionId
(
offerTransactionRequest
.
getTransactionId
());
log
.
debug
(
"Offer Transaction Response {}"
,
offerTransactionResponse
);
return
offerTransactionResponse
;
...
...
@@ -63,8 +66,8 @@ public class OfferCallingPEService {
findByOfferIdAndOfferStatusIgnoreCase
(
offer
.
getOfferId
(),
"ACTIVE"
);
if
(
optionalOfferMeta
.
isPresent
()){
OfferMetaDTO
offerMetaDTO
=
OfferConvertion
.
INSTANCE
.
map
(
optionalOfferMeta
.
get
());
OfferLookupDTO
offerLookupDTO
=
OfferConvertion
.
INSTANCE
.
map
(
offer
);
OfferMetaDTO
offerMetaDTO
=
INSTANCE
.
map
(
optionalOfferMeta
.
get
());
OfferLookupDTO
offerLookupDTO
=
INSTANCE
.
map
(
offer
);
offerLookupDTO
.
setOfferMetaDTO
(
offerMetaDTO
);
return
offerLookupDTO
;
}
...
...
src/main/java/com/nisum/offertransactionservice/util/ExceptionUtil.java
View file @
75ce3730
...
...
@@ -11,7 +11,7 @@ import reactor.core.publisher.Mono;
public
class
ExceptionUtil
{
private
ExceptionUtil
(){
throw
new
GlobalApiGenericException
();
throw
new
GlobalApiGenericException
();
}
public
static
Mono
<
Throwable
>
handleError
(
ClientResponse
clientResponse
)
{
...
...
src/main/resources/application.properties
View file @
75ce3730
spring.datasource.url
=
jdbc:postgresql://127.0.0.1:5432/
postgres
spring.datasource.username
=
user
spring.datasource.password
=
password123
spring.datasource.url
=
jdbc:postgresql://127.0.0.1:5432/
storedb
spring.datasource.username
=
postgres
spring.datasource.password
=
dbpwd
endpoint.url.promotionEngineUrl
=
/promotionEngine/calculateDiscount
endpoint.url.peBaseUrl
=
http://localhost:7073
endpoint.url.storeProducerUrl
=
/store/producer
...
...
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