安全:隔离主数据并封闭单条删除
This commit is contained in:
@@ -12,6 +12,8 @@ from common.enums import BusinessType
|
||||
from common.router import APIRouterPro
|
||||
from common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
from module_business.dependency.test_batch_dependency import TestBatchScopeDependency
|
||||
from module_business.domain.test_batch_scope import TestBatchScope
|
||||
from module_business.entity.vo.master_vo import (
|
||||
BusinessUserOptionModel,
|
||||
DeleteWarehouseModel,
|
||||
@@ -45,8 +47,9 @@ async def get_master_warehouse_users(
|
||||
request: Request,
|
||||
warehouse_id: Annotated[int, Path(gt=0, description='仓库ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
users = await PalletService.list_warehouse_users(query_db, warehouse_id)
|
||||
users = await PalletService.list_warehouse_users(query_db, warehouse_id, scope)
|
||||
return ResponseUtil.success(data=users)
|
||||
|
||||
|
||||
@@ -64,8 +67,9 @@ async def assign_master_warehouse_users(
|
||||
assignment: UserAssignModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, ASSIGN_CURRENT_USER()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
result = await PalletService.assign_warehouse_users(query_db, warehouse_id, assignment)
|
||||
result = await PalletService.assign_warehouse_users(query_db, warehouse_id, assignment, current_user, scope)
|
||||
return ResponseUtil.success(msg=result.message)
|
||||
|
||||
|
||||
@@ -80,8 +84,14 @@ async def get_master_warehouse_list(
|
||||
request: Request,
|
||||
warehouse_page_query: Annotated[WarehousePageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
warehouse_page_query_result = await MasterService.list_warehouse(query_db, warehouse_page_query, is_page=True)
|
||||
warehouse_page_query_result = await MasterService.list_warehouse(
|
||||
query_db,
|
||||
warehouse_page_query,
|
||||
scope,
|
||||
is_page=True,
|
||||
)
|
||||
|
||||
return ResponseUtil.success(model_content=warehouse_page_query_result)
|
||||
|
||||
@@ -97,8 +107,9 @@ async def query_detail_master_warehouse(
|
||||
request: Request,
|
||||
warehouse_id: Annotated[int, Path(gt=0, description='仓库ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
warehouse_detail_result = await MasterService.detail_warehouse(query_db, warehouse_id)
|
||||
warehouse_detail_result = await MasterService.detail_warehouse(query_db, warehouse_id, scope)
|
||||
|
||||
return ResponseUtil.success(data=warehouse_detail_result)
|
||||
|
||||
@@ -116,13 +127,14 @@ async def add_master_warehouse(
|
||||
add_warehouse: WarehouseModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
current_time = datetime.now()
|
||||
add_warehouse.create_by = current_user.user.user_name
|
||||
add_warehouse.create_time = current_time
|
||||
add_warehouse.update_by = current_user.user.user_name
|
||||
add_warehouse.update_time = current_time
|
||||
add_warehouse_result = await MasterService.add_warehouse(query_db, add_warehouse)
|
||||
add_warehouse_result = await MasterService.add_warehouse(query_db, add_warehouse, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=add_warehouse_result.message)
|
||||
|
||||
@@ -140,10 +152,11 @@ async def edit_master_warehouse(
|
||||
edit_warehouse: WarehouseModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
edit_warehouse.update_by = current_user.user.user_name
|
||||
edit_warehouse.update_time = datetime.now()
|
||||
edit_warehouse_result = await MasterService.edit_warehouse(query_db, edit_warehouse)
|
||||
edit_warehouse_result = await MasterService.edit_warehouse(query_db, edit_warehouse, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=edit_warehouse_result.message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user