张艾宸

修改配置文件为config.json

@@ -6,11 +6,11 @@ const fs = require("fs"); @@ -6,11 +6,11 @@ const fs = require("fs");
6 const method = require("../config/method") 6 const method = require("../config/method")
7 const config = require("../config/config") 7 const config = require("../config/config")
8 8
9 -const { GETCLASSURL, GETCLASSURLPARAMETER, PROJECTCATALOG, PROJECTWINCATALOG, BACKMEDIACONFIG } = config 9 +// const { GETCLASSURL, GETCLASSURLPARAMETER, PROJECTCATALOG, PROJECTWINCATALOG, BACKMEDIACONFIG } = config
10 const { YesterdayTime, getRequestClassIds } = method 10 const { YesterdayTime, getRequestClassIds } = method
11 11
12 const { startTime, endTime, ymd } = YesterdayTime() 12 const { startTime, endTime, ymd } = YesterdayTime()
13 -let siteIds = GETCLASSURLPARAMETER.siteId 13 +let siteIds = []
14 14
15 let classid = [] 15 let classid = []
16 let parentData = {} 16 let parentData = {}
@@ -24,7 +24,10 @@ class MediaCreat { @@ -24,7 +24,10 @@ class MediaCreat {
24 constructor() { } 24 constructor() { }
25 // 取出所有数据 25 // 取出所有数据
26 async allData() { 26 async allData() {
  27 + let fileConfig = await new MediaCreat().getConfigFileJson()
  28 + if(!fileConfig) return false
27 className = siteIds.shift() 29 className = siteIds.shift()
  30 + const { GETCLASSURL,GETCLASSURLPARAMETER } = JSON.parse(fileConfig)
28 let page = 1 31 let page = 1
29 if (className) { 32 if (className) {
30 let result = await getRequestClassIds(GETCLASSURL, className, GETCLASSURLPARAMETER.key, startTime, endTime, page) 33 let result = await getRequestClassIds(GETCLASSURL, className, GETCLASSURLPARAMETER.key, startTime, endTime, page)
@@ -42,7 +45,6 @@ class MediaCreat { @@ -42,7 +45,6 @@ class MediaCreat {
42 } 45 }
43 } 46 }
44 parentData[result.data.data.siteId] = Array.from(parentData[result.data.data.siteId]) 47 parentData[result.data.data.siteId] = Array.from(parentData[result.data.data.siteId])
45 -  
46 if (siteIds.length) { 48 if (siteIds.length) {
47 return await new MediaCreat().allData() 49 return await new MediaCreat().allData()
48 } 50 }
@@ -52,6 +54,10 @@ class MediaCreat { @@ -52,6 +54,10 @@ class MediaCreat {
52 } 54 }
53 } 55 }
54 async mediaCreat(id, siteId) { 56 async mediaCreat(id, siteId) {
  57 + let fileConfig = await new MediaCreat().getConfigFileJson()
  58 + if(!fileConfig) return false
  59 + const { BACKMEDIACONFIG,PROJECTWINCATALOG,PROJECTCATALOG } = JSON.parse(fileConfig)
  60 +
55 let mediaDir = PROJECTCATALOG + "/media/" 61 let mediaDir = PROJECTCATALOG + "/media/"
56 let classDir = PROJECTCATALOG + "/media/" + siteId 62 let classDir = PROJECTCATALOG + "/media/" + siteId
57 let ymdDir = PROJECTCATALOG + "/media/" + siteId + "/" + ymd 63 let ymdDir = PROJECTCATALOG + "/media/" + siteId + "/" + ymd
@@ -95,10 +101,21 @@ class MediaCreat { @@ -95,10 +101,21 @@ class MediaCreat {
95 } 101 }
96 }); 102 });
97 } 103 }
  104 +
  105 + async getConfigFileJson(){
  106 + const buffer= fs.readFileSync(process.cwd()+"/config/config.json")
  107 + return String(buffer)
  108 + }
98 } 109 }
99 110
100 111
101 router.get('/', async function (req, res, next) { 112 router.get('/', async function (req, res, next) {
  113 + let fileConfig = await new MediaCreat().getConfigFileJson()
  114 + if(!fileConfig) return false
  115 +
  116 + const {GETCLASSURLPARAMETER} = JSON.parse(fileConfig)
  117 + siteIds = GETCLASSURLPARAMETER.siteId
  118 +
102 let result = await new MediaCreat().allData() 119 let result = await new MediaCreat().allData()
103 if (result) { 120 if (result) {
104 // 去重 121 // 去重