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 VecsetPageObject, SaveVecsetModel | |
| from module_admin.entity.do.dataint_do import SysVecset | |
| from module_admin.dao.vecset_dao import VecsetDao | |
| from exceptions.exception import ServiceException, ServiceWarning | |
| from datetime import datetime | |
| from utils.common_util import CamelCaseUtil | |
| 
 | |
| 
 | |
| class VecsetService: | |
|     """ | |
|     智能问答服务层 | |
|     """ | |
| 
 | |
|     @classmethod | |
|     async def get_vecset_list_services(cls, result_db: AsyncSession, vecset_query: VecsetPageObject, current_user: CurrentUserModel): | |
|         result = await VecsetDao.get_vecset_list(result_db, vecset_query) | |
|         return CamelCaseUtil.transform_result(result) | |
| 
 | |
|     @classmethod | |
|     async def save_vecset(cls, result_db: AsyncSession, saveVecsetModel: SaveVecsetModel, current_user: CurrentUserModel): | |
|         if saveVecsetModel.onum is None: | |
|             # add | |
|             saveVecsetModel.onum = uuid.uuid4() | |
|             addObj = SysVecset(**saveVecsetModel.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 VecsetDao.insert_vecset(result_db, addObj) | |
|         else: | |
|             # update | |
|             oldObj = await VecsetDao.get_vecset_by_id(result_db, saveVecsetModel.onum) | |
|             if oldObj is None: | |
|                 raise ServiceException(message='所改对象不存在') | |
|             saveObj = saveVecsetModel.model_dump(exclude_unset=True) | |
|             saveObj['update_by'] = current_user.user.user_name | |
|             saveObj['update_time'] = datetime.now() | |
|             await VecsetDao.update_vecset(result_db, saveObj) | |
|         await result_db.commit() | |
|         return CrudResponseModel(is_success=True, message='操作成功') | |
| 
 | |
|     @classmethod | |
|     async def delete_vecset(cls, db: AsyncSession, array: List[str]): | |
|         await VecsetDao.delete_vecset(db, array) | |
|         await db.commit() | |
|         return CrudResponseModel(is_success=True, message='操作成功') | |
| 
 | |
| 
 |