feat(server): add model base (#9734)

This commit is contained in:
forehalo
2025-01-17 02:03:53 +00:00
parent c2149f218b
commit 64335b9e0c
12 changed files with 105 additions and 65 deletions
+8 -9
View File
@@ -1,9 +1,8 @@
import { Injectable, Logger } from '@nestjs/common';
import { Prisma, PrismaClient, type User, Workspace } from '@prisma/client';
import { Injectable } from '@nestjs/common';
import { Prisma, type User, Workspace } from '@prisma/client';
import { pick } from 'lodash-es';
import {
Config,
CryptoHelper,
EmailAlreadyUsed,
EventEmitter,
@@ -15,6 +14,7 @@ import {
import type { Payload } from '../base/event/def';
import { Permission } from '../core/permission';
import { Quota_FreePlanV1_1 } from '../core/quota/schema';
import { BaseModel } from './base';
const publicUserSelect = {
id: true,
@@ -64,14 +64,13 @@ export type PublicUser = Pick<User, keyof typeof publicUserSelect>;
export type { User };
@Injectable()
export class UserModel {
private readonly logger = new Logger(UserModel.name);
export class UserModel extends BaseModel {
constructor(
private readonly db: PrismaClient,
private readonly crypto: CryptoHelper,
private readonly event: EventEmitter,
private readonly config: Config
) {}
private readonly event: EventEmitter
) {
super();
}
async get(id: string) {
return this.db.user.findUnique({