|
|
@@ -18,7 +18,7 @@ export function createCrudRoutes<
|
|
|
>(
|
|
|
options: CrudOptions<T, CreateSchema, UpdateSchema, GetSchema, ListSchema>
|
|
|
) {
|
|
|
- const { entity, createSchema, updateSchema, getSchema, listSchema, searchFields, relations, middleware = [], userTracking, relationFields, readOnly = false } = options;
|
|
|
+ const { entity, createSchema, updateSchema, getSchema, listSchema, searchFields, relations, middleware = [], userTracking, relationFields, readOnly = false, dataPermission } = options;
|
|
|
|
|
|
// 创建路由实例
|
|
|
const app = new OpenAPIHono<AuthContext>();
|
|
|
@@ -262,7 +262,8 @@ export function createCrudRoutes<
|
|
|
}
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
|
|
|
const [data, total] = await crudService.getList(
|
|
|
@@ -299,7 +300,8 @@ export function createCrudRoutes<
|
|
|
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
const result = await crudService.create(data, user?.id);
|
|
|
return c.json(result, 201);
|
|
|
@@ -326,7 +328,8 @@ export function createCrudRoutes<
|
|
|
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
const result = await crudService.getById(id, relations || []);
|
|
|
|
|
|
@@ -355,7 +358,8 @@ export function createCrudRoutes<
|
|
|
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
const result = await crudService.update(id, data, user?.id);
|
|
|
|
|
|
@@ -380,7 +384,8 @@ export function createCrudRoutes<
|
|
|
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
const success = await crudService.delete(id);
|
|
|
|
|
|
@@ -428,7 +433,8 @@ export function createCrudRoutes<
|
|
|
}
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
|
|
|
const [data, total] = await crudService.getList(
|
|
|
@@ -463,7 +469,8 @@ export function createCrudRoutes<
|
|
|
|
|
|
const crudService = new ConcreteCrudService(entity, {
|
|
|
userTracking: userTracking,
|
|
|
- relationFields: relationFields
|
|
|
+ relationFields: relationFields,
|
|
|
+ dataPermission: dataPermission
|
|
|
});
|
|
|
const result = await crudService.getById(id, relations || []);
|
|
|
|