springboot中的统一响应处理方案
1、统一响应类 CommonResponse
package cn.bestriven.www.vo;
import lombok.Data;
import org.springframework.stereotype.Component;
import java.io.Serializable;
/**
* @Author: liufan
* @Date: 2019/8/19 16:08
* @Description:
*/
@Data
@Component
public class CommonResponse<T> implements Serializable {
private Integer code;
private String message;
private T data;
public CommonResponse(Integer code,String message){
this.code = code;
this.message = message;
}
}
2、方法拦截器CommonResponseDataAdvice
package cn.bestriven.www.advice;
import cn.bestriven.www.annotation.IgnoreResponseAdvice;
import cn.bestriven.www.vo.CommonResponse;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.