标签:pre tin intern .data 服务器 ltm col 枚举类 package
一、ResultInfo 实体承载类
package com.test.domi.common.system; public class ResultInfo<T> { private String code; private String message; private T data; public ResultInfo(){ } public String getCode(){ return this.code; } public void setCode(String code){ this.code = code; } public String getMessage(){ return this.message; } public void setMessage(String message){ this.message = message; } public Object getData(){ return this.data; } public void setData(T data){ this.data = data; } }
二、ResultCode 枚举类
package com.test.domi.common.system; public enum ResultCode { SUCCESS("000000","成功"), CONNECT_ERROR("100001","网络连接失败"), CONNECT_TIMEOUT("100002","网络连接超时"), INTERNAL_SERVER_ERROR("100003","服务器内部错误"), QUERY_ERROR("100004","查询失败"), INSERT_ERROR("100005","保存数据失败"), UPDATE_ERROR("100006","更新数据失败"), DELETE_ERROR("100007","删除数据失败"); private String code; private String msg; ResultCode(String code, String msg) { this.code = code; this.msg = msg; } public String getCode() { return code; } public String getMsg() { return msg; } }
三、ResultUtil 实例化工具类
package com.test.domi.common.system; public class ResultUtil { public ResultUtil(){ } public static ResultInfo getSuccessResult(Object object){ ResultInfo resultInfo = new ResultInfo(); resultInfo.setCode(ResultCode.SUCCESS.getCode()); resultInfo.setMessage(ResultCode.SUCCESS.getMsg()); resultInfo.setData(object); return resultInfo; } public static ResultInfo getFailResult(ResultCode resultCode){ return getFailResult(resultCode,(Object)null); } public static ResultInfo getFailResult(String resultCode,String resultMessage,Object data){ ResultInfo resultInfo = new ResultInfo(); resultInfo.setCode(resultCode); resultInfo.setMessage(resultMessage); resultInfo.setData(data); return resultInfo; } public static ResultInfo getFailResult(ResultCode resultCode,Object data){ ResultInfo resultInfo = new ResultInfo(); resultInfo.setCode(resultCode.getCode()); resultInfo.setMessage(resultCode.getMsg()); resultInfo.setData(data); return resultInfo; } }
标签:pre tin intern .data 服务器 ltm col 枚举类 package
原文地址:https://www.cnblogs.com/domi22/p/9096247.html