|
|
@@ -7,6 +7,7 @@ import { UserService } from '@/server/modules/users/user.service';
|
|
|
import { AuthService } from '@/server/modules/auth/auth.service';
|
|
|
import { UserSchema } from '@/server/modules/users/user.schema'
|
|
|
import { parseWithAwait } from '@/server/utils/parseWithAwait';
|
|
|
+import { FileService } from '@/server/modules/files/file.service';
|
|
|
|
|
|
const WechatLoginSchema = z.object({
|
|
|
code: z.string().min(1).openapi({
|
|
|
@@ -23,10 +24,6 @@ const TokenResponseSchema = z.object({
|
|
|
user: UserSchema.omit({ password: true })
|
|
|
})
|
|
|
|
|
|
-const userService = new UserService(AppDataSource);
|
|
|
-const authService = new AuthService(userService);
|
|
|
-const wechatAuthService = new WechatAuthService(userService, authService);
|
|
|
-
|
|
|
const wechatLoginRoute = createRoute({
|
|
|
method: 'post',
|
|
|
path: '/login',
|
|
|
@@ -70,6 +67,12 @@ const wechatLoginRoute = createRoute({
|
|
|
const app = new OpenAPIHono().openapi(wechatLoginRoute, async (c) => {
|
|
|
try {
|
|
|
const { code } = await c.req.json();
|
|
|
+
|
|
|
+ const userService = new UserService(AppDataSource);
|
|
|
+ const authService = new AuthService(userService);
|
|
|
+ const fileService = new FileService(AppDataSource)
|
|
|
+
|
|
|
+ const wechatAuthService = new WechatAuthService(userService, authService, fileService);
|
|
|
const result = await wechatAuthService.wechatLogin(code);
|
|
|
|
|
|
// 使用 parseWithAwait 确保返回数据符合Schema定义
|