博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
项目中自定义返回任意数据或者消息
阅读量:6824 次
发布时间:2019-06-26

本文共 2140 字,大约阅读时间需要 7 分钟。

public class AjaxMessage implements Serializable {
private String state; private String msg; private Object data; public String getState() {
return state; } public void setState(String state) {
this.state = state; } public String getMsg() {
return msg; } public void setMsg(String msg) {
this.msg = msg; } public Object getData() {
return data; } public void setData(Object data) {
this.data = data; } public String toJson() {
return JSON.toJSONString(this); } public static Builder SYS_ERR() {
return new Builder(ResponseCode.SYS_ERR); } public static Builder SUCC() {
return new Builder(ResponseCode.SUCC); } public static Builder ERR(ResponseCode responseCode) {
return new Builder(responseCode); } public static Builder ERR(String state, String msg) {
return new Builder(state, msg); } public static Builder ERR(String msg) {
return new Builder("00001", msg); } public AjaxMessage(Builder builder) {
this.state = builder.state; this.msg = builder.msg; this.data = builder.data; } public static class Builder {
private String state; private String msg; private Object data; public Builder(ResponseCode responseCode) {
this.state = responseCode.getState(); this.msg = responseCode.getMsg(); } public Builder(String state, String msg) {
this.state = state; this.msg = msg; } public Builder code(String state) {
this.state = state; return this; } public Builder message(String msg) {
this.msg = msg; return this; } public Builder data(Object data) {
this.data = data; return this; } public AjaxMessage build() {
return new AjaxMessage(this); } } }

转载于:https://www.cnblogs.com/JerryTomcat/p/8683108.html

你可能感兴趣的文章
【模板】矩阵快速幂
查看>>
AJAX笔记
查看>>
cadence 封装制作小结
查看>>
AFNetwork 作用和用法详解
查看>>
登录linux,输入ls显示anaconda-ks.cfg cobbler.ks ....., 原因在于root@ ~ / 区别
查看>>
虚拟机CentOS6.5网络配置
查看>>
bzoj2563 阿狸和桃子的游戏
查看>>
概念整理3
查看>>
《Hadoop基础教程》之初识Hadoop
查看>>
转:前端单元测试总结
查看>>
【LeetCode每天一题】 Intersection of Two Linked Lists(两个链表的入口节点)
查看>>
spring mvc 用ajaxSubmit 在iE8上传文件变下载的问题
查看>>
Nginx 负载均衡动静分离配置
查看>>
laravel, Composer和autoloading
查看>>
D3 JS study notes
查看>>
算法整理-二叉树和堆栈
查看>>
如何设计一个“高大上”的 logo
查看>>
clustalo安装
查看>>
[日常] Go语言圣经--示例: 并发的Clock服务习题
查看>>
个人总结8
查看>>