index.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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: ProductFunctionTypeEnum // 功能类型
  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 enum ProductFunctionTypeEnum {
  38. PROPERTY = 1, // 属性
  39. SERVICE = 2, // 服务
  40. EVENT = 3 // 事件
  41. }
  42. // IOT 产品功能(物模型)访问模式枚举类
  43. export enum ProductFunctionAccessModeEnum {
  44. READ_WRITE = 'rw', // 读写
  45. READ_ONLY = 'r' // 只读
  46. }
  47. // TODO @puhui999:getProductThingModelPage => getThingModelPage 哈,不用带 product 前缀
  48. // IoT 产品物模型 API
  49. export const ThinkModelFunctionApi = {
  50. // 查询产品物模型分页
  51. getProductThingModelPage: async (params: any) => {
  52. return await request.get({ url: `/iot/product-thing-model/page`, params })
  53. },
  54. // 获得产品物模型
  55. getProductThingModelListByProductId: async (params: any) => {
  56. return await request.get({
  57. url: `/iot/product-thing-model/list-by-product-id`,
  58. params
  59. })
  60. },
  61. // 查询产品物模型详情
  62. getProductThingModel: async (id: number) => {
  63. return await request.get({ url: `/iot/product-thing-model/get?id=` + id })
  64. },
  65. // 新增产品物模型
  66. createProductThingModel: async (data: ThingModelData) => {
  67. return await request.post({ url: `/iot/product-thing-model/create`, data })
  68. },
  69. // 修改产品物模型
  70. updateProductThingModel: async (data: ThingModelData) => {
  71. return await request.put({ url: `/iot/product-thing-model/update`, data })
  72. },
  73. // 删除产品物模型
  74. deleteProductThingModel: async (id: number) => {
  75. return await request.delete({ url: `/iot/product-thing-model/delete?id=` + id })
  76. }
  77. }