zoukankan      html  css  js  c++  java
  • ResultVO 接口返回参数封装

    public class ResultVO<T> {
    
        private Integer code;
    
        private String msg;
    
        private T data;
    
        /**
         * 无参构造方法
         */
        public ResultVO() {
        }
    
        /**
         * @param code restful调用结果代码
         * @param msg restful调用结果消息
         * @param data 数据
         */
        public ResultVO(Integer code, String msg, T data) {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }
    
        /**
         * 
         * @param code restful调用结果代码
         * @param msg restful调用结果消息
         */
        public ResultVO(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }
    
        /**
         * 创建新的实例
         * @param stauts restful调用结果代码 http 状态码
         * @param msg restful调用结果消息
         * @param data 数据
         * @return
         */
        public static <T> ResultVO<T> newInst(Status stauts, String msg, T data) {
            return new ResultVO<>(stauts.getStatusCode(), msg, data);
        }
    
        /**
         * 创建新的实例
         * @param code restful调用结果代码
         * @param msg restful调用结果消息
         * @param data 数据
         * @return
         */
        public static <T> ResultVO<T> newInst(Integer code, String msg, T data) {
            return new ResultVO<>(code, msg, data);
        }
    
        /**
         * 创建新的实例
         * @param stauts restful调用结果代码 http 状态码
         * @param message restful调用结果消息
         * @return
         */
        public static <T> ResultVO<T> newInst(HttpStatus stauts, String message) {
            return new ResultVO<>(stauts.value(), message);
        }
    
        public static <T> ResultVO<T> newInst(HttpStatus stauts, String message, T data) {
            return new ResultVO<>(stauts.value(), message, data);
        }
    
        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;
        }
    
        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
        }
    
        public String toJsonString() {
            return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
        }
    }
  • 相关阅读:
    proc文件系统
    sysfs文件系统
    linux 下 进程和线程的区别
    Linux内核中常见内存分配函数
    内核空间与用户空间的通信方式
    DoDataExchange函数,UpdateData(TRUE)和UpdateData(FALSE)的区别
    C# 获取文件路径
    C# WinForm 中 MessageBox的使用详解
    C#对于文件操作
    线程间操作无效: 从不是创建控件的线程访问它。
  • 原文地址:https://www.cnblogs.com/jiehanshi/p/13915178.html
Copyright © 2011-2022 走看看