You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					37 lines
				
				1.4 KiB
			
		
		
			
		
	
	
					37 lines
				
				1.4 KiB
			| 
											1 year ago
										 | from fastapi import APIRouter, BackgroundTasks, Depends, File, Query, Request, UploadFile | ||
|  | from module_admin.service.common_service import CommonService | ||
| 
											2 years ago
										 | from module_admin.service.login_service import LoginService | ||
| 
											1 year ago
										 | from utils.log_util import logger | ||
|  | from utils.response_util import ResponseUtil | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 | commonController = APIRouter(prefix='/common', dependencies=[Depends(LoginService.get_current_user)]) | ||
| 
											2 years ago
										 | 
 | ||
|  | 
 | ||
| 
											1 year ago
										 | @commonController.post('/upload') | ||
| 
											2 years ago
										 | async def common_upload(request: Request, file: UploadFile = File(...)): | ||
| 
											1 year ago
										 |     upload_result = await CommonService.upload_service(request, file) | ||
|  |     logger.info('上传成功') | ||
|  | 
 | ||
|  |     return ResponseUtil.success(model_content=upload_result.result) | ||
| 
											2 years ago
										 | 
 | ||
|  | 
 | ||
| 
											1 year ago
										 | @commonController.get('/download') | ||
|  | async def common_download( | ||
|  |     request: Request, | ||
|  |     background_tasks: BackgroundTasks, | ||
|  |     file_name: str = Query(alias='fileName'), | ||
|  |     delete: bool = Query(), | ||
|  | ): | ||
| 
											1 year ago
										 |     download_result = await CommonService.download_services(background_tasks, file_name, delete) | ||
|  |     logger.info(download_result.message) | ||
|  | 
 | ||
|  |     return ResponseUtil.streaming(data=download_result.result) | ||
| 
											2 years ago
										 | 
 | ||
|  | 
 | ||
| 
											1 year ago
										 | @commonController.get('/download/resource') | ||
|  | async def common_download_resource(request: Request, resource: str = Query()): | ||
| 
											1 year ago
										 |     download_resource_result = await CommonService.download_resource_services(resource) | ||
|  |     logger.info(download_resource_result.message) | ||
|  | 
 | ||
|  |     return ResponseUtil.streaming(data=download_resource_result.result) |