Compare commits
5 Commits
34ce5c01aa
...
17aa676fa9
Author | SHA1 | Date | |
---|---|---|---|
![]() |
17aa676fa9 | ||
![]() |
37f2472f5d | ||
![]() |
bf4f22d092 | ||
![]() |
96729c719a | ||
![]() |
075c60a9f8 |
79
src/fix_patch/patch_hdinfo.ts
Normal file
79
src/fix_patch/patch_hdinfo.ts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
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 12
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 12
|
||||||
|
}
|
||||||
|
|
||||||
|
@patchFun
|
||||||
|
async fun3(a: any) {
|
||||||
|
//这里执行脚本的内容,加了patchFun的函数,不允许重复执行
|
||||||
|
console.log("这是第3个脚本里内容");
|
||||||
|
|
||||||
|
let _hd = G.gc.huodong.find(i => i.htype == 5)
|
||||||
|
|
||||||
|
if (!_hd) {
|
||||||
|
console.log('htype5没查到活动')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await G.mongodb.collection('hdinfo').updateMany({htype: 5}, {$set: {data: _hd.data}})
|
||||||
|
|
||||||
|
console.log('这是第3个脚本执行完成')
|
||||||
|
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
setInterval(() => {
|
||||||
|
console.log(new Date().format("MM-dd hh:mm:ss"));
|
||||||
|
}, 1000);
|
||||||
|
console.log("逻辑执行完成,等待退出");
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
@ -15,7 +15,7 @@ export function patchFun(target: any, key: string, descriptor: PropertyDescripto
|
|||||||
throw new Error();
|
throw new Error();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let caller = (e.stack.split("\n").slice(2)[0].split("\\").slice(-2));
|
let caller = (e.stack.split("\n").slice(2)[0].split("\\").slice(-2));
|
||||||
scriptName = caller[1].split(':')[0];
|
scriptName = caller[0].split('(')[1].split(':')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!scriptName){
|
if(!scriptName){
|
||||||
|
Loading…
Reference in New Issue
Block a user