public enum StatusCode { SUCCESS(200, "成功"), FORBIDDEN(403, "權限失敗"), CREATE_TOKEN_ERROR(999, "Token建立失敗"), MISSING_REQUIRE_FIELD(1000, "參數缺失"), PARAMETER_VALUE_RANGE_ERROR(1001, "取值範圍錯誤"), HTTP_RESPONSE_ERROR(1002, "調用外部請求時,發生http請求錯誤"), JSON_ANALYSIS_ERROR(1003, "調用外部請求時,發生json數據解析錯誤"), INTERNET_IO_ERROR(1004, "調用外部請求時,發生網絡IO錯誤"), SEND_MESSAGE_FAILED(1005, "發送消息失敗"), METHOD_NOT_SUPPORT(1006, "方法調用錯誤,不支持此方法調用"), RESOURCE_UPDATE_FAILED(10001, "資源更新失敗"), RESOURCE_INSERT_FAILED(10002, "資源添加失敗"), RESOURCE_DELETE_FAILED(10003, "資源刪除失敗"), RESOURCE_NOT_MESSAGE_EXIT(10004, "資源信息不存在"), RESOURCE_IMPORT_ERROR(10005, "資源導入失敗"), ROLE_UPDATE_FAILED(10006, "角色更新失敗"), ROLE_INSERT_FAILED(10007, "角色添加失敗"), ROLE_DELETE_FAILED(10008, "角色刪除失敗"), ADMIN_USER_NOT_FOUND(10100, "帳戶不存在"), ADMIN_USER_WRONG_PASSWORD(10101, "登陸密碼錯誤"), ADMIN_USER_INSERT_FAILED(10102, "建立用戶失敗"), ADMIN_USER_UPDATE_FAILED(10103, "資源更新失敗"), ADMIN_USER_DELETE_FAILED(10104, "資源刪除失敗"), ROLE_LIST_NOT_EXISTS(10105, "角色列表不能爲空"), TOKEN_NOT_AVAILABLE(200001, "AccessToken已被註銷,請從新登陸"), TOKEN_IS_EMPTY(200002, "AccessToken爲空,請檢查參數"), ACCESS_TOKEN_EXPIRED(200003, "AccessToken已過時"), REFRESH_TOKEN_EXPIRED(200004, "RefreshToken已過時"), INVALID_ACCESS_TOKEN_TYPE(200005, "token類型錯誤,請使用accessToken"), INVALID_REFRESH_TOKEN_TYPE(20006, "token類型錯誤,請使用refresToken"), TOKEN_FORMAT_ERR(20007, "token格式錯誤"), MAIN_ACCOUNT_NOT_DELETE(10201, "主帳號不能被刪除"), PASSPORT_PWD_ERROR(10202, "密碼錯誤"), SEND_REQUEST_ERROR(10301, "發送請求失敗"), GET_RESPONSE_NULL(10302, "獲取第三方響應結果爲空"), NOT_OPERATE_AUTH(10401, "該用戶無操做權限"), NOT_ADMIN_AUTH(10601, "該用戶無此管理權限"), ADMIN_TYPE_CONFILICT(10602, "主管理員不能同時爲子管理員"), ADMIN_INSERT_FAILED(10605, "添加子管理員錯誤"), ADMIN_MODIFY_FAILED(10606, "修改子管理員錯誤"), CREATE_APP_ERR(60000, "建立App失敗"), CREATE_APP_SHORTCUTS_ERR(60001, "建立快捷方式失敗"), OPEN_APP_ERR(60002, "開通應用失敗"), ASSIGN_PERMISSION_ERR(60003, "分配權限失敗"), URL_SYNTAX_ERR(60004, "url語法錯誤"), ADD_NEW_LOGO_ERR(60005, "logo添加失敗"), EDIT_LOGO_ERR(60006, "logo修改失敗"), CREATE_GROUP_ERR(60007, "建立分組失敗"), SCHEDULER_PARAM_ERROR(70001, "taskId與outkey不得同時爲空"), SCHEDULER_TIME_OUT(70002, "當前時間已經超過定時器時間"), SCHEDULER_CREATE_ERROR(70003, "調度器建立任務失敗"), ERROR(500, "系統錯誤"); private String message; private int code; private StatusCode(int statusCode, String statusMessage) { this.message = statusMessage; this.code = statusCode; } @JsonValue public String getStatusMessage() { return this.message; } public int getStatusCode() { return this.code; } }
使用:return result ? success(true) : error(StatusCode.RESOURCE_UPDATE_FAILED);json