feat: 支持登录、个人信息存储
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { UserLevelProgress } from '../entities/user-level-progress.entity';
|
||||
import { IUserLevelProgressRepository } from './user-level-progress.repository.interface';
|
||||
|
||||
@Injectable()
|
||||
export class UserLevelProgressRepository
|
||||
implements IUserLevelProgressRepository
|
||||
{
|
||||
constructor(
|
||||
@InjectRepository(UserLevelProgress)
|
||||
private readonly repository: Repository<UserLevelProgress>,
|
||||
) {}
|
||||
|
||||
async findByUserId(userId: string): Promise<UserLevelProgress[]> {
|
||||
return this.repository.find({ where: { userId } });
|
||||
}
|
||||
|
||||
async findByUserAndLevel(
|
||||
userId: string,
|
||||
levelId: string,
|
||||
): Promise<UserLevelProgress | null> {
|
||||
return this.repository.findOne({ where: { userId, levelId } });
|
||||
}
|
||||
|
||||
create(data: Partial<UserLevelProgress>): UserLevelProgress {
|
||||
return this.repository.create(data);
|
||||
}
|
||||
|
||||
async save(progress: UserLevelProgress): Promise<UserLevelProgress> {
|
||||
return this.repository.save(progress);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user