<> Some basic classes needed :

ResultCode
Response
ResponseResult
CommonCode: custom code information
/** * Created by Li Xinyu * 2019-07-31 17:54 * <p> * 10000-- General error code * 22000--
Media error code * 23000-- User center error code * 24000-- cms error code * 25000-- file system */ public interface
ResultCode { // Whether the operation is successful ,true For success ,false operation failed boolean success(); // Operation code int code();
// Tips String message(); } /** * Created by Li Xinyu * 2019-07-31 17:54 */ public
interface Response { public static final boolean SUCCESS = true; public static
final int SUCCESS_CODE = 10000; } /** * Created by Li Xinyu * 2019-07-31 17:54 */
@Data @ToString @NoArgsConstructor public class ResponseResult implements
Response { // Whether the operation is successful boolean success = SUCCESS; // Operation code int code = SUCCESS_CODE;
// Tips String message; public ResponseResult(ResultCode resultCode) { this.
success= resultCode.success(); this.code = resultCode.code(); this.message =
resultCode.message(); } public static ResponseResult SUCCESS() { return new
ResponseResult(CommonCode.SUCCESS); } public static ResponseResult FAIL() {
return new ResponseResult(CommonCode.FAIL); } } /** * custom code information * Created by
Li Xinyu * 2019-07-31 17:54 */ @ToString public enum CommonCode implements ResultCode
{ SUCCESS(true,10000," Operation successful !"), FAIL(false,11111," operation failed !"), UNAUTHENTICATED(false,
10001," This operation requires logging in to the system !"), UNAUTHORISE(false,10002," Insufficient authority , No permission to operate !"), SERVER_ERROR(false,
99999," i 'm sorry , System busy , Please try again later !"); // private static ImmutableMap<Integer, CommonCode>
codes ; // Whether the operation is successful boolean success; // Operation code int code; // Tips String message;
private CommonCode(boolean success,int code, String message){ this.success =
success; this.code = code; this.message = message; } @Override public boolean
success() { return success; } @Override public int code() { return code; }
@Override public String message() { return message; } }
Custom exception start

ExceptionCast: Throw custom exception
ExceptionCatch: Unified exception capture class
/** * Throw custom exception * <p> * Created by Li Xinyu * 2019-07-31 17:54 */ public class
ExceptionCast { // Use this static method to throw a custom exception public static void cast(ResultCode resultCode)
{ throw new CustomException(resultCode); } } /** * Unified exception capture class * <p> * Created by
Li Xinyu * 2019-07-31 17:58 */ @ControllerAdvice // Controller enhancements public class ExceptionCatch
{ private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.
class); // capture CustomException Such abnormality @ExceptionHandler(CustomException.class)
@ResponseBody public ResponseResult customException(CustomException
customException) { // Log LOGGER.error("catch exception: {}", customException.
getMessage()); ResultCode resultCode = customException.getResultCode(); return
new ResponseResult(resultCode); } }
<> use
if (cmsPage1 != null) { ExceptionCast.cast(CommonCode.FAIL); }

Technology
©2019-2020 Toolsou All rights reserved,
First knowledge python Skills summary GDOI2019 travels c Linguistic 5 Three common sorting methods Python Basic knowledge and notes " Cephalosporin wine Say go and go "? DANGER ! Don't drink alcohol when taking these drugs Thorough explanation from Zhongtai vue The component page height is adaptive according to the screen size Classical algorithm - recursion ( The case of raw rabbit ) Big data tells you , How tired are Chinese women about keras use fit_generator Encountered in StopIteration