# 企业版OpenAPI

# 登录接口

接口地址 请求方式 content-type
/user/login POST application/x-www-form-urlencoded
参数名称 类型 是否必须 描述
username string 用户名
password string 密码
  • 访问登录接口可以获取token
  • 所有OpenAPI(除了登录接口)的访问都需要鉴权
  • 鉴权方法是在请求头中携带Authorization字段,其值是token

# 创建数据源

接口地址 请求方式 Content-Type
/datasource/add POST application/json
  • 参数示例
{
  "note": "local",
  "name": "local-mysql",
  "detail": {
    "type": "mysql",
    "url": "jdbc:mysql://localhost:3306/test?useSSL=false&characterEncoding=UTF-8&serverTimezone=GMT%2B8",
    "username": "root",
    "password": "root",
    "edit_password": true,
    "driver": "com.mysql.cj.jdbc.Driver",
    "druidProperties": "druid.testWhileIdle=true\ndruid.breakAfterAcquireFailure=true\ndruid.connectionErrorRetryAttempts=3",
    "tableSql": "show tables"
  },
  "type": "jdbc"
}

# 删除数据源

接口地址 请求方式 Content-Type
/datasource/delete/{id} POST application/x-www-form-urlencoded

# 创建分组

接口地址 请求方式 Content-Type
/group/create POST application/x-www-form-urlencoded
参数名称 类型 是否必须 描述
name string 分组名称

# 删除分组

接口地址 请求方式 Content-Type
/group/delete/{id} POST application/x-www-form-urlencoded

# 创建 API

接口地址 请求方式 Content-Type
/apiConfig/add POST application/json
  • 参数示例
{
  "note": "查询学生数据",
  "cachePlugin": {
    "pluginType": 1
  },
  "access": 1,
  "paramsJson": [
    {
      "name": "id",
      "type": "bigint",
      "note": "学生id"
    }
  ],
  "taskJson": [
    {
      "taskType": 1,
      "sqlList": [
        {
          "sqlText": "select * from student where id = #{id}"
        }
      ],
      "transaction": 0,
      "datasourceId": "5iaIut1Z"
    }
  ],
  "paramRules": [
    {
      "apiId": "J3z0SP59",
      "script": "id > 0",
      "type": "JavaScript",
      "message": "id必须是正数"
    }
  ],
  "groupId": "leqbGt5S",
  "globalTransformPlugin": {
    "pluginType": 3
  },
  "path": "student/all",
  "name": "查询数据",
  "alarmPlugins": [
    {
      "pluginType": 2
    }
  ],
  "transformScript": {
    "type": "JavaScript"
  },
  "contentType": "application/x-www-form-urlencoded",
  "jsonParam": "{}"
}

# 修改 API

接口地址 请求方式 Content-Type
/apiConfig/update POST application/json
  • 参数示例
{
  "note": "查询学生数据",
  "cachePlugin": {
    "pluginType": 1,
    "apiId": "J3z0SP59"
  },
  "access": 1,
  "paramsJson": [
    {
      "note": "学生id",
      "name": "id",
      "type": "bigint"
    }
  ],
  "taskJson": [
    {
      "taskType": 1,
      "sqlList": [
        {
          "sqlText": "select * from student where id = #{id}"
        }
      ],
      "transaction": 0,
      "datasourceId": "5iaIut1Z"
    }
  ],
  "paramRules": [
    {
      "id": 1,
      "apiId": "J3z0SP59",
      "script": "id > 0",
      "type": "JavaScript",
      "message": "id必须是正数"
    }
  ],
  "groupId": "leqbGt5S",
  "globalTransformPlugin": {
    "pluginType": 3,
    "apiId": "J3z0SP59"
  },
  "path": "student/all",
  "name": "查询数据",
  "alarmPlugins": [
    {
      "pluginType": 2,
      "apiId": "J3z0SP59"
    }
  ],
  "transformScript": {
    "apiId": "J3z0SP59",
    "type": "JavaScript"
  },
  "id": "J3z0SP59",
  "contentType": "application/x-www-form-urlencoded"
}

# 上线 API

接口地址 请求方式 Content-Type
/apiConfig/online/{id} POST application/x-www-form-urlencoded

# 下线 API

接口地址 请求方式 Content-Type
/apiConfig/offline/{id} POST application/x-www-form-urlencoded