zhangnaiwen 2 rokov pred
rodič
commit
0d589e260c

+ 2 - 0
src/app/api/__init__.py

@@ -11,6 +11,7 @@ from app.api.permission import ns as permission
 from app.api.information import ns as information
 from app.api.device import ns as device
 from app.api.download import ns as download
+from app.api.strategy import ns as strategy
 
 api = Api(version='v1.0', title='operation_management_center', description='运营管理中心', doc='/api')
 
@@ -19,6 +20,7 @@ api.add_namespace(users)
 api.add_namespace(organization)
 api.add_namespace(role)
 api.add_namespace(permission)
+api.add_namespace(strategy)
 api.add_namespace(message)
 api.add_namespace(information)
 api.add_namespace(device)

+ 35 - 2
src/app/api/strategy.py

@@ -1,6 +1,39 @@
-from flask import request
+import json
+
+from flask import request, current_app, jsonify
 from flask_restx import Resource, Namespace, reqparse
+from sqlalchemy import select
+from sqlalchemy.orm import Session
 
-from app.defines import StatesCode
+from app.defines import StatesCode, Module, OperationType
+from app.modle.strategy import MeetingRoom
+from app.utils.save_log import save_log
+from app.utils.util import to_dict
+from config import Config
 
 ns = Namespace('strategy', description='策略管理接口')
+
+config = Config()
+
+
+@ns.route('')
+class StrategyList(Resource):
+
+    @ns.doc(description='获取策略配置')
+    def get(self):
+        """获取策略列表"""
+        try:
+            data = {}
+            with Session(current_app.engine) as session:
+
+                stmt = select(MeetingRoom.floor_id)
+                for floor in session.execute(stmt).scalars().all():
+                    stmt = select(MeetingRoom.name).where(MeetingRoom.floor_id == floor)
+                    data[floor] = session.execute(stmt).scalars().all()
+
+            save_log(request, Module.STRATEGY, OperationType.INQUIRE, StatesCode.SUCCESS)
+
+            return jsonify(code=StatesCode.SUCCESS, message='成功', data=data)
+        except Exception as e:
+            save_log(request, Module.STRATEGY, OperationType.INQUIRE, StatesCode.UNKNOWN_ERROR)
+            return jsonify(code=StatesCode.UNKNOWN_ERROR, message=str(e))

+ 3 - 2
src/app/defines/__init__.py

@@ -11,8 +11,9 @@ class Module:
     USER = '用户管理'
     ORGANIZATION = '组织管理'
     ROLE = '角色管理'
-    MESSAGE = '消息管理'
-    INFORMATION = '信息管理'
+    MESSAGE = '消息配置'
+    INFORMATION = '信息配置'
+    STRATEGY = '策略配置'
     LOG = '日志管理'
     DEVICE = '设备管理'
     DATA = '数据管理'

+ 24 - 0
src/app/modle/strategy.py

@@ -0,0 +1,24 @@
+from sqlalchemy import String, Column, Integer, JSON
+
+from app.modle import Base
+
+
+class MeetingRoom(Base):
+    """会议室表"""
+
+    __tablename__ = 'meeting_room'
+
+    id = Column(Integer, primary_key=True, autoincrement=True, nullable=False, unique=True, doc='id')
+    order_no = Column(String, nullable=True, unique=False, index=False, doc='排序号')
+    mr_no = Column(String, nullable=True, unique=False, index=False, doc='编号')
+    name = Column(String, nullable=True, unique=False, index=False, doc='会议室名称')
+    floor_id = Column(Integer, nullable=True, unique=False, index=False, doc='楼层')
+    type = Column(String, nullable=True, unique=False, index=False, doc='类型')
+    status = Column(String, nullable=True, unique=False, index=False, doc='状态')
+    open_time = Column(String, nullable=True, unique=False, index=False, doc='开放时间')
+    close_time = Column(String, nullable=True, unique=False, index=False, doc='关闭时间')
+    audit_time = Column(String, nullable=True, unique=False, index=False, doc='会议超过几小时需要审核')
+    limit_day = Column(String, nullable=True, unique=False, index=False, doc='限定可预约时间(天)')
+    is_del = Column(Integer, nullable=True, unique=False, index=False, doc='是否删除')
+    remark = Column(String, nullable=True, unique=False, index=False, doc='备注信息')
+    capacity = Column(Integer, nullable=True, unique=False, index=False, doc='容纳人数')