| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  | from datetime import datetime | 
					
						
							|  |  |  | from pydantic import BaseModel, Field | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  | from typing import List, Optional | 
					
						
							| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ------------------------------ | 
					
						
							|  |  |  | # 请求模型(前端传参校验) | 
					
						
							|  |  |  | # ------------------------------ | 
					
						
							|  |  |  | class SensitiveCreateRequest(BaseModel): | 
					
						
							|  |  |  |     """创建敏感信息记录请求模型""" | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  |     name: str = Field(..., max_length=255, description="敏感词内容(必填)") | 
					
						
							| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SensitiveUpdateRequest(BaseModel): | 
					
						
							|  |  |  |     """更新敏感信息记录请求模型""" | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  |     name: Optional[str] = Field(None, max_length=255, description="敏感词内容(可选修改)") | 
					
						
							| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # ------------------------------ | 
					
						
							|  |  |  | # 响应模型(后端返回数据) | 
					
						
							|  |  |  | # ------------------------------ | 
					
						
							|  |  |  | class SensitiveResponse(BaseModel): | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  |     """敏感信息单条记录响应模型""" | 
					
						
							|  |  |  |     id: int = Field(..., description="主键ID") | 
					
						
							|  |  |  |     name: str = Field(..., description="敏感词内容") | 
					
						
							| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  |     created_at: datetime = Field(..., description="记录创建时间") | 
					
						
							|  |  |  |     updated_at: datetime = Field(..., description="记录更新时间") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  |     # 支持从数据库查询结果(字典/对象)自动转换 | 
					
						
							| 
									
										
										
										
											2025-09-03 20:47:24 +08:00
										 |  |  |     model_config = {"from_attributes": True} | 
					
						
							| 
									
										
										
										
											2025-09-15 17:43:36 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SensitiveListResponse(BaseModel): | 
					
						
							|  |  |  |     """敏感信息分页列表响应模型(新增)""" | 
					
						
							|  |  |  |     total: int = Field(..., description="敏感词总记录数") | 
					
						
							|  |  |  |     sensitives: List[SensitiveResponse] = Field(..., description="当前页敏感词列表") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     model_config = {"from_attributes": True} |