| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package zs.payment.resp;
- import com.alibaba.fastjson.annotation.JSONField;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * 统一响应封装
- */
- public class Result {
- @JSONField(name = "body")
- private Map<String, Object> body;
- private Result(Map<String, Object> body) {
- this.body = body;
- }
- public static Result success() {
- Map<String, Object> body = new HashMap<>();
- body.put("CODE", 200);
- body.put("MSG", "SUCCESS");
- return new Result(body);
- }
- // public static Result success(String token) {
- // Map<String, Object> body = new HashMap<>();
- // body.put("CODE", 200);
- // body.put("MSG", "SUCCESS");
- // body.put("token", token);
- // return new Result(body);
- // }
- public static Result success(Object data) {
- Map<String, Object> body = new HashMap<>();
- body.put("CODE", 200);
- body.put("MSG", "SUCCESS");
- body.put("data", data);
- return new Result(body);
- }
- public static Result fail(String msg) {
- Map<String, Object> body = new HashMap<>();
- body.put("CODE", 500);
- body.put("MSG", msg);
- return new Result(body);
- }
- public Map<String, Object> getBody() {
- return body;
- }
- public boolean isSuccess() {
- return Integer.valueOf(200).equals(body.get("CODE"));
- }
- }
|