package com.szxgl.nft.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 * @Author Leon
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("ret", 0);
		put("msg", "success");
	}
	
	public static R error() {
		return error("未知异常，请联系管理员");
	}
	
	public static R error(String msg) {
		return error(-1, msg);
	}
	
	public static R error(int ret, String msg) {
		R r = new R();
		r.put("ret", ret);
		r.put("msg", msg);
		return r;
	}

	public static R error(Map<String, Object> map) {
		R r = R.error();
		r.putAll(map);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}

	public static void main(String[] args) {
		String phone = encrypt("15023451234");
		System.out.println(phone);
		String s = "+852- 37123594";
		String replace = s.replaceAll(" ", "");
		replace = replace.replaceAll("-", "");
		System.out.println(replace);
		System.out.println(replace.substring(4));

	}

	//字符串加密
	public static String encrypt(String seed){
		String phone = "";
		try {
			EncryptUtil encryptUtil = new EncryptUtil();
			phone = encryptUtil.encrypt(seed);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return phone;
	}
}
