|
|
|
|
@ -6,7 +6,7 @@ import edu.ncst.award.vo.ResultVO; |
|
|
|
|
public class ResultUtils { |
|
|
|
|
|
|
|
|
|
// 成功
|
|
|
|
|
public static <T> ResultVO<T> success(String msg, T data) { |
|
|
|
|
public static <T> ResultVO<T> success(String msg, T data) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(0); |
|
|
|
|
resultVO.setMsg(msg); |
|
|
|
|
@ -14,7 +14,8 @@ public class ResultUtils { |
|
|
|
|
|
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
public static <T> ResultVO<T> success(String msg) { |
|
|
|
|
|
|
|
|
|
public static <T> ResultVO<T> success(String msg) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(0); |
|
|
|
|
resultVO.setMsg(msg); |
|
|
|
|
@ -24,7 +25,7 @@ public class ResultUtils { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 成功
|
|
|
|
|
public static <T> ResultVO<T> success(T data) { |
|
|
|
|
public static <T> ResultVO<T> success(T data) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(0); |
|
|
|
|
resultVO.setMsg("success"); |
|
|
|
|
@ -32,8 +33,16 @@ public class ResultUtils { |
|
|
|
|
|
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static <T> ResultVO<T> success() { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(0); |
|
|
|
|
resultVO.setMsg("success"); |
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 错误
|
|
|
|
|
public static <T> ResultVO<T> error(CodeMsg codeMsg) { |
|
|
|
|
public static <T> ResultVO<T> error(CodeMsg codeMsg) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(codeMsg.getCode()); |
|
|
|
|
resultVO.setMsg(codeMsg.getMsg()); |
|
|
|
|
@ -42,8 +51,28 @@ public class ResultUtils { |
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static <T> ResultVO<T> error() { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setMsg("fail"); |
|
|
|
|
resultVO.setData(null); |
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 错误
|
|
|
|
|
public static <T> ResultVO<T> error(String codeMsg, Boolean showCode) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setMsg(codeMsg); |
|
|
|
|
if (showCode) { |
|
|
|
|
resultVO.setCode(500); |
|
|
|
|
} |
|
|
|
|
resultVO.setData(null); |
|
|
|
|
|
|
|
|
|
return resultVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 错误
|
|
|
|
|
public static <T> ResultVO<T> error(String codeMsg) { |
|
|
|
|
public static <T> ResultVO<T> error(String codeMsg) { |
|
|
|
|
ResultVO<T> resultVO = new ResultVO<>(); |
|
|
|
|
resultVO.setCode(500); |
|
|
|
|
resultVO.setMsg(codeMsg); |
|
|
|
|
|