安全:隔离主数据并封闭单条删除
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 DeleteLineModel, LineModel, LinePageQueryModel
|
||||
from module_business.service.master_service import MasterService
|
||||
from utils.response_util import ResponseUtil
|
||||
@@ -30,8 +32,9 @@ async def get_master_line_list(
|
||||
request: Request,
|
||||
line_page_query: Annotated[LinePageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
line_page_query_result = await MasterService.list_line(query_db, line_page_query, is_page=True)
|
||||
line_page_query_result = await MasterService.list_line(query_db, line_page_query, scope, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=line_page_query_result)
|
||||
|
||||
@@ -47,8 +50,9 @@ async def query_detail_master_line(
|
||||
request: Request,
|
||||
line_id: Annotated[int, Path(gt=0, description='生产线ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency()],
|
||||
) -> Response:
|
||||
line_detail_result = await MasterService.detail_line(query_db, line_id)
|
||||
line_detail_result = await MasterService.detail_line(query_db, line_id, scope)
|
||||
|
||||
return ResponseUtil.success(data=line_detail_result)
|
||||
|
||||
@@ -66,13 +70,14 @@ async def add_master_line(
|
||||
add_line: LineModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
current_time = datetime.now()
|
||||
add_line.create_by = current_user.user.user_name
|
||||
add_line.create_time = current_time
|
||||
add_line.update_by = current_user.user.user_name
|
||||
add_line.update_time = current_time
|
||||
add_line_result = await MasterService.add_line(query_db, add_line)
|
||||
add_line_result = await MasterService.add_line(query_db, add_line, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=add_line_result.message)
|
||||
|
||||
@@ -90,10 +95,11 @@ async def edit_master_line(
|
||||
edit_line: LineModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
scope: Annotated[TestBatchScope, TestBatchScopeDependency(write=True)],
|
||||
) -> Response:
|
||||
edit_line.update_by = current_user.user.user_name
|
||||
edit_line.update_time = datetime.now()
|
||||
edit_line_result = await MasterService.edit_line(query_db, edit_line)
|
||||
edit_line_result = await MasterService.edit_line(query_db, edit_line, current_user, scope)
|
||||
|
||||
return ResponseUtil.success(msg=edit_line_result.message)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user