refactor(api): enforce layered architecture by moving db queries to core services

This commit is contained in:
yiling
2026-08-01 16:25:01 +08:00
parent fb66166b49
commit 97069042b2
26 changed files with 256 additions and 363 deletions
+24
View File
@@ -0,0 +1,24 @@
import { prisma } from '@shumai/db'
export class UserService {
constructor(private readonly prismaClient: typeof prisma = prisma) {}
async getUserById(id: string) {
return this.prismaClient.user.findUnique({
where: { id },
})
}
async createGuestUser(data: { name: string; email: string; guestEmail: string }) {
return this.prismaClient.user.create({
data: {
name: data.name,
email: data.email,
guestEmail: data.guestEmail,
type: 'human',
},
})
}
}
export const userService = new UserService()