安全:隔离主数据并封闭单条删除
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 DeleteStrainModel, StrainModel, StrainPageQueryModel
|
||||
from module_business.service.master_service import MasterService
|
||||
from utils.response_util import ResponseUtil
|
||||
@@ -32,8 +34,9 @@ async def get_master_strain_list(
|
||||
request: Request,
|
||||
strain_page_query: Annotated[StrainPageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
strain_page_query_result = await MasterService.list_strain(query_db, strain_page_query, is_page=True)
|
||||
strain_page_query_result = await MasterService.list_strain(query_db, strain_page_query, scope, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=strain_page_query_result)
|
||||
|
||||
@@ -49,8 +52,9 @@ async def query_detail_master_strain(
|
||||
request: Request,
|
||||
strain_id: Annotated[int, Path(gt=0, description='菌种ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
strain_detail_result = await MasterService.detail_strain(query_db, strain_id)
|
||||
strain_detail_result = await MasterService.detail_strain(query_db, strain_id, scope)
|
||||
|
||||
return ResponseUtil.success(data=strain_detail_result)
|
||||
|
||||
@@ -68,13 +72,14 @@ async def add_master_strain(
|
||||
add_strain: StrainModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
current_time = datetime.now()
|
||||
add_strain.create_by = current_user.user.user_name
|
||||
add_strain.create_time = current_time
|
||||
add_strain.update_by = current_user.user.user_name
|
||||
add_strain.update_time = current_time
|
||||
add_strain_result = await MasterService.add_strain(query_db, add_strain)
|
||||
add_strain_result = await MasterService.add_strain(query_db, add_strain, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=add_strain_result.message)
|
||||
|
||||
@@ -92,10 +97,11 @@ async def edit_master_strain(
|
||||
edit_strain: StrainModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
edit_strain.update_by = current_user.user.user_name
|
||||
edit_strain.update_time = datetime.now()
|
||||
edit_strain_result = await MasterService.edit_strain(query_db, edit_strain)
|
||||
edit_strain_result = await MasterService.edit_strain(query_db, edit_strain, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=edit_strain_result.message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user