|
|
@@ -602,7 +602,15 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const result = await orderService.findAll(query);
|
|
|
|
|
|
- return c.json(result, 200);
|
|
|
+ // 使用 parseWithAwait 验证和转换数据
|
|
|
+ const validatedData = await parseWithAwait(
|
|
|
+ z.object({
|
|
|
+ data: z.array(EmploymentOrderSchema),
|
|
|
+ total: z.number().int()
|
|
|
+ }),
|
|
|
+ result
|
|
|
+ );
|
|
|
+ return c.json(validatedData, 200);
|
|
|
} catch (error) {
|
|
|
return c.json({
|
|
|
code: 500,
|
|
|
@@ -700,7 +708,16 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const result = await orderService.batchAddPersons(orderId, persons);
|
|
|
|
|
|
- return c.json(result, 200);
|
|
|
+ // 使用 parseWithAwait 验证和转换数据
|
|
|
+ const validatedResult = await parseWithAwait(
|
|
|
+ z.object({
|
|
|
+ success: z.boolean(),
|
|
|
+ message: z.string(),
|
|
|
+ addedCount: z.number().int()
|
|
|
+ }),
|
|
|
+ result
|
|
|
+ );
|
|
|
+ return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
if (error instanceof Error && error.message.includes('已结束或已取消')) {
|
|
|
return c.json({
|
|
|
@@ -730,7 +747,22 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const result = await orderService.createOrderPersonAsset(data);
|
|
|
|
|
|
- return c.json(result, 200);
|
|
|
+ // 使用 parseWithAwait 验证和转换数据
|
|
|
+ const validatedResult = await parseWithAwait(
|
|
|
+ z.object({
|
|
|
+ id: z.number().int(),
|
|
|
+ orderId: z.number().int(),
|
|
|
+ personId: z.number().int(),
|
|
|
+ assetType: z.string(),
|
|
|
+ assetFileType: z.string(),
|
|
|
+ fileId: z.number().int(),
|
|
|
+ relatedTime: z.string().datetime(),
|
|
|
+ createTime: z.string().datetime(),
|
|
|
+ updateTime: z.string().datetime()
|
|
|
+ }),
|
|
|
+ result
|
|
|
+ );
|
|
|
+ return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
if (error instanceof Error && error.message.includes('文件不存在')) {
|
|
|
return c.json({
|
|
|
@@ -760,7 +792,25 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const result = await orderService.queryOrderPersonAsset(query);
|
|
|
|
|
|
- return c.json(result, 200);
|
|
|
+ // 使用 parseWithAwait 验证和转换数据
|
|
|
+ const validatedResult = await parseWithAwait(
|
|
|
+ z.object({
|
|
|
+ data: z.array(z.object({
|
|
|
+ id: z.number().int(),
|
|
|
+ orderId: z.number().int(),
|
|
|
+ personId: z.number().int(),
|
|
|
+ assetType: z.string(),
|
|
|
+ assetFileType: z.string(),
|
|
|
+ fileId: z.number().int(),
|
|
|
+ relatedTime: z.string().datetime(),
|
|
|
+ createTime: z.string().datetime(),
|
|
|
+ updateTime: z.string().datetime()
|
|
|
+ })),
|
|
|
+ total: z.number().int()
|
|
|
+ }),
|
|
|
+ result
|
|
|
+ );
|
|
|
+ return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
return c.json({
|
|
|
code: 500,
|
|
|
@@ -776,7 +826,15 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
|
|
|
const result = await orderService.deleteOrderPersonAsset(id);
|
|
|
|
|
|
- return c.json(result, 200);
|
|
|
+ // 使用 parseWithAwait 验证和转换数据
|
|
|
+ const validatedResult = await parseWithAwait(
|
|
|
+ z.object({
|
|
|
+ success: z.boolean(),
|
|
|
+ message: z.string()
|
|
|
+ }),
|
|
|
+ result
|
|
|
+ );
|
|
|
+ return c.json(validatedResult, 200);
|
|
|
} catch (error) {
|
|
|
if (error instanceof Error && error.message.includes('资产ID')) {
|
|
|
return c.json({
|