Commit 1c8b3d6c authored by wangquan  wangquan's avatar wangquan wangquan
Browse files

22

parent 440ddd1b
package com.zxr.demos.common.enums;
/**
* @author 花荣
* @since created in 2021/3/24 5:56 下午
* @project shb-paas
* @Modified by
* @Description
*/
public interface ResultCode {
/**
* 信息
* @return 信息
*/
String getMessage();
/**
* 编码
* @return 编码
*/
int getCode();
}
package com.zxr.demos.common.enums;
import lombok.Getter;
/**
* 售后宝es特殊字符映射生僻字
*
* @author wuchenzheng
**/
@Getter
public enum SpecialSymbolEnum {
//~!@#$^&()_}{:?><"!¥%……*()—|:“《》?·【】、;’,。/ `-=[];',./\、
Tilde("~", "獘"),
ExclamationEn("!", "獙"),
At("@", "獚"),
Number("#", "獛"),
Dollar("$", "獜"),
Caret("^", "獝"),
Ampersand("&", "獞"),
PrenthesesLeft("(", "獟"),
ParenthesesRight(")", "獠"),
Underscore("_", "獡"),
BracesLeft("}", "獤"),
BracesRight("{", "獥"),
ColonEn(":", "焧"),
QuestionEn("?", "焨"),
Less(">", "嵞"),
Greater("<", "焪"),
QuotationEn("\"", "焫"),
ExclamationCn("!", "焬"),
RMB("¥", "焭"),
Percent("%", "焮"),
Ellipsis("…", "焯"),
Asterisk("*", "嶤"),
PrenthesesLeftCn("(", "焲"),
ParenthesesRightEn(")", "焳"),
Minus("—", "焴"),
Vertical("|", "焵"),
ColonCn(":", "焷"),
QuotationCn("“", "栊"),
PunctuationLeft("《", "櫹"),
PunctuationRight("》", "櫶"),
QuestionCn("?", "櫷"),
Period("·", "櫼"),
BracketsLeftCn("【", "櫽"),
BracketsRightCn("】", "櫾"),
Stop("、", "櫿"),
SemicolonCn(";", "欀"),
//懔懕懖懗懘懙懚懛懜懝怼懠懡懢懑懤懥懦懧恹懩懪懫
ApostropheCn("’", "懔"),
CommaCn(",", "懕"),
Dot("。", "懖"),
Slash("/", "懗"),
Grave("`", "懘"),
Sub("-", "懙"),
Equals("=", "懚"),
BracketsLeftEn("[", "懛"),
BracketsRightEn("]", "懠"),
SemicolonEn(";", "懡"),
ApostropheEn("'", "懧"),
CommaEn(",", "懪"),
DotEn(".", "懫"),
Backslash("\\", "愸"),
StopEn("、", "嶲"),
Add("+", "灋"),
Adds("‘", "暥"),
AddAnd("”", "戅"),
NULL(" ", "奯");
SpecialSymbolEnum(String key, String word) {
this.key = key;
this.word = word;
}
private String key;
private String word;
}
package com.zxr.demos.common.enums;
public enum StatusCodeEnum {
SUCCESS(0, "success"),
FAIL(1, "fail"),
ERROR(-1, "error");
private final int code;
private final String msg;
private StatusCodeEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return this.code;
}
public String getMsg() {
return this.msg;
}
}
package com.zxr.demos.common.enums;
import lombok.ToString;
/**
* @author wuxihao
* @since 2023年08月22日19:09:40
*/
@ToString
public enum UdspApiResultCode implements ResultCode{
/**
* SUCCESSFUL : 0
*/
SUCCESS(200, "success");
/**
* 消息
*/
private String message;
/**
* 错误码
*/
private int code;
UdspApiResultCode(int code, String message) {
this.message = message;
this.code = code;
}
@Override
public String getMessage() {
return message;
}
@Override
public int getCode() {
return code;
}
}
package com.zxr.demos.common.message;
import com.alibaba.fastjson.JSON;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
public class ShbMapMessage extends ShbMqMessage{
private Map<String, Object> map = new HashMap();
public ShbMapMessage() {
super((String)null, "*", (String)null);
}
public ShbMapMessage(String topic, String tag, String key) {
super(topic, tag, key);
}
public byte[] getBody() {
try {
return JSON.toJSONString(this.map).getBytes("UTF-8");
} catch (Exception var2) {
throw new RuntimeException("map to bytes error.", var2);
}
}
public void setBody(byte[] bytes) {
try {
String body = new String(bytes, "UTF-8");
this.map = (Map)JSON.parseObject(body, Map.class);
} catch (Exception var3) {
throw new RuntimeException("parse body error.", var3);
}
}
public boolean getBoolean(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return false;
} else if (value instanceof Boolean) {
return (Boolean)value;
} else if (value instanceof String) {
return Boolean.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read a boolean from " + value.getClass().getName());
}
}
public byte getByte(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0;
} else if (value instanceof Byte) {
return (Byte)value;
} else if (value instanceof String) {
return Byte.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read a byte from " + value.getClass().getName());
}
}
public short getShort(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0;
} else if (value instanceof Short) {
return (Short)value;
} else if (value instanceof Byte) {
return ((Byte)value).shortValue();
} else if (value instanceof String) {
return Short.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read a short from " + value.getClass().getName());
}
}
public char getChar(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
throw new NullPointerException();
} else if (value instanceof Character) {
return (Character)value;
} else {
throw new RuntimeException(" cannot read a char from " + value.getClass().getName());
}
}
public int getInt(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0;
} else if (value instanceof Integer) {
return (Integer)value;
} else if (value instanceof Short) {
return ((Short)value).intValue();
} else if (value instanceof Byte) {
return ((Byte)value).intValue();
} else if (value instanceof String) {
return Integer.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read an int from " + value.getClass().getName());
}
}
public long getLong(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0L;
} else if (value instanceof Long) {
return (Long)value;
} else if (value instanceof Integer) {
return ((Integer)value).longValue();
} else if (value instanceof Short) {
return ((Short)value).longValue();
} else if (value instanceof Byte) {
return ((Byte)value).longValue();
} else if (value instanceof String) {
return Long.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read a long from " + value.getClass().getName());
}
}
public float getFloat(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0.0F;
} else if (value instanceof Float) {
return (Float)value;
} else if (value instanceof String) {
return Float.valueOf(value.toString());
} else {
throw new RuntimeException(" cannot read a float from " + value.getClass().getName());
}
}
public double getDouble(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return 0.0;
} else if (value instanceof Double) {
return (Double)value;
} else if (value instanceof Float) {
return (double)(Float)value;
} else if (value instanceof String) {
return Double.valueOf(value.toString());
} else {
throw new RuntimeException("Cannot read a double from " + value.getClass().getName());
}
}
public String getString(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return null;
} else if (value instanceof byte[]) {
throw new RuntimeException("Use getBytes to read a byte array");
} else {
return value.toString();
}
}
public byte[] getBytes(String name) {
this.initializeReading();
Object value = this.map.get(name);
if (value == null) {
return null;
} else if (value instanceof byte[]) {
return (byte[])((byte[])value);
} else {
throw new RuntimeException(" cannot read a byte[] from " + value.getClass().getName());
}
}
public Object getObject(String name) {
this.initializeReading();
Object result = this.map.get(name);
return result;
}
public Enumeration<String> getMapNames() {
this.initializeReading();
return Collections.enumeration(this.map.keySet());
}
protected void put(String name, Object value) {
if (name == null) {
throw new IllegalArgumentException("The name of the property cannot be null.");
} else if (name.length() == 0) {
throw new IllegalArgumentException("The name of the property cannot be an emprty string.");
} else {
this.map.put(name, value);
}
}
public void setBoolean(String name, boolean value) {
this.initializeWriting();
this.put(name, value ? Boolean.TRUE : Boolean.FALSE);
}
public void setByte(String name, byte value) {
this.initializeWriting();
this.put(name, value);
}
public void setShort(String name, short value) {
this.initializeWriting();
this.put(name, value);
}
public void setChar(String name, char value) {
this.initializeWriting();
this.put(name, value);
}
public void setInt(String name, int value) {
this.initializeWriting();
this.put(name, value);
}
public void setLong(String name, long value) {
this.initializeWriting();
this.put(name, value);
}
public void setFloat(String name, float value) {
this.initializeWriting();
this.put(name, new Float(value));
}
public void setDouble(String name, double value) {
this.initializeWriting();
this.put(name, new Double(value));
}
public void setString(String name, String value) {
this.initializeWriting();
this.put(name, value);
}
public void setBytes(String name, byte[] value) {
this.initializeWriting();
if (value != null) {
this.put(name, value);
} else {
this.map.remove(name);
}
}
public void setBytes(String name, byte[] value, int offset, int length) {
this.initializeWriting();
byte[] data = new byte[length];
System.arraycopy(value, offset, data, 0, length);
this.put(name, data);
}
public void setObject(String name, Object value) {
this.initializeWriting();
if (value != null) {
this.put(name, value);
} else {
this.put(name, (Object)null);
}
}
public boolean itemExists(String name) {
this.initializeReading();
return this.map.containsKey(name);
}
private void initializeReading() {
}
private void initializeWriting() {
}
}
\ No newline at end of file
package com.zxr.demos.common.message;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
public class ShbMqMessage {private String topic;
private String tag;
private byte[] body;
private String key;
private String messageId;
private String shardingKey;
public String getShardingKey() {
return this.shardingKey;
}
public void setShardingKey(String shardingKey) {
this.shardingKey = shardingKey;
}
public String getMessageId() {
return this.messageId;
}
public void setMessageId(String messageId) {
this.messageId = messageId;
}
public String getTopic() {
return this.topic;
}
public String getTag() {
return this.tag;
}
public byte[] getBody() {
return this.body;
}
public String getKey() {
return this.key;
}
public void setTopic(String topic) {
this.topic = topic;
}
public void setTag(String tag) {
this.tag = tag;
}
public void setBody(byte[] body) {
this.body = body;
}
public void setKey(String key) {
this.key = key;
}
public ShbMqMessage(String topic, String tag, String key) {
this.topic = topic;
this.tag = tag;
this.key = key;
}
public ShbMqMessage(String tag, byte[] body, String key) {
this.tag = tag;
this.body = body;
this.key = key;
}
public ShbMqMessage(String topic, String tag, byte[] body, String key) {
this.topic = topic;
this.tag = tag;
this.body = body;
this.key = key;
}
public static ShbMqMessage createMessage(String topic, String tag, byte[] body, String key) {
if (!StringUtils.isAnyBlank(new CharSequence[]{topic, tag, key}) && !ArrayUtils.isEmpty(body)) {
return new ShbMqMessage(topic, tag, body, key);
} else {
throw new IllegalArgumentException("");
}
}
}
\ No newline at end of file
package com.zxr.demos.common.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BarCodeParam {
private EsbInfo esbInfo;
private RequestInfo requestInfo;
@AllArgsConstructor
@NoArgsConstructor
@Data
public static class EsbInfo {
private String attr1;
private String attr2;
private String attr3;
private String instId;
private String requestTime;
}
@AllArgsConstructor
@NoArgsConstructor
@Data
public static class RequestInfo {
private String appSecret;
private String companyName;
private String scan_id;
private String scan_date;
private String billNo;
private String barcode;
}
}
package com.zxr.demos.common.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@ApiModel("用于产品类型查询条件接收")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseProductCatalogSearchModel {
@ApiModelProperty("关键字")
private String keyWord;
@ApiModelProperty("关联的产品个数")
private Integer productNum;
@ApiModelProperty("类型ID")
private Long catalogId;
@ApiModelProperty("类型名称")
private String catalogName;
@ApiModelProperty("类型描述")
private String productDesc;
@ApiModelProperty("产品类型编号")
private String catalogNum;
@ApiModelProperty("根节点到叶子结点路径名称")
private String pathName;
@ApiModelProperty("创建用户ID")
private String createUserId;
@ApiModelProperty("创建用户名")
private String createUser;
@ApiModelProperty("创建开始时间")
private String createTimeStart;
@ApiModelProperty("创建结束时间")
private String createTimeEnd;
@ApiModelProperty("租户ID")
private String tenantId;
@ApiModelProperty("类型ID集合")
private List<Long> ids;
@ApiModelProperty("质保起算时间")
private List<String> qualityStartDate;
@ApiModelProperty("质保起算时间关联字段")
private List<String> qualityFiledName;
@ApiModelProperty("父节点ID集合")
private List<Long> parentIds;
@ApiModelProperty("质保单位")
private String qualityUnit;
private Integer materielId;
@ApiModelProperty("质保时长")
private Integer qualityDuration;
@ApiModelProperty("是否删除")
private Integer isDelete;
@ApiModelProperty("0:目录 1:类型")
private Integer conData;
@ApiModelProperty("编号集合")
private List<String> catalogNumList;
@ApiModelProperty("类型名称集合,建议只用在根据名称搜产品目录上")
private List<String> catalogNameList;
@ApiModelProperty("服务项目id集合")
private List<String> relatedServiceItem;
/**
* 产品分类层级
*/
private String catalogLevel;
/**
* 分类类型
*/
private String catalogType;
/**
* 生产组织
*/
private String productionOrg;
/**
* 财务组织
*/
private String financeOrg;
/**
* 条码属性
*/
private String barcodeId;
private int exportTotal;
}
package com.zxr.demos.common.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class CommonPageParam extends ShbBasePage{
private String commonSearch;
}
package com.zxr.demos.common.param;
import com.zxr.demos.common.vo.MacroServiceSettleStandardVo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.List;
/**
* Macro服务费结算标准
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class MacroServiceSettleStandardForm {
private Integer id;
/**
* 状态:未生效、已生效、已失效(单选,默认“已生效”)
*/
private String state;
/**
* 服务类型:下拉菜单,支持多选
*/
private List<String> serviceTypes;
/**
* 产品分类:下拉菜单,支持多选
*/
private List<String> productCategories;
/**
* 地区:下拉菜单,支持多选
*/
private List<String> regionForms;
/**
* 创建日期
*/
private Long createTime;
//结算标准:单行文本,必填
private String standardName;
private String serviceTypeId;
// 服务类型:下拉菜单,选项=取【1-1-3 服务类型设置】页面“启用”状态的值,单选,必填
private String serviceType;
// 保修类型:下拉菜单,选项=保内,默认选中保内,必填
private String warrantyType;
private Long productCategoryId;
// 产品大类:下拉菜单,选项=取【3-2 产品分类】列表内“产品大类”的分类名称,单选,必填
private String productCategory;
// 生效日期:日期控件,仅可选择明天及之后的时间,格式年月日时分秒,时分秒默认为00:00:00,且不可修改,必填
private Long effectiveDate;
// 失效日期:日期控件,需日期需晚于或等于生效日期,格式年月日时分秒,时分秒默认为23:59:59,且不可修改,必填
private Long expirationDate;
// 一二级市场:数值,可输入范围0<=X<=99999,最多保留2位小数,必填
private BigDecimal primaryToSecondMarket;
// 三四级市场:数值,可输入范围0<=X<=99999,最多保留2位小数,必填
private BigDecimal thirdToFourthMarket;
// 五六级市场:数值,可输入范围0<=X<=99999,最多保留2位小数,必填
private BigDecimal fifthToSixthMarket;
// 其他市场:数值,可输入范围0<=X<=99999,最多保留2位小数,非必填
private BigDecimal otherMarket;
// 产品小类:下拉菜单,显示已选择产品大类下的小类,选项来源=【3-2 产品分类】列表内“产品小类”,多选,非必填
private List<MacroServiceSettleStandardVo.productSubCategory> productSubCategories;
// 指定产品:选择弹窗,数据来源【3-3 产品型号】列表内“已启用”的产品类型名称,支持多选,非必填
private List<MacroServiceSettleStandardVo.specifiedProduct> specifiedProducts;
// 指定网点:下拉菜单,选项=服务网点列表内为撤点的数据,显示网点名称+网点编号,支持多选,非必填
private List<MacroServiceSettleStandardVo.Provider> serviceProviders;
// 指定地区:级联控件,可选择省-市,支持多选,非必填
private List<MacroServiceSettleStandardVo.Region> regions;
// 备注:文本,非必填
private String remark;
}
package com.zxr.demos.common.param;
public class ShbBasePage {
private Integer pageNum = 1;
private Integer pageSize = 10;
private String orderBy;
public ShbBasePage() {
}
public Integer getPageNum() {
return this.pageNum;
}
public void setPageNum(Integer pageNum) {
if (pageNum == null || pageNum <= 0) {
pageNum = 1;
}
this.pageNum = pageNum;
}
public Integer getPageSize() {
return this.pageSize;
}
public void setPageSize(Integer pageSize) {
if (pageSize == null || pageSize < 0) {
pageSize = 10;
}
if (pageSize >= 500) {
pageSize = 500;
}
this.pageSize = pageSize;
}
public String getOrderBy() {
return this.orderBy;
}
public void setOrderBy(String orderBy) {
this.orderBy = orderBy;
}
}
package com.zxr.demos.common.param;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.LinkedHashMap;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class TestParam {
@JsonProperty("ID")
private Long id;
private LinkedHashMap attribute;
}
package com.zxr.demos.common.param;
import lombok.Data;
@Data
public class UdspQueryCarSeriesListParam {
private Integer pageNo = 1;
private Integer pageSize = 10;
private String modelName;
}
package com.zxr.demos.common.param;
import lombok.Data;
@Data
public class UdspQueryPartsParam {
private Integer pageNo = 1;
private Integer pageSize = 10;
private String partsCode;
private String partsEname;
private String partsCname;
}
package com.zxr.demos.common.param;
import lombok.Data;
@Data
public class UdspQueryWorkHourParam {
private Integer pageNo = 1;
private Integer pageSize = 10;
private String taskName;
private String taskCode;
}
package com.zxr.demos.common.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BarCodeResponseData {
private EsbInfo esbInfo;
private QueryInfo queryInfo;
private List<ResultInfo> resultInfo;
@AllArgsConstructor
@NoArgsConstructor
@Data
// QueryInfo类
static class QueryInfo {
private int totalRecord;
private int totalPage;
private int pageSize;
private int currentPage;
}
@AllArgsConstructor
@NoArgsConstructor
@Data
// ResultInfo类
static class ResultInfo {
private String org_name;
private String warehouse_name;
private String cust_code;
private String barcode;
private String org_code;
private String engineering_proj_name;
private int bill_type;
private int id;
private String cust_name;
private String item_code;
private String in_warehouse_name;
private String item_name;
private String guarantee;
private String warehouse_code;
private String engineering_proj_sn;
private String bill_no;
private String channel;
private String bill_date;
private String in_warehouse_code;
private String is_install;
// Getters and Setters
// ...
}
@AllArgsConstructor
@NoArgsConstructor
@Data
public static class EsbInfo {
private String instId;
private String returnStatus;
private String returnCode;
private String returnMsg;
private String requestTime;
private String responseTime;
private String attr1;
private String attr2;
private String attr3;
}
}
package com.zxr.demos.common.response;
import com.zxr.demos.common.enums.UdspApiResultCode;
import com.zxr.demos.common.enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Objects;
/**
* @author xiaoyu
* 吉利接口响应结果
* @since 2023/8/16
*/
@Data
@AllArgsConstructor
public class GeelyResult<T> {
/**
* 200表示请求成功,其他表示失败
*/
private int code;
private String message;
private Boolean success;
private T data; // 使用泛型T来表示data字段的类型
public GeelyResult() {
}
private static <T> GeelyResult<T> newInstance(Integer code, String message, T data) {
GeelyResult<T> result = new GeelyResult<>();
result.setMessage(message);
result.setCode(code);
result.setData(data);
result.setSuccess(Objects.equals(code, UdspApiResultCode.SUCCESS.getCode()));
return result;
}
public static <T> GeelyResult<T> fail(ResultCode status) {
return newInstance(status.getCode(), status.getMessage(), null);
}
public static <T> GeelyResult<T> success(T data) {
return newInstance(UdspApiResultCode.SUCCESS.getCode(), UdspApiResultCode.SUCCESS.getMessage(), data);
}
}
package com.zxr.demos.common.response;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PerformResult {
private Integer resultCode;
private String msg;
}
package com.zxr.demos.common.response;
import com.zxr.demos.common.enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Objects;
import static com.zxr.demos.common.enums.CommonResultCode.系统错误;
import static com.zxr.demos.common.enums.CommonResultCode.请求成功;
@Data
@AllArgsConstructor
public class Result<T> {
private Boolean success;
private Integer code;
private String message;
private T data;
public Result() {
}
private static <T> Result<T> newInstance(Integer code, String message, T data) {
Result<T> result = new Result<>();
result.setMessage(message);
result.setCode(code);
result.setData(data);
result.setSuccess(Objects.equals(code, 请求成功.getCode()));
return result;
}
public static <T> Result<T> fail(ResultCode status) {
return newInstance(status.getCode(), status.getMessage(), null);
}
public static <T> Result<T> fail(String failMessage) {
return newInstance(系统错误.getCode(), failMessage, null);
}
public static <T> Result<T> fail(Integer code, String message) {
return newInstance(code, message, null);
}
public static <T> Result<T> success(T data) {
return newInstance(请求成功.getCode(), 请求成功.getMessage(), data);
}
public static <T> Result<T> success(ResultCode status, T data) {
return newInstance(status.getCode(), status.getMessage(), data);
}
public static <T> Result<T> success() {
return newInstance(请求成功.getCode(), 请求成功.getMessage(), null);
}
public boolean isSuccess() {
return this.success;
}
}
package com.zxr.demos.common.response;
import com.zxr.demos.common.enums.StatusCodeEnum;
public class ShbResult<T> {
private int status;
private boolean success;
private String message;
private T data;
public ShbResult() {
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
public boolean isSuccess() {
return this.success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return this.data;
}
public void setData(T data) {
this.data = data;
}
private static <T> ShbResult<T> newInstance(int status, String message, T data) {
ShbResult<T> result = new ShbResult();
result.status = status;
result.success = status == StatusCodeEnum.SUCCESS.getCode();
result.message = message;
result.data = data;
return result;
}
private static <T> ShbResult<T> newInstance(StatusCodeEnum statusCode) {
return newInstance(statusCode, statusCode.getMsg());
}
private static <T> ShbResult<T> newInstance(StatusCodeEnum statusCode, String message) {
return (ShbResult<T>) newInstance(statusCode.getCode(), message, (Object)null);
}
private static <T> ShbResult<T> newInstance(StatusCodeEnum statusCode, T data) {
return newInstance(statusCode.getCode(), statusCode.getMsg(), data);
}
public static <T> ShbResult<T> success() {
return newInstance(StatusCodeEnum.SUCCESS);
}
public static <T> ShbResult<T> success(String message) {
return newInstance(StatusCodeEnum.SUCCESS, message);
}
public static <T> ShbResult<T> success(T data) {
return newInstance(StatusCodeEnum.SUCCESS, data);
}
public static <T> ShbResult<T> fail(String message) {
return newInstance(StatusCodeEnum.FAIL, message);
}
public static <T> ShbResult<T> fail() {
return newInstance(StatusCodeEnum.FAIL, StatusCodeEnum.FAIL.getMsg());
}
public static <T> ShbResult<T> fail(String message, T data) {
return newInstance(StatusCodeEnum.FAIL.getCode(), message, data);
}
public static <T> ShbResult<T> error(String message) {
return newInstance(StatusCodeEnum.ERROR, message);
}
public static <T> ShbResult<T> fail(StatusCodeEnum statusCode) {
return newInstance(statusCode);
}
public static <T> ShbResult<T> fail(StatusCodeEnum statusCode, T data) {
return newInstance(statusCode, data);
}
public static <T> ShbResult<T> of(int status, String message, T data) {
return newInstance(status, message, data);
}
public static <T> ShbResult<T> of(int status, T data) {
return newInstance(status, "", data);
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment