Commit 9a891adc80dc90249bdbde343acd4d6c46b10bb0
1 parent
b7d9f7f9
# fix修改返回结果提示消息
Showing
3 changed files
with
12 additions
and
7 deletions
pom.xml
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | 6 | ||
| 7 | <groupId>com.irrigation</groupId> | 7 | <groupId>com.irrigation</groupId> |
| 8 | <artifactId>common-lib</artifactId> | 8 | <artifactId>common-lib</artifactId> |
| 9 | - <version>2.0.1</version> | 9 | + <version>2.0.2</version> |
| 10 | 10 | ||
| 11 | <properties> | 11 | <properties> |
| 12 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | 12 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
src/main/java/com/irrigation/icl/entity/RestResult.java
| @@ -12,6 +12,7 @@ import lombok.NoArgsConstructor; | @@ -12,6 +12,7 @@ import lombok.NoArgsConstructor; | ||
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * 公共返回类 | 14 | * 公共返回类 |
| 15 | + * | ||
| 15 | * @param <T> | 16 | * @param <T> |
| 16 | */ | 17 | */ |
| 17 | @Data | 18 | @Data |
| @@ -19,17 +20,19 @@ import lombok.NoArgsConstructor; | @@ -19,17 +20,19 @@ import lombok.NoArgsConstructor; | ||
| 19 | @NoArgsConstructor | 20 | @NoArgsConstructor |
| 20 | @ApiModel(value = "RestResult") | 21 | @ApiModel(value = "RestResult") |
| 21 | public class RestResult<T> { | 22 | public class RestResult<T> { |
| 22 | - @ApiModelProperty(value = "返回编码类型",example = "200",allowableValues = "200,400") | 23 | + @ApiModelProperty(value = "返回编码类型", example = "200", allowableValues = "200,400") |
| 23 | private int code; | 24 | private int code; |
| 24 | - @ApiModelProperty(value = "返回提示消息",example = "成功") | 25 | + @ApiModelProperty(value = "返回提示消息", example = "成功") |
| 25 | private String message; | 26 | private String message; |
| 26 | @ApiModelProperty(value = "返回请求数据对象") | 27 | @ApiModelProperty(value = "返回请求数据对象") |
| 27 | private T data; | 28 | private T data; |
| 28 | 29 | ||
| 29 | public String getMessage() { | 30 | public String getMessage() { |
| 30 | - return message != null?message: ResultEnum.getCode(code).getMessage(); | 31 | + return message != null ? message : ResultEnum.getCode(code).getMessage(); |
| 31 | } | 32 | } |
| 32 | - public String toString(){ | 33 | + |
| 34 | + @Override | ||
| 35 | + public String toString() { | ||
| 33 | return JSON.toJSONString(this); | 36 | return JSON.toJSONString(this); |
| 34 | } | 37 | } |
| 35 | } | 38 | } |
src/main/java/com/irrigation/icl/enums/ResultEnum.java
| @@ -5,9 +5,11 @@ import java.util.Optional; | @@ -5,9 +5,11 @@ import java.util.Optional; | ||
| 5 | 5 | ||
| 6 | public enum ResultEnum { | 6 | public enum ResultEnum { |
| 7 | 7 | ||
| 8 | - SUCCESS(200, "success"), | 8 | + SUCCESS(200, "操作成功"), |
| 9 | + | ||
| 9 | SUCCESS_NO_DATA(202,"查询成功,无数据"), | 10 | SUCCESS_NO_DATA(202,"查询成功,无数据"), |
| 10 | - ERROR(400, "failed"), | 11 | + |
| 12 | + ERROR(400, "操作失败"), | ||
| 11 | 13 | ||
| 12 | PARAMETER_MISMATCH(402, "参数不匹配!"), | 14 | PARAMETER_MISMATCH(402, "参数不匹配!"), |
| 13 | 15 |