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
userManagement
Commits
6f421cbd
Commit
6f421cbd
authored
1 year ago
by
Mahesh Maney R
Browse files
Options
Download
Patches
Plain Diff
payment gateway <ManeyMR>.
parent
719b8311
main
UAT_quick_fix_keycloak
UPHRH_8164_ErrorHandling
dev
dev_stable
devops-patch
feature_update_fee
payment-webhook
rahu_error_message_fix
uat
No related merge requests found
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
pom.xml
+12
-0
pom.xml
src/main/java/com/tarento/upsmf/userManagement/controller/UserController.java
+12
-0
...rento/upsmf/userManagement/controller/UserController.java
src/main/java/com/tarento/upsmf/userManagement/model/Course.java
+38
-0
...n/java/com/tarento/upsmf/userManagement/model/Course.java
src/main/java/com/tarento/upsmf/userManagement/model/Exam.java
+48
-0
...ain/java/com/tarento/upsmf/userManagement/model/Exam.java
src/main/java/com/tarento/upsmf/userManagement/model/Institute.java
+33
-0
...ava/com/tarento/upsmf/userManagement/model/Institute.java
src/main/java/com/tarento/upsmf/userManagement/model/Payment.java
+33
-0
.../java/com/tarento/upsmf/userManagement/model/Payment.java
src/main/java/com/tarento/upsmf/userManagement/model/ResponseDto.java
+92
-0
...a/com/tarento/upsmf/userManagement/model/ResponseDto.java
src/main/java/com/tarento/upsmf/userManagement/model/ResponseParams.java
+50
-0
...om/tarento/upsmf/userManagement/model/ResponseParams.java
src/main/java/com/tarento/upsmf/userManagement/services/PaymentService.java
+10
-0
...tarento/upsmf/userManagement/services/PaymentService.java
src/main/java/com/tarento/upsmf/userManagement/services/impl/PaymentServiceImpl.java
+44
-0
...psmf/userManagement/services/impl/PaymentServiceImpl.java
src/main/java/repository/PaymentRepository.java
+15
-0
src/main/java/repository/PaymentRepository.java
with
387 additions
and
0 deletions
+387
-0
pom.xml
+
12
−
0
View file @
6f421cbd
...
@@ -95,6 +95,18 @@
...
@@ -95,6 +95,18 @@
<version>
21.1.2
</version>
<version>
21.1.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
jakarta.persistence
</groupId>
<artifactId>
jakarta.persistence-api
</artifactId>
<version>
2.2.3
</version>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-jpa
</artifactId>
<version>
2.7.14
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/controller/UserController.java
+
12
−
0
View file @
6f421cbd
...
@@ -2,6 +2,9 @@ package com.tarento.upsmf.userManagement.controller;
...
@@ -2,6 +2,9 @@ package com.tarento.upsmf.userManagement.controller;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.tarento.upsmf.userManagement.handler.UserHandler
;
import
com.tarento.upsmf.userManagement.handler.UserHandler
;
import
com.tarento.upsmf.userManagement.model.Payment
;
import
com.tarento.upsmf.userManagement.model.ResponseDto
;
import
com.tarento.upsmf.userManagement.services.PaymentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -13,6 +16,9 @@ import java.net.URISyntaxException;
...
@@ -13,6 +16,9 @@ import java.net.URISyntaxException;
@RequestMapping
(
value
=
"/api/v1/user"
)
@RequestMapping
(
value
=
"/api/v1/user"
)
public
class
UserController
{
public
class
UserController
{
@Autowired
PaymentService
paymentService
;
@Autowired
@Autowired
private
UserHandler
userHandler
;
private
UserHandler
userHandler
;
...
@@ -61,4 +67,10 @@ public class UserController {
...
@@ -61,4 +67,10 @@ public class UserController {
return
userHandler
.
login
(
body
);
return
userHandler
.
login
(
body
);
}
}
@PostMapping
(
value
=
"/payment"
)
public
ResponseEntity
<?>
payment
(
@RequestBody
Payment
payment
){
ResponseDto
response
=
paymentService
.
makePayment
(
payment
);
return
new
ResponseEntity
<>(
response
,
response
.
getResponseCode
());
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/Course.java
0 → 100644
+
38
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonManagedReference
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.util.List
;
@Entity
@Table
(
name
=
"course"
)
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Builder
public
class
Course
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
private
String
courseCode
;
private
String
courseName
;
private
String
description
;
@ManyToOne
@JoinColumn
(
name
=
"institute_id"
)
@JsonIgnore
private
Institute
institute
;
@OneToMany
(
mappedBy
=
"course"
)
@JsonIgnore
private
List
<
Exam
>
exams
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/Exam.java
0 → 100644
+
48
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
@Entity
@Table
(
name
=
"exam"
)
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Builder
public
class
Exam
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"exam_cycle_id"
)
private
Long
examCycleId
;
// Link to the ExamCycle entity
@Column
(
name
=
"exam_date"
)
private
LocalDate
examDate
;
@Column
(
name
=
"created_by"
)
private
String
createdBy
;
@Column
(
name
=
"created_on"
)
private
LocalDateTime
createdOn
;
@Column
(
name
=
"modified_by"
)
private
String
modifiedBy
;
@Column
(
name
=
"modified_on"
)
private
LocalDateTime
modifiedOn
;
@ManyToOne
@JoinColumn
(
name
=
"course_id"
)
private
Course
course
;
@Column
(
name
=
"obsolete"
,
nullable
=
false
,
columnDefinition
=
"int default 0"
)
private
Integer
obsolete
=
0
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/Institute.java
0 → 100644
+
33
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
import
com.fasterxml.jackson.annotation.JsonBackReference
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonManagedReference
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.util.List
;
@Entity
@Table
(
name
=
"institute"
)
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Builder
public
class
Institute
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
private
String
instituteName
;
private
String
instituteCode
;
private
String
address
;
@OneToMany
(
mappedBy
=
"institute"
)
@JsonIgnore
private
List
<
Course
>
courses
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/Payment.java
0 → 100644
+
33
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
import
lombok.*
;
import
javax.persistence.*
;
import
javax.persistence.OneToMany.*
;
import
java.util.List
;
@Entity
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
(
includeFieldNames
=
true
)
@Builder
@Table
(
name
=
"payment"
)
public
class
Payment
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
feeId
;
private
String
fullName
;
@OneToMany
(
cascade
=
CascadeType
.
ALL
,
orphanRemoval
=
true
)
@JoinColumn
(
name
=
"fee_id"
)
private
List
<
Exam
>
exams
;
private
Integer
noOfExams
;
private
Integer
feeAmount
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/ResponseDto.java
0 → 100644
+
92
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
import
java.sql.Timestamp
;
import
java.util.HashMap
;
import
java.util.Map
;
import
lombok.Getter
;
import
org.springframework.http.HttpStatus
;
public
class
ResponseDto
{
private
String
id
;
private
String
ver
;
@Getter
private
String
ts
;
private
ResponseParams
params
;
private
HttpStatus
responseCode
;
private
transient
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
public
ResponseDto
()
{
this
.
ver
=
"v1"
;
this
.
ts
=
String
.
valueOf
(
new
Timestamp
(
System
.
currentTimeMillis
()));
this
.
params
=
new
ResponseParams
();
}
public
ResponseDto
(
String
id
)
{
this
();
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getVer
()
{
return
ver
;
}
public
void
setVer
(
String
ver
)
{
this
.
ver
=
ver
;
}
public
void
setTs
(
String
ts
)
{
this
.
ts
=
ts
;
}
public
ResponseParams
getParams
()
{
return
params
;
}
public
void
setParams
(
ResponseParams
params
)
{
this
.
params
=
params
;
}
public
HttpStatus
getResponseCode
()
{
return
responseCode
;
}
public
void
setResponseCode
(
HttpStatus
responseCode
)
{
this
.
responseCode
=
responseCode
;
}
public
Map
<
String
,
Object
>
getResult
()
{
return
response
;
}
public
void
setResult
(
Map
<
String
,
Object
>
result
)
{
response
=
result
;
}
public
Object
get
(
String
key
)
{
return
response
.
get
(
key
);
}
public
void
put
(
String
key
,
Object
vo
)
{
response
.
put
(
key
,
vo
);
}
public
void
putAll
(
Map
<
String
,
Object
>
map
)
{
response
.
putAll
(
map
);
}
public
boolean
containsKey
(
String
key
)
{
return
response
.
containsKey
(
key
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/model/ResponseParams.java
0 → 100644
+
50
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.model
;
public
class
ResponseParams
{
private
String
resmsgid
;
private
String
msgid
;
private
String
err
;
private
String
status
;
private
String
errmsg
;
public
String
getResmsgid
()
{
return
resmsgid
;
}
public
void
setResmsgid
(
String
resmsgid
)
{
this
.
resmsgid
=
resmsgid
;
}
public
String
getMsgid
()
{
return
msgid
;
}
public
void
setMsgid
(
String
msgid
)
{
this
.
msgid
=
msgid
;
}
public
String
getErr
()
{
return
err
;
}
public
void
setErr
(
String
err
)
{
this
.
err
=
err
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getErrmsg
()
{
return
errmsg
;
}
public
void
setErrmsg
(
String
errmsg
)
{
this
.
errmsg
=
errmsg
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/services/PaymentService.java
0 → 100644
+
10
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.services
;
import
com.tarento.upsmf.userManagement.model.Payment
;
import
com.tarento.upsmf.userManagement.model.ResponseDto
;
import
org.springframework.stereotype.Service
;
@Service
public
interface
PaymentService
{
public
ResponseDto
makePayment
(
Payment
payment
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/tarento/upsmf/userManagement/services/impl/PaymentServiceImpl.java
0 → 100644
+
44
−
0
View file @
6f421cbd
package
com.tarento.upsmf.userManagement.services.impl
;
import
com.tarento.upsmf.userManagement.model.Payment
;
import
com.tarento.upsmf.userManagement.model.ResponseDto
;
import
com.tarento.upsmf.userManagement.services.PaymentService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Service
;
import
repository.PaymentRepository
;
@Service
public
class
PaymentServiceImpl
implements
PaymentService
{
@Autowired
PaymentRepository
paymentRepository
;
@Override
public
ResponseDto
makePayment
(
Payment
payment
)
{
ResponseDto
response
=
new
ResponseDto
(
"api.payment.make"
);
// Calculate noOfExams based on the number of selected options
int
noOfExams
=
payment
.
getExams
().
size
();
// Calculate the fee amount based on noOfExams and exam fee amount (replace with actual fee calculation)
int
examFeeAmount
=
100
;
// Example exam fee amount
int
feeAmount
=
calculateFee
(
noOfExams
,
examFeeAmount
);
// Set the calculated values in the FeeManage object
payment
.
setNoOfExams
(
noOfExams
);
payment
.
setFeeAmount
(
feeAmount
);
// Save the FeeManage object
try
{
Payment
result
=
paymentRepository
.
save
(
payment
);
response
.
put
(
"message"
,
"Success"
);
response
.
put
(
"response"
,
"Created."
);
response
.
setResponseCode
(
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
response
.
put
(
"message"
,
"Error saving fee details"
);
response
.
put
(
"response"
,
"Failed to create a message"
);
response
.
setResponseCode
(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
return
response
;
}
public
Integer
calculateFee
(
Integer
noOfExams
,
Integer
examFeeAmount
)
{
return
noOfExams
*
examFeeAmount
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/repository/PaymentRepository.java
0 → 100644
+
15
−
0
View file @
6f421cbd
package
repository
;
import
com.tarento.upsmf.userManagement.model.Payment
;
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
java.util.Optional
;
@Repository
public
interface
PaymentRepository
extends
JpaRepository
<
Payment
,
Integer
>
{
@Query
(
value
=
"SELECT * FROM fee_details f LEFT JOIN exam_details e ON f.fee_id = e.fee_id WHERE f.fee_id = :id"
,
nativeQuery
=
true
)
Optional
<
Payment
>
findByIdWithExamsNative
(
@Param
(
"id"
)
Integer
id
);
}
\ No newline at end of file
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