HJ_Server/src/fix_patch/patch_hdinfo_20231228.ts
2023-12-28 19:49:06 +08:00

83 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {patchFun, patchInit} from "../patch";
class Path {
@patchFun
async fun1(a: any) {
//这里执行脚本的内容加了patchFun的函数不允许重复执行
console.log("这是第1个脚本里内容");
let _hd = G.gc.huodong.find(i => i.hdid == 4000)
if (!_hd) {
console.log('htype4没查到活动')
return
}
await G.mongodb.collection('hdinfo').findOneAndUpdate({hdid: 4000}, {$set: {data: _hd.data}})
console.log('这是第1个脚本执行完成')
return _hd
}
@patchFun
async fun2(a: any) {
//这里执行脚本的内容加了patchFun的函数不允许重复执行
console.log("这是第2个脚本里内容");
let _hd = G.gc.huodong.find(i => i.htype == 2)
if (!_hd) {
console.log('htype2没查到活动')
return
}
await G.mongodb.collection('hdinfo').updateMany({htype: 2}, {$set: {data: _hd.data}})
console.log('这是第2个脚本执行完成')
return _hd
}
@patchFun
async fun3(a: any) {
//这里执行脚本的内容加了patchFun的函数不允许重复执行
console.log("这是第3个脚本里内容");
let _hd = G.gc.huodong.filter(i => i.htype == 5)
if (!_hd.length) {
console.log('htype5没查到活动')
return
}
_hd.map(i => {
// @ts-ignore
G.mongodb.collection('hdinfo').updateOne({hdid: i.hdid}, {$set: {...i}}, {upsert: true})
})
console.log('这是第3个脚本执行完成')
return _hd
}
async run() {
await this.fun1(1);
await this.fun2(2);
await this.fun3(3);
}
}
async function main() {
await patchInit()
let patch = new Path();
await patch.run();
console.log("逻辑执行完成,等待退出");
setTimeout(function() {
console.log('结束程序');
process.exit();
}, 3000);
}
main();