Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.v2.controller;

import com.spice.profitmandi.common.model.ProfitMandiResponse;
import com.spice.profitmandi.web.v2.response.ApiResponse;
import org.springframework.http.ResponseEntity;

public abstract class V2BaseController {

    @SuppressWarnings("rawtypes")
    protected ResponseEntity<ApiResponse<?>> wrapResponse(ResponseEntity<?> v1Response) {
        Object body = v1Response.getBody();
        Object data = body;

        if (body instanceof ProfitMandiResponse) {
            data = ((ProfitMandiResponse) body).getResponse();
        }

        ApiResponse<?> apiResponse = ApiResponse.success(data);
        return ResponseEntity.ok(apiResponse);
    }
}