1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-10-07 00:15:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

后台返回数据统一为CommonReturnType

This commit is contained in:
2022-03-15 13:48:58 +08:00
parent ae26ecc372
commit cbfc277c9c
7 changed files with 62 additions and 13 deletions

View File

@@ -0,0 +1,26 @@
package plus.bookshelf.Common.Response;
import lombok.Data;
@Data
public class CommonReturnType {
// 表明对应请求的返回处理结果 "success" 或 "fail"
private String Status;
// 若 status == "success" 则data内返回前端需要的JSON数据
// 若 status == "fail" 则data内使用通用的错误码格式
private Object Data;
// 定义一个通用的创建方法
public static CommonReturnType create(Object result) {
return CommonReturnType.create(result, CommonReturnTypeStatus.SUCCESS);
}
public static CommonReturnType create(Object result, CommonReturnTypeStatus status) {
CommonReturnType type = new CommonReturnType();
type.setData(result);
type.setStatus(status.toString());
return type;
}
}