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.
		
		
		
		
			
				
					55 lines
				
				2.2 KiB
			
		
		
			
		
	
	
					55 lines
				
				2.2 KiB
			| 
								 
											8 months ago
										 
									 | 
							
								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 CdplbPageObject, SaveCdplbModel
							 | 
						||
| 
								 | 
							
								from module_admin.entity.do.dataint_do import SysCdplb
							 | 
						||
| 
								 | 
							
								from module_admin.dao.cdplb_dao import CdplbDao
							 | 
						||
| 
								 | 
							
								from exceptions.exception import ServiceException, ServiceWarning
							 | 
						||
| 
								 | 
							
								from datetime import datetime
							 | 
						||
| 
								 | 
							
								from utils.common_util import CamelCaseUtil
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class CdplbService:
							 | 
						||
| 
								 | 
							
								    """
							 | 
						||
| 
								 | 
							
								    智能问答服务层
							 | 
						||
| 
								 | 
							
								    """
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @classmethod
							 | 
						||
| 
								 | 
							
								    async def get_cdplb_list_services(cls, result_db: AsyncSession, cdplb_query: CdplbPageObject, current_user: CurrentUserModel):
							 | 
						||
| 
								 | 
							
								        result = await CdplbDao.get_cdplb_list(result_db, cdplb_query)
							 | 
						||
| 
								 | 
							
								        return CamelCaseUtil.transform_result(result)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @classmethod
							 | 
						||
| 
								 | 
							
								    async def save_cdplb(cls, result_db: AsyncSession, saveCdplbModel: SaveCdplbModel, current_user: CurrentUserModel):
							 | 
						||
| 
								 | 
							
								        if saveCdplbModel.onum is None:
							 | 
						||
| 
								 | 
							
								            # add
							 | 
						||
| 
								 | 
							
								            saveCdplbModel.onum = uuid.uuid4()
							 | 
						||
| 
								 | 
							
								            addObj = SysCdplb(**saveCdplbModel.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 CdplbDao.insert_cdplb(result_db, addObj)
							 | 
						||
| 
								 | 
							
								        else:
							 | 
						||
| 
								 | 
							
								            # update
							 | 
						||
| 
								 | 
							
								            oldObj = await CdplbDao.get_cdplb_by_id(result_db, saveCdplbModel.onum)
							 | 
						||
| 
								 | 
							
								            if oldObj is None:
							 | 
						||
| 
								 | 
							
								                raise ServiceException(message='所改对象不存在')
							 | 
						||
| 
								 | 
							
								            saveObj = saveCdplbModel.model_dump(exclude_unset=True)
							 | 
						||
| 
								 | 
							
								            saveObj['update_by'] = current_user.user.user_name
							 | 
						||
| 
								 | 
							
								            saveObj['update_time'] = datetime.now()
							 | 
						||
| 
								 | 
							
								            await CdplbDao.update_cdplb(result_db, saveObj)
							 | 
						||
| 
								 | 
							
								        await result_db.commit()
							 | 
						||
| 
								 | 
							
								        return CrudResponseModel(is_success=True, message='操作成功')
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @classmethod
							 | 
						||
| 
								 | 
							
								    async def delete_cdplb(cls, db: AsyncSession, array: List[str]):
							 | 
						||
| 
								 | 
							
								        await CdplbDao.delete_cdplb(db, array)
							 | 
						||
| 
								 | 
							
								        await db.commit()
							 | 
						||
| 
								 | 
							
								        return CrudResponseModel(is_success=True, message='操作成功')
							 | 
						||
| 
								 | 
							
								
							 |