java 泛型静态方法入参泛型类 和 RestTemplate 泛型返回

 /**
     * 删除
     * @param url 地址
     * @param token token信息
     * @return RuiResponse
     */
    public static  RuiResponse> requestList(String url, Map params,ParameterizedTypeReference>> responseType, String token){
        HttpHeaders headers = new HttpHeaders();
        headers.set("accessToken",token);
        HttpEntity> request = new HttpEntity<>(null, headers);
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity>> entity = restTemplate.exchange(url, HttpMethod.GET, request, responseType, params);
        Optional.ofNullable(entity).map(ResponseEntity::getBody).map(RuiResponse::getCode).filter(code-> RuiHttpStatus.CODE_2.getCode().equals(code)).orElseThrow(()->new RRException("查询状态异常"));
        return entity.getBody();
    }
    @Override
    public RuiPageResponse getInfo(Map params) {
        ParameterizedTypeReference>> responseType = new ParameterizedTypeReference>>(){};
        RuiResponse> ruiPageResponseRuiResponse = ReqUtil.requestList(GaspStaffApiConstants.GASP_STAFF_LIST, params,responseType,  tokenManager.getToken());
        return ruiPageResponseRuiResponse.getData();
    }

你可能感兴趣的:(小技能点,java,开发语言)