SOP 1.2.0 发布,开放平台解决方案项目

  

SOP 1.1.0发布,此次更新内容如下:

  • SOP Admin新增用户登录
  • 新增基础SDK(Java,C#) doc

下个版本将会发布:

  • 文档整合
  • springmvc项目接入demo
  • 限流管理

本次更新的重点是基础SDK,Java版SDK使用方式如下:

String url = "http://localhost:8081/api"; // zuul
String appId = "2019032617262200001";
String privateKey = "你的私钥";

// 声明一个就行
OpenClient client = new OpenClient(url, appId, privateKey);

// 标准用法
@Test
public void testGet() {
    // 创建请求对象
    GetStoryRequest request = new GetStoryRequest();
    // 请求参数
    GetStoryModel model = new GetStoryModel();
    model.setName("白雪公主");

    request.setBizModel(model);

    // 发送请求
    GetStoryResponse response = client.execute(request);

    if (response.isSuccess()) {
        // 返回结果
        System.out.println(String.format("成功!response:%s\n响应原始内容:%s", 
                JSON.toJSONString(response), response.getBody()));
    } else {
        System.out.println("错误,subCode:" + response.getSubCode() + ", subMsg:" + response.getSubMsg());
    }
}

C#版本SDK使用方式如下:

static string url = "http://localhost:8081/api";
        static string appId = "201904035630907729292csharp";
        // 私钥, PKCS1 2048
        static string privateKey = "你的私钥";

        // 从文件中加载
        //static string filePath = "/Users/thc/logs/priKey.txt";
        //static OpenClient client = new OpenClient(url, appId, filePath, true);

        // 声明一个就行
        static OpenClient client = new OpenClient(url, appId, privateKey);


        public static void Main(string[] args)
        {
            TestGet();            
        }

        // 标准用法
        private static void TestGet()
        {
            // 创建请求对象
            GetStoryRequest request = new GetStoryRequest();
            // 请求参数
            GetStoryModel model = new GetStoryModel();
            model.Name = "白雪公主";
            request.BizModel = model;

            // 发送请求
            GetStoryResponse response = client.Execute(request);

            if (response.IsSuccess())
            {
                // 返回结果
                Console.WriteLine("成功!response:{0}\n响应原始内容:{1}", JsonUtil.ToJSONString(response), response.Body);
            }
            else
            {
                Console.WriteLine("错误, code:{0}, msg:{1}, subCode:{2}, subMsg:{3}",
                    response.Code, response.Msg, response.SubCode, response.SubMsg);
            }
        }

关于SOP

SOP(Simple Open Platform)

一个开放平台解决方案项目,基于Spring Cloud实现,目标是能够让用户快速得搭建起自己的开放平台。

SOP提供了两种接口调用方式,分别是:支付宝开放平台的调用方式和淘宝开放平台的调用方式。 通过简单的配置后,你的项目就具备了和支付宝开放平台的一样的接口提供能力。

SOP封装了开放平台大部分功能包括:签名验证、统一异常处理、统一返回内容 、业务参数验证(JSR-303)、秘钥管理等,未来还会实现更多功能。

项目特点

  • 接入方式简单,与老项目不冲突,老项目注册到注册中心,然后在方法上加上注解即可。
  • 架构松耦合,业务代码实现在各自微服务上,SOP不参与业务实现,这也是Spring Cloud微服务体系带来的好处。
  • 扩展简单,开放平台对应的功能各自独立,可以自定义实现自己的需求,如:更改参数,更改签名规则等。

谁可以使用这个项目

  • 有现成的项目,想改造成开放平台供他人调用
  • 有现成的项目,想暴露其中几个接口并通过开放平台供他人调用
  • 想搭一个开放平台新项目,并结合微服务的方式去维护
  • 对开放平台感兴趣的朋友

以上情况都可以考虑使用SOP

架构图

SOP架构图

猜你喜欢

转载自www.oschina.net/news/105751/sop-1-2-0-released
SOP