加入userSession Service
This commit is contained in:
21
tone-page-server/src/user/services/user-session.service.ts
Normal file
21
tone-page-server/src/user/services/user-session.service.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { InjectRepository } from "@nestjs/typeorm";
|
||||||
|
import { Injectable } from "@nestjs/common";
|
||||||
|
import { UserSession } from "../entities/user-session.entity";
|
||||||
|
import { Repository } from "typeorm";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UserSessionService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(UserSession)
|
||||||
|
private readonly userSessionRepository: Repository<UserSession>,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
|
||||||
|
async createSession(userId: string, sessionId: string): Promise<UserSession> {
|
||||||
|
const session = this.userSessionRepository.create({
|
||||||
|
userId,
|
||||||
|
sessionId,
|
||||||
|
});
|
||||||
|
return await this.userSessionRepository.save(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user