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
8dc94187
Commit
8dc94187
authored
Apr 06, 2020
by
Kali Padhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added EndofSale Database logic
parent
e3199ff0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
15 deletions
+59
-15
build.gradle
build.gradle
+6
-1
readme.md
readme.md
+22
-0
OfferTransactionController.java
...sactionservice/controller/OfferTransactionController.java
+2
-1
EndOfSaleEntity.java
.../nisum/offertransactionservice/model/EndOfSaleEntity.java
+16
-9
EndOfSaleService.java
...sum/offertransactionservice/service/EndOfSaleService.java
+12
-3
application.properties
src/main/resources/application.properties
+1
-1
No files found.
build.gradle
View file @
8dc94187
...
...
@@ -16,7 +16,7 @@ configurations {
repositories
{
flatDir
{
dirs
'C:\\Users\\
sgan
dhi\\.m2\\repository\\com\\nisum\\exceptionservice\\0.0.1'
dirs
'C:\\Users\\
kpa
dhi\\.m2\\repository\\com\\nisum\\exceptionservice\\0.0.1'
}
mavenCentral
()
}
...
...
@@ -32,6 +32,11 @@ dependencies {
annotationProcessor
'org.projectlombok:lombok'
testImplementation
(
'org.springframework.boot:spring-boot-starter-test'
)
compile
'com.nisum:exceptionservice:0.0.1'
// https://mvnrepository.com/artifact/org.codehaus.jackson/jackson-mapper-asl
compile
group:
'org.codehaus.jackson'
,
name:
'jackson-mapper-asl'
,
version:
'1.9.0'
// https://mvnrepository.com/artifact/com.vladmihalcea/hibernate-types-parent
compile
'com.vladmihalcea:hibernate-types-52:2.0.0'
implementation
group:
'junit'
,
name:
'junit'
,
version:
'4.12'
testImplementation
(
'org.springframework.boot:spring-boot-starter-test'
)
testImplementation
group:
'org.springframework.boot'
,
name:
'spring-boot-starter-test'
,
version:
'2.0.3.RELEASE'
...
...
readme.md
View file @
8dc94187
...
...
@@ -57,6 +57,28 @@ INSERT INTO public.offerlookup(
VALUES ('1234567890','0001','002','UPC','01','AND');
Create a table for end of sale
==============================
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TABLE endofsale(
uuid uuid NOT NULL DEFAULT uuid_generate_v1(),
offertransactionresponse jsonb NOT NULL,
offers jsonb NOT NULL
);
dummy data
==========
INSERT INTO endofsale VALUES ( uuid_generate_v4() ,
'{"name": "Paint house", "tags":
[
"Improvements", "Office"
]
, "finished": true}',
'{"name": "Paint house", "tags":
[
"Improvements", "Office"
]
, "finished": true}' );
...
...
src/main/java/com/nisum/offertransactionservice/controller/OfferTransactionController.java
View file @
8dc94187
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.io.IOException
;
import
java.util.UUID
;
@RestController
...
...
@@ -32,7 +33,7 @@ public class OfferTransactionController {
@PostMapping
(
"endOfSale"
)
public
ResponseEntity
<
String
>
endOfSale
(
@Valid
@RequestBody
EndOfSaleReq
endOfSaleReq
)
{
public
ResponseEntity
<
String
>
endOfSale
(
@Valid
@RequestBody
EndOfSaleReq
endOfSaleReq
)
throws
IOException
{
UUID
uuid
=
endOfSaleService
.
putEndofSaleResInDb
(
endOfSaleReq
);
return
new
ResponseEntity
<
String
>(
uuid
.
toString
(),
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/offertransactionservice/model/EndOfSaleEntity.java
View file @
8dc94187
package
com
.
nisum
.
offertransactionservice
.
model
;
import
com.vladmihalcea.hibernate.type.json.JsonBinaryType
;
import
lombok.AccessLevel
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.FieldDefaults
;
import
org.hibernate.annotations.Type
;
import
org.hibernate.annotations.TypeDef
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
...
...
@@ -19,21 +22,25 @@ import java.util.UUID;
@FieldDefaults
(
level
=
AccessLevel
.
PRIVATE
,
makeFinal
=
false
)
@Entity
@Table
(
name
=
"endofsale"
)
@TypeDef
(
name
=
"jsonb"
,
typeClass
=
JsonBinaryType
.
class
)
public
class
EndOfSaleEntity
{
@Id
@Column
(
name
=
"uuid"
)
UUID
uuid
;
/*
*
* offerTransaction Response and offers
* Can we put these data in JSON_PAYLOAD
*
*
* */
@Type
(
type
=
"jsonb"
)
@Column
(
name
=
"offertransactionresponse"
)
String
offerTransactionResponse
;
OfferTransactionResponse
offerTransactionResponse
;
//OfferTransactionResponse offerTransactionResponse;
@Type
(
type
=
"jsonb"
)
@Column
(
name
=
"offers"
)
List
<
OfferLookup
>
offers
;
String
offers
;
//List<OfferLookup> offers;
}
src/main/java/com/nisum/offertransactionservice/service/EndOfSaleService.java
View file @
8dc94187
...
...
@@ -4,9 +4,11 @@ import com.nisum.offertransactionservice.dao.EndOfSaleRepo;
import
com.nisum.offertransactionservice.model.EndOfSaleReq
;
import
com.nisum.offertransactionservice.model.EndOfSaleEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.util.UUID
;
@Service
...
...
@@ -16,10 +18,17 @@ public class EndOfSaleService {
@Autowired
private
EndOfSaleRepo
endOfSaleRepo
;
public
UUID
putEndofSaleResInDb
(
EndOfSaleReq
endOfSaleReq
){
public
UUID
putEndofSaleResInDb
(
EndOfSaleReq
endOfSaleReq
)
throws
IOException
{
ObjectMapper
mapper
=
new
ObjectMapper
();
String
offerTransactionResponseJson
=
mapper
.
writeValueAsString
(
endOfSaleReq
.
getOfferTransactionResponse
());
String
offersJosn
=
mapper
.
writeValueAsString
(
endOfSaleReq
.
getOffers
());
EndOfSaleEntity
endOfSaleEntity
=
new
EndOfSaleEntity
();
endOfSaleEntity
.
setOfferTransactionResponse
(
endOfSaleReq
.
getOfferTransactionResponse
()
);
endOfSaleEntity
.
setOffers
(
endOfSaleReq
.
getOffers
()
);
endOfSaleEntity
.
setOfferTransactionResponse
(
offerTransactionResponseJson
);
endOfSaleEntity
.
setOffers
(
offersJosn
);
endOfSaleEntity
.
setUuid
(
UUID
.
randomUUID
());
endOfSaleRepo
.
save
(
endOfSaleEntity
);
return
endOfSaleEntity
.
getUuid
();
...
...
src/main/resources/application.properties
View file @
8dc94187
spring.datasource.url
=
jdbc:postgresql://127.0.0.1:5432/
user
spring.datasource.url
=
jdbc:postgresql://127.0.0.1:5432/
postgres
spring.datasource.username
=
user
spring.datasource.password
=
password123
promotion.engine.calculate.discount.url
=
/promotionEngine/calculateDiscount
...
...
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