当前位置: 首页 > news >正文

网站做任务 炸金花百度云服务器官网

网站做任务 炸金花,百度云服务器官网,网站建设为中心,电子书网站 跟我学做家常菜800目的:给返回对象补充一些信息,告诉前端这个请求在业务层面上是成功还是失败,以及具体的描述信息。 我们需要自定义错误码(因为前端的HTTP状态码默认的值比较少)和正常错误返回类。 ErrorCode : package …

目的:给返回对象补充一些信息,告诉前端这个请求在业务层面上是成功还是失败,以及具体的描述信息。

我们需要自定义错误码(因为前端的HTTP状态码默认的值比较少)和正常错误返回类。

ErrorCode :

package com.heo.ezyuserbackend.common;public enum ErrorCode {SUCCESS(0, "ok", ""),PARAMS_ERROR(40000, "请求参数错误", ""),NULL_ERROR(40001, "请求参数为空", ""),NOT_LOGIN(40100, "未登录", ""),NO_AUTH(40101, "无权限", ""),SYSTEM_ERROR(50000,"系统内部异常","");private final int code;/*** 状态码信息*/private  final String message;public int getCode() {return code;}public String getMessage() {return message;}public String getDescription() {return description;}/*** 状态码描述(详情)*/private final String description;ErrorCode(int code, String message, String description) {this.code = code;this.message = message;this.description = description;}
}

BaseResponse:

package com.heo.ezyuserbackend.common;import lombok.Data;import java.io.Serializable;/*** 通用返回类** @param <T>*/
@Data
public class BaseResponse<T> implements Serializable {private int code;private T data;private String message;private String description;public BaseResponse(int code, T data, String message, String description) {this.code = code;this.data = data;this.message = message;this.description = description;}public BaseResponse(int code, T data,String message) {this(code, data, message,"");}public BaseResponse(int code, T data) {this(code, data, "", "");}public BaseResponse(ErrorCode errorCode) {this(errorCode.getCode(), null, errorCode.getMessage(), errorCode.getDescription());}
}

ResultUtil :

package com.heo.ezyuserbackend.common;import com.fasterxml.jackson.databind.ser.Serializers;/*** 返回工具类*/
public class ResultUtil {/*** 成功** @param data* @param <T>* @return*/public static <T> BaseResponse<T> success(T data) {return new BaseResponse<>(0, data, "ok");}/*** 失败** @param errorCode* @return*/public static <T> BaseResponse<T> error(ErrorCode errorCode) {return new BaseResponse<>(errorCode);}/*** 失败** @param code* @param message* @param description* @param <T>* @return*/public static <T> BaseResponse<T> error(int code, String message, String description) {return new BaseResponse<>(code, null, message, description);}/*** 失败** @param errorCode* @param message* @param description* @param <T>* @return*/public static <T> BaseResponse<T> error(ErrorCode errorCode, String message, String description) {return new BaseResponse<>(errorCode.getCode(), null, message, description);}/*** 失败** @param errorCode* @param description* @return*/public static BaseResponse error(ErrorCode errorCode, String description) {return new BaseResponse<>(errorCode.getCode(), errorCode.getMessage(), description);}
}
http://www.hkea.cn/news/425093/

相关文章:

  • 包头怎样做网站我想做电商怎么加入
  • 株洲企业网站建设品牌2023免费b站推广大全
  • 仿制单页面网站多少钱免费制作网站app
  • 商城网站制作网站长尾词挖掘工具
  • 夹克定制公司trinseo公司
  • 四川智能网站建设制作网站链接分析工具
  • 制作销售网站有哪些宁波网络营销推广咨询报价
  • 佛山做外贸网站服务新闻发稿平台
  • 做网站前怎么写文档域名收录
  • 中信建设有限责任公司钟宁关键词优化的方法有哪些
  • 建站之星平台优化推广网站排名
  • wordpress 网盘 插件郑州seo外包阿亮
  • 怎样建设网站首页广告营销平台
  • wordpress调起淘宝app什么叫做seo
  • 嘉兴做网站优化的公司网站维护公司
  • css层叠样式会不会影响打开网站的速度百度免费下载安装百度
  • 网站模板制作流程nba交易最新消息汇总
  • 近的网站在线客服系统网络优化工程师前景如何
  • 网站制作职业google入口
  • 广州网站 制作信科便宜网络营销软文范例500
  • 网站建设公开课长沙网站推广和优化
  • 建设网站的需求分析俄罗斯搜索引擎yandex推广入口
  • 可以做英文纵横字谜的网站搜狗网站收录入口
  • web前端开发是不是做网站百家号关键词排名优化
  • 夸克看网站要钱吗电商网站seo优化
  • 自己做网站排版138ip查询网域名解析
  • 东莞做网站 南城石佳2023网站推广入口
  • 广东省省建设厅网站郴州网站建设网络推广平台
  • 校园网站推广方案怎么做应用商店优化
  • 巩义网站建设网络营销公司是做什么的