mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-01 19:58:46 +08:00
fix: swagger(path)
This commit is contained in:
parent
0226b10f49
commit
1a66018b2d
@ -99,6 +99,11 @@ wget -qO dgiot_install.sh https://gitee.com/dgiiot/dgiot/raw/master/dgiot_instal
|
||||
rm ./apps/dgiot_api/priv/www -rf
|
||||
cp ../dgiot-dashboard/dist/ ./apps/dgiot_api/priv/www -rf
|
||||
make run
|
||||
cd ./apps/dgiot_api/priv/www
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_dashboard.tar.gz &> /dev/null
|
||||
tar xf dgiot_dashboard.tar.gz &> /dev/null
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_file.tar.gz &> /dev/null
|
||||
tar xf dgiot_file.tar.gz &> /dev/null
|
||||
```
|
||||
+ Make Debug
|
||||
```
|
||||
|
@ -51,6 +51,11 @@
|
||||
cp ../dgiot_dashboard/dist/ ./apps/dgiot_api/priv/www -rf
|
||||
cp ../dgiot_dashboard/swagger ./apps/dgiot_api/priv/www/ -rf
|
||||
make run
|
||||
cd ./apps/dgiot_api/priv/www
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_dashboard.tar.gz &> /dev/null
|
||||
tar xf dgiot_dashboard.tar.gz &> /dev/null
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_file.tar.gz &> /dev/null
|
||||
tar xf dgiot_file.tar.gz &> /dev/null
|
||||
```
|
||||
+ Make Debug
|
||||
```
|
||||
|
@ -51,6 +51,11 @@
|
||||
cp ../dgiot_dashboard/dist/ ./apps/dgiot_api/priv/www -rf
|
||||
cp ../dgiot_dashboard/swagger ./apps/dgiot_api/priv/www/ -rf
|
||||
make run
|
||||
cd ./apps/dgiot_api/priv/www
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_dashboard.tar.gz &> /dev/null
|
||||
tar xf dgiot_dashboard.tar.gz &> /dev/null
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_file.tar.gz &> /dev/null
|
||||
tar xf dgiot_file.tar.gz &> /dev/null
|
||||
```
|
||||
+ Make Debug
|
||||
```
|
||||
|
@ -56,6 +56,11 @@ Before 2016, the Shuwa team had been crawling on the Internet and the mobile Int
|
||||
rm ./apps/dgiot_api/priv/www -rf
|
||||
cp ../dgiot-dashboard/dist/ ./apps/dgiot_api/priv/www/ -rf
|
||||
make run
|
||||
cd ./apps/dgiot_api/priv/www
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_dashboard.tar.gz &> /dev/null
|
||||
tar xf dgiot_dashboard.tar.gz &> /dev/null
|
||||
wget https://dgiot-release-1306147891.cos.ap-nanjing.myqcloud.com/v4.4.0/dgiot_file.tar.gz &> /dev/null
|
||||
tar xf dgiot_file.tar.gz &> /dev/null
|
||||
```
|
||||
+ Make Debug
|
||||
```
|
||||
|
@ -40,6 +40,164 @@
|
||||
"AMIS"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/amis_device": {
|
||||
"get": {
|
||||
"description": "查询amis设备",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceid",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"default": "b1002a0317",
|
||||
"description": "设备Id"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns operation status"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"summary": "查询amis设备",
|
||||
"tags": [
|
||||
"AMIS"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"description": "修改amis设备",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "user",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deviceid": {
|
||||
"type": "string",
|
||||
"description": "设备Id",
|
||||
"required": true
|
||||
},
|
||||
"name": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "设备名称"
|
||||
},
|
||||
"devaddr": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "设备地址"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns operation status"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"summary": "修改amis设备",
|
||||
"tags": [
|
||||
"AMIS"
|
||||
]
|
||||
},
|
||||
"delete": {
|
||||
"description": "删除amis设备",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "deviceid",
|
||||
"in": "query",
|
||||
"type": "string",
|
||||
"default": "b1002a0317",
|
||||
"description": "设备Id"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns operation status"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"summary": "删除amis设备",
|
||||
"tags": [
|
||||
"AMIS"
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"description": "创建amis设备",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "user",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"deviceid": {
|
||||
"type": "string",
|
||||
"description": "设备Id",
|
||||
"required": true
|
||||
},
|
||||
"ChannelId": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "设备通道Id"
|
||||
},
|
||||
"DTUIP": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"description": "设备DTUIP"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns operation status"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"summary": "创建amis设备",
|
||||
"tags": [
|
||||
"AMIS"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,46 @@
|
||||
-module(dgiot_bamis).
|
||||
-include("dgiot_bamis.hrl").
|
||||
-include_lib("dgiot/include/logger.hrl").
|
||||
-include_lib("dgiot/include/dgiot_mnesia.hrl").
|
||||
-export([
|
||||
create_amis/3
|
||||
create_amis/3,
|
||||
put_amis_device/3,
|
||||
del_amis_device/1,
|
||||
created_amis_device/3
|
||||
]).
|
||||
|
||||
-define(APP, ?MODULE).
|
||||
del_amis_device(DeviceId) ->
|
||||
dgiot_mnesia:delete(DeviceId).
|
||||
%%修改设备
|
||||
put_amis_device(put_amis_device, #{<<"objectId">> := Deviceid} = Body, SessionToken) ->
|
||||
case dgiot_parse:get_object(<<"Device">>, Deviceid,
|
||||
[{"X-Parse-Session-Token", SessionToken}], [{from, rest}]) of
|
||||
{ok, #{<<"data">> := OldRole}} ->
|
||||
dgiot_parse:update_object(<<"Device">>, Deviceid, #{
|
||||
<<"data">> => maps:without([
|
||||
<<"parent">>,
|
||||
<<"createdAt">>,
|
||||
<<"updatedAt">>], maps:merge(OldRole, Body))},
|
||||
[{"X-Parse-Session-Token", SessionToken}], [{from, rest}]);
|
||||
Error -> Error
|
||||
end.
|
||||
|
||||
%%新设备
|
||||
created_amis_device(DtuAddr, ChannelId, DTUIP) ->
|
||||
{ProductId, Acl, _Properties} = dgiot_data:get({amis, ChannelId}),
|
||||
Requests = #{
|
||||
<<"devaddr">> => DtuAddr,
|
||||
<<"name">> => <<"AMIS_", DtuAddr/binary>>,
|
||||
<<"ip">> => DTUIP,
|
||||
<<"isEnable">> => true,
|
||||
<<"product">> => ProductId,
|
||||
<<"ACL">> => Acl,
|
||||
<<"status">> => <<"ONLINE">>,
|
||||
<<"brand">> => <<"AMIS", DtuAddr/binary>>,
|
||||
<<"devModel">> => <<"AMIS">>
|
||||
},
|
||||
dgiot_device:create_device(Requests).
|
||||
|
||||
%%新设备
|
||||
create_amis(DtuAddr, ChannelId, DTUIP) ->
|
||||
|
@ -32,7 +32,7 @@
|
||||
%% dgiot_http_server:bind(<<"/swagger_amis.json">>, ?MODULE, [], priv)
|
||||
swagger_amis() ->
|
||||
[
|
||||
dgiot_http_server:bind(<<"/swagger_amis.json">>, ?MODULE, [], priv)
|
||||
dgiot_http_server:bind(<<"/swagger_bamis.json">>, ?MODULE, [], priv) %需要于priv/swagger/目录下放置swagger.json文件名保持一致
|
||||
].
|
||||
|
||||
|
||||
@ -85,6 +85,56 @@ do_request(get_amis, #{<<"deviceid">> := Deviceid}, _Context, _Req) ->
|
||||
{ok, #{}}
|
||||
end;
|
||||
|
||||
%% iot_hub 概要: 查询amis设备
|
||||
%% OperationId:get_amis
|
||||
%% 请求:POST /iotapi/get_amis_device
|
||||
do_request(get_amis_device, #{<<"deviceid">> := Deviceid}, _Context, _Req) ->
|
||||
case dgiot_parse:get_object(<<"Device">>, Deviceid) of
|
||||
{ok, info} ->
|
||||
{ok, info};
|
||||
_ ->
|
||||
{ok, #{}}
|
||||
end;
|
||||
|
||||
%% Role模版 概要: 修改amis设备
|
||||
%% OperationId:put_amis_device
|
||||
%% 请求:POST /iotapi/put_amis_device
|
||||
do_request(put_amis_device, #{<<"objectId">> := Deviceid} = Body, #{<<"sessionToken">> := SessionToken} = _Context, _Req0) ->
|
||||
%% io:format("Body ~p~n", [Body]),
|
||||
case Deviceid of
|
||||
<<"Klht7ERlYn">> ->
|
||||
{ok, #{<<"code">> => 401, <<"result">> => <<"dgiot_admin Cannot be Resignation">>}};
|
||||
<<"lerYRy2jsh">> ->
|
||||
{ok, #{<<"code">> => 401, <<"result">> => <<"dgiot_admin Cannot be Resignation">>}};
|
||||
_ ->
|
||||
dgiot_bamis:put_amis_device(Body, SessionToken,_Context)
|
||||
end;
|
||||
|
||||
%% iot_hub 概要: 删除amis设备
|
||||
%% OperationId:del_amis_device
|
||||
%% 请求:POST /iotapi/del_amis_device
|
||||
do_request(delete_amis_device, #{<<"deviceid">> := Deviceid} = _Body, _Context, _Req) ->
|
||||
case Deviceid of
|
||||
<<"Klht7ERlYn">> ->
|
||||
{ok, #{<<"code">> => 401, <<"result">> => <<"dgiot_admin Cannot be Resignation">>}};
|
||||
<<"lerYRy2jsh">> ->
|
||||
{ok, #{<<"code">> => 401, <<"result">> => <<"dgiot_admin Cannot be Resignation">>}};
|
||||
_ ->
|
||||
dgiot_bamis:del_amis_device(Deviceid)
|
||||
end;
|
||||
|
||||
|
||||
|
||||
%% iot_hub 概要: 创建amis设备
|
||||
%% OperationId:created_amis_device
|
||||
%% 请求:POST /iotapi/created_amis_device
|
||||
do_request(post_amis_device, #{<<"deviceid">> := Deviceid, <<"ChannelId">> := ChannelId,<<"DTUIP">> := DTUIP} = _Body,_Context, _Req) ->
|
||||
case Deviceid of
|
||||
<<"test">> ->
|
||||
{ok, #{<<"code">> => test, <<"result">> => <<"you input test">>}};
|
||||
_ ->
|
||||
{ok, dgiot_bamis:created_amis_device(Deviceid,ChannelId,DTUIP)}
|
||||
end;
|
||||
|
||||
%% 服务器不支持的API接口
|
||||
do_request(_OperationId, _Args, _Context, _Req) ->
|
||||
|
Loading…
Reference in New Issue
Block a user