• web接入层 传入参数的格式化及web返回值传出数据的参数格式化,都要统一


    1.web接入层 传入参数的格式化及web返回值传出数据的参数格式化,都要统一。

    比如acSpace中,

    传入层参数@RequestBody javaBean对象。统一转换为javabean传入参数。

    返回值,统一返回ResultObject对象,resultObject实现了序列化。且resultObject中定义好了传输回去哪些属性,

     3.ResultObject,定义的公共传出参数属性

    public class ResultObject implements Serializable {
    
        /**
         * 
         */
        private static final long serialVersionUID = -2523760680706423997L;
        private String res_info = "";
        private Object data = "";
        private int result = 200;
    
        // TODO 分页对象
    
        public ResultObject(String res_info) {
            this.res_info = res_info;
        }
    
        public ResultObject(Object data) {
            this.data = data;
        }
    
        public ResultObject(ResultCode ResultCode) {
            this.res_info = ResultCode.getName();
            this.result = ResultCode.getIndex();
        }
    
        @SuppressWarnings("unchecked")
        public <T extends ResultObject> T configErrMsg(ResultCode err) {
            this.setResult(err.getIndex());
            this.setRes_info(err.getName());
            return (T) this;
        }
    
        public ResultObject() {
        }
    
        public String getRes_info() {
            return res_info;
        }
    
        public void setRes_info(String res_info) {
            this.res_info = res_info;
        }
    
        public Object getData() {
            return data;
        }
    
        public void setData(Object data) {
            this.data = data;
        }
    
        public int getResult() {
            return result;
        }
    
        public void setResult(int result) {
            this.result = result;
        }
    
    }

     3.返回ResultObject对象中,定义了多个构造函数。

    用于传入不同的类型,并将之返回。有

    ResultObject(String res_info)
    ResultObject(ResultCode ResultCode)
    ResultObject(Object data)
    
    
        private static final long serialVersionUID = -2523760680706423997L;
        private String res_info = "";
        private Object data = "";
        private int result = 200;
    
        // TODO 分页对象
    
        public ResultObject(String res_info) {
            this.res_info = res_info;
        }
    
        public ResultObject(Object data) {
            this.data = data;
        }
    
        public ResultObject(ResultCode ResultCode) {
            this.res_info = ResultCode.getName();
            this.result = ResultCode.getIndex();
        }
    
        @SuppressWarnings("unchecked")
        public <T extends ResultObject> T configErrMsg(ResultCode err) {
            this.setResult(err.getIndex());
            this.setRes_info(err.getName());
            return (T) this;
        }
  • 相关阅读:
    传感器仿真平台——数据生成模块(三)
    写一个ES6 的遍历目录函数
    编码风格
    关于DOM事件的一个例子
    WEB DB
    表格资料
    css3 鼠标移入移出效果
    css 3D
    正向代理和反向代理
    FileReader 对象
  • 原文地址:https://www.cnblogs.com/panxuejun/p/6180706.html
Copyright © 2020-2023  润新知