mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update lianlian
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
*/
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
*/
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) 2005-2012 springside.org.cn
|
||||
*/
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jsowell.common.util.lianlian;
|
||||
package com.jsowell.common.lianlian;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.jsowell.common.lianlian.common;
|
||||
|
||||
|
||||
import com.jsowell.common.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.jsowell.common.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