Bläddra i källkod

配置表提交

dw_yinsong 5 år sedan
förälder
incheckning
ea79d5361b
33 ändrade filer med 442 tillägg och 6 borttagningar
  1. 1 1
      assets/scripts/data/buildingLevel.js
  2. 1 0
      assets/scripts/data/friendReward.js
  3. 0 0
      assets/scripts/data/lottery.js
  4. 0 0
      assets/scripts/data/mainTask.js
  5. 16 1
      tools/config.js
  6. 76 0
      tools/config.js.bak
  7. BIN
      tools/headlines_excel/taptapstar_buildingLevel.xlsx
  8. BIN
      tools/headlines_excel/taptapstar_dailyDegree.xlsx
  9. BIN
      tools/headlines_excel/taptapstar_dailyTask.xlsx
  10. BIN
      tools/headlines_excel/taptapstar_friendReward.xlsx
  11. BIN
      tools/headlines_excel/taptapstar_gift.xlsx
  12. BIN
      tools/headlines_excel/taptapstar_inviteReward.xlsx
  13. BIN
      tools/headlines_excel/taptapstar_item.xlsx
  14. BIN
      tools/headlines_excel/taptapstar_loginReward.xlsx
  15. BIN
      tools/headlines_excel/taptapstar_lottery.xlsx
  16. BIN
      tools/headlines_excel/taptapstar_lotteryNew.xlsx
  17. BIN
      tools/headlines_excel/taptapstar_mainTask.xlsx
  18. BIN
      tools/headlines_excel/taptapstar_roomInfo.xlsx
  19. BIN
      tools/headlines_excel/taptapstar_shop.xlsx
  20. BIN
      tools/headlines_excel/taptapstar_sign.xlsx
  21. BIN
      tools/headlines_excel/taptapstar_skillInfo.xlsx
  22. BIN
      tools/headlines_excel/taptapstar_skillLevel.xlsx
  23. BIN
      tools/headlines_excel/taptapstar_starAreaType.xlsx
  24. BIN
      tools/headlines_excel/taptapstar_starGold.xlsx
  25. BIN
      tools/headlines_excel/taptapstar_starInfo.xlsx
  26. 161 0
      tools/headlines_local.js
  27. 161 0
      tools/headlines_local.js.bak
  28. 23 3
      tools/mongo.js
  29. 1 0
      tools/package.json
  30. 1 1
      tools/sheet/buildingLevel.json
  31. 1 0
      tools/sheet/friendReward.json
  32. 0 0
      tools/sheet/lottery.json
  33. 0 0
      tools/sheet/mainTask.json

+ 1 - 1
assets/scripts/data/buildingLevel.js

@@ -1 +1 @@
-module.exports=[{"level":1,"upGold":"100"},{"level":2,"upGold":"105"},{"level":3,"upGold":"110"},{"level":4,"upGold":"115"},{"level":5,"upGold":"120"},{"level":6,"upGold":"126"},{"level":7,"upGold":"132"},{"level":8,"upGold":"138"},{"level":9,"upGold":"144"},{"level":10,"upGold":"151"},{"level":11,"upGold":"158"},{"level":12,"upGold":"165"},{"level":13,"upGold":"173"},{"level":14,"upGold":"181"},{"level":15,"upGold":"190"},{"level":16,"upGold":"199"},{"level":17,"upGold":"208"},{"level":18,"upGold":"218"},{"level":19,"upGold":"228"},{"level":20,"upGold":"239"},{"level":21,"upGold":"250"},{"level":22,"upGold":"262"},{"level":23,"upGold":"275"},{"level":24,"upGold":"288"},{"level":25,"upGold":"302"}]
+module.exports=[{"level":1,"upGold":"100"},{"level":2,"upGold":"105"},{"level":3,"upGold":"110"},{"level":4,"upGold":"115"},{"level":5,"upGold":"120"},{"level":6,"upGold":"126"},{"level":7,"upGold":"132"},{"level":8,"upGold":"138"},{"level":9,"upGold":"144"},{"level":10,"upGold":"151"},{"level":11,"upGold":"158"},{"level":12,"upGold":"165"},{"level":13,"upGold":"173"},{"level":14,"upGold":"181"},{"level":15,"upGold":"190"},{"level":16,"upGold":"199"},{"level":17,"upGold":"208"},{"level":18,"upGold":"218"},{"level":19,"upGold":"228"},{"level":20,"upGold":"239"},{"level":21,"upGold":"250"},{"level":22,"upGold":"262"},{"level":23,"upGold":"275"},{"level":24,"upGold":"288"},{"level":25,"upGold":"3022"}]

