style: 使用ruff格式化日志管理模块,优化导入
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Text, BigInteger, Index
|
||||
from config.database import Base
|
||||
from datetime import datetime
|
||||
from sqlalchemy import BigInteger, Column, DateTime, Index, Integer, String
|
||||
from config.database import Base
|
||||
|
||||
|
||||
class SysLogininfor(Base):
|
||||
"""
|
||||
系统访问记录
|
||||
"""
|
||||
|
||||
__tablename__ = 'sys_logininfor'
|
||||
|
||||
info_id = Column(Integer, primary_key=True, autoincrement=True, comment='访问ID')
|
||||
@@ -15,7 +16,9 @@ class SysLogininfor(Base):
|
||||
login_location = Column(String(255, collation='utf8_general_ci'), nullable=True, default='', comment='登录地点')
|
||||
browser = Column(String(50, collation='utf8_general_ci'), nullable=True, default='', comment='浏览器类型')
|
||||
os = Column(String(50, collation='utf8_general_ci'), nullable=True, default='', comment='操作系统')
|
||||
status = Column(String(1, collation='utf8_general_ci'), nullable=True, default='0', comment='登录状态(0成功 1失败)')
|
||||
status = Column(
|
||||
String(1, collation='utf8_general_ci'), nullable=True, default='0', comment='登录状态(0成功 1失败)'
|
||||
)
|
||||
msg = Column(String(255, collation='utf8_general_ci'), nullable=True, default='', comment='提示消息')
|
||||
login_time = Column(DateTime, nullable=True, default=datetime.now(), comment='访问时间')
|
||||
|
||||
@@ -27,6 +30,7 @@ class SysOperLog(Base):
|
||||
"""
|
||||
操作日志记录
|
||||
"""
|
||||
|
||||
__tablename__ = 'sys_oper_log'
|
||||
|
||||
oper_id = Column(BigInteger, primary_key=True, autoincrement=True, comment='日志主键')
|
||||
|
@@ -1,22 +1,29 @@
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic.alias_generators import to_camel
|
||||
from typing import Union, Optional, List, Literal
|
||||
from datetime import datetime
|
||||
from module_admin.annotation.pydantic_annotation import as_query, as_form
|
||||
from typing import Literal, Optional
|
||||
from module_admin.annotation.pydantic_annotation import as_form, as_query
|
||||
|
||||
|
||||
class OperLogModel(BaseModel):
|
||||
"""
|
||||
操作日志表对应pydantic模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
||||
|
||||
oper_id: Optional[int] = Field(default=None, description='日志主键')
|
||||
title: Optional[str] = Field(default=None, description='模块标题')
|
||||
business_type: Optional[Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']] = Field(default=None, description='业务类型(0其它 1新增 2修改 3删除 4授权 5导出 6导入 7强退 8生成代码 9清空数据)')
|
||||
business_type: Optional[Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']] = (
|
||||
Field(
|
||||
default=None, description='业务类型(0其它 1新增 2修改 3删除 4授权 5导出 6导入 7强退 8生成代码 9清空数据)'
|
||||
)
|
||||
)
|
||||
method: Optional[str] = Field(default=None, description='方法名称')
|
||||
request_method: Optional[str] = Field(default=None, description='请求方式')
|
||||
operator_type: Optional[Literal[0, 1, 2]] = Field(default=None, description='操作类别(0其它 1后台用户 2手机端用户)')
|
||||
operator_type: Optional[Literal[0, 1, 2]] = Field(
|
||||
default=None, description='操作类别(0其它 1后台用户 2手机端用户)'
|
||||
)
|
||||
oper_name: Optional[str] = Field(default=None, description='操作人员')
|
||||
dept_name: Optional[str] = Field(default=None, description='部门名称')
|
||||
oper_url: Optional[str] = Field(default=None, description='请求URL')
|
||||
@@ -34,6 +41,7 @@ class LogininforModel(BaseModel):
|
||||
"""
|
||||
登录日志表对应pydantic模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
||||
|
||||
info_id: Optional[int] = Field(default=None, description='访问ID')
|
||||
@@ -51,8 +59,11 @@ class OperLogQueryModel(OperLogModel):
|
||||
"""
|
||||
操作日志管理不分页查询模型
|
||||
"""
|
||||
|
||||
order_by_column: Optional[str] = Field(default=None, description='排序的字段名称')
|
||||
is_asc: Optional[Literal['ascending', 'descending']] = Field(default=None, description='排序方式(ascending升序 descending降序)')
|
||||
is_asc: Optional[Literal['ascending', 'descending']] = Field(
|
||||
default=None, description='排序方式(ascending升序 descending降序)'
|
||||
)
|
||||
begin_time: Optional[str] = Field(default=None, description='开始时间')
|
||||
end_time: Optional[str] = Field(default=None, description='结束时间')
|
||||
|
||||
@@ -63,6 +74,7 @@ class OperLogPageQueryModel(OperLogQueryModel):
|
||||
"""
|
||||
操作日志管理分页查询模型
|
||||
"""
|
||||
|
||||
page_num: int = Field(default=1, description='当前页码')
|
||||
page_size: int = Field(default=10, description='每页记录数')
|
||||
|
||||
@@ -71,6 +83,7 @@ class DeleteOperLogModel(BaseModel):
|
||||
"""
|
||||
删除操作日志模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
|
||||
oper_ids: str = Field(description='需要删除的日志主键')
|
||||
@@ -80,19 +93,22 @@ class LoginLogQueryModel(LogininforModel):
|
||||
"""
|
||||
登录日志管理不分页查询模型
|
||||
"""
|
||||
|
||||
order_by_column: Optional[str] = Field(default=None, description='排序的字段名称')
|
||||
is_asc: Optional[Literal['ascending', 'descending']] = Field(default=None, description='排序方式(ascending升序 descending降序)')
|
||||
is_asc: Optional[Literal['ascending', 'descending']] = Field(
|
||||
default=None, description='排序方式(ascending升序 descending降序)'
|
||||
)
|
||||
begin_time: Optional[str] = Field(default=None, description='开始时间')
|
||||
end_time: Optional[str] = Field(default=None, description='结束时间')
|
||||
|
||||
|
||||
|
||||
@as_query
|
||||
@as_form
|
||||
class LoginLogPageQueryModel(LoginLogQueryModel):
|
||||
"""
|
||||
登录日志管理分页查询模型
|
||||
"""
|
||||
|
||||
page_num: int = Field(default=1, description='当前页码')
|
||||
page_size: int = Field(default=10, description='每页记录数')
|
||||
|
||||
@@ -101,6 +117,7 @@ class DeleteLoginLogModel(BaseModel):
|
||||
"""
|
||||
删除登录日志模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
|
||||
info_ids: str = Field(description='需要删除的访问ID')
|
||||
@@ -110,6 +127,7 @@ class UnlockUser(BaseModel):
|
||||
"""
|
||||
解锁用户模型
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(alias_generator=to_camel)
|
||||
|
||||
user_name: str = Field(description='用户名称')
|
||||
|
Reference in New Issue
Block a user