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;
        }
    }
  • 相关阅读:
    使用JdbcTemplate访问数据库
    解决为什么每次打开Eclipse新的workspace需要更新nexus-maven-repository-index问题
    java内存设置
    Eclipse如何解决启动慢
    eclipse的包的加减号展开方式
    maven总结5
    maven总结4
    maven总结3
    maven总结2
    maven总结1
  • 原文地址:https://www.cnblogs.com/zygyun/p/8674650.html
Copyright © 2011-2022 走看看