| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-02-07 09:48:29 |
| 4 | * @LastEditTime: 2025-03-24 15:14:58 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 平台主类 |
| 7 | */ |
| 8 | import { |
| 9 | AccountInfoTypeRV, |
| 10 | CommentData, |
| 11 | CookiesType, |
| 12 | DashboardData, |
| 13 | IAccountInfoParams, |
| 14 | IGetLocationDataParams, |
| 15 | IGetLocationResponse, |
| 16 | IGetMixListResponse, |
| 17 | IGetTopicsParams, |
| 18 | IGetTopicsResponse, |
| 19 | IGetUsersParams, |
| 20 | IGetUsersResponse, |
| 21 | ResponsePageInfo, |
| 22 | StatisticsData, |
| 23 | VideoCallbackType, |
| 24 | WorkData, |
| 25 | } from './plat.type'; |
| 26 | import { PublishVideoResult } from './module'; |
| 27 | import { PlatType } from '../../../commont/AccountEnum'; |
| 28 | import { AccountModel } from '../../db/models/account'; |
| 29 | import { VideoModel } from '../../db/models/video'; |
| 30 | import { ImgTextModel } from '../../db/models/imgText'; |
| 31 | |
| 32 | /** |
| 33 | * 平台基类,所有平台都该继承这个类 |
| 34 | */ |
| 35 | export abstract class PlatformBase { |
| 36 | // 平台类型 |
| 37 | protected readonly type: PlatType; |
| 38 | |
| 39 | constructor(type: PlatType) { |
| 40 | this.type = type; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * 平台登录 |
| 45 | * @param params |
| 46 | */ |
| 47 | abstract login(params?: any): Promise<AccountInfoTypeRV>; |
| 48 | |
| 49 | /** |
| 50 | * 登录状态检测 |
| 51 | * @param account |
| 52 | */ |
| 53 | abstract loginCheck(account: AccountModel): Promise<{ |
| 54 | // true=在线,false=离线 |
| 55 | online: boolean; |
| 56 | // 要额外更新的账户数据 |
| 57 | account?: Partial<AccountModel>; |
| 58 | }>; |
| 59 | |
| 60 | /** |
| 61 | * 获取该平台的用户信息 |
| 62 | * @param params |
| 63 | */ |
| 64 | abstract getAccountInfo( |
| 65 | params: IAccountInfoParams, |
| 66 | ): Promise<AccountInfoTypeRV>; |
| 67 | |
| 68 | /** |
| 69 | * 获取统计数据 |
| 70 | * @param account 账号 |
| 71 | */ |
| 72 | abstract getStatistics(account: AccountModel): Promise<StatisticsData>; |
| 73 | |
| 74 | /** |
| 75 | * 获取账户的看板数据 |
| 76 | * @param account 账号 |
| 77 | * @param time |
| 78 | */ |
| 79 | abstract getDashboard( |
| 80 | account: AccountModel, |
| 81 | time: string[], |
| 82 | ): Promise<DashboardData[]>; |
| 83 | |
| 84 | /** |
| 85 | * 点赞 |
| 86 | * @param account 账户 |
| 87 | * @param dataId 数据ID |
| 88 | * @param option 配置项 |
| 89 | */ |
| 90 | abstract dianzanDyOther( |
| 91 | account: AccountModel, |
| 92 | dataId: string, |
| 93 | option?: any, |
| 94 | ): Promise<any>; |
| 95 | |
| 96 | /** |
| 97 | * 收藏 |
| 98 | * @param account 账户 |
| 99 | * @param pcursor 分页游标 |
| 100 | */ |
| 101 | abstract shoucangDyOther( |
| 102 | account: AccountModel, |
| 103 | pcursor?: string, |
| 104 | ): Promise<any>; |
| 105 | |
| 106 | /** |
| 107 | * 获取作品列表 |
| 108 | * @param account 账户 |
| 109 | * @param pcursor 分页游标 |
| 110 | */ |
| 111 | abstract getWorkList( |
| 112 | account: AccountModel, |
| 113 | pcursor?: string, |
| 114 | ): Promise<{ |
| 115 | list: WorkData[]; |
| 116 | pageInfo: ResponsePageInfo; |
| 117 | }>; |
| 118 | |
| 119 | /** |
| 120 | * 搜索作品 |
| 121 | * @param account 账户 |
| 122 | * @param qe 搜索关键词 |
| 123 | * @param pageInfo 分页信息 |
| 124 | */ |
| 125 | abstract getsearchNodeList( |
| 126 | account: AccountModel, |
| 127 | qe?: string, |
| 128 | pageInfo?: any, |
| 129 | ): Promise<{ |
| 130 | list: WorkData[]; |
| 131 | pageInfo: ResponsePageInfo; |
| 132 | }>; |
| 133 | |
| 134 | /** |
| 135 | * 获取某个作品的数据 |
| 136 | * @param dataId 作品的唯一标识 |
| 137 | */ |
| 138 | abstract getWorkData(dataId: string): Promise<WorkData>; |
| 139 | |
| 140 | /** |
| 141 | * 获取评论列表 |
| 142 | * @param account |
| 143 | * @param dataId |
| 144 | * @param pcursor |
| 145 | */ |
| 146 | abstract getCommentList( |
| 147 | account: AccountModel, |
| 148 | workData: WorkData, |
| 149 | pcursor?: string, |
| 150 | ): Promise<{ |
| 151 | list: CommentData[]; |
| 152 | pageInfo: ResponsePageInfo; |
| 153 | }>; |
| 154 | |
| 155 | /** |
| 156 | * 获取他人作品的二级评论列表 |
| 157 | * @param account |
| 158 | * @param dataId |
| 159 | * @param pcursor |
| 160 | */ |
| 161 | abstract getCreatorSecondCommentListByOther( |
| 162 | account: AccountModel, |
| 163 | workData: WorkData, |
| 164 | root_comment_id: string, |
| 165 | pcursor?: string, |
| 166 | ): Promise<any>; |
| 167 | |
| 168 | /** |
| 169 | * 获取评论列表 |
| 170 | * @param account |
| 171 | * @param dataId |
| 172 | * @param pcursor |
| 173 | */ |
| 174 | abstract getCreatorCommentListByOther( |
| 175 | account: AccountModel, |
| 176 | workData: WorkData, |
| 177 | pcursor?: string, |
| 178 | ): Promise<{ |
| 179 | list: CommentData[]; |
| 180 | orgList?: any; |
| 181 | pageInfo: ResponsePageInfo; |
| 182 | }>; |
| 183 | |
| 184 | /** |
| 185 | * 创建评论 |
| 186 | */ |
| 187 | abstract createComment( |
| 188 | account: AccountModel, |
| 189 | dataId: string, // 作品ID |
| 190 | content: string, |
| 191 | ): Promise<boolean>; |
| 192 | |
| 193 | /** |
| 194 | * 创建评论 |
| 195 | */ |
| 196 | abstract createCommentByOther( |
| 197 | account: AccountModel, |
| 198 | dataId: string, // 作品ID |
| 199 | content: string, |
| 200 | authorId?: string, |
| 201 | ): Promise<any>; |
| 202 | |
| 203 | /** |
| 204 | * 回复评论 |
| 205 | */ |
| 206 | abstract replyCommentByOther( |
| 207 | account: AccountModel, |
| 208 | commentId: string, |
| 209 | content: string, |
| 210 | option: { |
| 211 | dataId?: string; // 作品ID |
| 212 | comment: any; // 辅助数据,原数据 |
| 213 | videoAuthId?: string; // 视频作者ID |
| 214 | }, |
| 215 | ): Promise<any>; |
| 216 | |
| 217 | /** |
| 218 | * 回复评论 |
| 219 | */ |
| 220 | abstract replyComment( |
| 221 | account: AccountModel, |
| 222 | commentId: string, |
| 223 | content: string, |
| 224 | option: { |
| 225 | dataId?: string; // 作品ID |
| 226 | comment: any; // 辅助数据,原数据 |
| 227 | }, |
| 228 | ): Promise<boolean>; |
| 229 | |
| 230 | /** |
| 231 | * 视频发布 |
| 232 | */ |
| 233 | abstract videoPublish( |
| 234 | params: VideoModel, |
| 235 | // 获取发布进度的回调函数 |
| 236 | callback: VideoCallbackType, |
| 237 | ): Promise<PublishVideoResult>; |
| 238 | |
| 239 | /** |
| 240 | * 图文发布,有些平台不支持图文发布 |
| 241 | */ |
| 242 | imgTextPublish(params: ImgTextModel): Promise<PublishVideoResult> { |
| 243 | throw `平台${this.type}不支持图文发布`; |
| 244 | } |
| 245 | |
| 246 | // 获取合集 |
| 247 | getMixList(cookie: CookiesType): Promise<IGetMixListResponse> { |
| 248 | throw `平台${this.type}不支持获取合集`; |
| 249 | } |
| 250 | |
| 251 | // 话题数据获取 |
| 252 | abstract getTopics(params: IGetTopicsParams): Promise<IGetTopicsResponse>; |
| 253 | |
| 254 | // 获取位置数据 |
| 255 | abstract getLocationData( |
| 256 | params: IGetLocationDataParams, |
| 257 | ): Promise<IGetLocationResponse>; |
| 258 | |
| 259 | // 获取@用户数据 |
| 260 | abstract getUsers(params: IGetUsersParams): Promise<IGetUsersResponse>; |
| 261 | } |
| 262 |