| 36321 |
vikas |
1 |
package com.spice.profitmandi.web.v2.controller;
|
|
|
2 |
|
|
|
3 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
|
|
4 |
import com.spice.profitmandi.web.v2.response.ApiResponse;
|
|
|
5 |
import org.springframework.http.ResponseEntity;
|
|
|
6 |
|
|
|
7 |
public abstract class V2BaseController {
|
|
|
8 |
|
|
|
9 |
@SuppressWarnings("rawtypes")
|
|
|
10 |
protected ResponseEntity<ApiResponse<?>> wrapResponse(ResponseEntity<?> v1Response) {
|
|
|
11 |
Object body = v1Response.getBody();
|
|
|
12 |
Object data = body;
|
|
|
13 |
|
|
|
14 |
if (body instanceof ProfitMandiResponse) {
|
|
|
15 |
data = ((ProfitMandiResponse) body).getResponse();
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
ApiResponse<?> apiResponse = ApiResponse.success(data);
|
|
|
19 |
return ResponseEntity.ok(apiResponse);
|
|
|
20 |
}
|
|
|
21 |
}
|