| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- package com.template.model.result;
- import com.flyhigh.common.config.CoreConstant;
- import com.flyhigh.common.exception.CustomizeException;
- import io.swagger.annotations.ApiModel;
- import io.swagger.annotations.ApiModelProperty;
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import java.io.Serializable;
- */
- /**
- * 请求响应数据
- *
- * @param <T> 数据类型
- *//*
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
- @ApiModel("请求响应数据")
- public class Result<T> implements Serializable {
- */
- /**
- * 数据
- *//*
- @ApiModelProperty("数据")
- private T data;
- */
- /**
- * 信息
- *//*
- @ApiModelProperty("信息")
- private String message;
- */
- /**
- * 状态码
- *//*
- @ApiModelProperty("状态码")
- private int code;
- public static <T> Result<T> ok() {
- return new Result<>(null, "" , 200);
- }
- public static <T> Result<T> ok(T data) {
- return new Result<>(data, "" , 200);
- }
- public static <T> Result<T> ok(T data, String message) {
- return new Result<>(data, message, 200);
- }
- public static <T> Result<T> fail(String message, int code) {
- return new Result<>(null, message, code);
- }
- public static <T> Result<T> fail(T data, String message, int code) {
- return new Result<>(data, message, code);
- }
- public static <T> Result<T> fail(CustomizeException e) {
- return new Result<>(null, e.getMessage(), e.getCode());
- }
- public static <T> Result<T> failClient(String message) {
- return new Result<>(null, message, CoreConstant.CLIENT_LOGIC_ERROR);
- }
- public static <T> Result<T> failSystem(String message) {
- return new Result<>(null, message, CoreConstant.SERVER_LOGIC_ERROR);
- }
- }
- */
|