com.yanyun.auth.dto.ResultDto Maven / Gradle / Ivy
package com.yanyun.auth.dto;
import java.io.Serializable;
public class ResultDto implements Serializable {
private Integer code;
private String msg;
private T data;
private long time;
public static ResultDto success(){
ResultDto resultDto = new ResultDto();
resultDto.setCode(200);
resultDto.setMsg("操作成功");
resultDto.setTime(System.currentTimeMillis());
return resultDto;
}
public static ResultDto success(Object data){
ResultDto resultDto = new ResultDto();
resultDto.setCode(200);
resultDto.setMsg("操作成功");
resultDto.setData(data);
resultDto.setTime(System.currentTimeMillis());
return resultDto;
}
public static ResultDto error(){
ResultDto resultDto = new ResultDto();
resultDto.setCode(500);
resultDto.setMsg("操作失败");
resultDto.setTime(System.currentTimeMillis());
return resultDto;
}
public static ResultDto error(Object data){
ResultDto resultDto = new ResultDto();
resultDto.setCode(500);
resultDto.setMsg("操作失败");
resultDto.setData(data);
resultDto.setTime(System.currentTimeMillis());
return resultDto;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
@Override
public String toString() {
return "ResultDto{" +
"code=" + code +
", msg='" + msg + '\'' +
", data=" + data +
", time=" + time +
'}';
}
}