使用SSM架构的使用,打算使用json详解编程语言

1、自己写一个实现类,里面包含3个属性和一些状态值,最主要的就是这个类要实现序列化

package com.auth.common;

 

import java.io.Serializable;

import java.util.List;

 

import com.elevator.liftRealTimeTask.entity.LiftRealTimeTask;

 

public class AjaxResult<T> implements Serializable {

private static final long serialVersionUID = -3291987235896997470L;

public static final Integer AJAX_STATUS_CODE_SUCCESS=0;

public static final Integer AJAX_STATUS_CODE_WARN=1;

public static final Integer AJAX_STATUS_CODE_ERROR=2;

 

private Integer statusCode;

private String message;

private  T data;

 

 

 

public AjaxResult(){

super();

}

 

public AjaxResult(String message,Integer statusCode){

super();

this.statusCode=statusCode;

this.message=message;

}

 

public AjaxResult(String message,Integer statusCode,T data){

super();

this.statusCode=statusCode;

this.message=message;

this.data=data;

}

 

 

public static AjaxResult success(){

AjaxResult ajaxResult=new AjaxResult();

ajaxResult.setStatusCode(AjaxResult.AJAX_STATUS_CODE_SUCCESS);

ajaxResult.setMessage(“操作成功”);

return ajaxResult;

}

 

public AjaxResult success(T data){

AjaxResult ajaxResult=new AjaxResult();

ajaxResult.setStatusCode(AjaxResult.AJAX_STATUS_CODE_SUCCESS);

ajaxResult.setMessage(“操作成功!”);

ajaxResult.setData(data);

return ajaxResult;

}

 

//手机

/*public AjaxResult success(List list){

AjaxResult ajaxResult=new AjaxResult();

ajaxResult.setStatusCode(AjaxResult.AJAX_STATUS_CODE_SUCCESS);

ajaxResult.setMessage(“操作成功”);

ajaxResult.setData(list);

return ajaxResult;

}*/

public static AjaxResult error(){

AjaxResult ajaxResult=new AjaxResult();

ajaxResult.setStatusCode(AjaxResult.AJAX_STATUS_CODE_ERROR);

ajaxResult.setMessage(“操作异常!”);

return ajaxResult;

}

 

public static AjaxResult warn(){

AjaxResult ajaxResult=new AjaxResult();

ajaxResult.setStatusCode(AjaxResult.AJAX_STATUS_CODE_WARN);

return ajaxResult;

}

 

 

 

public Integer getStatusCode() {

return statusCode;

}

 

public void setStatusCode(Integer statusCode) {

this.statusCode = statusCode;

}

 

public String getMessage() {

return message;

}

 

public void setMessage(String message) {

this.message = message;

}

 

public  T getData() {

return data;

}

 

public void setData(T data) {

this.data = data;

}

 

 

}

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/15488.html

(0)
上一篇 2021年7月19日 17:52
下一篇 2021年7月19日 17:52

相关推荐

发表回复

登录后才能评论