20
20
21
21
import io .swagger .v3 .oas .annotations .Operation ;
22
22
import io .swagger .v3 .oas .annotations .Parameter ;
23
- import io .swagger .v3 .oas .annotations .media .ArraySchema ;
24
23
import io .swagger .v3 .oas .annotations .media .Content ;
25
24
import io .swagger .v3 .oas .annotations .media .Schema ;
26
25
import io .swagger .v3 .oas .annotations .parameters .RequestBody ;
35
34
import jakarta .ws .rs .Path ;
36
35
import jakarta .ws .rs .PathParam ;
37
36
import jakarta .ws .rs .Produces ;
38
- import jakarta .ws .rs .core .Context ;
39
37
import jakarta .ws .rs .core .MediaType ;
40
- import jakarta .ws .rs .core .UriInfo ;
41
- import java .util .Collection ;
38
+ import java .util .List ;
42
39
import lombok .RequiredArgsConstructor ;
43
40
import org .apache .fineract .commands .domain .CommandWrapper ;
44
41
import org .apache .fineract .commands .service .CommandWrapperBuilder ;
49
46
import org .apache .fineract .organisation .monetary .data .CurrencyData ;
50
47
import org .apache .fineract .organisation .monetary .service .CurrencyReadPlatformService ;
51
48
import org .apache .fineract .portfolio .collateralmanagement .data .CollateralManagementData ;
49
+ import org .apache .fineract .portfolio .collateralmanagement .data .CollateralManagementProductRequest ;
50
+ import org .apache .fineract .portfolio .collateralmanagement .data .CollateralProductRequest ;
52
51
import org .apache .fineract .portfolio .collateralmanagement .service .CollateralManagementReadPlatformService ;
53
52
import org .springframework .stereotype .Component ;
54
53
@@ -69,76 +68,64 @@ public class CollateralManagementApiResource {
69
68
@ Consumes ({ MediaType .APPLICATION_JSON })
70
69
@ Produces ({ MediaType .APPLICATION_JSON })
71
70
@ Operation (summary = "Create a new collateral" , description = "Collateral Creation" )
72
- @ RequestBody (required = true , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger . PostCollateralManagementProductRequest .class )))
71
+ @ RequestBody (required = true , content = @ Content (schema = @ Schema (implementation = CollateralManagementProductRequest .class )))
73
72
@ ApiResponses ({
74
73
@ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .PostCollateralManagementProductResponse .class ))) })
75
- public String createCollateral (@ Parameter (hidden = true ) final String apiRequestBodyAsJson ) {
76
- final CommandWrapper commandWrapper = new CommandWrapperBuilder ().createCollateral ().withJson (apiRequestBodyAsJson ).build ();
77
- final CommandProcessingResult commandProcessingResult = this .commandsSourceWritePlatformService .logCommandSource (commandWrapper );
78
- return this .apiJsonSerializerService .serialize (commandProcessingResult );
74
+ public CommandProcessingResult createCollateral (
75
+ @ Parameter (hidden = true ) final CollateralManagementProductRequest collateralManagementProductRequest ) {
76
+ final CommandWrapper commandWrapper = new CommandWrapperBuilder ().createCollateral ()
77
+ .withJson (apiJsonSerializerService .serialize (collateralManagementProductRequest )).build ();
78
+ return this .commandsSourceWritePlatformService .logCommandSource (commandWrapper );
79
79
}
80
80
81
81
@ GET
82
82
@ Path ("{collateralId}" )
83
83
@ Consumes ({ MediaType .APPLICATION_JSON })
84
84
@ Produces ({ MediaType .APPLICATION_JSON })
85
85
@ Operation (summary = "Get Collateral" , description = "Fetch Collateral" )
86
- @ ApiResponses ({
87
- @ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .GetCollateralManagementsResponse .class ))) })
88
- public String getCollateral (@ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ,
89
- @ Context final UriInfo uriInfo ) {
86
+ public CollateralManagementData getCollateral (
87
+ @ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ) {
90
88
91
89
this .context .authenticatedUser ()
92
90
.validateHasReadPermission (CollateralManagementJsonInputParams .COLLATERAL_PRODUCT_READ_PERMISSION .getValue ());
93
91
94
- final CollateralManagementData collateralManagementData = this .collateralManagementReadPlatformService
95
- .getCollateralProduct (collateralId );
96
-
97
- return this .apiJsonSerializerService .serialize (collateralManagementData );
92
+ return this .collateralManagementReadPlatformService .getCollateralProduct (collateralId );
98
93
}
99
94
100
95
@ GET
101
96
@ Consumes ({ MediaType .APPLICATION_JSON })
102
97
@ Produces ({ MediaType .APPLICATION_JSON })
103
98
@ Operation (summary = "Get All Collaterals" , description = "Fetch all Collateral Products" )
104
- @ ApiResponses ({
105
- @ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (array = @ ArraySchema (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .GetCollateralManagementsResponse .class )))) })
106
- public String getAllCollaterals (@ Context final UriInfo uriInfo ) {
99
+ public List <CollateralManagementData > getAllCollaterals () {
107
100
this .context .authenticatedUser ()
108
101
.validateHasReadPermission (CollateralManagementJsonInputParams .COLLATERAL_PRODUCT_READ_PERMISSION .getValue ());
109
- Collection <CollateralManagementData > collateralManagementDataList = this .collateralManagementReadPlatformService
110
- .getAllCollateralProducts ();
111
- return this .apiJsonSerializerService .serialize (collateralManagementDataList );
102
+ return this .collateralManagementReadPlatformService .getAllCollateralProducts ();
112
103
}
113
104
114
105
@ GET
115
106
@ Path ("template" )
116
107
@ Consumes ({ MediaType .APPLICATION_JSON })
117
108
@ Produces ({ MediaType .APPLICATION_JSON })
118
109
@ Operation (summary = "Get Collateral Template" , description = "Get Collateral Template" )
119
- @ ApiResponses ({
120
- @ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (array = @ ArraySchema (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .GetCollateralProductTemplate .class )))) })
121
- public String getCollateralTemplate (@ Context final UriInfo uriInfo ) {
122
- Collection <CurrencyData > currencyDataCollection = this .currencyReadPlatformService .retrieveAllPlatformCurrencies ();
123
- return this .apiJsonSerializerServiceForCurrency .serialize (currencyDataCollection );
110
+ public List <CurrencyData > getCollateralTemplate () {
111
+ return currencyReadPlatformService .retrieveAllPlatformCurrencies ();
124
112
}
125
113
126
114
@ PUT
127
115
@ Path ("{collateralId}" )
128
116
@ Consumes ({ MediaType .APPLICATION_JSON })
129
117
@ Produces ({ MediaType .APPLICATION_JSON })
130
118
@ Operation (summary = "Update Collateral" , description = "Update Collateral" )
131
- @ RequestBody (required = true , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger . PutCollateralProductRequest .class )))
119
+ @ RequestBody (required = true , content = @ Content (schema = @ Schema (implementation = CollateralProductRequest .class )))
132
120
@ ApiResponses ({
133
121
@ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .PutCollateralProductResponse .class ))) })
134
- public String updateCollateral (@ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ,
135
- @ Parameter (hidden = true ) final String jsonBody ) {
136
- final CommandWrapper commandWrapper = new CommandWrapperBuilder ().updateCollateralProduct (collateralId ).withJson (jsonBody ).build ();
137
-
138
- final CommandProcessingResult commandProcessingResult = this .commandsSourceWritePlatformService .logCommandSource (commandWrapper );
139
-
140
- return this .apiJsonSerializerService .serialize (commandProcessingResult );
122
+ public CommandProcessingResult updateCollateral (
123
+ @ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ,
124
+ @ Parameter (hidden = true ) final CollateralProductRequest collateralProductRequest ) {
125
+ final CommandWrapper commandWrapper = new CommandWrapperBuilder ().updateCollateralProduct (collateralId )
126
+ .withJson (apiJsonSerializerService .serialize (collateralProductRequest )).build ();
141
127
128
+ return this .commandsSourceWritePlatformService .logCommandSource (commandWrapper );
142
129
}
143
130
144
131
@ DELETE
@@ -148,13 +135,12 @@ public String updateCollateral(@PathParam("collateralId") @Parameter(description
148
135
@ Operation (summary = "Delete a Collateral" , description = "Delete Collateral" )
149
136
@ ApiResponses ({
150
137
@ ApiResponse (responseCode = "200" , description = "OK" , content = @ Content (schema = @ Schema (implementation = CollateralManagementApiResourceSwagger .DeleteCollateralProductResponse .class ))) })
151
- public String deleteCollateral (@ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ) {
138
+ public CommandProcessingResult deleteCollateral (
139
+ @ PathParam ("collateralId" ) @ Parameter (description = "collateralId" ) final Long collateralId ) {
152
140
153
141
final CommandWrapper commandRequest = new CommandWrapperBuilder ().deleteCollateralProduct (collateralId ).build ();
154
142
155
- final CommandProcessingResult commandProcessingResult = this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
156
-
157
- return this .apiJsonSerializerService .serialize (commandProcessingResult );
143
+ return this .commandsSourceWritePlatformService .logCommandSource (commandRequest );
158
144
}
159
145
160
146
}
0 commit comments