Ver Fonte

refactor: api test

Casper Dai há 2 anos atrás
pai
commit
d05cd48514
3 ficheiros alterados com 78 adições e 9 exclusões
  1. 52 0
      src/api/platform.js
  2. 4 5
      src/api/statistics.js
  3. 22 4
      src/views/test-api.vue

+ 52 - 0
src/api/platform.js

@@ -146,3 +146,55 @@ export function getOperationResults (query) {
     }
   })
 }
+
+export function addOrUpdateWorkflow (data) {
+  return messageSend({
+    url: '/workflow/saveOrUpdate',
+    method: 'POST',
+    data
+  }, '操作')
+}
+
+export function deleteWorkflow ({ id }) {
+  return del({
+    url: '/workflow/saveOrUpdate',
+    method: 'POST',
+    data: { id }
+  })
+}
+
+export function getWorkflowDetail ({ id }) {
+  return request({
+    url: '/workflow/getBussinessData',
+    method: 'GET',
+    params: { workflowId: id }
+  })
+}
+
+export function getWorkflows (query) {
+  const { pageNum: pageIndex, pageSize, ...params } = query
+  return request({
+    url: '/workflow/pageByPropertis',
+    method: 'GET',
+    params: {
+      pageIndex, pageSize,
+      ...params
+    }
+  })
+}
+
+export function getWorkflow ({ id }) {
+  return request({
+    url: '/workflow/getById',
+    method: 'GET',
+    params: { workflowId: id }
+  })
+}
+
+export function resolveWorkflow ({ id }) {
+  return request({
+    url: '/workflow/getById',
+    method: 'GET',
+    params: { workflowId: id }
+  })
+}

+ 4 - 5
src/api/statistics.js

@@ -1,13 +1,12 @@
 import request from '@/utils/request'
-import { messageSend } from './base'
 
 // yyyy-MM-dd
 export function triggerAdSnap (date) {
-  return messageSend({
+  return request({
     url: '/ad/statistic/daily/compute/trigger',
     method: 'GET',
     params: { date }
-  }, '触发')
+  })
 }
 
 export function getAdReport (query = {}) {
@@ -47,10 +46,10 @@ export function getAdCollect (query = {}) {
 }
 
 export function triggetOnlineDurationSnap () {
-  return messageSend({
+  return request({
     url: '/deviceOnlineInfoDetail/syncDeviceOnlineSummary',
     method: 'GET'
-  }, '触发')
+  })
 }
 
 export function getOnlineDurationByDevice (id) {

+ 22 - 4
src/views/test-api.vue

@@ -143,7 +143,6 @@ export default {
     },
     getMonth () {
       const endDate = new Date()
-      endDate.setDate(endDate.getDate() + 1)
       const startDate = new Date(endDate.getTime())
       startDate.setMonth(startDate.getMonth() - 1)
       return {
@@ -152,7 +151,12 @@ export default {
       }
     },
     onTriggerOnlineDurationSnap () {
-      triggetOnlineDurationSnap()
+      triggetOnlineDurationSnap().then(() => {
+        this.$message({
+          type: 'success',
+          message: '触发完成'
+        })
+      })
     },
     onGetOnlineDurationByDevice () {
       this.checkDevice() && getOnlineDurationByDevice(this.deviceId).then(this.onData)
@@ -166,8 +170,22 @@ export default {
         sumDateTo: endDate
       }).then(this.onData)
     },
-    onTriggerAdSnap () {
-      triggerAdSnap(parseTime(new Date(), '{y}-{m}-{d}'))
+    async onTriggerAdSnap () {
+      const endDate = new Date()
+      let startDate = new Date(endDate.getTime())
+      startDate.setMonth(startDate.getMonth() - 1)
+      while (startDate <= endDate) {
+        try {
+          await triggerAdSnap(parseTime(startDate, '{y}-{m}-{d}'))
+        } catch (e) {
+          console.log('onTriggerAdSnap fail', parseTime(startDate, '{y}-{m}-{d}'))
+        }
+        startDate = new Date(startDate.setDate(startDate.getDate() + 1))
+      }
+      this.$message({
+        type: 'success',
+        message: '触发完成'
+      })
     },
     onGetAdReportForPlatfrom () {
       getAdReport(this.getMonth()).then(this.onData)