|
@@ -161,18 +161,18 @@ const getSalaryVideosRoute = createRoute({
|
|
|
const app = new OpenAPIHono<TalentAuthContext>()
|
|
const app = new OpenAPIHono<TalentAuthContext>()
|
|
|
// 获取当前就业状态
|
|
// 获取当前就业状态
|
|
|
.openapi(getEmploymentStatusRoute, async (c) => {
|
|
.openapi(getEmploymentStatusRoute, async (c) => {
|
|
|
- const user = c.get('user') as TalentUser;
|
|
|
|
|
- const personId = user.personId;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const user = c.get('user') as TalentUser;
|
|
|
|
|
+ const personId = user.personId;
|
|
|
|
|
|
|
|
- // 验证person_id是否存在
|
|
|
|
|
- if (!personId) {
|
|
|
|
|
- return c.json({
|
|
|
|
|
- code: 404,
|
|
|
|
|
- message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
- } as any, 404);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 验证person_id是否存在
|
|
|
|
|
+ if (!personId) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 404,
|
|
|
|
|
+ message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
+ }, 404);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
const orderService = new OrderService(AppDataSource);
|
|
const orderService = new OrderService(AppDataSource);
|
|
|
const employmentStatus = await orderService.getCurrentEmploymentStatus(personId);
|
|
const employmentStatus = await orderService.getCurrentEmploymentStatus(personId);
|
|
|
|
|
|
|
@@ -180,31 +180,39 @@ const app = new OpenAPIHono<TalentAuthContext>()
|
|
|
return c.json({
|
|
return c.json({
|
|
|
code: 404,
|
|
code: 404,
|
|
|
message: '未找到就业记录'
|
|
message: '未找到就业记录'
|
|
|
- } as any, 404);
|
|
|
|
|
|
|
+ }, 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const validatedResult = await parseWithAwait(EmploymentStatusResponseSchema, employmentStatus);
|
|
const validatedResult = await parseWithAwait(EmploymentStatusResponseSchema, employmentStatus);
|
|
|
return c.json(validatedResult, 200);
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
|
+ if (error instanceof z.ZodError) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ message: '参数错误',
|
|
|
|
|
+ errors: error.issues
|
|
|
|
|
+ }, 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return c.json({
|
|
return c.json({
|
|
|
code: 500,
|
|
code: 500,
|
|
|
message: error instanceof Error ? error.message : '获取当前就业状态失败'
|
|
message: error instanceof Error ? error.message : '获取当前就业状态失败'
|
|
|
- } as any, 500);
|
|
|
|
|
|
|
+ }, 500);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
// 获取薪资记录
|
|
// 获取薪资记录
|
|
|
.openapi(getSalaryRecordsRoute, async (c) => {
|
|
.openapi(getSalaryRecordsRoute, async (c) => {
|
|
|
- const user = c.get('user') as TalentUser;
|
|
|
|
|
- const personId = user.personId;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const user = c.get('user') as TalentUser;
|
|
|
|
|
+ const personId = user.personId;
|
|
|
|
|
|
|
|
- if (!personId) {
|
|
|
|
|
- return c.json({
|
|
|
|
|
- code: 404,
|
|
|
|
|
- message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
- } as any, 404);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!personId) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 404,
|
|
|
|
|
+ message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
+ }, 404);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
const query = c.req.valid('query');
|
|
const query = c.req.valid('query');
|
|
|
const orderService = new OrderService(AppDataSource);
|
|
const orderService = new OrderService(AppDataSource);
|
|
|
const salaryRecords = await orderService.getSalaryRecords(
|
|
const salaryRecords = await orderService.getSalaryRecords(
|
|
@@ -217,25 +225,33 @@ const app = new OpenAPIHono<TalentAuthContext>()
|
|
|
const validatedResult = await parseWithAwait(SalaryRecordsResponseSchema, salaryRecords);
|
|
const validatedResult = await parseWithAwait(SalaryRecordsResponseSchema, salaryRecords);
|
|
|
return c.json(validatedResult, 200);
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
|
+ if (error instanceof z.ZodError) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ message: '参数错误',
|
|
|
|
|
+ errors: error.issues
|
|
|
|
|
+ }, 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return c.json({
|
|
return c.json({
|
|
|
code: 500,
|
|
code: 500,
|
|
|
message: error instanceof Error ? error.message : '获取薪资记录失败'
|
|
message: error instanceof Error ? error.message : '获取薪资记录失败'
|
|
|
- } as any, 500);
|
|
|
|
|
|
|
+ }, 500);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
// 获取就业历史
|
|
// 获取就业历史
|
|
|
.openapi(getEmploymentHistoryRoute, async (c) => {
|
|
.openapi(getEmploymentHistoryRoute, async (c) => {
|
|
|
- const user = c.get('user') as TalentUser;
|
|
|
|
|
- const personId = user.personId;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const user = c.get('user') as TalentUser;
|
|
|
|
|
+ const personId = user.personId;
|
|
|
|
|
|
|
|
- if (!personId) {
|
|
|
|
|
- return c.json({
|
|
|
|
|
- code: 404,
|
|
|
|
|
- message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
- } as any, 404);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!personId) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 404,
|
|
|
|
|
+ message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
+ }, 404);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
const query = c.req.valid('query');
|
|
const query = c.req.valid('query');
|
|
|
const orderService = new OrderService(AppDataSource);
|
|
const orderService = new OrderService(AppDataSource);
|
|
|
const employmentHistory = await orderService.getEmploymentHistory(
|
|
const employmentHistory = await orderService.getEmploymentHistory(
|
|
@@ -247,25 +263,33 @@ const app = new OpenAPIHono<TalentAuthContext>()
|
|
|
const validatedResult = await parseWithAwait(EmploymentHistoryResponseSchema, employmentHistory);
|
|
const validatedResult = await parseWithAwait(EmploymentHistoryResponseSchema, employmentHistory);
|
|
|
return c.json(validatedResult, 200);
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
|
+ if (error instanceof z.ZodError) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ message: '参数错误',
|
|
|
|
|
+ errors: error.issues
|
|
|
|
|
+ }, 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return c.json({
|
|
return c.json({
|
|
|
code: 500,
|
|
code: 500,
|
|
|
message: error instanceof Error ? error.message : '获取就业历史失败'
|
|
message: error instanceof Error ? error.message : '获取就业历史失败'
|
|
|
- } as any, 500);
|
|
|
|
|
|
|
+ }, 500);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
// 获取薪资视频
|
|
// 获取薪资视频
|
|
|
.openapi(getSalaryVideosRoute, async (c) => {
|
|
.openapi(getSalaryVideosRoute, async (c) => {
|
|
|
- const user = c.get('user') as TalentUser;
|
|
|
|
|
- const personId = user.personId;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const user = c.get('user') as TalentUser;
|
|
|
|
|
+ const personId = user.personId;
|
|
|
|
|
|
|
|
- if (!personId) {
|
|
|
|
|
- return c.json({
|
|
|
|
|
- code: 404,
|
|
|
|
|
- message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
- } as any, 404);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (!personId) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 404,
|
|
|
|
|
+ message: '用户不存在或未关联残疾人信息'
|
|
|
|
|
+ }, 404);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
const query = c.req.valid('query');
|
|
const query = c.req.valid('query');
|
|
|
const orderService = new OrderService(AppDataSource);
|
|
const orderService = new OrderService(AppDataSource);
|
|
|
const salaryVideos = await orderService.getSalaryVideos(
|
|
const salaryVideos = await orderService.getSalaryVideos(
|
|
@@ -279,10 +303,18 @@ const app = new OpenAPIHono<TalentAuthContext>()
|
|
|
const validatedResult = await parseWithAwait(SalaryVideosResponseSchema, salaryVideos);
|
|
const validatedResult = await parseWithAwait(SalaryVideosResponseSchema, salaryVideos);
|
|
|
return c.json(validatedResult, 200);
|
|
return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
|
|
+ if (error instanceof z.ZodError) {
|
|
|
|
|
+ return c.json({
|
|
|
|
|
+ code: 400,
|
|
|
|
|
+ message: '参数错误',
|
|
|
|
|
+ errors: error.issues
|
|
|
|
|
+ }, 400);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return c.json({
|
|
return c.json({
|
|
|
code: 500,
|
|
code: 500,
|
|
|
message: error instanceof Error ? error.message : '获取薪资视频失败'
|
|
message: error instanceof Error ? error.message : '获取薪资视频失败'
|
|
|
- } as any, 500);
|
|
|
|
|
|
|
+ }, 500);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|