+ 1 - 0
assets/scripts/data/friendReward.js

@@ -0,0 +1 @@
+module.exports=[{"rewardId":1,"count":1,"time":900},{"rewardId":2,"count":2,"time":1800},{"rewardId":3,"count":3,"time":3600}]

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
assets/scripts/data/lottery.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
assets/scripts/data/mainTask.js


+ 16 - 1
tools/config.js

@@ -55,10 +55,25 @@ const QQReplSetConf = {
     }
 }
 
+const HLReplSetConf = {
+    R1 : {
+        servers: [
+            "58.215.52.59:10003",
+            "58.215.52.21:10002",
+            "14.215.104.240:10003"
+        ],
+        username: "headlines_admin",
+        password: "mtB78u3890x1",
+        replicaSet: "taptapstarqqmongo",
+        dbname: "taptapstar_home_headlines"
+    }
+}
+
 module.exports = {
     RedisConf,
     CommonConf,
     MongoConf,
     ReplSetConf,
-	QQReplSetConf
+	QQReplSetConf,
+	HLReplSetConf
 }

+ 76 - 0
tools/config.js.bak

@@ -0,0 +1,76 @@
+const RedisConf = {
+    R1 : {
+        port: 6380,
+        host: "61.160.36.19",
+        password: "33fa134e11b",
+        db: 5
+    }
+}
+
+const CommonConf = {
+
+}
+
+/**
+ * 测试环境MongoDB
+ */
+const MongoConf = {
+    R1 : {
+        port: 27017,
+        host: "61.147.187.176",
+        username: "ojiatest",
+        password: "ojia305",
+        dbname: "taptapstar_home"
+    }
+}
+
+/**
+ * 正式环境MongoDB复制集
+ */
+const ReplSetConf = {
+    R1 : {
+        servers: [
+            "58.215.52.59:10002",
+            "58.215.52.21:10003",
+            "14.215.104.240:10002"
+        ],
+        username: "taptapstar_rw",
+        password: "o890usVM1e0",
+        replicaSet: "taptapstarmongo",
+        dbname: "taptapstar_home"
+    }
+}
+
+const QQReplSetConf = {
+    R1 : {
+        servers: [
+            "58.215.52.59:10003",
+            "58.215.52.21:10002",
+            "14.215.104.240:10003"
+        ],
+        username: "taptapstarqq_mongo_rw",
+        password: "gW0CxPhL6I56",
+        replicaSet: "taptapstarqqmongo",
+        dbname: "taptapstarqq_mongo"
+    }
+}
+
+const HLReplSetConf = {
+    R1 : {
+		port: 10003,
+        host: "14.215.104.240",
+        username: "headlines_admin",
+        password: "mtB78u3890x1",
+        dbname: "taptapstar_home_headlines"
+       
+    }
+}
+
+module.exports = {
+    RedisConf,
+    CommonConf,
+    MongoConf,
+    ReplSetConf,
+	QQReplSetConf,
+	HLReplSetConf
+}

BIN
tools/headlines_excel/taptapstar_buildingLevel.xlsx


BIN
tools/headlines_excel/taptapstar_dailyDegree.xlsx


BIN
tools/headlines_excel/taptapstar_dailyTask.xlsx


BIN
tools/headlines_excel/taptapstar_friendReward.xlsx


