Przeglądaj źródła

日志管理过滤条件修改

zhangnaiwen 2 lat temu
rodzic
commit
8dbf988ee5
3 zmienionych plików z 16 dodań i 10 usunięć
  1. 9 2
      requirements.txt
  2. 5 6
      src/app/api/log.py
  3. 2 2
      src/app/api/message.py

+ 9 - 2
requirements.txt

@@ -1,24 +1,31 @@
 aniso8601==9.0.1
+APScheduler==3.10.1
 attrs==22.2.0
 cffi==1.15.1
 click==8.1.3
 cryptography==39.0.2
 Flask==2.2.3
+Flask-APScheduler==1.12.4
 Flask-Cors==3.0.10
 flask-restx==1.1.0
 greenlet==2.0.2
 itsdangerous==2.1.2
 Jinja2==3.1.2
 jsonschema==4.17.3
-jwt==1.3.1
 MarkupSafe==2.1.2
+pika==1.3.1
 psycopg2==2.9.5
 pycparser==2.21
+PyJWT==2.6.0
 pyrsistent==0.19.3
+python-dateutil==2.8.2
 pytz==2022.7.1
-pyyaml
+pytz-deprecation-shim==0.1.0.post0
+PyYAML==6.0
 six==1.16.0
 SQLAlchemy==2.0.7
 SQLAlchemy-Utils==0.40.0
 typing_extensions==4.5.0
+tzdata==2022.7
+tzlocal==4.3
 Werkzeug==2.2.3

+ 5 - 6
src/app/api/log.py

@@ -43,16 +43,15 @@ class LogList(Resource):
             stmt = select(Log)
 
             if module:
-                stmt.where(Log.module == module)
+                stmt = stmt.where(Log.module == module)
             if name:
-                stmt.where(Log.operation_staff == name)
+                stmt = stmt.where(Log.operation_staff == name)
             if operation_type:
-                stmt.where(Log.operation_type == operation_type)
+                stmt = stmt.where(Log.operation_type == operation_type)
             if operation_status:
-                stmt.where(Log.operation_status == operation_status)
-
-            stmt.offset(page_size * (page - 1)).limit(page_size)
+                stmt = stmt.where(Log.operation_status == operation_status)
 
+            stmt = stmt.offset(page_size * (page - 1)).limit(page_size)
             results = session.execute(stmt).scalars().all()
 
         save_log(request, Module.LOG, OperationType.INQUIRE, StatesCode.SUCCESS)

+ 2 - 2
src/app/api/message.py

@@ -101,7 +101,7 @@ class MessageApi(Resource):
 
         staff_list = []
 
-        with Session(User) as session:
+        with Session(current_app.engine) as session:
             if staff == 'all':
                 stmt = select(User.user_name)
                 staff_list.extend(session.execute(stmt).scalars().all())
@@ -185,7 +185,7 @@ class MessageApi(Resource):
 
         staff_list = []
 
-        with Session(User) as session:
+        with Session(current_app.engine) as session:
             if staff == 'all':
                 stmt = select(User.user_name)
                 staff_list.extend(session.execute(stmt).scalars().all())