Bläddra i källkod

feat:接口定义

lvkun 2 år sedan
förälder
incheckning
b95bc3c38b

+ 11 - 0
src/api/common/index.ts

@@ -12,3 +12,14 @@ export const getTransport = () => {
     method: 'GET'
   })
 }
+
+/**
+ * 获取账户的系统配置
+ * @returns
+ */
+export const getSysConf = () => {
+  return request<COMMON.SYS.Conf>({
+    url: '/sysConf',
+    method: 'GET'
+  })
+}

+ 8 - 0
src/api/iot/device.ts

@@ -251,3 +251,11 @@ export const getDevicShadow = (deviceId: string) => {
     method: 'GET'
   })
 }
+
+/** 设备拓扑 */
+export const getDevicTopology = (modelId: string) => {
+  return request<IOT.API.DEVICE.Topology[]>({
+    url: `/device/topology?modelId=${modelId}`,
+    method: 'GET'
+  })
+}

+ 26 - 0
src/api/iot/model.ts

@@ -250,3 +250,29 @@ export const getModelCount = () => {
     method: 'GET'
   })
 }
+
+/** 获取产品模型库列表 */
+export const getModelTemplate = (params: any) => {
+  return request<IOT.API.MODELTEMPLATE.modelTemplate[]>({
+    url: '/modelTemplate/page',
+    method: 'GET',
+    params
+  })
+}
+
+/** 获取产品模型库列表详情 */
+export const getModelTemplateById = (id: string) => {
+  return request<IOT.API.MODELTEMPLATE.modelTemplate>({
+    url: '/modelTemplate/page',
+    method: 'GET',
+    params: { id }
+  })
+}
+
+/** 加入产品模型库列表 */
+export const postModelTemplate = ({ modelId, templateLabel }: {modelId: string, templateLabel: string}) => {
+  return request<string>({
+    url: `/modelTemplate/join/${modelId}templateLabel=${templateLabel}`,
+    method: 'GET'
+  })
+}

+ 9 - 0
src/api/iot/task.ts

@@ -0,0 +1,9 @@
+import request from '@/service/request'
+
+export const getTaskPage = (params: {page: number, pageSize: number, taskLabel?: string, status?: boolean}) => {
+  return request<IOT.API.DEVICE.Device[]>({
+    url: '/task/page',
+    method: 'GET',
+    params
+  })
+}

+ 14 - 1
src/controller/iot/model.ts

