张艾宸

修改配置文件为config.json

... ... @@ -6,11 +6,11 @@ const fs = require("fs");
const method = require("../config/method")
const config = require("../config/config")
const { GETCLASSURL, GETCLASSURLPARAMETER, PROJECTCATALOG, PROJECTWINCATALOG, BACKMEDIACONFIG } = config
// const { GETCLASSURL, GETCLASSURLPARAMETER, PROJECTCATALOG, PROJECTWINCATALOG, BACKMEDIACONFIG } = config
const { YesterdayTime, getRequestClassIds } = method
const { startTime, endTime, ymd } = YesterdayTime()
let siteIds = GETCLASSURLPARAMETER.siteId
let siteIds = []
let classid = []
let parentData = {}
... ... @@ -24,7 +24,10 @@ class MediaCreat {
constructor() { }
// 取出所有数据
async allData() {
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
className = siteIds.shift()
const { GETCLASSURL,GETCLASSURLPARAMETER } = JSON.parse(fileConfig)
let page = 1
if (className) {
let result = await getRequestClassIds(GETCLASSURL, className, GETCLASSURLPARAMETER.key, startTime, endTime, page)
... ... @@ -42,7 +45,6 @@ class MediaCreat {
}
}
parentData[result.data.data.siteId] = Array.from(parentData[result.data.data.siteId])
if (siteIds.length) {
return await new MediaCreat().allData()
}
... ... @@ -52,6 +54,10 @@ class MediaCreat {
}
}
async mediaCreat(id, siteId) {
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
const { BACKMEDIACONFIG,PROJECTWINCATALOG,PROJECTCATALOG } = JSON.parse(fileConfig)
let mediaDir = PROJECTCATALOG + "/media/"
let classDir = PROJECTCATALOG + "/media/" + siteId
let ymdDir = PROJECTCATALOG + "/media/" + siteId + "/" + ymd
... ... @@ -95,10 +101,21 @@ class MediaCreat {
}
});
}
async getConfigFileJson(){
const buffer= fs.readFileSync(process.cwd()+"/config/config.json")
return String(buffer)
}
}
router.get('/', async function (req, res, next) {
let fileConfig = await new MediaCreat().getConfigFileJson()
if(!fileConfig) return false
const {GETCLASSURLPARAMETER} = JSON.parse(fileConfig)
siteIds = GETCLASSURLPARAMETER.siteId
let result = await new MediaCreat().allData()
if (result) {
// 去重
... ...