feat: 设计菜单权限和员工端登录

This commit is contained in:
湛兮
2026-05-26 12:30:38 +08:00
parent 55b99b5307
commit aa65cb0928
17 changed files with 708 additions and 64 deletions
+27 -1
View File
@@ -8,7 +8,33 @@ import { authService } from "./auth.service";
export async function authRoutes(app: FastifyInstance): Promise<void> {
app.post("/auth/login", async (request) => {
const body = loginBodySchema.parse(request.body);
const { user, payload } = await authService.login(body);
const { user, payload } = await authService.loginManagement(body);
const token = app.jwt.sign(payload);
return ok({
token,
tokenType: "Bearer",
expiresIn: env.JWT_EXPIRES_IN,
user,
});
});
app.post("/auth/admin/login", async (request) => {
const body = loginBodySchema.parse(request.body);
const { user, payload } = await authService.loginManagement(body);
const token = app.jwt.sign(payload);
return ok({
token,
tokenType: "Bearer",
expiresIn: env.JWT_EXPIRES_IN,
user,
});
});
app.post("/auth/employee/login", async (request) => {
const body = loginBodySchema.parse(request.body);
const { user, payload } = await authService.loginEmployee(body);
const token = app.jwt.sign(payload);
return ok({