|
|
@@ -360,7 +360,9 @@ export function createCrudRoutes<
|
|
|
crudService.setTenantContext(finalTenantId);
|
|
|
}
|
|
|
const result = await crudService.create(data, user?.id);
|
|
|
- return c.json(await parseWithAwait(getSchema, result), 201);
|
|
|
+ // 重新获取包含关联关系的数据
|
|
|
+ const fullResult = await crudService.getById(result.id, relations || [], user?.id);
|
|
|
+ return c.json(await parseWithAwait(getSchema, fullResult), 201);
|
|
|
} catch (error) {
|
|
|
if (error instanceof z.ZodError) {
|
|
|
const zodError = error as ZodError;
|
|
|
@@ -476,7 +478,9 @@ export function createCrudRoutes<
|
|
|
return c.json({ code: 404, message: '资源不存在' }, 404);
|
|
|
}
|
|
|
|
|
|
- return c.json(await parseWithAwait(getSchema, result), 200);
|
|
|
+ // 重新获取包含关联关系的数据
|
|
|
+ const fullResult = await crudService.getById(id, relations || [], user?.id);
|
|
|
+ return c.json(await parseWithAwait(getSchema, fullResult), 200);
|
|
|
} catch (error) {
|
|
|
if (error instanceof z.ZodError) {
|
|
|
const zodError = error as ZodError;
|