zoukankan      html  css  js  c++  java
  • 通用结果类 Result

    package com.zhongyuan.ota.utils;
    
    import java.util.HashMap;
    import java.util.Map;
    
    /**
     * 返回结果数据
     */
    public class Result extends HashMap<String, Object> {
    
        private static final long serialVersionUID = 1L;
    
        public Result() {
            put("code", 0);
        }
    
        public static Result error() {
            return error(500, "未知异常,请联系管理员");
        }
    
        public static Result error(String msg) {
            return error(500, msg);
        }
    
        public static Result error(int code, String msg) {
            Result result = new Result();
            result.put("code", code);
            result.put("msg", msg);
            return result;
        }
    
        public static Result success() {
            return new Result();
        }
        
        public static Result success(String msg) {
            Result result = new Result();
            result.put("msg", msg);
            return result;
        }
        
        public static Result success(String msg, int total, Object object) {
            Result result = new Result();
            result.put("msg", msg);
            result.put("total", total);
            result.put("rows", object);
            return result;
        }
    
        public static Result success(Map<String, Object> map) {
            Result result = new Result();
            result.putAll(map);
            return result;
        }
    
        @Override
        public Result put(String key, Object value) {
            super.put(key, value);
            return this;
        }
    }
  • 相关阅读:
    flask强大的第三方组件之falsk-sqlalchemy
    flask 外键关系和多对多查询
    flask sqlalchemy 单表查询
    functools模块
    面试题
    ansible git
    python 操作 表格
    matplotlib
    node,npm,webpack,vue-cli模块化编程安装流程
    Webpack
  • 原文地址:https://www.cnblogs.com/zygyun/p/8674650.html
Copyright © 2011-2022 走看看