功能:新增业务基础资料接口
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Path, Query, Request, Response
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.annotation.log_annotation import Log
|
||||
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 common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
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
|
||||
|
||||
customer_controller = APIRouterPro(
|
||||
prefix='/master/customer', tags=['基础资料-客户管理'], dependencies=[PreAuthDependency()]
|
||||
)
|
||||
|
||||
|
||||
@customer_controller.get(
|
||||
'/list',
|
||||
summary='获取客户分页列表接口',
|
||||
description='用于获取客户分页列表',
|
||||
response_model=PageResponseModel[CustomerModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:customer:list')],
|
||||
)
|
||||
async def get_master_customer_list(
|
||||
request: Request,
|
||||
customer_page_query: Annotated[CustomerPageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
customer_page_query_result = await MasterService.list_customer(query_db, customer_page_query, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=customer_page_query_result)
|
||||
|
||||
|
||||
@customer_controller.get(
|
||||
'/{customer_id}',
|
||||
summary='获取客户详情接口',
|
||||
description='用于获取指定客户的详细信息',
|
||||
response_model=DataResponseModel[CustomerModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:customer:query')],
|
||||
)
|
||||
async def query_detail_master_customer(
|
||||
request: Request,
|
||||
customer_id: Annotated[int, Path(gt=0, description='客户ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
customer_detail_result = await MasterService.detail_customer(query_db, customer_id)
|
||||
|
||||
return ResponseUtil.success(data=customer_detail_result)
|
||||
|
||||
|
||||
@customer_controller.post(
|
||||
'',
|
||||
summary='新增客户接口',
|
||||
description='用于新增客户',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:customer:add')],
|
||||
)
|
||||
@Log(title='客户管理', business_type=BusinessType.INSERT)
|
||||
async def add_master_customer(
|
||||
request: Request,
|
||||
add_customer: CustomerModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=add_customer_result.message)
|
||||
|
||||
|
||||
@customer_controller.put(
|
||||
'',
|
||||
summary='编辑客户接口',
|
||||
description='用于编辑客户',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:customer:edit')],
|
||||
)
|
||||
@Log(title='客户管理', business_type=BusinessType.UPDATE)
|
||||
async def edit_master_customer(
|
||||
request: Request,
|
||||
edit_customer: CustomerModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=edit_customer_result.message)
|
||||
|
||||
|
||||
@customer_controller.delete(
|
||||
'/{customer_ids}',
|
||||
summary='删除客户接口',
|
||||
description='用于删除客户',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:customer:remove')],
|
||||
)
|
||||
@Log(title='客户管理', business_type=BusinessType.DELETE)
|
||||
async def delete_master_customer(
|
||||
request: Request,
|
||||
customer_ids: Annotated[
|
||||
str,
|
||||
Path(pattern=r'^[1-9]\d*(,[1-9]\d*)*$', description='需要删除的客户ID'),
|
||||
],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
delete_customer = DeleteCustomerModel(customerIds=[int(customer_id) for customer_id in customer_ids.split(',')])
|
||||
delete_customer_result = await MasterService.remove_customer(query_db, delete_customer)
|
||||
|
||||
return ResponseUtil.success(msg=delete_customer_result.message)
|
||||
@@ -0,0 +1,121 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Path, Query, Request, Response
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.annotation.log_annotation import Log
|
||||
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 common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
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
|
||||
|
||||
line_controller = APIRouterPro(prefix='/master/line', tags=['基础资料-生产线管理'], dependencies=[PreAuthDependency()])
|
||||
|
||||
|
||||
@line_controller.get(
|
||||
'/list',
|
||||
summary='获取生产线分页列表接口',
|
||||
description='用于获取生产线分页列表',
|
||||
response_model=PageResponseModel[LineModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:line:list')],
|
||||
)
|
||||
async def get_master_line_list(
|
||||
request: Request,
|
||||
line_page_query: Annotated[LinePageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
line_page_query_result = await MasterService.list_line(query_db, line_page_query, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=line_page_query_result)
|
||||
|
||||
|
||||
@line_controller.get(
|
||||
'/{line_id}',
|
||||
summary='获取生产线详情接口',
|
||||
description='用于获取指定生产线的详细信息',
|
||||
response_model=DataResponseModel[LineModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:line:query')],
|
||||
)
|
||||
async def query_detail_master_line(
|
||||
request: Request,
|
||||
line_id: Annotated[int, Path(gt=0, description='生产线ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
line_detail_result = await MasterService.detail_line(query_db, line_id)
|
||||
|
||||
return ResponseUtil.success(data=line_detail_result)
|
||||
|
||||
|
||||
@line_controller.post(
|
||||
'',
|
||||
summary='新增生产线接口',
|
||||
description='用于新增生产线',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:line:add')],
|
||||
)
|
||||
@Log(title='生产线管理', business_type=BusinessType.INSERT)
|
||||
async def add_master_line(
|
||||
request: Request,
|
||||
add_line: LineModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=add_line_result.message)
|
||||
|
||||
|
||||
@line_controller.put(
|
||||
'',
|
||||
summary='编辑生产线接口',
|
||||
description='用于编辑生产线',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:line:edit')],
|
||||
)
|
||||
@Log(title='生产线管理', business_type=BusinessType.UPDATE)
|
||||
async def edit_master_line(
|
||||
request: Request,
|
||||
edit_line: LineModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=edit_line_result.message)
|
||||
|
||||
|
||||
@line_controller.delete(
|
||||
'/{line_ids}',
|
||||
summary='删除生产线接口',
|
||||
description='用于删除生产线',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:line:remove')],
|
||||
)
|
||||
@Log(title='生产线管理', business_type=BusinessType.DELETE)
|
||||
async def delete_master_line(
|
||||
request: Request,
|
||||
line_ids: Annotated[
|
||||
str,
|
||||
Path(pattern=r'^[1-9]\d*(,[1-9]\d*)*$', description='需要删除的生产线ID'),
|
||||
],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
delete_line = DeleteLineModel(lineIds=[int(line_id) for line_id in line_ids.split(',')])
|
||||
delete_line_result = await MasterService.remove_line(query_db, delete_line)
|
||||
|
||||
return ResponseUtil.success(msg=delete_line_result.message)
|
||||
@@ -0,0 +1,123 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Path, Query, Request, Response
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.annotation.log_annotation import Log
|
||||
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 common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
from module_business.entity.vo.master_vo import DeleteSiteModel, SiteModel, SitePageQueryModel
|
||||
from module_business.service.master_service import MasterService
|
||||
from utils.response_util import ResponseUtil
|
||||
|
||||
site_controller = APIRouterPro(
|
||||
prefix='/master/site', tags=['基础资料-客户现场管理'], dependencies=[PreAuthDependency()]
|
||||
)
|
||||
|
||||
|
||||
@site_controller.get(
|
||||
'/list',
|
||||
summary='获取客户现场分页列表接口',
|
||||
description='用于获取客户现场分页列表',
|
||||
response_model=PageResponseModel[SiteModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:site:list')],
|
||||
)
|
||||
async def get_master_site_list(
|
||||
request: Request,
|
||||
site_page_query: Annotated[SitePageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
site_page_query_result = await MasterService.list_site(query_db, site_page_query, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=site_page_query_result)
|
||||
|
||||
|
||||
@site_controller.get(
|
||||
'/{site_id}',
|
||||
summary='获取客户现场详情接口',
|
||||
description='用于获取指定客户现场的详细信息',
|
||||
response_model=DataResponseModel[SiteModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:site:query')],
|
||||
)
|
||||
async def query_detail_master_site(
|
||||
request: Request,
|
||||
site_id: Annotated[int, Path(gt=0, description='客户现场ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
site_detail_result = await MasterService.detail_site(query_db, site_id)
|
||||
|
||||
return ResponseUtil.success(data=site_detail_result)
|
||||
|
||||
|
||||
@site_controller.post(
|
||||
'',
|
||||
summary='新增客户现场接口',
|
||||
description='用于新增客户现场',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:site:add')],
|
||||
)
|
||||
@Log(title='客户现场管理', business_type=BusinessType.INSERT)
|
||||
async def add_master_site(
|
||||
request: Request,
|
||||
add_site: SiteModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
current_time = datetime.now()
|
||||
add_site.create_by = current_user.user.user_name
|
||||
add_site.create_time = current_time
|
||||
add_site.update_by = current_user.user.user_name
|
||||
add_site.update_time = current_time
|
||||
add_site_result = await MasterService.add_site(query_db, add_site)
|
||||
|
||||
return ResponseUtil.success(msg=add_site_result.message)
|
||||
|
||||
|
||||
@site_controller.put(
|
||||
'',
|
||||
summary='编辑客户现场接口',
|
||||
description='用于编辑客户现场',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:site:edit')],
|
||||
)
|
||||
@Log(title='客户现场管理', business_type=BusinessType.UPDATE)
|
||||
async def edit_master_site(
|
||||
request: Request,
|
||||
edit_site: SiteModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
edit_site.update_by = current_user.user.user_name
|
||||
edit_site.update_time = datetime.now()
|
||||
edit_site_result = await MasterService.edit_site(query_db, edit_site)
|
||||
|
||||
return ResponseUtil.success(msg=edit_site_result.message)
|
||||
|
||||
|
||||
@site_controller.delete(
|
||||
'/{site_ids}',
|
||||
summary='删除客户现场接口',
|
||||
description='用于删除客户现场',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:site:remove')],
|
||||
)
|
||||
@Log(title='客户现场管理', business_type=BusinessType.DELETE)
|
||||
async def delete_master_site(
|
||||
request: Request,
|
||||
site_ids: Annotated[
|
||||
str,
|
||||
Path(pattern=r'^[1-9]\d*(,[1-9]\d*)*$', description='需要删除的客户现场ID'),
|
||||
],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
delete_site = DeleteSiteModel(siteIds=[int(site_id) for site_id in site_ids.split(',')])
|
||||
delete_site_result = await MasterService.remove_site(query_db, delete_site)
|
||||
|
||||
return ResponseUtil.success(msg=delete_site_result.message)
|
||||
@@ -0,0 +1,123 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Path, Query, Request, Response
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.annotation.log_annotation import Log
|
||||
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 common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
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
|
||||
|
||||
strain_controller = APIRouterPro(
|
||||
prefix='/master/strain', tags=['基础资料-菌种管理'], dependencies=[PreAuthDependency()]
|
||||
)
|
||||
|
||||
|
||||
@strain_controller.get(
|
||||
'/list',
|
||||
summary='获取菌种分页列表接口',
|
||||
description='用于获取菌种分页列表',
|
||||
response_model=PageResponseModel[StrainModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:strain:list')],
|
||||
)
|
||||
async def get_master_strain_list(
|
||||
request: Request,
|
||||
strain_page_query: Annotated[StrainPageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
strain_page_query_result = await MasterService.list_strain(query_db, strain_page_query, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=strain_page_query_result)
|
||||
|
||||
|
||||
@strain_controller.get(
|
||||
'/{strain_id}',
|
||||
summary='获取菌种详情接口',
|
||||
description='用于获取指定菌种的详细信息',
|
||||
response_model=DataResponseModel[StrainModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:strain:query')],
|
||||
)
|
||||
async def query_detail_master_strain(
|
||||
request: Request,
|
||||
strain_id: Annotated[int, Path(gt=0, description='菌种ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
strain_detail_result = await MasterService.detail_strain(query_db, strain_id)
|
||||
|
||||
return ResponseUtil.success(data=strain_detail_result)
|
||||
|
||||
|
||||
@strain_controller.post(
|
||||
'',
|
||||
summary='新增菌种接口',
|
||||
description='用于新增菌种',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:strain:add')],
|
||||
)
|
||||
@Log(title='菌种管理', business_type=BusinessType.INSERT)
|
||||
async def add_master_strain(
|
||||
request: Request,
|
||||
add_strain: StrainModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=add_strain_result.message)
|
||||
|
||||
|
||||
@strain_controller.put(
|
||||
'',
|
||||
summary='编辑菌种接口',
|
||||
description='用于编辑菌种',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:strain:edit')],
|
||||
)
|
||||
@Log(title='菌种管理', business_type=BusinessType.UPDATE)
|
||||
async def edit_master_strain(
|
||||
request: Request,
|
||||
edit_strain: StrainModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=edit_strain_result.message)
|
||||
|
||||
|
||||
@strain_controller.delete(
|
||||
'/{strain_ids}',
|
||||
summary='删除菌种接口',
|
||||
description='用于删除菌种',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:strain:remove')],
|
||||
)
|
||||
@Log(title='菌种管理', business_type=BusinessType.DELETE)
|
||||
async def delete_master_strain(
|
||||
request: Request,
|
||||
strain_ids: Annotated[
|
||||
str,
|
||||
Path(pattern=r'^[1-9]\d*(,[1-9]\d*)*$', description='需要删除的菌种ID'),
|
||||
],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
delete_strain = DeleteStrainModel(strainIds=[int(strain_id) for strain_id in strain_ids.split(',')])
|
||||
delete_strain_result = await MasterService.remove_strain(query_db, delete_strain)
|
||||
|
||||
return ResponseUtil.success(msg=delete_strain_result.message)
|
||||
@@ -0,0 +1,125 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Path, Query, Request, Response
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from common.annotation.log_annotation import Log
|
||||
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 common.vo import DataResponseModel, PageResponseModel, ResponseBaseModel
|
||||
from module_admin.entity.vo.user_vo import CurrentUserModel
|
||||
from module_business.entity.vo.master_vo import DeleteWarehouseModel, WarehouseModel, WarehousePageQueryModel
|
||||
from module_business.service.master_service import MasterService
|
||||
from utils.response_util import ResponseUtil
|
||||
|
||||
warehouse_controller = APIRouterPro(
|
||||
prefix='/master/warehouse', tags=['基础资料-仓库管理'], dependencies=[PreAuthDependency()]
|
||||
)
|
||||
|
||||
|
||||
@warehouse_controller.get(
|
||||
'/list',
|
||||
summary='获取仓库分页列表接口',
|
||||
description='用于获取仓库分页列表',
|
||||
response_model=PageResponseModel[WarehouseModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:warehouse:list')],
|
||||
)
|
||||
async def get_master_warehouse_list(
|
||||
request: Request,
|
||||
warehouse_page_query: Annotated[WarehousePageQueryModel, Query()],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
warehouse_page_query_result = await MasterService.list_warehouse(query_db, warehouse_page_query, is_page=True)
|
||||
|
||||
return ResponseUtil.success(model_content=warehouse_page_query_result)
|
||||
|
||||
|
||||
@warehouse_controller.get(
|
||||
'/{warehouse_id}',
|
||||
summary='获取仓库详情接口',
|
||||
description='用于获取指定仓库的详细信息',
|
||||
response_model=DataResponseModel[WarehouseModel],
|
||||
dependencies=[UserInterfaceAuthDependency('master:warehouse:query')],
|
||||
)
|
||||
async def query_detail_master_warehouse(
|
||||
request: Request,
|
||||
warehouse_id: Annotated[int, Path(gt=0, description='仓库ID')],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
) -> Response:
|
||||
warehouse_detail_result = await MasterService.detail_warehouse(query_db, warehouse_id)
|
||||
|
||||
return ResponseUtil.success(data=warehouse_detail_result)
|
||||
|
||||
|
||||
@warehouse_controller.post(
|
||||
'',
|
||||
summary='新增仓库接口',
|
||||
description='用于新增仓库',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:warehouse:add')],
|
||||
)
|
||||
@Log(title='仓库管理', business_type=BusinessType.INSERT)
|
||||
async def add_master_warehouse(
|
||||
request: Request,
|
||||
add_warehouse: WarehouseModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=add_warehouse_result.message)
|
||||
|
||||
|
||||
@warehouse_controller.put(
|
||||
'',
|
||||
summary='编辑仓库接口',
|
||||
description='用于编辑仓库',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:warehouse:edit')],
|
||||
)
|
||||
@Log(title='仓库管理', business_type=BusinessType.UPDATE)
|
||||
async def edit_master_warehouse(
|
||||
request: Request,
|
||||
edit_warehouse: WarehouseModel,
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> 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)
|
||||
|
||||
return ResponseUtil.success(msg=edit_warehouse_result.message)
|
||||
|
||||
|
||||
@warehouse_controller.delete(
|
||||
'/{warehouse_ids}',
|
||||
summary='删除仓库接口',
|
||||
description='用于删除仓库',
|
||||
response_model=ResponseBaseModel,
|
||||
dependencies=[UserInterfaceAuthDependency('master:warehouse:remove')],
|
||||
)
|
||||
@Log(title='仓库管理', business_type=BusinessType.DELETE)
|
||||
async def delete_master_warehouse(
|
||||
request: Request,
|
||||
warehouse_ids: Annotated[
|
||||
str,
|
||||
Path(pattern=r'^[1-9]\d*(,[1-9]\d*)*$', description='需要删除的仓库ID'),
|
||||
],
|
||||
query_db: Annotated[AsyncSession, DBSessionDependency()],
|
||||
current_user: Annotated[CurrentUserModel, CurrentUserDependency()],
|
||||
) -> Response:
|
||||
delete_warehouse = DeleteWarehouseModel(
|
||||
warehouseIds=[int(warehouse_id) for warehouse_id in warehouse_ids.split(',')]
|
||||
)
|
||||
delete_warehouse_result = await MasterService.remove_warehouse(query_db, delete_warehouse)
|
||||
|
||||
return ResponseUtil.success(msg=delete_warehouse_result.message)
|
||||
Reference in New Issue
Block a user