当前位置:网站首页>Response < t > class
Response < t > class
2022-07-28 05:28:00 【MusicCodeM】
Project scenario :
Now the data returned by the development backend to the front end is json data , So use the following tool class , Make a note of . Convenient for future use .Solution :
Tips : Fill in the specific solution to the problem here :
utils:
Response.java
public class Response<T> {
private Boolean success;
private String message;
private T data;
public Response() {
}
public Response(Boolean success) {
this.success = success;
}
public Response(Boolean success, String message) {
this.success = success;
this.message = message;
}
public Response(Boolean success, String message, T data) {
this.success = success;
this.message = message;
this.data = data;
}
public static <T> Response<T> yes() {
return new Response(true, " Successful operation ");
}
public static <T> Response<T> yes(String message,T data) {
return new Response(true, message, data);
}
public static <T> Response<T> yes(T data) {
return new Response(true, " Successful operation ", data);
}
public static <T> Response<T> no() {
return new Response(false, " operation failed ");
}
public static <T> Response<T> no(String message) {
return new Response(false, message);
}
public Boolean isSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
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;
}
}
边栏推荐
- Implementation of simple upload function in PHP development
- 微服务故障模式与构建弹性系统
- 【CVPR2022 oral】Balanced Multimodal Learning via On-the-fly Gradient Modulation
- Mysql基本查询
- VMware Workstation 与 Device/Credential Guard 不兼容。禁用 Device/Credential Guard
- PC side bug record
- New arrow function in ES6
- 7. < tag string and API trade-offs> supplement: Sword finger offer 05. replace spaces
- I've been in an outsourcing company for two years, and I feel like I'm going to die
- New methods and features of ES6 built-in objects
猜你喜欢

IDEA使用dev-tool实现热部署

11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC

Mysql基本查询

【idea插件神器】教你如何使用IDEA一键set实体类中所有属性

【ARXIV2204】Simple Baselines for Image Restoration

【CVPR2022 oral】Balanced Multimodal Learning via On-the-fly Gradient Modulation

11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc

Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address

Eccv2022 | 29 papers of Tencent Youtu were selected, including face security, image segmentation, target detection and other research directions

【SLAM】LVI-SAM解析——综述
随机推荐
Mysql处理遗留数据样例
Database date types are all 0
Advanced assignment method of ES6 -- Deconstruction assignment
【单例模式】懒汉模式的线程安全问题
FeignClient 调用GET 方法报错 ResultVO{result=未知异常,异常详情:Request method ‘POST‘ not supported
Internal implementation principle of yymodel
【CVPR2022】Lite Vision Transformer with Enhanced Self-Attention
7.<tag-字符串和API的取舍>补充: 剑指 Offer 05. 替换空格
C language classic 100 question exercise (1~21)
The solution after the samesite by default cookies of Chrome browser 91 version are removed, and the solution that cross domain post requests in chrome cannot carry cookies
Making RPM packages with nfpm
这种动态规划你见过吗——状态机动态规划之股票问题(中)
数据库日期类型全部为0
Bean的作用域、执行流程、生命周期
Thinking on multi system architecture design
PC端-bug记录
类和对象【中】
从微服务基本概念到核心组件-通过一个实例来讲解和分析
Specific differences between typedef and define
【idea插件神器】教你如何使用IDEA一键set实体类中所有属性