com.fengwenyi.api.result.Result Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-result Show documentation
Show all versions of api-result Show documentation
一套RESTful风格API接口响应参数规范化的解决方案
package com.fengwenyi.api.result;
/**
*
* 结果码接口
*
*
* @author Erwin Feng
* @since 2.7.0
*/
public interface Result {
/**
* 结果码
* @return 结果码
*/
String getCode();
/**
* 描述
* @return 描述
*/
String getMsg();
/**
* 默认
*/
class Default implements Result {
/* -----------------成功---------------------------- */
public static final Result SUCCESS = new Default("SUCCESS", "Success");
/* ------------------错误--------------------------- */
public static final Result ERROR = new Default("ERROR", "错误");
/** 结果码 */
private final String code;
/** 提示信息 */
private final String msg;
/**
* 构造方法
* @param code 返回码
* @param msg 提示信息
*/
public Default(String code, String msg) {
this.code = code;
this.msg = msg;
}
/**
* {@code errCode} get方法
* @return 错误码
*/
@Override
public String getCode() {
return code;
}
/**
* {@code msg} get方法
* @return 描述
*/
@Override
public String getMsg() {
return msg;
}
}
}