index.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import request from '@/config/axios'
  2. /**
  3. * IoT 产品物模型
  4. */
  5. export interface ThingModelData {
  6. id?: number // 物模型功能编号
  7. identifier?: string // 功能标识
  8. name?: string // 功能名称
  9. description?: string // 功能描述
  10. productId?: number // 产品编号
  11. productKey?: string // 产品标识
  12. dataType: string // 数据类型,与 dataSpecs 的 dataType 保持一致
  13. type: number // 功能类型
  14. property: ThingModelProperty // 属性
  15. event?: ThingModelEvent // 事件
  16. service?: ThingModelService // 服务
  17. }
  18. /**
  19. * ThingModelProperty 类型
  20. */
  21. export interface ThingModelProperty {
  22. [key: string]: any
  23. }
  24. /**
  25. * ThingModelEvent 类型
  26. */
  27. export interface ThingModelEvent {
  28. [key: string]: any
  29. }
  30. /**
  31. * ThingModelService 类型
  32. */
  33. export interface ThingModelService {
  34. [key: string]: any
  35. }
  36. // IOT 产品物模型类型枚举类
  37. export const ThingModelType = {
  38. PROPERTY: 1, // 属性
  39. SERVICE: 2, // 服务
  40. EVENT: 3 // 事件
  41. } as const
  42. // IOT 产品物模型访问模式枚举类
  43. export const ThingModelAccessMode = {
  44. READ_WRITE: {
  45. label: '读写',
  46. value: 'rw'
  47. },
  48. READ_ONLY: {
  49. label: '只读',
  50. value: 'r'
  51. }
  52. } as const
  53. // IOT 产品物模型服务调用方式枚举
  54. export const ThingModelServiceCallType = {
  55. ASYNC: {
  56. label: '异步调用',
  57. value: 'async'
  58. },
  59. SYNC: {
  60. label: '同步调用',
  61. value: 'sync'
  62. }
  63. } as const
  64. // IOT 产品物模型事件类型枚举
  65. export const ThingModelServiceEventType = {
  66. INFO: {
  67. label: '信息',
  68. value: 'info'
  69. },
  70. ALERT: {
  71. label: '告警',
  72. value: 'alert'
  73. },
  74. ERROR: {
  75. label: '故障',
  76. value: 'error'
  77. }
  78. } as const
  79. // IOT 产品物模型参数是输入参数还是输出参数
  80. export const ThingModelParamDirection = {
  81. INPUT: 'input', // 输入参数
  82. OUTPUT: 'output' // 输出参数
  83. } as const
  84. // IoT 产品物模型 API
  85. export const ThingModelApi = {
  86. // 查询产品物模型分页
  87. getThingModelPage: async (params: any) => {
  88. return await request.get({ url: `/iot/product-thing-model/page`, params })
  89. },
  90. // 获得产品物模型
  91. getThingModelListByProductId: async (params: any) => {
  92. return await request.get({
  93. url: `/iot/product-thing-model/list-by-product-id`,
  94. params
  95. })
  96. },
  97. // 查询产品物模型详情
  98. getThingModel: async (id: number) => {
  99. return await request.get({ url: `/iot/product-thing-model/get?id=` + id })
  100. },
  101. // 新增产品物模型
  102. createThingModel: async (data: ThingModelData) => {
  103. return await request.post({ url: `/iot/product-thing-model/create`, data })
  104. },
  105. // 修改产品物模型
  106. updateThingModel: async (data: ThingModelData) => {
  107. return await request.put({ url: `/iot/product-thing-model/update`, data })
  108. },
  109. // 删除产品物模型
  110. deleteThingModel: async (id: number) => {
  111. return await request.delete({ url: `/iot/product-thing-model/delete?id=` + id })
  112. }
  113. }