From 58f24ecc8d017ca16b586c1bd32005ef8432c7af Mon Sep 17 00:00:00 2001 From: pho6e2qjw <1563847437@qq.com> Date: Wed, 26 Jun 2024 08:38:11 +0800 Subject: [PATCH] Add Result.java --- Result.java | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Result.java diff --git a/Result.java b/Result.java new file mode 100644 index 0000000..8ba8fb2 --- /dev/null +++ b/Result.java @@ -0,0 +1,54 @@ +//数据封装 +package com.power.travel.core; + +import com.alibaba.fastjson.JSON; + +/** + * 统一API响应结果封装 + */ +public class Result { + + private int code; + + private String message; + + private Object data; + + public Result setCode(ResultCode resultCode) { + this.code = resultCode.getCode(); + return this; + } + + public int getCode() { + return code; + } + + public Result setCode(int code) { + this.code = code; + return this; + } + + public String getMessage() { + return message; + } + + public Result setMessage(String message) { + this.message = message; + return this; + } + + public Object getData() { + return data; + } + + public Result setData(Object data) { + this.data = data; + return this; + } + + @Override + public String toString() { + return JSON.toJSONString(this); + } + +}