Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 获取一键互动的记录列表
牛文政d80fe07c05fc
diff --git a/electron/main/interaction/controller.ts b/electron/main/interaction/controller.tsindex 1990d774..5c6067c8 100644--- a/electron/main/interaction/controller.ts+++ b/electron/main/interaction/controller.ts@@ -15,6 +15,9 @@ import { SendChannelEnum } from '../../../commont/UtilsEnum';import type { WorkData } from '../plat/plat.type';import { AutorWorksInteractionScheduleEvent } from '../../../commont/types/interaction';import { AutoInteractionCache } from './cacheData';+import { getUserInfo } from '../user/comment';+import type { CorrectQuery } from '../../global/table';+import { AccountType } from '../../../commont/AccountEnum';@Controller()export class InteractionController {@@ -138,6 +141,27 @@ export class InteractionController {return res.status === 1;}+ /**+ * 获取一键互动的记录列表+ */+ @Icp('ICP_GET_INTERACTION_RECORD_LIST')+ async getInteractionRecordList(+ event: Electron.IpcMainInvokeEvent,+ page: CorrectQuery,+ query: {+ accountId?: number;+ type?: AccountType;+ },+ ): Promise<any> {+ const userInfo = getUserInfo();++ return this.interactionService.getInteractionRecordList(+ userInfo.id,+ page,+ query,+ );+ }+/*** 获取一键互动的任务信息*/diff --git a/electron/main/interaction/service.ts b/electron/main/interaction/service.tsindex e2b2d693..d91dd66c 100644--- a/electron/main/interaction/service.ts+++ b/electron/main/interaction/service.ts@@ -12,7 +12,7 @@ import { toolsApi } from '../api/tools';import { AutoRunService } from '../autoRun/service';import { AutoRunModel } from '../../db/models/autoRun';import { sysNotice } from '../../global/notice';-import { Repository } from 'typeorm';+import { FindOptionsWhere, Repository } from 'typeorm';import { AppDataSource } from '../../db';import { getUserInfo } from '../user/comment';import { AutoRunRecordStatus } from '../../db/models/autoRunRecord';@@ -21,6 +21,8 @@ import { InteractionRecordModel } from '../../db/models/interactionRecord';import { AutorWorksInteractionScheduleEvent } from '../../../commont/types/interaction';import { WorkData } from '../plat/plat.type';import { AutoInteractionCache } from './cacheData';+import { backPageData, CorrectQuery } from '../../global/table';+import { AccountType } from '../../../commont/AccountEnum';@Injectable()export class InteractionService {@@ -79,11 +81,34 @@ export class InteractionService {});}+ // 获取互动记录列表+ async getInteractionRecordList(+ userId: string,+ page: CorrectQuery,+ query: {+ accountId?: number;+ type?: AccountType;+ },+ ) {+ const filter: FindOptionsWhere<InteractionRecordModel> = {+ userId,+ ...(query.accountId && { accountId: query.accountId }),+ ...(query.type && { type: query.type }),+ };++ const [list, totalCount] =+ await this.interactionRecordRepository.findAndCount({+ where: filter,+ });++ return backPageData(list, totalCount, page);+ }+/*** 自动一键互动:作品评论,收藏,点赞* 规则:评论作品,已经评论不评论*/- async autorInteraction(+ async autorInteraction(account: AccountModel,worksList: WorkData[],option: {@@ -174,12 +199,12 @@ export class InteractionService {let isLike: 0 | 1 = 0;try {console.log('------ 开始点赞作品:', works.dataId);- const isLikeRes = await platController.dianzanDyOther(+ const isLikeRes = await platController.dianzanDyOther(account,works.dataId,{authid: works.author?.id,- }+ },);isLike = isLikeRes ? 1 : 0;console.log('------ 点赞结果:', isLikeRes);@@ -192,7 +217,7 @@ export class InteractionService {isLike,},});- }+ }// ----- 3-收藏作品 -----let isCollect: 0 | 1 = 0;@@ -211,7 +236,7 @@ export class InteractionService {isLike,},});- }+ }// 创建互动记录this.createInteractionRecord(@@ -224,7 +249,7 @@ export class InteractionService {},option.commentContent,isLike,- 0, // 收藏状态设为0+ isCollect, // 收藏状态设为0);console.log('------ 作品处理完成:', works.dataId);}diff --git a/src/icp/replyother.ts b/src/icp/replyother.tsindex 2bd3c2a2..4f1af0e7 100644--- a/src/icp/replyother.ts+++ b/src/icp/replyother.ts@@ -3,8 +3,9 @@* @Date: 2025-01-23 15:48:14* @LastEditTime: 2025-03-20 22:39:03* @LastEditors: nevin- * @Description:+ * @Description: 评论他人*/+import { AccountType } from '@@/AccountEnum';export type WorkData = {dataId: string;readCount?: number;@@ -246,3 +247,27 @@ export async function ipcGetAutoRunOfInteractionInfo() {);return res;}++/**+ * 获取一键互动的记录列表+ * @param accountId+ * @param dataId+ * @param cycleType+ */+export async function ipcGetInteractionRecordList(+ page: {+ page_size: number;+ page_no: number;+ },+ query: {+ accountId?: number;+ type?: AccountType;+ },+) {+ const res: string = await window.ipcRenderer.invoke(+ 'ICP_GET_INTERACTION_RECORD_LIST',+ page,+ query,+ );+ return res;+}