@@ -1,4 +1,4 @@
-import { addModel, addModelPlugin, debugModelPlugin, delModel, getModel, getModelById, getModelCount, getModelList, getModelPlugin, updateModelPlugin } from '@/api/iot/model'
+import { addModel, addModelPlugin, debugModelPlugin, delModel, getModel, getModelById, getModelCount, getModelList, getModelPlugin, getModelTemplate, getModelTemplateById, postModelTemplate, updateModelPlugin } from '@/api/iot/model'
 import { message } from 'ant-design-vue'
 
 export class ModelController {
@@ -56,4 +56,17 @@ export class ModelController {
   static async debugPlugin (data: {input: string, pluginBody: string, decode: boolean}) {
     return await debugModelPlugin(data)
   }
+
+  static async modelTemplate (params: {page: number, pageSize: number, templateLabel: string}) {
+    return getModelTemplate(params)
+  }
+
+  static async modelTemplateById (id: string) {
+    return getModelTemplateById(id)
+  }
+
+  static async postModelTemplate (data: {modelId: string, templateLabel: string}) {
+    await postModelTemplate(data)
+    message.success('加入产品模型库列表成功')
+  }
 }

+ 7 - 0
src/controller/iot/task.ts

@@ -0,0 +1,7 @@
+import { getTaskPage } from '@/api/iot/task'
+
+export class TaskController {
+  static async taskPage (params: {page: number, pageSize: number, taskLabel?: string, status?: boolean}) {
+    return getTaskPage(params)
+  }
+}

+ 8 - 0
src/layout/sysSetting.vue

@@ -0,0 +1,8 @@
+<template>
+<a-card>
+</a-card>
+</template>
+<script lang='ts' setup >
+</script>
+<style lang='less' scoped >
+</style>

+ 3 - 1
src/layout/user.vue

@@ -8,13 +8,15 @@
 
     <template #overlay>
       <a-menu>
+        <a-menu-item>
+          <a href="javascript:;">系统配置</a>
+        </a-menu-item>
         <a-menu-item>
           <a href="javascript:;">退出登录</a>
         </a-menu-item>
       </a-menu>
     </template>
   </a-dropdown>
-
   </div>
 </template>
 

+ 9 - 0
src/pages/Iot/model/models.vue

@@ -0,0 +1,9 @@
+<template>
+<a-card>
+</a-card>
+</template>
+<script lang='ts' setup >
+
+</script>
+<style lang='less' scoped >
+</style>

+ 6 - 1
src/router/index.ts

@@ -18,7 +18,7 @@ export const routes: Array<ROUTER.RoutesProps> = [
       },
       {
         path: '/product',
-        name: '产品模型',
+        name: '产品',
         redirect: '/product/index',
         icon: 'AppstoreOutlined',
         children: [
@@ -27,6 +27,11 @@ export const routes: Array<ROUTER.RoutesProps> = [
             name: '产品模型',
             component: () => import('@/pages/iot/model/index.vue')
           },
+          {
+            path: '/product/models',
+            name: '产品模型库',
+            component: () => import('@/pages/iot/model/index.vue')
+          },
           {
             path: '/product/detail',
             name: '产品模型详情',

+ 20 - 0
src/type/common.d.ts

@@ -17,4 +17,24 @@ declare namespace COMMON {
       type ComType = 'input' | 'select' | 'datepick' | 'textarea'
     }
 
+    namespace SYS {
+      interface Conf {
+        'id': string,
+        'createAt': number,
+        'updateAt': null,
+        'deleted': false,
+        'sysLabel': string, // 系统名称
+        'sysIcon': string, // 系统图片,上传时候限制大小为3M 并且base64 编码
+        'sysTheme': string, // 系统主题
+        'tenantId': 'nil',
+        'mailConf': {
+          'host': string, // 邮件地址
+          'port': number, // 邮件端口
+          'protocol': string, // 邮件协议
+          'username': string, // 邮件账号
+          'password': string // 邮件密码
+        }
+      }
+    }
+
 }

+ 43 - 0
src/type/iot.d.ts

@@ -46,6 +46,26 @@ declare namespace IOT {
       }
     }
 
+    namespace MODELTEMPLATE {
+      interface modelTemplate {
+        id: string
+        templateLabel: string
+        templateAttribute: {
+          id: string
+          attributeKey: string
+          attributeLabel: string
+          dataType: string
+          dataUnit: string
+          scope: string
+          expr: string
+          modelId: string
+          key: string
+        }[]
+        templatePlugin: any
+        templateCmd: any
+      }
+    }
+
     namespace CMD {
       interface Cmd {
         id: string,
@@ -160,6 +180,19 @@ declare namespace IOT {
         deviceGroupId: string,
         searchValue?: string,
       }
+
+      interface Topology {
+        'id': string,
+        'createAt': number,
+        'updateAt': string,
+        'deleted': string,
+        'modelLabel': string,
+        'transportType': string,
+        'payloadType': string,
+        'deviceType': string,
+        'modelDescription': string,
+        'tenantId': string
+      }
     }
 
     namespace EVENT {
@@ -287,6 +320,16 @@ declare namespace IOT {
         noticeLabel: string
       }
     }
+
+    namespace TASK {
+      interface Task {
+        'taskLabel': string,
+        'taskConfig': {}, // 任务配置
+        'status': number, // 任务状态
+        'taskDescription': string,
+        'cornDescr': string // corn 表达式
+      }
+    }
 }
 
 }