content: package com.cn.psychological.utils.response;
  import lombok.Data;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * 返回数据
   *
   * @author Mark sunlightcs@gmail.com
   */
  @Data
  public class R {
  	private static final long serialVersionUID = 1L;
  
  
      private Boolean success;
  
      private Integer code;
  
      private String message;
  
      private Map<String, Object> data = new HashMap<String, Object>();
  
      private R(){}
  
      public static R ok(){
          R r = new R();
          r.setSuccess(true);
          r.setCode(20000);
          r.setMessage("成功");
          return r;
      }
  
      public static R error(String mag){
          R r = new R();
          r.setSuccess(false);
          r.setCode(20001);
          r.setMessage(mag);
          return r;
      }
  
      public static R error(){
          R r = new R();
          r.setSuccess(false);
          r.setCode(20001);
          r.setMessage("失败");
          return r;
      }
  
  
      public R data(String key, Object value){
          this.data.put(key, value);
          return this;
      }
  
      public R data(Map<String, Object> map){
          this.setData(map);
          return this;
      }
  
  
  }
  