package net.shapelight.modules.fegin;

import com.alibaba.fastjson.JSONObject;


import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class OpHystrix implements FallbackFactory<OpFeignClient> {

    @Override
    public OpFeignClient create(Throwable throwable) {
        return new OpFeignClient() {
            @Override
            public JSONObject empower(Map<String, Object> params) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("errormsg","获取密钥失败");
                return jsonObject;
            }

            @Override
            public JSONObject submitData(Map<String, Object> params) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("errormsg",params.get("operation")+"失败");
                return jsonObject;
            }

            @Override
            public JSONObject getToken(Map<String, Object> params) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("errorMessage","token获取失败");
                return jsonObject;
            }

            @Override
            public JSONObject createIotGroupId(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject removeIotGroupDevice(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject addIotGroupDevice(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject getIotGroupInfo(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject activeLicenseDevice(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject getLicenseDeviceInfo(Map<String, Object> params) {
                return null;
            }

            @Override
            public JSONObject createOrder(Map<String, Object> params) {
                return null;
            }
        };
    }
}