wwf
6 小时以前 a1d7e81859f554f3a53680cc35f0f49bf1f77098
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import request from '@/config/axios'
 
// IoT 产品 VO
export interface ProductVO {
  id: number // 产品编号
  name: string // 产品名称
  productKey: string // 产品标识
  protocolId: number // 协议编号
  categoryId: number // 产品所属品类标识符
  categoryName?: string // 产品所属品类名称
  icon: string // 产品图标
  picUrl: string // 产品图片
  description: string // 产品描述
  status: number // 产品状态
  deviceType: number // 设备类型
  locationType: number // 设备类型
  netType: number // 联网方式
  codecType: string // 数据格式(编解码器类型)
  deviceCount: number // 设备数量
  createTime: Date // 创建时间
}
 
// IOT 产品设备类型枚举类 0: 直连设备, 1: 网关子设备, 2: 网关设备
export enum DeviceTypeEnum {
  DEVICE = 0, // 直连设备
  GATEWAY_SUB = 1, // 网关子设备
  GATEWAY = 2 // 网关设备
}
// IOT 产品定位类型枚举类 0: 手动定位, 1: IP 定位, 2: 定位模块定位
export enum LocationTypeEnum {
  IP = 1, // IP 定位
  MODULE = 2, // 设备定位
  MANUAL = 3 // 手动定位
}
// IOT 数据格式(编解码器类型)枚举类
export enum CodecTypeEnum {
  ALINK = 'Alink' // 阿里云 Alink 协议
}
 
// IoT 产品 API
export const ProductApi = {
  // 查询产品分页
  getProductPage: async (params: any) => {
    return await request.get({ url: `/iot/product/page`, params })
  },
 
  // 查询产品详情
  getProduct: async (id: number) => {
    return await request.get({ url: `/iot/product/get?id=` + id })
  },
 
  // 新增产品
  createProduct: async (data: ProductVO) => {
    return await request.post({ url: `/iot/product/create`, data })
  },
 
  // 修改产品
  updateProduct: async (data: ProductVO) => {
    return await request.put({ url: `/iot/product/update`, data })
  },
 
  // 删除产品
  deleteProduct: async (id: number) => {
    return await request.delete({ url: `/iot/product/delete?id=` + id })
  },
 
  // 导出产品 Excel
  exportProduct: async (params) => {
    return await request.download({ url: `/iot/product/export-excel`, params })
  },
 
  // 更新产品状态
  updateProductStatus: async (id: number, status: number) => {
    return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status })
  },
 
  // 查询产品(精简)列表
  getSimpleProductList() {
    return request.get({ url: '/iot/product/simple-list' })
  },
 
  // 根据 ProductKey 获取产品信息
  getProductByKey: async (productKey: string) => {
    return await request.get({ url: `/iot/product/get-by-key`, params: { productKey } })
  }
}