安全:隔离主数据并封闭单条删除

This commit is contained in:
焦龙言
2026-09-22 18:16:30 +08:00
parent af5428d0e3
commit b6f606d9f2
13 changed files with 1382 additions and 1131 deletions
@@ -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 CustomerModel, CustomerPageQueryModel, DeleteCustomerModel
from module_business.service.master_service import MasterService
from utils.response_util import ResponseUtil
@@ -32,8 +34,9 @@ async def get_master_customer_list(
request: Request,
customer_page_query: Annotated[CustomerPageQueryModel, Query()],
query_db: Annotated[AsyncSession, DBSessionDependency()],
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
) -> Response:
customer_page_query_result = await MasterService.list_customer(query_db, customer_page_query, is_page=True)
customer_page_query_result = await MasterService.list_customer(query_db, customer_page_query, scope, is_page=True)
return ResponseUtil.success(model_content=customer_page_query_result)
@@ -49,8 +52,9 @@ async def query_detail_master_customer(
request: Request,
customer_id: Annotated[int, Path(gt=0, description='客户ID')],
query_db: Annotated[AsyncSession, DBSessionDependency()],
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
) -> Response:
customer_detail_result = await MasterService.detail_customer(query_db, customer_id)
customer_detail_result = await MasterService.detail_customer(query_db, customer_id, scope)
return ResponseUtil.success(data=customer_detail_result)
@@ -68,13 +72,14 @@ async def add_master_customer(
add_customer: CustomerModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
) -> Response:
current_time = datetime.now()
add_customer.create_by = current_user.user.user_name
add_customer.create_time = current_time
add_customer.update_by = current_user.user.user_name
add_customer.update_time = current_time
add_customer_result = await MasterService.add_customer(query_db, add_customer)
add_customer_result = await MasterService.add_customer(query_db, add_customer, current_user, scope)
return ResponseUtil.success(msg=add_customer_result.message)
@@ -92,10 +97,11 @@ async def edit_master_customer(
edit_customer: CustomerModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
) -> Response:
edit_customer.update_by = current_user.user.user_name
edit_customer.update_time = datetime.now()
edit_customer_result = await MasterService.edit_customer(query_db, edit_customer)
edit_customer_result = await MasterService.edit_customer(query_db, edit_customer, current_user, scope)
return ResponseUtil.success(msg=edit_customer_result.message)