index.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import request from '@/config/axios'
  2. // IoT 产品 VO
  3. export interface ProductVO {
  4. id: number // 产品编号
  5. name: string // 产品名称
  6. productKey: string // 产品标识
  7. protocolId: number // 协议编号
  8. categoryId: number // 产品所属品类标识符
  9. categoryName?: string // 产品所属品类名称
  10. description: string // 产品描述
  11. validateType: number // 数据校验级别
  12. status: number // 产品状态
  13. deviceType: number // 设备类型
  14. netType: number // 联网方式
  15. protocolType: number // 接入网关协议
  16. dataFormat: number // 数据格式
  17. deviceCount: number // 设备数量
  18. createTime: Date // 创建时间
  19. }
  20. // IOT 数据校验级别枚举类
  21. export enum ValidateTypeEnum {
  22. WEAK = 0, // 弱校验
  23. NONE = 1 // 免校验
  24. }
  25. // IOT 产品设备类型枚举类 0: 直连设备, 1: 网关子设备, 2: 网关设备
  26. export enum DeviceTypeEnum {
  27. DEVICE = 0, // 直连设备
  28. GATEWAY_SUB = 1, // 网关子设备
  29. GATEWAY = 2 // 网关设备
  30. }
  31. // IOT 数据格式枚举类
  32. export enum DataFormatEnum {
  33. JSON = 0, // 标准数据格式(JSON)
  34. CUSTOMIZE = 1 // 透传/自定义
  35. }
  36. // IoT 产品 API
  37. export const ProductApi = {
  38. // 查询产品分页
  39. getProductPage: async (params: any) => {
  40. return await request.get({ url: `/iot/product/page`, params })
  41. },
  42. // 查询产品详情
  43. getProduct: async (id: number) => {
  44. return await request.get({ url: `/iot/product/get?id=` + id })
  45. },
  46. // 新增产品
  47. createProduct: async (data: ProductVO) => {
  48. return await request.post({ url: `/iot/product/create`, data })
  49. },
  50. // 修改产品
  51. updateProduct: async (data: ProductVO) => {
  52. return await request.put({ url: `/iot/product/update`, data })
  53. },
  54. // 删除产品
  55. deleteProduct: async (id: number) => {
  56. return await request.delete({ url: `/iot/product/delete?id=` + id })
  57. },
  58. // 导出产品 Excel
  59. exportProduct: async (params) => {
  60. return await request.download({ url: `/iot/product/export-excel`, params })
  61. },
  62. // 更新产品状态
  63. updateProductStatus: async (id: number, status: number) => {
  64. return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status })
  65. },
  66. // 查询产品(精简)列表
  67. getSimpleProductList() {
  68. return request.get({ url: '/iot/product/simple-list' })
  69. }
  70. }