1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| package com.example.usercenter.common;
public class ResultUtil {
public static <T> BaseResponse<T> success(T data){ return new BaseResponse<>(0, data, "ok"); }
public static BaseResponse error(ErrorCode errorCode){ return new BaseResponse<>(errorCode); }
public static BaseResponse error(int code, String message, String description){ return new BaseResponse<>(code, null, message, description); }
public static BaseResponse error(ErrorCode errorCode, String message, String description){ return new BaseResponse<>(errorCode.getCode(), null, message, description); }
public static BaseResponse error(ErrorCode errorCode, String description){ return new BaseResponse<>(errorCode.getCode(), null, errorCode.getMessage(), description); } }
|