BIN
tools/headlines_excel/taptapstar_gift.xlsx


BIN
tools/headlines_excel/taptapstar_inviteReward.xlsx


BIN
tools/headlines_excel/taptapstar_item.xlsx


BIN
tools/headlines_excel/taptapstar_loginReward.xlsx


BIN
tools/headlines_excel/taptapstar_lottery.xlsx


BIN
tools/headlines_excel/taptapstar_lotteryNew.xlsx


BIN
tools/headlines_excel/taptapstar_mainTask.xlsx


BIN
tools/headlines_excel/taptapstar_roomInfo.xlsx


BIN
tools/headlines_excel/taptapstar_shop.xlsx


BIN
tools/headlines_excel/taptapstar_sign.xlsx


BIN
tools/headlines_excel/taptapstar_skillInfo.xlsx


BIN
tools/headlines_excel/taptapstar_skillLevel.xlsx


BIN
tools/headlines_excel/taptapstar_starAreaType.xlsx


BIN
tools/headlines_excel/taptapstar_starGold.xlsx


BIN
tools/headlines_excel/taptapstar_starInfo.xlsx


+ 161 - 0
tools/headlines_local.js

@@ -0,0 +1,161 @@
+const fs = require('fs')
+const path = require('path')
+const XLSX = require('xlsx')
+// const Rsync = require('rsync')
+const {MongoConf} = require('./config')
+
+const MongoClient = require('mongodb').MongoClient
+const assert = require('assert')
+
+const dbIns = MongoConf['R1']
+const connStr = `mongodb://${dbIns.host}:${dbIns.port}`
+const connOpt = {
+    auth : {
+        user: dbIns.username,
+        password: dbIns.password,
+    },
+    authSource: dbIns.dbname,
+    authMechanism: "SCRAM-SHA-1",
+    useNewUrlParser: true
+}
+
+const dataPath = "../assets/scripts/data"
+const dataPrefix =  "taptapstar_"
+
+
+/**
+ * excel表转换为json对象
+ * @param {String} filename 文件名
+ */
+const getSheet = function (filename) {
+    let filePath = path.join(__dirname, "/headlines_excel", filename)
+    // let buf = fs.readFile(filePath);
+    let workbook = XLSX.readFileSync(filePath)
+    let sheets = workbook.SheetNames
+    let sheetsObj = {}
+    
+    sheets.forEach(n => {
+        let ws = workbook.Sheets[n]
+        let def = XLSX.utils.sheet_to_json(ws, {range: 0, header: 1})
+        let typeMap = {}
+        let typeArr = def[0]
+        let keyArr = def[2]
+        keyArr.forEach((item, index) => {
+            typeMap[item] = typeArr[index]
+        })
+
+        let res = XLSX.utils.sheet_to_json(ws, {range: 2})
+        res.forEach(item => {
+            for(let i in item) {
+                item[i] = formatType(item[i], typeMap[i])
+            }
+        })
+        sheetsObj[n] = res
+    })
+    return sheetsObj
+    
+    // console.log(XLSX.utils.sheet_to_json(ws));
+    // console.log(workbook.SheetNames);
+}
+
+/**
+ * 写入json内容到客户端assets目录
+ * @param {String} filename 文件名
+ * @param {Object} content json内容
+ */
+const writeToAssets = function (filename, content) {
+    let writeFileName = filename.replace(/\.xlsx|\.xls/, '.js').replace(dataPrefix, "")
+    let writePath = path.join(__dirname, dataPath, writeFileName)
+    let string = JSON.stringify(content);
+    fs.writeFile(writePath, 'module.exports=' + string)
+    // console.log(JSON.stringify(content, null, 2));
+}
+
+/**
+ * 配置表生成的json内容rsync到静态资源服务器
+ * @param {String} filename 文件名
+ * @param {Object} content json内容
+ */
+const rsyncJson = function (filename, content) {
+    let writeFileName = filename.replace(/\.xlsx|\.xls/, '.json').replace(dataPrefix, "")
+    let writePath = path.join(__dirname, "/sheet", writeFileName)
+
+    fs.writeFile(writePath, JSON.stringify(content))
+}
+
+const formatType = function(target, type) {
+    let _type = type.toLowerCase()
+    switch (_type) {
+        case 'integer':
+            target = parseInt(target, 10)
+            break;
+        case 'double':
+            target = parseFloat(target)
+            break;
+        case 'string':
+            target = target.toString()
+            break;
+        case 'object':
+            target = JSON.parse(target)
+            break;
+        default:
+            break;
+    }
+    return target
+}
+
+const init = function () {
+    fs.readdir("./excel", (err, file) => {
+        file.forEach(n => {
+            if(n.match(/\~\$/)) {
+                return
+            }
+            let ws = getSheet(n)
+            let sheetName = n.replace(/\.xlsx|\.xls/, "")
+
+            let target
+            if(ws.length > 0) {
+                //单个表
+                // ws.forEach(n => {
+                //     if(typeof n['id'] != undefined) {
+                //         n['_id'] = n['id']
+                //     }
+                // })
+
+                target = ws
+            } else {
+                //多个表合拼成一个Array
+                let _array = []
+                for(let i in ws) {
+                    _array = _array.concat(ws[i])
+                }
+                target = _array                
+            }
+
+            // MongoClient.connect(connStr, connOpt, (err, client) => {
+            //     var db = client.db(dbIns.dbname)
+            //     var collection = db.collection(sheetName)
+            //     collection.drop(null, () => {
+            //         collection.insert(target, () => {
+            //             console.log(`成功更新配置表:${sheetName}`)
+            //             client.close()
+            //         })
+            //     })
+            // });
+
+            //把生成的js写入客户端assets目录
+            let wsKeys = Object.keys(ws)
+            if(wsKeys.length == 1) {
+                writeToAssets(n, ws[wsKeys[0]])
+                rsyncJson(n, ws[wsKeys[0]])
+            } else {
+                writeToAssets(n, ws)
+                rsyncJson(n, ws)
+            }
+        })
+
+        // process.exit()
+    })
+}
+
+init()

