| | |
| | | package com.qxueyou.scc.base.model; |
| | | |
| | | import com.qxueyou.scc.base.util.CollectionUtils; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 操作结果类 接口统一返回数据类型 |
| | | * 操作结果类 接口统一返回数据类型 |
| | | * |
| | | * { |
| | | * "result": 返回结果(boolean值), |
| | | * "data": 返回数据(object), |
| | | * "msg": 返回消息, |
| | | * "result": 返回结果(boolean值), |
| | | * "data": 返回数据(object), |
| | | * "msg": 返回消息, |
| | | * } |
| | | * |
| | | * @author zhiyong |
| | |
| | | |
| | | private static final long serialVersionUID = -9024761391789730558L; |
| | | |
| | | /** 成功:true,失败:false */ |
| | | /** 成功:true,失败:false */ |
| | | private boolean success; |
| | | |
| | | /** 返回编码 */ |
| | | /** 返回编码 */ |
| | | private int resultCode ; |
| | | |
| | | /** 返回消息 */ |
| | | /** 返回消息 */ |
| | | private String msg; |
| | | |
| | | /** 结果数据 */ |
| | | /** 结果数据 */ |
| | | private Object data; |
| | | |
| | | |
| | | public static final String MSG_SUCCESS = "success"; |
| | | |
| | | public static final String MSG_FAIL = "fail"; |
| | | /** |
| | | * 非法请求状态码 |
| | | * 非法请求状态码 |
| | | */ |
| | | public static final int CODE_FORBIDDEN = 403; |
| | | |
| | | public static final Result SUCCESS = new Result(true); |
| | | |
| | | public static final Result FAIL = new Result(false); |
| | | |
| | | |
| | | public Result() { |
| | | super(); |
| | | } |
| | |
| | | this.msg=msg; |
| | | this.data=data; |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | public Result(boolean success, Object... objs) { |
| | | this.success = success; |
| | | this.msg = success ? MSG_SUCCESS : MSG_FAIL; |
| | | this.data = CollectionUtils.newObjectMap(objs); |
| | | } |
| | | |
| | | public boolean isSuccess() { |
| | | return success; |
| | | } |
| | | |
| | |
| | | this.success = success; |
| | | } |
| | | |
| | | public Boolean getSuccess() { |
| | | return success; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |