权限:移除业务物理删除入口

This commit is contained in:
焦龙言
2026-09-24 08:13:16 +08:00
parent 4706c4afeb
commit ae8c4c8c38
35 changed files with 668 additions and 445 deletions
@@ -111,7 +111,7 @@ async def edit_master_customer(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:customer:remove')],
dependencies=[UserInterfaceAuthDependency('master:customer:list')],
)
@Log(title='客户管理', business_type=BusinessType.DELETE)
async def delete_master_customer(
@@ -163,7 +163,7 @@ async def edit_business_inbound(
summary='不支持单条物理删除,请通过测试数据批次清理',
description='不支持单条物理删除,请通过测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('business:inbound:remove')],
dependencies=[UserInterfaceAuthDependency('business:inbound:list')],
)
@Log(title='仓库入库', business_type=BusinessType.DELETE)
async def delete_business_inbound(
@@ -109,7 +109,7 @@ async def edit_master_line(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:line:remove')],
dependencies=[UserInterfaceAuthDependency('master:line:list')],
)
@Log(title='生产线管理', business_type=BusinessType.DELETE)
async def delete_master_line(
@@ -123,7 +123,7 @@ async def edit_master_pallet(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:pallet:remove')],
dependencies=[UserInterfaceAuthDependency('master:pallet:list')],
)
@Log(title='托盘管理', business_type=BusinessType.DELETE)
async def delete_master_pallet(
@@ -180,7 +180,7 @@ async def edit_business_shipment(
summary='不支持单条物理删除,请通过测试数据批次清理',
description='不支持单条物理删除,请通过测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('business:shipment:remove')],
dependencies=[UserInterfaceAuthDependency('business:shipment:list')],
)
@Log(title='整托发货', business_type=BusinessType.DELETE)
async def delete_business_shipment(
@@ -161,7 +161,7 @@ async def edit_master_site(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:site:remove')],
dependencies=[UserInterfaceAuthDependency('master:site:list')],
)
@Log(title='客户现场管理', business_type=BusinessType.DELETE)
async def delete_master_site(
@@ -111,7 +111,7 @@ async def edit_master_strain(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:strain:remove')],
dependencies=[UserInterfaceAuthDependency('master:strain:list')],
)
@Log(title='菌种管理', business_type=BusinessType.DELETE)
async def delete_master_strain(
@@ -0,0 +1,262 @@
from typing import Annotated
from fastapi import Path, Request, Response
from sqlalchemy.ext.asyncio import AsyncSession
from common.annotation.log_annotation import Log, RequestLogFieldRoot
from common.aspect.db_seesion import DBSessionDependency
from common.aspect.interface_auth import UserInterfaceAuthDependency
from common.aspect.pre_auth import CurrentUserDependency, PreAuthDependency
from common.enums import BusinessType
from common.router import APIRouterPro
from module_admin.entity.vo.user_vo import CurrentUserModel
from module_business.entity.vo.test_batch_vo import (
AdoptionExecuteRequestModel,
AdoptionPreviewRequestModel,
PurgeExecuteRequestModel,
TestBatchCreateModel,
TestBatchEditModel,
TestBatchUserAssignModel,
)
from module_business.service.test_batch_adoption_service import TestBatchAdoptionService
from module_business.service.test_batch_purge_service import TestBatchPurgeService
from module_business.service.test_batch_service import TestBatchService
from utils.response_util import ResponseUtil
test_batch_controller = APIRouterPro(
prefix='/system/test-batch',
tags=['系统管理-测试数据批次'],
dependencies=[PreAuthDependency()],
)
@test_batch_controller.get('/options')
async def list_test_batch_options(
request: Request,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.list_available_batches(query_db, current_user)
return ResponseUtil.success(data=result)
@test_batch_controller.get(
'/list',
dependencies=[UserInterfaceAuthDependency('system:testbatch:list')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.OTHER,
request_log_mode='summary',
response_log_mode='summary',
)
async def list_test_batches(
request: Request,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.list_batches(query_db, current_user)
return ResponseUtil.success(rows=result, dict_content={'total': len(result)})
@test_batch_controller.post(
'',
dependencies=[UserInterfaceAuthDependency('system:testbatch:add')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.INSERT,
request_log_mode='summary',
response_log_mode='summary',
)
async def create_test_batch(
request: Request,
command: TestBatchCreateModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.create_batch(query_db, command, current_user)
return ResponseUtil.success(msg=result.message)
@test_batch_controller.put(
'/{batch_id}',
dependencies=[UserInterfaceAuthDependency('system:testbatch:edit')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.UPDATE,
request_log_mode='summary',
response_log_mode='summary',
)
async def edit_test_batch(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
command: TestBatchEditModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.edit_batch(query_db, batch_id, command, current_user)
return ResponseUtil.success(msg=result.message)
@test_batch_controller.put(
'/{batch_id}/users',
dependencies=[UserInterfaceAuthDependency('system:testbatch:assign')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.GRANT,
request_log_mode='summary',
response_log_mode='summary',
)
async def assign_test_batch_users(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
command: TestBatchUserAssignModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.replace_users(query_db, batch_id, command, current_user)
return ResponseUtil.success(msg=result.message)
@test_batch_controller.put(
'/{batch_id}/close',
dependencies=[UserInterfaceAuthDependency('system:testbatch:close')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.UPDATE,
request_log_mode='summary',
response_log_mode='summary',
)
async def close_test_batch(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.close_batch(query_db, batch_id, current_user)
return ResponseUtil.success(msg=result.message)
@test_batch_controller.put(
'/{batch_id}/reopen',
dependencies=[UserInterfaceAuthDependency('system:testbatch:close')],
)
@Log(
title='测试数据批次',
business_type=BusinessType.UPDATE,
request_log_mode='summary',
response_log_mode='summary',
)
async def reopen_test_batch(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.reopen_batch(query_db, batch_id, current_user)
return ResponseUtil.success(msg=result.message)
@Log(
title='测试数据批次',
business_type=BusinessType.CLEAN,
request_log_mode='include',
request_include_fields=(RequestLogFieldRoot.PATH_PARAMS.field('batch_id'),),
response_log_mode='summary',
)
@test_batch_controller.post(
'/{batch_id}/adoption/preview',
dependencies=[UserInterfaceAuthDependency('system:testbatch:adopt')],
)
async def preview_test_batch_adoption(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
command: AdoptionPreviewRequestModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchAdoptionService.preview(query_db, batch_id, command, current_user)
return ResponseUtil.success(data=result)
@Log(
title='测试数据批次',
business_type=BusinessType.CLEAN,
request_log_mode='include',
request_include_fields=(RequestLogFieldRoot.PATH_PARAMS.field('batch_id'),),
response_log_mode='summary',
)
@test_batch_controller.post(
'/{batch_id}/adoption/execute',
dependencies=[UserInterfaceAuthDependency('system:testbatch:adopt')],
)
async def execute_test_batch_adoption(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
command: AdoptionExecuteRequestModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchAdoptionService.execute(query_db, batch_id, command, current_user)
return ResponseUtil.success(msg=result.message)
@Log(
title='测试数据批次',
business_type=BusinessType.CLEAN,
request_log_mode='include',
request_include_fields=(RequestLogFieldRoot.PATH_PARAMS.field('batch_id'),),
response_log_mode='summary',
)
@test_batch_controller.post(
'/{batch_id}/purge/preview',
dependencies=[UserInterfaceAuthDependency('system:testbatch:purge')],
)
async def preview_test_batch_purge(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchPurgeService.preview(query_db, batch_id, current_user)
return ResponseUtil.success(data=result)
@Log(
title='测试数据批次',
business_type=BusinessType.CLEAN,
request_log_mode='include',
request_include_fields=(RequestLogFieldRoot.PATH_PARAMS.field('batch_id'),),
response_log_mode='summary',
)
@test_batch_controller.post(
'/{batch_id}/purge',
dependencies=[UserInterfaceAuthDependency('system:testbatch:purge')],
)
async def purge_test_batch(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
command: PurgeExecuteRequestModel,
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchPurgeService.purge(query_db, batch_id, command, current_user)
return ResponseUtil.success(msg=result.message)
@test_batch_controller.get(
'/{batch_id}',
dependencies=[UserInterfaceAuthDependency('system:testbatch:query')],
)
async def get_test_batch(
request: Request,
batch_id: Annotated[int, Path(gt=0, description='测试批次ID')],
query_db: Annotated[AsyncSession, DBSessionDependency()],
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
) -> Response:
result = await TestBatchService.get_batch_detail(query_db, batch_id, current_user)
return ResponseUtil.success(data=result)
@@ -166,7 +166,7 @@ async def edit_master_warehouse(
summary='兼容旧接口,固定拒绝,请使用测试数据批次清理',
description='兼容旧接口,固定拒绝单条物理删除,请使用测试数据批次清理',
response_model=ResponseBaseModel,
dependencies=[UserInterfaceAuthDependency('master:warehouse:remove')],
dependencies=[UserInterfaceAuthDependency('master:warehouse:list')],
)
@Log(title='仓库管理', business_type=BusinessType.DELETE)
async def delete_master_warehouse(