Skip to content

Commit 999a933

Browse files
committed
feat: 添加 SimpleRes.ResError 构造函数,传入 ErrorEnum
1 parent e332d57 commit 999a933

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/top/cadecode/simple/common/response/SimpleRes.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,15 @@ public class SimpleRes {
3434
*/
3535
@Data
3636
@AllArgsConstructor
37+
@NoArgsConstructor
3738
public static class ResError {
3839
private Integer code;
3940
private String reason;
41+
42+
public ResError(ErrorEnum errorEnum){
43+
this.code = errorEnum.getCode();
44+
this.reason = errorEnum.getReason();
45+
}
4046
}
4147

4248
/**
@@ -63,7 +69,7 @@ public static SimpleRes fail(ErrorEnum errorEnum) {
6369
SimpleRes res = new SimpleRes();
6470
res.setStatus(errorEnum.getStatusEnum().getStatus());
6571
res.setMessage(errorEnum.getStatusEnum().getMessage());
66-
res.setError(new ResError(errorEnum.getCode(), errorEnum.getReason()));
72+
res.setError(new ResError(errorEnum));
6773
return res;
6874
}
6975

0 commit comments

Comments
 (0)