规范接口结果格式,增加全局常量类
This commit is contained in:
parent
9e985b7f84
commit
164ad8dfc0
|
@ -0,0 +1,10 @@
|
|||
package com.zheng.common.base;
|
||||
|
||||
/**
|
||||
* 全局常量
|
||||
* Created by shuzheng on 2017/2/18.
|
||||
*/
|
||||
public class BaseConstants {
|
||||
|
||||
|
||||
}
|
|
@ -17,11 +17,6 @@ public abstract class BaseController {
|
|||
|
||||
private final static Logger _log = LoggerFactory.getLogger(BaseController.class);
|
||||
|
||||
public static final String RESULT = "result";
|
||||
public static final String DATA = "data";
|
||||
public static final String SUCCESS = "success";
|
||||
public static final String FAILED = "failed";
|
||||
|
||||
/**
|
||||
* 统一异常处理
|
||||
* @param request
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.zheng.common.base;
|
||||
|
||||
/**
|
||||
* 统一返回结果类
|
||||
* Created by shuzheng on 2017/2/18.
|
||||
*/
|
||||
public class BaseResult {
|
||||
|
||||
// 状态码:1成功,其他为失败
|
||||
public int code;
|
||||
|
||||
// 成功为success,其他为失败原因
|
||||
public String message;
|
||||
|
||||
// 数据结果集
|
||||
public Object data;
|
||||
|
||||
public BaseResult(int code, String message, Object data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue