Skip to content

Commit

Permalink
fix(设备分组): 设备分组接口错误处理
Browse files Browse the repository at this point in the history
设备分组接口处理

re #214
  • Loading branch information
Lind-pro committed Oct 16, 2020
1 parent fbbc361 commit 15a93f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ export const routes = [
component: './device/group',
},
{
hideInMenu: true,
path: '/device/tree',
name: '设备树',
name: '分组',
tenant: ['admin', 'member'],
authority: ['device-group', 'admin'],
version: 'pro',
icon: 'gold',
component: './device/tree'
},
Expand Down
13 changes: 11 additions & 2 deletions src/pages/device/tree/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseService from "@/services/crud";
import request from "@/utils/request";
import { message } from "antd";
import { defer, from } from "rxjs";
import { map } from "rxjs/operators";
import { filter, map } from "rxjs/operators";

class Service extends BaseService<any>{

Expand All @@ -11,14 +11,17 @@ class Service extends BaseService<any>{
method: 'GET',
params
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

public groupTree = (params: any) => defer(
() => from(request(`/jetlinks/device/group/_query/_children/tree`, {
method: 'GET',
params
params,
errorHandler: () => message.error('服务器错误!')
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

Expand All @@ -28,13 +31,15 @@ class Service extends BaseService<any>{
data,
errorHandler: (res) => { message.error(res.data.message) }
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));
public removeGroup = (id: string) => defer(
() => from(request(`/jetlinks/device/group/${id}`, {
method: 'DELETE',
errorHandler: (res) => { message.error(res.data.message) }
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

Expand All @@ -43,6 +48,7 @@ class Service extends BaseService<any>{
method: 'GET',
params: param
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

Expand All @@ -52,6 +58,7 @@ class Service extends BaseService<any>{
data: deviceId,
errorHandler: (res) => { message.error(res.data.message) }
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

Expand All @@ -61,13 +68,15 @@ class Service extends BaseService<any>{
data: deviceId,
errorHandler: (res) => { message.error(res.data.message) }
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));

public unbindAll = (id: string) => defer(
() => from(request(`/jetlinks/device/group/${id}/_unbind/all`, {
method: 'POST',
})).pipe(
filter(resp => resp.status === 200),
map(resp => resp.result)
));
}
Expand Down

0 comments on commit 15a93f6

Please sign in to comment.