Skip to content

Let's use AI to Earn!

refactor(account): account add token (#311)

nevin8cfa3f079da7
diff --git a/project/backend/apps/aitoearn-server/src/account/account.service.ts b/project/backend/apps/aitoearn-server/src/account/account.service.ts
index 380926a1..7b6368bf 100644
--- a/project/backend/apps/aitoearn-server/src/account/account.service.ts
+++ b/project/backend/apps/aitoearn-server/src/account/account.service.ts
@@ -63,7 +63,6 @@ export class AccountService {
}
async addAccount(userId: string, data: CreateAccountDto): Promise<Account | null> {
- this.logger.log(`Adding new account with data: ${JSON.stringify(data)}`)
let group = null
if (!data.groupId) {
group = await this.accountGroupService.getDefaultGroup(
diff --git a/project/backend/apps/aitoearn-server/src/account/dto/account.dto.ts b/project/backend/apps/aitoearn-server/src/account/dto/account.dto.ts
index 0ff8fedc..ae753987 100644
--- a/project/backend/apps/aitoearn-server/src/account/dto/account.dto.ts
+++ b/project/backend/apps/aitoearn-server/src/account/dto/account.dto.ts
@@ -10,6 +10,7 @@ const CreateAccountSchema = z.object({
loginTime: z.coerce.date().optional(),
uid: z.string().min(1),
account: z.string().min(1),
+ token: z.string().optional(),
avatar: z.string().optional(),
nickname: z.string().min(1),
fansCount: z.number().optional(),
@@ -22,7 +23,6 @@ const CreateAccountSchema = z.object({
workCount: z.number().optional(),
income: z.number().optional(),
groupId: z.string().optional(),
- _id: z.string().optional(),
})
export class CreateAccountDto extends createZodDto(
CreateAccountSchema,
@@ -30,9 +30,25 @@ export class CreateAccountDto extends createZodDto(
const UpdateAccountSchema = z.object({
id: z.string({ message: 'ID' }),
- name: z.string({ message: '昵称' }).optional(),
- avatar: z.string({ message: '头像' }).optional(),
- desc: z.string({ message: '简介' }).optional(),
+ refresh_token: z.string().min(1).optional(),
+ access_token: z.string().min(1).optional(),
+ type: z.enum(AccountType).optional(),
+ loginCookie: z.string().min(1).optional(),
+ loginTime: z.coerce.date().optional(),
+ uid: z.string().min(1).optional(),
+ account: z.string().min(1).optional(),
+ token: z.string().optional(),
+ avatar: z.string().optional(),
+ nickname: z.string().min(1).optional(),
+ fansCount: z.number().optional(),
+ readCount: z.number().optional(),
+ likeCount: z.number().optional(),
+ collectCount: z.number().optional(),
+ forwardCount: z.number().optional(),
+ commentCount: z.number().optional(),
+ lastStatsTime: z.coerce.date().optional(),
+ workCount: z.number().optional(),
+ income: z.number().optional(),
groupId: z.string().optional(),
})
export class UpdateAccountDto extends createZodDto(
diff --git a/project/backend/libs/mongodb/src/schemas/account.schema.ts b/project/backend/libs/mongodb/src/schemas/account.schema.ts
index efa56482..f4910377 100644
--- a/project/backend/libs/mongodb/src/schemas/account.schema.ts
+++ b/project/backend/libs/mongodb/src/schemas/account.schema.ts
@@ -5,8 +5,8 @@ import { Schema as MongooseSchema } from 'mongoose'
import { WithTimestampSchema } from './timestamp.schema'
export enum AccountStatus {
- NORMAL = 1, // 可用
- ABNORMAL = 0, // 不可用
+ NORMAL = 1,
+ ABNORMAL = 0,
}
@Schema({
@@ -36,13 +36,13 @@ export class Account extends WithTimestampSchema {
type: AccountType
@Prop({
- required: true, // 平台账户的唯一ID˝
+ required: true,
index: true,
})
uid: string
@Prop({
- required: false, // 部分平台的补充ID
+ required: false,
index: true,
})
account: string
@@ -70,7 +70,7 @@ export class Account extends WithTimestampSchema {
type: String,
default: '',
})
- token: string // 其他token 目前抖音用
+ token: string
@Prop({
required: false,
@@ -143,7 +143,6 @@ export class Account extends WithTimestampSchema {
})
income: number
- // 账户关联组,与 accountGroup.id 关联
@Prop({ type: String, required: true })
groupId: string
@@ -152,12 +151,11 @@ export class Account extends WithTimestampSchema {
default: AccountStatus.NORMAL,
index: true,
})
- status: AccountStatus // 登录状态,用于判断是否失效
+ status: AccountStatus
@Prop({ type: String, required: false })
channelId: string
- // 排序
@Prop({
required: true,
type: Number,