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.
		
		
		
		
		
			
		
			
				
					
					
						
							54 lines
						
					
					
						
							2.2 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							54 lines
						
					
					
						
							2.2 KiB
						
					
					
				| import json | |
| import uuid | |
| 
 | |
| from typing import Optional, List | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from module_admin.entity.vo.common_vo import CrudResponseModel | |
| from module_admin.entity.vo.user_vo import CurrentUserModel | |
| from module_admin.entity.vo.dataint_vo import TsmcbPageObject, SaveTsmcbModel | |
| from module_admin.entity.do.dataint_do import SysTsmcb | |
| from module_admin.dao.tsmcb_dao import TsmcbDao | |
| from exceptions.exception import ServiceException, ServiceWarning | |
| from datetime import datetime | |
| from utils.common_util import CamelCaseUtil | |
| 
 | |
| 
 | |
| class TsmcbService: | |
|     """ | |
|     智能问答服务层 | |
|     """ | |
| 
 | |
|     @classmethod | |
|     async def get_tsmcb_list_services(cls, result_db: AsyncSession, tsmcb_query: TsmcbPageObject, current_user: CurrentUserModel): | |
|         result = await TsmcbDao.get_tsmcb_list(result_db, tsmcb_query) | |
|         return CamelCaseUtil.transform_result(result) | |
| 
 | |
|     @classmethod | |
|     async def save_tsmcb(cls, result_db: AsyncSession, saveTsmcbModel: SaveTsmcbModel, current_user: CurrentUserModel): | |
|         if saveTsmcbModel.onum is None: | |
|             # add | |
|             saveTsmcbModel.onum = uuid.uuid4() | |
|             addObj = SysTsmcb(**saveTsmcbModel.model_dump()) | |
|             addObj.create_by = current_user.user.user_name | |
|             addObj.create_time = datetime.now() | |
|             addObj.update_by = current_user.user.user_name | |
|             addObj.update_time = datetime.now() | |
|             await TsmcbDao.insert_tsmcb(result_db, addObj) | |
|         else: | |
|             # update | |
|             oldObj = await TsmcbDao.get_tsmcb_by_id(result_db, saveTsmcbModel.onum) | |
|             if oldObj is None: | |
|                 raise ServiceException(message='所改对象不存在') | |
|             saveObj = saveTsmcbModel.model_dump(exclude_unset=True) | |
|             saveObj['update_by'] = current_user.user.user_name | |
|             saveObj['update_time'] = datetime.now() | |
|             await TsmcbDao.update_tsmcb(result_db, saveObj) | |
|         await result_db.commit() | |
|         return CrudResponseModel(is_success=True, message='操作成功') | |
| 
 | |
|     @classmethod | |
|     async def delete_tsmcb(cls, db: AsyncSession, array: List[str]): | |
|         await TsmcbDao.delete_tsmcb(db, array) | |
|         await db.commit() | |
|         return CrudResponseModel(is_success=True, message='操作成功') | |
| 
 | |
| 
 |