返回 AiToEarn
workData.ts
1 /*
2 * @Author: nevin
3 * @Date: 2025-01-20 16:24:16
4 * @LastEditTime: 2025-02-12 18:31:21
5 * @LastEditors: nevin
6 * @Description: 视频发布记录 不是数据表实体
7 */
8 import { Column, PrimaryGeneratedColumn } from 'typeorm';
9 import { TempModel } from './temp';
10 import { PlatType } from '../../../commont/AccountEnum';
11 import type {
12 CookiesType,
13 ILocationDataItem,
14 WxSphEvent,
15 } from '../../main/plat/plat.type';
16 import {
17 PubStatus,
18 VisibleTypeEnum,
19 } from '../../../commont/publish/PublishEnum';
20 import { DeclarationDouyin } from '../../../commont/plat/douyin/common.douyin';
21
22 // 包含一个name和一个value的对象
23 export interface ILableValue {
24 label: string;
25 value: string | number;
26 }
27
28 /**
29 * 不同平台的差异化参数
30 * 每个平台有相同点,有不同点,这不同点都在这个参数下集合
31 */
32 export type DiffParmasType = {
33 [PlatType.Xhs]?: {};
34 [PlatType.Douyin]?: {
35 // 申请关联的热点
36 hotPoint?: ILableValue;
37 // 申请关联的活动
38 activitys?: ILableValue[];
39 // 自主声明
40 selfDeclare?: DeclarationDouyin;
41 };
42 [PlatType.WxSph]?: {
43 // 是否为原创
44 isOriginal?: boolean;
45 // 扩展链接
46 extLink?: string;
47 // 活动
48 activity?: WxSphEvent;
49 };
50 [PlatType.KWAI]?: {};
51 };
52
53 export type WorkDataModel = WorkData;
54
55 export class WorkData extends TempModel {
56 // 数据唯一ID
57 @Column({ type: 'varchar', nullable: true, comment: '数据唯一ID' })
58 dataId?: string;
59
60 @PrimaryGeneratedColumn({ type: 'int', comment: 'id' })
61 id?: number;
62
63 @Column({ type: 'varchar', nullable: false, comment: '用户id' })
64 userId!: string;
65
66 // 最后统计时间
67 @Column({ type: 'datetime', nullable: true, comment: '最后统计时间' })
68 lastStatsTime?: Date;
69
70 // 预览地址,这个值是发布完成手动拼接的
71 @Column({ type: 'varchar', nullable: true, comment: '预览地址' })
72 previewVideoLink?: string;
73
74 @Column({
75 type: 'int',
76 nullable: false,
77 comment: '发布记录id,对应PubRecord表id',
78 })
79 pubRecordId!: number;
80
81 @Column({ type: 'int', nullable: false, comment: '账号id,对应account表id' })
82 accountId!: number;
83
84 @Column({
85 type: 'varchar',
86 enum: PlatType,
87 nullable: false,
88 comment: '平台类型',
89 })
90 type!: PlatType;
91
92 // 发布时间
93 @Column({ type: 'datetime', nullable: true, comment: '发布时间' })
94 publishTime?: Date;
95
96 // 其他信息
97 @Column({ type: 'json', nullable: true, comment: '其他信息' })
98 otherInfo?: Record<string, any>;
99
100 // 失败原因
101 @Column({
102 type: 'varchar',
103 nullable: true,
104 comment: '发布失败原因(如果失败)',
105 })
106 failMsg?: string;
107
108 // 状态
109 @Column({
110 type: 'tinyint',
111 nullable: false,
112 comment: '状态 0 未发布/草稿 1 已发布 2=发布失败 3=部分成功 4=审核中',
113 default: PubStatus.UNPUBLISH,
114 })
115 status!: PubStatus;
116
117 // 阅读数量
118 @Column({ type: 'int', nullable: false, comment: '阅读数量', default: 0 })
119 readCount?: number;
120
121 // 点赞数量
122 @Column({ type: 'int', nullable: false, comment: '点赞数量', default: 0 })
123 likeCount?: number;
124
125 // 收藏数量
126 @Column({ type: 'int', nullable: false, comment: '收藏数量', default: 0 })
127 collectCount?: number;
128
129 // 转发数量
130 @Column({ type: 'int', nullable: false, comment: '转发数量', default: 0 })
131 forwardCount?: number;
132
133 // 评论数量
134 @Column({ type: 'int', nullable: false, comment: '评论数量', default: 0 })
135 commentCount?: number;
136
137 // 收益(分)
138 @Column({ type: 'bigint', nullable: false, comment: '收益', default: 0 })
139 income?: number;
140
141 // 以下为发布需要的参数 --------------------------------------------------------------------
142
143 // 标题
144 @Column({ type: 'varchar', nullable: true, comment: '标题' })
145 title?: string;
146
147 // 简介,简介中不该包含话题,如果有需要每个平台再自己做处理。
148 @Column({ type: 'varchar', nullable: true, comment: '简介' })
149 desc?: string;
150
151 // 封面路径,机器的本地路径
152 @Column({ type: 'varchar', nullable: true, comment: '封面路径' })
153 coverPath?: string;
154
155 // 合集
156 @Column({ type: 'json', nullable: true, comment: '合集' })
157 mixInfo?: ILableValue;
158
159 // 话题 格式:['话题1', '话题2'],不该包含 ‘#’
160 @Column({ type: 'json', nullable: true, comment: '话题', default: '[]' })
161 topics!: string[];
162
163 // 位置
164 @Column({ type: 'json', nullable: true, comment: '位置' })
165 location?: ILocationDataItem;
166
167 /**
168 * 差异化参数
169 * 所有平台有通用参数,如:标题、话题、简介
170 * 也有每个平台自己独有的参数,如:抖音活动奖励、抖音热点、视频号声明原创
171 */
172 @Column({
173 type: 'json',
174 nullable: true,
175 comment: '不同平台的差异化参数',
176 default: '{}',
177 })
178 diffParams?: DiffParmasType;
179
180 // 可见性,作品的查看权限
181 @Column({
182 type: 'tinyint',
183 nullable: false,
184 comment: '可见性',
185 default: VisibleTypeEnum.Public,
186 })
187 visibleType?: VisibleTypeEnum;
188
189 // 定时发布日期
190 @Column({ type: 'datetime', nullable: true, comment: '定时发布日期' })
191 timingTime?: Date;
192
193 // @用户
194 @Column({ type: 'json', nullable: true, comment: '@用户数组', default: '[]' })
195 mentionedUserInfo!: ILableValue[];
196
197 // 以下参数通过外部赋值,不存储在数据库中
198 cookies?: CookiesType;
199 // 这个参数从 account 中赋值,这是从创作者中心的localStorage中获取的参数
200 token?: string;
201 proxyIp?: string;
202 }
203
203 lines TYPESCRIPT