package cn.zhios.zhiying_comm;

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

public class ZhiyingFlutterCommNativeResult {
    public boolean             success;
    public String              msg;
    public Map<String, Object> data;

    public ZhiyingFlutterCommNativeResult(String msg, boolean success, Map<String, Object> data) {
        this.msg     = msg;
        this.success = success;
        this.data    = data;
    }

    public Map toMap() {
        Map map = new HashMap<>();
        map.put("msg", this.msg);
        map.put("success", this.success ? "1" : "0");
        map.put("data", this.data);
        return map;
    }

    public static ZhiyingFlutterCommNativeResult success(String msg) {
        return new ZhiyingFlutterCommNativeResult(msg, true, null);
    }

    public static ZhiyingFlutterCommNativeResult success(String msg, Map<String, Object> data) {
        return new ZhiyingFlutterCommNativeResult(msg, true, data);
    }

    public static ZhiyingFlutterCommNativeResult failed(String msg) {
        return new ZhiyingFlutterCommNativeResult(msg, false, null);
    }

    public static ZhiyingFlutterCommNativeResult failed(String msg, Map<String, Object> data) {
        return new ZhiyingFlutterCommNativeResult(msg, false, data);
    }

    public static ZhiyingFlutterCommNativeResult notImp() {
        return new ZhiyingFlutterCommNativeResult("native调用失败", false, null);
    }

}
