返回 AiToEarn
userConfig.service.ts
根目录 / project / aitoearn-electron / server / src / user / userConfig.service.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-06-17 19:19:15
4 * @LastEditTime: 2025-03-03 14:05:25
5 * @LastEditors: nevin
6 * @Description:
7 */
8 import { Injectable } from '@nestjs/common';
9 import { InjectModel } from '@nestjs/mongoose';
10 import { Model } from 'mongoose';
11 import { User, UserEarnInfo } from '../db/schema/user.schema';
12 import { RedisService } from 'src/lib/redis/redis.service';
13
14 @Injectable()
15 export class UserConfigService {
16 constructor(
17 private readonly redisService: RedisService,
18
19 @InjectModel(User.name)
20 private readonly userModel: Model<User>,
21 ) { }
22
23 // 更新用户的赚钱配置
24 async setUserEarnInfo(id: string, newData: UserEarnInfo): Promise<User> {
25 const res = await this.userModel.findByIdAndUpdate(id, { $set: { earnInfo: newData } });
26 this.redisService.del(`UserInfo:${id}`);
27 return res;
28 }
29 }
30
30 lines TYPESCRIPT