+ 161 - 0
tools/headlines_local.js.bak

@@ -0,0 +1,161 @@
+const fs = require('fs')
+const path = require('path')
+const XLSX = require('xlsx')
+// const Rsync = require('rsync')
+const {MongoConf} = require('./config')
+
+const MongoClient = require('mongodb').MongoClient
+const assert = require('assert')
+
+const dbIns = MongoConf['R1']
+const connStr = `mongodb://${dbIns.host}:${dbIns.port}`
+const connOpt = {
+    auth : {
+        user: dbIns.username,
+        password: dbIns.password,
+    },
+    authSource: dbIns.dbname,
+    authMechanism: "SCRAM-SHA-1",
+    useNewUrlParser: true
+}
+
+const dataPath = "../assets/scripts/data"
+const dataPrefix =  "taptapstar_"
+
+
+/**
+ * excel表转换为json对象
+ * @param {String} filename 文件名
+ */
+const getSheet = function (filename) {
+    let filePath = path.join(__dirname, "/excel", filename)
+    // let buf = fs.readFile(filePath);
+    let workbook = XLSX.readFileSync(filePath)
+    let sheets = workbook.SheetNames
+    let sheetsObj = {}
+    
+    sheets.forEach(n => {
+        let ws = workbook.Sheets[n]
+        let def = XLSX.utils.sheet_to_json(ws, {range: 0, header: 1})
+        let typeMap = {}
+        let typeArr = def[0]
+        let keyArr = def[2]
+        keyArr.forEach((item, index) => {
+            typeMap[item] = typeArr[index]
+        })
+
+        let res = XLSX.utils.sheet_to_json(ws, {range: 2})
+        res.forEach(item => {
+            for(let i in item) {
+                item[i] = formatType(item[i], typeMap[i])
+            }
+        })
+        sheetsObj[n] = res
+    })
+    return sheetsObj
+    
+    // console.log(XLSX.utils.sheet_to_json(ws));
+    // console.log(workbook.SheetNames);
+}
+
+/**
+ * 写入json内容到客户端assets目录
+ * @param {String} filename 文件名
+ * @param {Object} content json内容
+ */
+const writeToAssets = function (filename, content) {
+    let writeFileName = filename.replace(/\.xlsx|\.xls/, '.js').replace(dataPrefix, "")
+    let writePath = path.join(__dirname, dataPath, writeFileName)
+    let string = JSON.stringify(content);
+    fs.writeFile(writePath, 'module.exports=' + string)
+    // console.log(JSON.stringify(content, null, 2));
+}
+
+/**
+ * 配置表生成的json内容rsync到静态资源服务器
+ * @param {String} filename 文件名
+ * @param {Object} content json内容
+ */
+const rsyncJson = function (filename, content) {
+    let writeFileName = filename.replace(/\.xlsx|\.xls/, '.json').replace(dataPrefix, "")
+    let writePath = path.join(__dirname, "/sheet", writeFileName)
+
+    fs.writeFile(writePath, JSON.stringify(content))
+}
+
+const formatType = function(target, type) {
+    let _type = type.toLowerCase()
+    switch (_type) {
+        case 'integer':
+            target = parseInt(target, 10)
+            break;
+        case 'double':
+            target = parseFloat(target)
+            break;
+        case 'string':
+            target = target.toString()
+            break;
+        case 'object':
+            target = JSON.parse(target)
+            break;
+        default:
+            break;
+    }
+    return target
+}
+
+const init = function () {
+    fs.readdir("./excel", (err, file) => {
+        file.forEach(n => {
+            if(n.match(/\~\$/)) {
+                return
+            }
+            let ws = getSheet(n)
+            let sheetName = n.replace(/\.xlsx|\.xls/, "")
+
+            let target
+            if(ws.length > 0) {
+                //单个表
+                // ws.forEach(n => {
+                //     if(typeof n['id'] != undefined) {
+                //         n['_id'] = n['id']
+                //     }
+                // })
+
+                target = ws
+            } else {
+                //多个表合拼成一个Array
+                let _array = []
+                for(let i in ws) {
+                    _array = _array.concat(ws[i])
+                }
+                target = _array                
+            }
+
+            // MongoClient.connect(connStr, connOpt, (err, client) => {
+            //     var db = client.db(dbIns.dbname)
+            //     var collection = db.collection(sheetName)
+            //     collection.drop(null, () => {
+            //         collection.insert(target, () => {
+            //             console.log(`成功更新配置表:${sheetName}`)
+            //             client.close()
+            //         })
+            //     })
+            // });
+
+            //把生成的js写入客户端assets目录
+            let wsKeys = Object.keys(ws)
+            if(wsKeys.length == 1) {
+                writeToAssets(n, ws[wsKeys[0]])
+                rsyncJson(n, ws[wsKeys[0]])
+            } else {
+                writeToAssets(n, ws)
+                rsyncJson(n, ws)
+            }
+        })
+
+        // process.exit()
+    })
+}
+
+init()

