mark for pull
This commit is contained in:
105
ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java
Normal file
105
ym-common/src/main/java/com/cnbm/common/vo/ApiErrorCode.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
/**
|
||||
* REST API 错误码
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/1
|
||||
* @since 1.0
|
||||
*/
|
||||
public enum ApiErrorCode implements IErrorCode {
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESSFUL(CODE_SUCCESSFUL, "成功"),
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAILED(CODE_FAILED, "失败"),
|
||||
/**
|
||||
* 无效的请求参数
|
||||
*/
|
||||
//INVALID_PARAMETER(CODE_INVALID_PARAMETER, "无效的请求参数"),
|
||||
INVALID_PARAMETER(CODE_INVALID_PARAMETER, "Invalid request parameter"),
|
||||
/**
|
||||
* 数据未授权
|
||||
*/
|
||||
FORBIDDEN_DATA(CODE_FORBIDDEN_DATA, "数据未授权"),
|
||||
/**
|
||||
* 用户已存在
|
||||
*/
|
||||
USER_EXISTENT(CODE_USER_EXISTENT, "用户已存在"),
|
||||
/**
|
||||
* 用户不存在
|
||||
*/
|
||||
//USER_NON_EXISTENT(CODE_USER_NON_EXISTENT, "用户不存在"),
|
||||
USER_NON_EXISTENT(CODE_USER_NON_EXISTENT, "User does not exist"),
|
||||
/**
|
||||
* 用户已停用
|
||||
*/
|
||||
USER_DISABLED(CODE_FAILED, "用户已停用"),
|
||||
/**
|
||||
* 用户不存在或密码错误
|
||||
*/
|
||||
USER_NON_EXISTENT_OR_INVALID_PASSWORD(CODE_FAILED, "The user does not exist or the password is wrong"),
|
||||
//USER_NON_EXISTENT_OR_INVALID_PASSWORD(CODE_FAILED, "用户不存在或密码错误"),
|
||||
/**
|
||||
* 密码错误
|
||||
*/
|
||||
//INVALID_PASSWORD(CODE_FAILED, "密码错误"),
|
||||
INVALID_PASSWORD(CODE_FAILED, "Wrong password"),
|
||||
|
||||
/**
|
||||
* 电话号码不能为空
|
||||
*/
|
||||
MOBILE_IS_EMPTY(CODE_FAILED, "手机号码不能为空"),
|
||||
|
||||
/**
|
||||
* 用户未登录
|
||||
*/
|
||||
UNAUTHORIZED(CODE_UNAUTHORIZED, "用户未登录"),
|
||||
/**
|
||||
* 用户未授权
|
||||
*/
|
||||
FORBIDDEN(CODE_FORBIDDEN, "用户未授权");
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
ApiErrorCode(final int code, final String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static ApiErrorCode fromCode(int code) {
|
||||
ApiErrorCode[] apiErrorCodes = ApiErrorCode.values();
|
||||
for (ApiErrorCode apiErrorCode : apiErrorCodes) {
|
||||
if (apiErrorCode.getCode() == code) {
|
||||
return apiErrorCode;
|
||||
}
|
||||
}
|
||||
return SUCCESSFUL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg);
|
||||
}
|
||||
}
|
||||
78
ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java
Normal file
78
ym-common/src/main/java/com/cnbm/common/vo/CommonVo.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 公共视图对象
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/9
|
||||
* @since 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
@ApiModel("公共视图对象")
|
||||
public class CommonVo {
|
||||
|
||||
/**
|
||||
* 启用状态:0 、停用,1、启用
|
||||
*/
|
||||
@ApiModelProperty(value = "启用状态:0 、停用,1、启用", example = "1", position = Integer.MAX_VALUE - 1)
|
||||
private Integer enabled;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注", position = Integer.MAX_VALUE - 1)
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人", example = "1", position = Integer.MAX_VALUE)
|
||||
private Long creatorId;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人姓名", example = "ulabcare", position = Integer.MAX_VALUE)
|
||||
private String creatorName;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间", position = Integer.MAX_VALUE)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人", example = "1", position = Integer.MAX_VALUE)
|
||||
private Long updaterId;
|
||||
|
||||
/**
|
||||
* 更新人姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人姓名", example = "ulabcare", position = Integer.MAX_VALUE)
|
||||
private String updaterName;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ApiModelProperty(value = "更新时间", position = Integer.MAX_VALUE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
24
ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java
Normal file
24
ym-common/src/main/java/com/cnbm/common/vo/DictDataVo.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </P>
|
||||
*
|
||||
* @author FanYi
|
||||
* @date 2020/7/6
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel("字典值对象")
|
||||
@Data
|
||||
public class DictDataVo {
|
||||
@ApiModelProperty("字典编码")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("字典名称")
|
||||
private String name;
|
||||
}
|
||||
63
ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java
Normal file
63
ym-common/src/main/java/com/cnbm/common/vo/IErrorCode.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
/**
|
||||
* api错误码定义
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/1
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface IErrorCode {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
int CODE_SUCCESSFUL = 0;
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
int CODE_FAILED = 1;
|
||||
/**
|
||||
* 无效的请求参数
|
||||
*/
|
||||
int CODE_INVALID_PARAMETER = 2;
|
||||
/**
|
||||
* 数据未授权
|
||||
*/
|
||||
int CODE_FORBIDDEN_DATA = 9;
|
||||
/**
|
||||
* 用户已存在
|
||||
*/
|
||||
int CODE_USER_EXISTENT = 10;
|
||||
/**
|
||||
* 用户不存在
|
||||
*/
|
||||
int CODE_USER_NON_EXISTENT = 11;
|
||||
/**
|
||||
* 用户未登录
|
||||
*/
|
||||
int CODE_UNAUTHORIZED = 401;
|
||||
/**
|
||||
* 用户未授权
|
||||
*/
|
||||
int CODE_FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* 错误编码:0、成功 否则失败
|
||||
*
|
||||
* @return 错误码:0、成功 否则失败
|
||||
*/
|
||||
int getCode();
|
||||
|
||||
/**
|
||||
* 错误描述
|
||||
*
|
||||
* @return 错误描述
|
||||
*/
|
||||
String getMsg();
|
||||
}
|
||||
33
ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java
Normal file
33
ym-common/src/main/java/com/cnbm/common/vo/IdListVo.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 主键列表对象
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/14
|
||||
* @since 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
@Builder
|
||||
@ApiModel("主键列表视图对象")
|
||||
public class IdListVo {
|
||||
@ApiModelProperty(value = "主键列表", required = true, example = "[1]", notes = "根据实际接口返回不同对象的主键列表")
|
||||
private List<Long> ids;
|
||||
}
|
||||
32
ym-common/src/main/java/com/cnbm/common/vo/IdVo.java
Normal file
32
ym-common/src/main/java/com/cnbm/common/vo/IdVo.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
/**
|
||||
* 主键对象
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/7
|
||||
* @since 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@Data
|
||||
@Builder
|
||||
@ApiModel("主键视图对象")
|
||||
public class IdVo {
|
||||
@ApiModelProperty(value = "主键", required = true, example = "1", notes = "根据实际接口返回不同对象的主键")
|
||||
private Long id;
|
||||
}
|
||||
102
ym-common/src/main/java/com/cnbm/common/vo/R.java
Normal file
102
ym-common/src/main/java/com/cnbm/common/vo/R.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 处理结果类
|
||||
*
|
||||
* @param <T> 返回的数据类型
|
||||
* @author jiff
|
||||
* @date 2018/11/7
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@ApiModel("处理结果类")
|
||||
@Accessors
|
||||
public class R<T> implements Serializable {
|
||||
@NonNull
|
||||
@ApiModelProperty(value = "结果码", example = "0")
|
||||
private int code = IErrorCode.CODE_SUCCESSFUL;
|
||||
@ApiModelProperty(value = "结果说明", example = "成功")
|
||||
private String msg;
|
||||
@ApiModelProperty(value = "业务数据")
|
||||
private T data;
|
||||
|
||||
public R<T> code(int code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public R<T> msg(String msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public R<T> data(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean ok() {
|
||||
return code == IErrorCode.CODE_SUCCESSFUL;
|
||||
}
|
||||
|
||||
public static <T> R<T> failed() {
|
||||
return failed("系统错误!");
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(String msg) {
|
||||
return failed(ApiErrorCode.FAILED.getCode(), msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(int code, String msg) {
|
||||
return failed(code, msg, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(int code, String msg, T data) {
|
||||
return r(code == ApiErrorCode.SUCCESSFUL.getCode() ? ApiErrorCode.FAILED.getCode() : code, msg, data);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(IErrorCode errorCode) {
|
||||
return r(errorCode, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> r(IErrorCode errorCode, T data) {
|
||||
return r(errorCode.getCode(), errorCode.getMsg(), data);
|
||||
}
|
||||
|
||||
public static <T> R<T> r(int code, String msg, T data) {
|
||||
return new R<T>().code(code).msg(msg).data(data);
|
||||
}
|
||||
|
||||
public static <T> R<T> unauthorized() {
|
||||
return failed(ApiErrorCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
public static <T> R<T> forbidden() {
|
||||
return failed(ApiErrorCode.FORBIDDEN);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return new R<T>().data(data);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(String msg, T data) {
|
||||
return new R<T>().msg(msg).data(data);
|
||||
}
|
||||
|
||||
}
|
||||
26
ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java
Normal file
26
ym-common/src/main/java/com/cnbm/common/vo/SelectVo.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </P>
|
||||
*
|
||||
* @author FanYi
|
||||
* @date 2020/7/6
|
||||
* @since 1.0
|
||||
*/
|
||||
@ApiModel("下拉选择列表对象")
|
||||
@Data
|
||||
public class SelectVo {
|
||||
@ApiModelProperty("key值,用于传给后端")
|
||||
private Object k;
|
||||
|
||||
@ApiModelProperty("value值,用于前端显示")
|
||||
private Object v;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </P>
|
||||
*
|
||||
* @author FanYi
|
||||
* @date 2020/4/28
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
public class SmsSignCodeVo {
|
||||
private Long sceneId;
|
||||
|
||||
private String signName;
|
||||
|
||||
private String templateCode;
|
||||
|
||||
private Integer templateType;
|
||||
|
||||
private String templateContent;
|
||||
}
|
||||
30
ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java
Normal file
30
ym-common/src/main/java/com/cnbm/common/vo/WhetherVo.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.cnbm.common.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
/**
|
||||
* 是否对象
|
||||
*
|
||||
* @author jiff
|
||||
* @date 2018/11/11
|
||||
* @since 1.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@ApiModel("是否对象")
|
||||
public class WhetherVo {
|
||||
@ApiModelProperty(value = "是否:true、是,false、否", required = true, example = "true")
|
||||
private Boolean whether;
|
||||
}
|
||||
Reference in New Issue
Block a user