package com.yang;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public enum ResultStatus {
// -1为通用失败(根据ApiResult.java中的构造方法注释而来)
FAIL(-1, "common fail"),
// 0为成功
SUCCESS(0, "success"),
error_pic_file(3,"非法图片文件"),
error_pic_upload(4,"图片上传失败"),
error_record_not_found(5, "没有找到对应的数据"),
error_max_page_size(6, "请求记录数超出每次请求最大允许值"),
error_create_failed(7,"新增失败"),
error_update_failed(8,"修改失败"),
error_delete_failed(9,"删除失败"),
error_search_failed(10,"查询失败"),
error_count_failed(11,"查询数据总数失败"),
error_string_to_obj(12,"字符串转java对象失败"),
error_invalid_argument(13,"参数不合法"),
error_update_not_allowed(14,"更新失败:%s"),
error_duplicated_data(15,"数据已存在"),
error_unknown_database_operation(16,"未知数据库操作失败,请联系管理员解决"),
error_column_unique(17,"字段s%违反唯一约束性条件"),
error_file_download(18,"文件下载失败"),
error_file_upload(19,"文件上传失败"),
//100-511为http 状态码
// --- 4xx Client Error ---
http_status_bad_request(400, "Bad Request"),
http_status_unauthorized(401, "Unauthorized"),
http_status_payment_required(402, "Payment Required"),
http_status_forbidden(403, "Forbidden"),
http_status_not_found(404, "Not Found"),
http_status_method_not_allowed(405, "Method Not Allowed"),
http_status_not_acceptable(406, "Not Acceptable"),
http_status_proxy_authentication_required(407, "Proxy Authentication Required"),
http_status_request_timeout(408, "Request Timeout"),
http_status_conflict(409, "Conflict"),
http_status_gone(410, "Gone"),
http_status_length_required(411, "Length Required"),
http_status_precondition_failed(412, "Precondition Failed"),
http_status_payload_too_large(413, "Payload Too Large"),
http_status_uri_too_long(414, "URI Too Long"),
http_status_unsupported_media_type(415, "Unsupported Media Type"),
http_status_requested_range_not_satisfiable(416, "Requested range not satisfiable"),
http_status_expectation_failed(417, "Expectation Failed"),
http_status_im_a_teapot(418, "I'm a teapot"),
http_status_unprocessable_entity(422, "Unprocessable Entity"),
http_status_locked(423, "Locked"),
http_status_failed_dependency(424, "Failed Dependency"),
http_status_upgrade_required(426, "Upgrade Required"),
http_status_precondition_required(428, "Precondition Required"),
http_status_too_many_requests(429, "Too Many Requests"),
http_status_request_header_fields_too_large(431, "Request Header Fields Too Large"),
// --- 5xx Server Error ---
http_status_internal_server_error(500, "系统错误"),
http_status_not_implemented(501, "Not Implemented"),
http_status_bad_gateway(502, "Bad Gateway"),
http_status_service_unavailable(503, "Service Unavailable"),
http_status_gateway_timeout(504, "Gateway Timeout"),
http_status_http_version_not_supported(505, "HTTP Version not supported"),
http_status_variant_also_negotiates(506, "Variant Also Negotiates"),
http_status_insufficient_storage(507, "Insufficient Storage"),
http_status_loop_detected(508, "Loop Detected"),
http_status_bandwidth_limit_exceeded(509, "Bandwidth Limit Exceeded"),
http_status_not_extended(510, "Not Extended"),
http_status_network_authentication_required(511, "Network Authentication Required"),
// --- 8xx common error ---
EXCEPTION(800, "exception"),
INVALID_PARAM(801, "invalid.param"),
INVALID_PRIVI(802, "invalid.privi"),
//1000以内是系统错误,
no_login(1000,"没有登录"),
config_error(1001,"参数配置表错误"),
user_exist(1002,"用户名已存在"),
userpwd_not_exist(1003,"用户名不存在或者密码错误"),
;
private static final Logger LOGGER = LoggerFactory.getLogger(ResultStatus.class);
private int code;
private String msg;
ResultStatus(int code, String msg){
this.code = code;
this.msg = msg;
}
public static int getCode(String define){
try {
return ResultStatus.valueOf(define).code;
} catch (IllegalArgumentException e) {
LOGGER.error("undefined error code: {}", define);
return FAIL.getErrorCode();
}
}
public static String getMsg(String define){
try {
return ResultStatus.valueOf(define).msg;
} catch (IllegalArgumentException e) {
LOGGER.error("undefined error code: {}", define);
return FAIL.getErrorMsg();
}
}
public static String getMsg(int code){
for(ResultStatus err : ResultStatus.values()){
if(err.code==code){
return err.msg;
}
}
return "errorCode not defined ";
}
public int getErrorCode(){
return code;
}
public String getErrorMsg(){
return msg;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论























收起资源包目录








































































































共 64 条
- 1
资源评论


yanguo110
- 粉丝: 30
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 如何学习好单片机编程设计方案.doc
- 互联网+背景下体育人文素养对大学生创业能力的影响.docx
- 如何使用AutoCAD的工具选项板.docx
- 对互联网+专业护理资源介入安康市养老事业发展的探索.docx
- 教育信息化管理的问题及解决对策.docx
- 第二章变电站综合自动化系统的间隔层装置.doc
- 区块链技术对于深化会计电算化的前景分析.docx
- 计算机竞赛题大全.docx
- myeclipse连接数据库建立web工程简单测试访问成功例子.doc
- VxWorks嵌入式数据库管理系统设计方案.doc
- 企业网络管理和业务调度自动化设计方案.docx
- “教学中的互联网搜索”《记金华的双龙洞》教案设计思路.doc
- 基于 IMDB 情感分析数据集运用 LSTM 结合预训练词典向量模型开展电影评论情感分类研究
- 交通指挥灯PLC控制系统方案设计书.doc
- 浅析大数据时代电力企业档案的开发利用.docx
- 项目管理之需求识别和项目识别.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
