mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-28 23:15:11 +08:00
update lianlian
This commit is contained in:
144
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/common/CommonResult.java
vendored
Normal file
144
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/common/CommonResult.java
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.jsowell.thirdparty.lianlian.common;
|
||||
|
||||
|
||||
import com.jsowell.thirdparty.lianlian.common.enums.ResultCode;
|
||||
|
||||
/**
|
||||
* 接口返回类
|
||||
*
|
||||
* @author 联联充电
|
||||
*/
|
||||
public class CommonResult<T> {
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
private long ret;
|
||||
|
||||
/**
|
||||
* 响应信息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 返回数据
|
||||
*/
|
||||
private T data;
|
||||
|
||||
private String sig;
|
||||
|
||||
protected CommonResult() {
|
||||
|
||||
}
|
||||
|
||||
protected CommonResult(long ret, String msg, T data, String sig) {
|
||||
this.ret = ret;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
this.sig = sig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @param data 获取的数据
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> success(T data) {
|
||||
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), data, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回结果
|
||||
*
|
||||
* @param data 获取的数据
|
||||
* @param message 提示的信息
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> success(T data, String message) {
|
||||
return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data, null);
|
||||
}
|
||||
|
||||
public static <T> CommonResult<T> success(Integer ret, String msg, T data, String sig) {
|
||||
return new CommonResult<T>(ret, msg, data, sig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回结果
|
||||
*
|
||||
* @param resultCode 错误码
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(ResultCode resultCode) {
|
||||
return new CommonResult<T>(resultCode.getCode(), resultCode.getMsg(), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回
|
||||
*
|
||||
* @param code 错误码
|
||||
* @param msg 提示信息
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(long code, String msg) {
|
||||
return new CommonResult<T>(code, msg, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回结果
|
||||
*
|
||||
* @param msg 提示信息
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(String msg) {
|
||||
return failed(ResultCode.ERROR.getCode(), msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回结果
|
||||
*
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> failed() {
|
||||
return failed(ResultCode.ERROR);
|
||||
}
|
||||
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public long getRet() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setRet(long ret) {
|
||||
this.ret = ret;
|
||||
}
|
||||
|
||||
public String getSig() {
|
||||
return sig;
|
||||
}
|
||||
|
||||
public void setSig(String sig) {
|
||||
this.sig = sig;
|
||||
}
|
||||
}
|
||||
30
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/common/enums/ResultCode.java
vendored
Normal file
30
jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/common/enums/ResultCode.java
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.jsowell.thirdparty.lianlian.common.enums;
|
||||
|
||||
/**
|
||||
* 返回结果枚举
|
||||
*/
|
||||
public enum ResultCode {
|
||||
|
||||
/**
|
||||
* 接口返回枚举
|
||||
*/
|
||||
SUCCESS(200, "成功"),
|
||||
ERROR(-1, "失败");
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
ResultCode(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user