+ 23 - 3
tools/mongo.js

@@ -2,13 +2,27 @@ const fs = require('fs')
 const path = require('path')
 const XLSX = require('xlsx')
 // const Rsync = require('rsync')
-const {MongoConf, ReplSetConf,QQReplSetConf} = require('./config')
+const {MongoConf, ReplSetConf,QQReplSetConf,HLReplSetConf} = require('./config')
 
 const MongoClient = require('mongodb').MongoClient
 
 console.log(process.env.NODE_ENV);
 var dbIns, connStr , connOpt;
-if(process.env.NODE_ENV == 'qq') {
+if(process.env.NODE_ENV == 'headlines') {
+    // 正式环境
+    dbIns = HLReplSetConf['R1']
+    connStr = `mongodb://${dbIns.servers.join(',')}`
+    connOpt = {
+        auth : {
+            user: dbIns.username,
+            password: dbIns.password,
+        },
+        replicaSet: dbIns.replicaSet,
+        authSource: dbIns.dbname,
+        authMechanism: "SCRAM-SHA-1",
+        useNewUrlParser: true
+    }
+}else if(process.env.NODE_ENV == 'qq') {
     // 正式环境
     dbIns = QQReplSetConf['R1']
     connStr = `mongodb://${dbIns.servers.join(',')}`
@@ -60,7 +74,13 @@ const dataPrefix =  "taptapstar_"
  * @param {String} filename 文件名
  */
 const getSheet = function (filename) {
-    let filePath = path.join(__dirname, "/excel", filename)
+	let filePath;
+	if(process.env.NODE_ENV == 'headlines'){
+		filePath = path.join(__dirname, "/headlines_excel", filename)
+	}else{
+		filePath = path.join(__dirname, "/excel", filename)
+	}
+	console.log('filePath: ' + filePath);
     // let buf = fs.readFile(filePath);
     let workbook = XLSX.readFileSync(filePath)
     let sheets = workbook.SheetNames

+ 1 - 0
tools/package.json

@@ -10,6 +10,7 @@
     "mongo:test": "cross-env NODE_ENV=test node mongo.js",
     "mongo:prod": "cross-env NODE_ENV=production node mongo.js",
     "mongo:qq": "cross-env NODE_ENV=qq node mongo.js",
+    "mongo:headlines": "cross-env NODE_ENV=headlines node mongo.js",
     "local": "node local.js"
   },
   "author": "",

+ 1 - 1
tools/sheet/buildingLevel.json

@@ -1 +1 @@
-[{"level":1,"upGold":"100"},{"level":2,"upGold":"105"},{"level":3,"upGold":"110"},{"level":4,"upGold":"115"},{"level":5,"upGold":"120"},{"level":6,"upGold":"126"},{"level":7,"upGold":"132"},{"level":8,"upGold":"138"},{"level":9,"upGold":"144"},{"level":10,"upGold":"151"},{"level":11,"upGold":"158"},{"level":12,"upGold":"165"},{"level":13,"upGold":"173"},{"level":14,"upGold":"181"},{"level":15,"upGold":"190"},{"level":16,"upGold":"199"},{"level":17,"upGold":"208"},{"level":18,"upGold":"218"},{"level":19,"upGold":"228"},{"level":20,"upGold":"239"},{"level":21,"upGold":"250"},{"level":22,"upGold":"262"},{"level":23,"upGold":"275"},{"level":24,"upGold":"288"},{"level":25,"upGold":"302"}]
+[{"level":1,"upGold":"100"},{"level":2,"upGold":"105"},{"level":3,"upGold":"110"},{"level":4,"upGold":"115"},{"level":5,"upGold":"120"},{"level":6,"upGold":"126"},{"level":7,"upGold":"132"},{"level":8,"upGold":"138"},{"level":9,"upGold":"144"},{"level":10,"upGold":"151"},{"level":11,"upGold":"158"},{"level":12,"upGold":"165"},{"level":13,"upGold":"173"},{"level":14,"upGold":"181"},{"level":15,"upGold":"190"},{"level":16,"upGold":"199"},{"level":17,"upGold":"208"},{"level":18,"upGold":"218"},{"level":19,"upGold":"228"},{"level":20,"upGold":"239"},{"level":21,"upGold":"250"},{"level":22,"upGold":"262"},{"level":23,"upGold":"275"},{"level":24,"upGold":"288"},{"level":25,"upGold":"3022"}]

+ 1 - 0
tools/sheet/friendReward.json

@@ -0,0 +1 @@
+[{"rewardId":1,"count":1,"time":900},{"rewardId":2,"count":2,"time":1800},{"rewardId":3,"count":3,"time":3600}]

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
tools/sheet/lottery.json


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
tools/sheet/mainTask.json


Vissa filer visades inte eftersom för många filer har ändrats