返回 AiToEarn
autoRun.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-01-20 16:24:16
4 * @LastEditTime: 2025-03-19 19:31:29
5 * @LastEditors: nevin
6 * @Description: 自动任务 autoRun
7 */
8 import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
9 import { TempModel } from './temp';
10
11 // 状态 进行中 暂停 删除
12 export enum AutoRunStatus {
13 DOING = 2, // 进行中
14 PAUSE = 3, // 暂停
15 DELETE = 4, // 删除
16 }
17
18 export enum AutoRunType {
19 ReplyComment = 1, // 回复评论
20 }
21
22 @Entity({ name: 'autoRun' })
23 export class AutoRunModel extends TempModel {
24 @PrimaryGeneratedColumn({ type: 'int', comment: 'id' })
25 id!: number;
26
27 @Column({ type: 'varchar', nullable: false, comment: '用户id' })
28 userId!: string;
29
30 @Column({ type: 'int', nullable: false, comment: '账号id,对应account表id' })
31 accountId!: number;
32
33 @Column({
34 type: 'text',
35 nullable: false,
36 comment: '对应数据的数据内容 JSON字符串',
37 })
38 data!: string;
39 dataInfo?: Record<string, any>; // 解析后的数据
40
41 @Column({ type: 'int', nullable: false, comment: '执行次数', default: 0 })
42 runCount!: number;
43
44 @Column({
45 type: 'tinyint',
46 nullable: false,
47 comment: '自动程序状态',
48 default: AutoRunStatus.DOING,
49 })
50 status!: AutoRunStatus;
51
52 @Column({
53 type: 'tinyint',
54 nullable: false,
55 comment: '类型',
56 })
57 type!: AutoRunType;
58
59 @Column({
60 type: 'varchar',
61 nullable: false,
62 comment:
63 '周期类型 天 day-22 (例:每天22时) 周 week-2 (例:每周周二,周日0) 月 month-22 (例:每月22号)',
64 })
65 cycleType!: string;
66 }
67
67 lines TYPESCRIPT