Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
let tree = new Map([
[
{
"role": "admin",
},
[
"/user",
"/user/查询登陆日志",
"/user/查询观看日志",
"/admin",
"/admin/查询登陆日志",
"/admin/查询权限",
]
],
]);
let authMenuColl = "auth_menu"
let authorityColl = "authority"
const MongoClient = require('mongodb').MongoClient;
let dburl = "mongodb://192.168.1.249:27017,192.168.1.249:27018,192.168.1.249:27019/video?replicaSet=mongoRepl&maxPoolSize=200&connectTimeout=30";
MongoClient.connect(dburl, {useUnifiedTopology: true, useNewUrlParser: true}, (err, db) => {
if (err) {
console.log('数据库连接失败!');
return;
}
;
let videoDB = db.db("video");
let pArray = []
for ([key, value] of tree) {
let ps = value.map(e => {
return new Promise(function (resolve, rejcet) {
videoDB.collection(authMenuColl).findOne({"path": e}, (err, result) => {
if (err) {
rejcet('查询失败!' + err)
return
}
;
resolve(result._id)
});
})
})
let p = Promise.all(ps).then(ids => {
return new Promise(function (resolve, rejcet) {
videoDB.collection(authorityColl).updateOne(
{
role: key.role,
},
{
$set: {
...key,
auth: ids,
createdAt: (new Date()),
updatedAt: (new Date()),
}
},
{upsert: true},
(err) => {
if (err) {
rejcet('inset失败!' + err)
return
}
;
resolve()
})
})
})
pArray.push(p)
}
Promise.all(pArray).then(() => {
db.close()
console.log('完成!');
}).catch(err => {
db.close()
console.log(err);
})
})