fred-admin 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fred_admin/__init__.py +91 -0
- fred_admin/common/AliyunSms.py +66 -0
- fred_admin/common/Blueprints.py +99 -0
- fred_admin/common/Email.py +23 -0
- fred_admin/common/Extensions.py +319 -0
- fred_admin/common/HandleExcetion.py +204 -0
- fred_admin/common/ImageVerification.py +117 -0
- fred_admin/common/IoTDBClient.py +698 -0
- fred_admin/common/PageSchema.py +65 -0
- fred_admin/common/Response.py +251 -0
- fred_admin/common/Route.py +390 -0
- fred_admin/common/RuntimeHook.py +111 -0
- fred_admin/common/SchedulerLog.py +277 -0
- fred_admin/common/Sqlacodegen.py +170 -0
- fred_admin/common/Swagger.py +77 -0
- fred_admin/common/SystemLog.py +80 -0
- fred_admin/common/Utils.py +1060 -0
- fred_admin/common/WechatLogin.py +97 -0
- fred_admin/common/__init__.py +3 -0
- fred_admin/config/Config.py +104 -0
- fred_admin/config/Logger.py +34 -0
- fred_admin/config/__init__.py +3 -0
- fred_admin/create_module.py +787 -0
- fred_admin/demo/app.py +6 -0
- fred_admin/demo/common/__init__.py +1 -0
- fred_admin/demo/common/config/Config.py +82 -0
- fred_admin/demo/common/config/README.md +8 -0
- fred_admin/demo/common/config/__init__.py +1 -0
- fred_admin/demo/common/config/__pycache__/Config.cpython-312.pyc +0 -0
- fred_admin/demo/common/config/__pycache__/__init__.cpython-312.pyc +0 -0
- fred_admin/demo/common/config/jwt_secret_key +1 -0
- fred_admin/demo/common/config/session_secret_key +1 -0
- fred_admin/demo/common/model/__pycache__/__init__.cpython-312.pyc +0 -0
- fred_admin/demo/common/model/__pycache__/model.cpython-312.pyc +0 -0
- fred_admin/demo/common/model/model.py +274 -0
- fred_admin/demo/demo_.gitignore +42 -0
- fred_admin/demo/modules/__init__.py +1 -0
- fred_admin/demo/modules/admin/README.md +38 -0
- fred_admin/demo/modules/admin/__init__.py +3 -0
- fred_admin/demo/modules/admin/backend/__init__.py +7 -0
- fred_admin/demo/modules/admin/backend/constant/RedisKey.py +10 -0
- fred_admin/demo/modules/admin/backend/controller/AdminAuthController.py +39 -0
- fred_admin/demo/modules/admin/backend/controller/AdminController.py +226 -0
- fred_admin/demo/modules/admin/backend/controller/ApiAuthController.py +93 -0
- fred_admin/demo/modules/admin/backend/controller/ButtonManageController.py +90 -0
- fred_admin/demo/modules/admin/backend/controller/FileController.py +28 -0
- fred_admin/demo/modules/admin/backend/controller/OrganizationController.py +218 -0
- fred_admin/demo/modules/admin/backend/controller/RoleController.py +143 -0
- fred_admin/demo/modules/admin/backend/controller/SystemController.py +112 -0
- fred_admin/demo/modules/admin/backend/controller/SystemLogController.py +63 -0
- fred_admin/demo/modules/admin/backend/controller/TableController.py +175 -0
- fred_admin/demo/modules/admin/backend/controller/__init__.py +55 -0
- fred_admin/demo/modules/admin/backend/schema/AdminSchema.py +356 -0
- fred_admin/demo/modules/admin/backend/schema/ApiAuthSchema.py +72 -0
- fred_admin/demo/modules/admin/backend/schema/AuthMenuSchema.py +79 -0
- fred_admin/demo/modules/admin/backend/schema/ButtonManageSchema.py +98 -0
- fred_admin/demo/modules/admin/backend/schema/OrganizationSchema.py +134 -0
- fred_admin/demo/modules/admin/backend/schema/RoleSchema.py +94 -0
- fred_admin/demo/modules/admin/backend/schema/SystemConfigSchema.py +115 -0
- fred_admin/demo/modules/admin/backend/schema/TableSchema.py +153 -0
- fred_admin/demo/modules/admin/backend/schema/UploadImg.py +35 -0
- fred_admin/demo/modules/admin/backend/schema/__init__.py +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/AdminSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/ApiAuthSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/AuthMenuSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/ButtonManageSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/OrganizationSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/RoleSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/SystemConfigSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/TableSchema.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/UploadImg.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/schema/__pycache__/__init__.cpython-312.pyc +0 -0
- fred_admin/demo/modules/admin/backend/service/AdminService.py +377 -0
- fred_admin/demo/modules/admin/backend/service/ApiAuthService.py +237 -0
- fred_admin/demo/modules/admin/backend/service/AuthButtonsService.py +155 -0
- fred_admin/demo/modules/admin/backend/service/AuthMenuService.py +265 -0
- fred_admin/demo/modules/admin/backend/service/ButtonManageService.py +386 -0
- fred_admin/demo/modules/admin/backend/service/ButtonManageService.py.broken +113 -0
- fred_admin/demo/modules/admin/backend/service/FileService.py +33 -0
- fred_admin/demo/modules/admin/backend/service/OrganizationService.py +465 -0
- fred_admin/demo/modules/admin/backend/service/RoleService.py +445 -0
- fred_admin/demo/modules/admin/backend/service/SystemConfigService.py +89 -0
- fred_admin/demo/modules/admin/backend/service/SystemLogService.py +142 -0
- fred_admin/demo/modules/admin/backend/service/TableService.py +978 -0
- fred_admin/demo/modules/admin/backend/service/__init__.py +1 -0
- fred_admin/demo/modules/admin/backend/sql/app.db +0 -0
- fred_admin/demo/modules/admin/backend/sql/fred.sql +3780 -0
- fred_admin/demo/modules/admin/frontend/LICENSE +21 -0
- fred_admin/demo/modules/admin/frontend/build/getEnv.ts +46 -0
- fred_admin/demo/modules/admin/frontend/build/plugins.ts +118 -0
- fred_admin/demo/modules/admin/frontend/build/proxy.ts +30 -0
- fred_admin/demo/modules/admin/frontend/commitlint.config.cjs +162 -0
- fred_admin/demo/modules/admin/frontend/demo_editorconfig +15 -0
- fred_admin/demo/modules/admin/frontend/demo_env +15 -0
- fred_admin/demo/modules/admin/frontend/demo_env.development +21 -0
- fred_admin/demo/modules/admin/frontend/demo_env.production +25 -0
- fred_admin/demo/modules/admin/frontend/demo_eslintignore +15 -0
- fred_admin/demo/modules/admin/frontend/demo_eslintrc.cjs +61 -0
- fred_admin/demo/modules/admin/frontend/demo_gitignore +27 -0
- fred_admin/demo/modules/admin/frontend/demo_prettierignore +9 -0
- fred_admin/demo/modules/admin/frontend/demo_prettierrc.cjs +41 -0
- fred_admin/demo/modules/admin/frontend/demo_stylelintignore +4 -0
- fred_admin/demo/modules/admin/frontend/demo_stylelintrc.cjs +40 -0
- fred_admin/demo/modules/admin/frontend/index.html +105 -0
- fred_admin/demo/modules/admin/frontend/lint-staged.config.cjs +8 -0
- fred_admin/demo/modules/admin/frontend/package.json +129 -0
- fred_admin/demo/modules/admin/frontend/pnpm-lock.yaml +11150 -0
- fred_admin/demo/modules/admin/frontend/postcss.config.cjs +5 -0
- fred_admin/demo/modules/admin/frontend/public/logo.png +0 -0
- fred_admin/demo/modules/admin/frontend/public/vue.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/App.vue +44 -0
- fred_admin/demo/modules/admin/frontend/src/api/config/servicePort.ts +2 -0
- fred_admin/demo/modules/admin/frontend/src/api/helper/axiosCancel.ts +57 -0
- fred_admin/demo/modules/admin/frontend/src/api/helper/checkStatus.ts +43 -0
- fred_admin/demo/modules/admin/frontend/src/api/index.ts +167 -0
- fred_admin/demo/modules/admin/frontend/src/api/interface/index.ts +179 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/adminModel.ts +135 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/apiAuthModel.ts +72 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/index.ts +24 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/loginModel.ts +79 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/roleModel.ts +68 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/storeModel.ts +80 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/systemModel.ts +162 -0
- fred_admin/demo/modules/admin/frontend/src/api/model/uploadModel.ts +153 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/admin.ts +76 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/apiAuth.ts +53 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/buttonManage.ts +119 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/dataBase.ts +60 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/login.ts +54 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/organization.ts +123 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/role.ts +61 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/store.ts +303 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/system.ts +125 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/upload.ts +132 -0
- fred_admin/demo/modules/admin/frontend/src/api/modules/user.ts +63 -0
- fred_admin/demo/modules/admin/frontend/src/assets/fonts/DIN.otf +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/fonts/MetroDF.ttf +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/fonts/YouSheBiaoTiHei.ttf +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/fonts/font.scss +14 -0
- fred_admin/demo/modules/admin/frontend/src/assets/iconfont/iconfont.scss +51 -0
- fred_admin/demo/modules/admin/frontend/src/assets/iconfont/iconfont.ttf +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingdaoyu.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingdiqiu.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingditu.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingfanchuan.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingfeiji.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxinglvhangriji.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingtianqiyubao.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingxiangjipaizhao.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingxiarilengyin.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingyoulun.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/icons/xianxingzijiayou.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/403.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/404.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/500.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/avatar.gif +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_bg.svg +33 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left1.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left2.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left3.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left4.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/login_left5.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/logo.svg +1 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/msg01.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/msg02.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/msg03.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/msg04.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/msg05.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/notData.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/images/welcome.png +0 -0
- fred_admin/demo/modules/admin/frontend/src/assets/json/authButtonList.json +8 -0
- fred_admin/demo/modules/admin/frontend/src/assets/json/authMenuList.json +1075 -0
- fred_admin/demo/modules/admin/frontend/src/assets/mock/Easy-Mock-API.zip +0 -0
- fred_admin/demo/modules/admin/frontend/src/components/ECharts/config/index.ts +72 -0
- fred_admin/demo/modules/admin/frontend/src/components/ECharts/index.vue +104 -0
- fred_admin/demo/modules/admin/frontend/src/components/ErrorMessage/403.vue +19 -0
- fred_admin/demo/modules/admin/frontend/src/components/ErrorMessage/404.vue +19 -0
- fred_admin/demo/modules/admin/frontend/src/components/ErrorMessage/500.vue +19 -0
- fred_admin/demo/modules/admin/frontend/src/components/ErrorMessage/index.scss +32 -0
- fred_admin/demo/modules/admin/frontend/src/components/Grid/components/GridItem.vue +68 -0
- fred_admin/demo/modules/admin/frontend/src/components/Grid/index.vue +167 -0
- fred_admin/demo/modules/admin/frontend/src/components/Grid/interface/index.ts +6 -0
- fred_admin/demo/modules/admin/frontend/src/components/ImageCaptcha/index.vue +71 -0
- fred_admin/demo/modules/admin/frontend/src/components/ImportExcel/index.scss +3 -0
- fred_admin/demo/modules/admin/frontend/src/components/ImportExcel/index.vue +151 -0
- fred_admin/demo/modules/admin/frontend/src/components/JsonViewer/index.vue +249 -0
- fred_admin/demo/modules/admin/frontend/src/components/Loading/fullScreen.ts +45 -0
- fred_admin/demo/modules/admin/frontend/src/components/Loading/index.scss +67 -0
- fred_admin/demo/modules/admin/frontend/src/components/Loading/index.vue +13 -0
- fred_admin/demo/modules/admin/frontend/src/components/ProTable/components/ColSetting.vue +45 -0
- fred_admin/demo/modules/admin/frontend/src/components/ProTable/components/Pagination.vue +101 -0
- fred_admin/demo/modules/admin/frontend/src/components/ProTable/components/TableColumn.vue +58 -0
- fred_admin/demo/modules/admin/frontend/src/components/ProTable/index.vue +348 -0
- fred_admin/demo/modules/admin/frontend/src/components/ProTable/interface/index.ts +87 -0
- fred_admin/demo/modules/admin/frontend/src/components/SearchForm/components/SearchFormItem.vue +96 -0
- fred_admin/demo/modules/admin/frontend/src/components/SearchForm/index.vue +98 -0
- fred_admin/demo/modules/admin/frontend/src/components/SelectFilter/index.scss +63 -0
- fred_admin/demo/modules/admin/frontend/src/components/SelectFilter/index.vue +110 -0
- fred_admin/demo/modules/admin/frontend/src/components/SelectIcon/index.scss +39 -0
- fred_admin/demo/modules/admin/frontend/src/components/SelectIcon/index.vue +90 -0
- fred_admin/demo/modules/admin/frontend/src/components/StoreFilter/index.vue +356 -0
- fred_admin/demo/modules/admin/frontend/src/components/SvgIcon/index.vue +22 -0
- fred_admin/demo/modules/admin/frontend/src/components/SwitchDark/index.vue +12 -0
- fred_admin/demo/modules/admin/frontend/src/components/TreeFilter/index.scss +44 -0
- fred_admin/demo/modules/admin/frontend/src/components/TreeFilter/index.vue +165 -0
- fred_admin/demo/modules/admin/frontend/src/components/Upload/Img.vue +304 -0
- fred_admin/demo/modules/admin/frontend/src/components/Upload/Imgs.vue +316 -0
- fred_admin/demo/modules/admin/frontend/src/components/WangEditor/index.scss +28 -0
- fred_admin/demo/modules/admin/frontend/src/components/WangEditor/index.vue +154 -0
- fred_admin/demo/modules/admin/frontend/src/config/amapMap.ts +11 -0
- fred_admin/demo/modules/admin/frontend/src/config/index.ts +16 -0
- fred_admin/demo/modules/admin/frontend/src/config/nprogress.ts +12 -0
- fred_admin/demo/modules/admin/frontend/src/directives/index.ts +28 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/auth.ts +26 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/copy.ts +37 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/debounce.ts +31 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/draggable.ts +49 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/longpress.ts +49 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/throttle.ts +41 -0
- fred_admin/demo/modules/admin/frontend/src/directives/modules/waterMarker.ts +36 -0
- fred_admin/demo/modules/admin/frontend/src/enums/httpEnum.ts +35 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/interface/index.ts +32 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useAuthButtons.ts +22 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useDownload.ts +42 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useHandleData.ts +41 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useI18n.ts +51 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useOnline.ts +31 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useSelection.ts +34 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useTable.ts +150 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useTheme.ts +111 -0
- fred_admin/demo/modules/admin/frontend/src/hooks/useTime.ts +38 -0
- fred_admin/demo/modules/admin/frontend/src/languages/index.ts +32 -0
- fred_admin/demo/modules/admin/frontend/src/languages/modules/en.ts +978 -0
- fred_admin/demo/modules/admin/frontend/src/languages/modules/zh.ts +996 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutClassic/index.scss +60 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutClassic/index.vue +62 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutColumns/index.scss +95 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutColumns/index.vue +103 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutTransverse/index.scss +60 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutTransverse/index.vue +61 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutVertical/index.scss +48 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/LayoutVertical/index.vue +56 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Footer/index.scss +11 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Footer/index.vue +9 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/ToolBarLeft.vue +23 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/ToolBarRight.vue +51 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/AssemblySize.vue +37 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/Avatar.vue +79 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/Breadcrumb.vue +122 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/CollapseIcon.vue +21 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/Fullscreen.vue +25 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/InfoDialog.vue +22 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/Language.vue +38 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/Message.vue +109 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/PasswordDialog.vue +81 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/SearchMenu.vue +183 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Header/components/ThemeSetting.vue +12 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Main/components/Maximize.vue +39 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Main/index.scss +10 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Main/index.vue +88 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Menu/SubMenu.vue +85 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Tabs/components/MoreButton.vue +85 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Tabs/index.scss +69 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/Tabs/index.vue +115 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/ThemeDrawer/index.scss +137 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/components/ThemeDrawer/index.vue +191 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/index.vue +42 -0
- fred_admin/demo/modules/admin/frontend/src/layouts/indexAsync.vue +46 -0
- fred_admin/demo/modules/admin/frontend/src/main.ts +45 -0
- fred_admin/demo/modules/admin/frontend/src/routers/index.ts +106 -0
- fred_admin/demo/modules/admin/frontend/src/routers/modules/dynamicRouter.ts +99 -0
- fred_admin/demo/modules/admin/frontend/src/routers/modules/staticRouter.ts +63 -0
- fred_admin/demo/modules/admin/frontend/src/stores/helper/persist.ts +19 -0
- fred_admin/demo/modules/admin/frontend/src/stores/index.ts +8 -0
- fred_admin/demo/modules/admin/frontend/src/stores/interface/index.ts +63 -0
- fred_admin/demo/modules/admin/frontend/src/stores/modules/auth.ts +50 -0
- fred_admin/demo/modules/admin/frontend/src/stores/modules/global.ts +55 -0
- fred_admin/demo/modules/admin/frontend/src/stores/modules/keepAlive.ts +25 -0
- fred_admin/demo/modules/admin/frontend/src/stores/modules/tabs.ts +78 -0
- fred_admin/demo/modules/admin/frontend/src/stores/modules/user.ts +23 -0
- fred_admin/demo/modules/admin/frontend/src/styles/common.scss +129 -0
- fred_admin/demo/modules/admin/frontend/src/styles/element-dark.scss +28 -0
- fred_admin/demo/modules/admin/frontend/src/styles/element.scss +264 -0
- fred_admin/demo/modules/admin/frontend/src/styles/modules/annotation.scss +746 -0
- fred_admin/demo/modules/admin/frontend/src/styles/modules/assembly.scss +714 -0
- fred_admin/demo/modules/admin/frontend/src/styles/modules/device-manager.scss +659 -0
- fred_admin/demo/modules/admin/frontend/src/styles/modules/directives.scss +381 -0
- fred_admin/demo/modules/admin/frontend/src/styles/reset.scss +143 -0
- fred_admin/demo/modules/admin/frontend/src/styles/table-optimization.scss +242 -0
- fred_admin/demo/modules/admin/frontend/src/styles/theme/aside.ts +16 -0
- fred_admin/demo/modules/admin/frontend/src/styles/theme/header.ts +25 -0
- fred_admin/demo/modules/admin/frontend/src/styles/theme/menu.ts +31 -0
- fred_admin/demo/modules/admin/frontend/src/styles/var.scss +2 -0
- fred_admin/demo/modules/admin/frontend/src/typings/global.d.ts +74 -0
- fred_admin/demo/modules/admin/frontend/src/typings/utils.d.ts +17 -0
- fred_admin/demo/modules/admin/frontend/src/typings/window.d.ts +8 -0
- fred_admin/demo/modules/admin/frontend/src/utils/color.ts +59 -0
- fred_admin/demo/modules/admin/frontend/src/utils/dict.ts +17 -0
- fred_admin/demo/modules/admin/frontend/src/utils/eleValidate.ts +14 -0
- fred_admin/demo/modules/admin/frontend/src/utils/errorHandler.ts +28 -0
- fred_admin/demo/modules/admin/frontend/src/utils/index.ts +327 -0
- fred_admin/demo/modules/admin/frontend/src/utils/is/index.ts +125 -0
- fred_admin/demo/modules/admin/frontend/src/utils/mittBus.ts +5 -0
- fred_admin/demo/modules/admin/frontend/src/utils/svg.ts +13 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/fieldType/components/FieldTypeDrawer.vue +89 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/fieldType/index.vue +99 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/tableManage/components/DataBaseDrawer.vue +254 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/tableManage/components/IndexDrawer.vue +226 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/tableManage/components/TableDataDrawer.vue +136 -0
- fred_admin/demo/modules/admin/frontend/src/views/dataBase/tableManage/index.vue +234 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/columnChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/columnChart/index.vue +139 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/lineChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/lineChart/index.vue +123 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/nestedChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/nestedChart/index.vue +97 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/pieChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/pieChart/index.vue +68 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/radarChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/radarChart/index.vue +56 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/waterChart/index.scss +0 -0
- fred_admin/demo/modules/admin/frontend/src/views/echarts/waterChart/index.vue +298 -0
- fred_admin/demo/modules/admin/frontend/src/views/home/index.scss +12 -0
- fred_admin/demo/modules/admin/frontend/src/views/home/index.vue +11 -0
- fred_admin/demo/modules/admin/frontend/src/views/login/components/LoginForm.vue +147 -0
- fred_admin/demo/modules/admin/frontend/src/views/login/index.scss +83 -0
- fred_admin/demo/modules/admin/frontend/src/views/login/index.vue +27 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/complexProTable/index.vue +176 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/components/UserDrawer.vue +152 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/document/index.vue +13 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/treeProTable/index.vue +129 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/useProTable/detail.vue +12 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/useProTable/index.vue +258 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/useSelectFilter/index.vue +184 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/useTreeFilter/detail.vue +12 -0
- fred_admin/demo/modules/admin/frontend/src/views/proTable/useTreeFilter/index.vue +147 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/accountManage/index.vue +244 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/apiAuth/components/ApiDrawer.vue +114 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/apiAuth/components/TokenDrawer.vue +160 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/apiAuth/index.vue +354 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/buttonManage/components/ButtonDrawer.vue +460 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/buttonManage/index.vue +426 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/configManage/components/ConfigDrawer.vue +106 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/configManage/index.vue +116 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/departmentManage/index.vue +7 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/dictManage/index.vue +7 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/menuManage/components/MenuDrawer.vue +262 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/menuManage/index.vue +310 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/organizationManage/components/CompanyDrawer.vue +72 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/organizationManage/components/DepartmentDrawer.vue +120 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/organizationManage/components/TeamDrawer.vue +162 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/organizationManage/components/TeamMemberDrawer.vue +243 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/organizationManage/index.vue +414 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/roleManage/components/RoleButtonDrawer.vue +587 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/roleManage/components/RoleDrawer.vue +77 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/roleManage/components/RoleMenuDrawer.vue +236 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/roleManage/components/RoleUserDrawer.vue +125 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/roleManage/index.vue +143 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/systemLog/components/SystemLogDrawer.vue +207 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/systemLog/index.vue +219 -0
- fred_admin/demo/modules/admin/frontend/src/views/system/timingTask/index.vue +7 -0
- fred_admin/demo/modules/admin/frontend/src/vite-env.d.ts +7 -0
- fred_admin/demo/modules/admin/frontend/tsconfig.json +42 -0
- fred_admin/demo/modules/admin/frontend/vite.config.ts +91 -0
- fred_admin/demo/modules/admin/frontend//321/205/320/231/320/235/321/207/320/273/320/277/321/204/342/225/227/320/263/321/207/320/260/320/221/321/210/320/277/342/224/244/321/206/320/250/320/236.md +100 -0
- fred_admin/demo/requirements.txt +1 -0
- fred_admin/fonts/NotoSansSC-VariableFont_wght.ttf +0 -0
- fred_admin/install_hook.py +1633 -0
- fred_admin/setup.py +18 -0
- fred_admin-1.0.0.dist-info/METADATA +97 -0
- fred_admin-1.0.0.dist-info/RECORD +376 -0
- fred_admin-1.0.0.dist-info/WHEEL +5 -0
- fred_admin-1.0.0.dist-info/entry_points.txt +3 -0
- fred_admin-1.0.0.dist-info/licenses/LICENSE +21 -0
- fred_admin-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
from marshmallow import Schema, fields
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
* @Author:PyCharm - yougangchen
|
|
6
|
+
* @Package:PageSchema
|
|
7
|
+
* @Project:fred-frame
|
|
8
|
+
* @name:PageSchema
|
|
9
|
+
* @Date:2025/7/2 11:33 - 星期三
|
|
10
|
+
* @Filename:PageSchema
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PageSchema(Schema):
|
|
16
|
+
"""
|
|
17
|
+
@desc : 公共分页参数,支持泛型和嵌套
|
|
18
|
+
"""
|
|
19
|
+
total = fields.Int(metadata={'description': '总数'})
|
|
20
|
+
pageNum = fields.Int(metadata={'description': '页码'})
|
|
21
|
+
pageSize = fields.Int(metadata={'description': '每页数量'})
|
|
22
|
+
|
|
23
|
+
def __init__(self, item_schema=None, *args, **kwargs):
|
|
24
|
+
super().__init__(*args, **kwargs)
|
|
25
|
+
if item_schema is not None:
|
|
26
|
+
# 支持传入schema类或实例
|
|
27
|
+
if isinstance(item_schema, type) and issubclass(item_schema, Schema):
|
|
28
|
+
self.declared_fields['records'] = fields.List(fields.Nested(item_schema), metadata={'description': '列表'})
|
|
29
|
+
elif isinstance(item_schema, Schema):
|
|
30
|
+
self.declared_fields['records'] = fields.List(fields.Nested(item_schema.__class__), metadata={'description': '列表'})
|
|
31
|
+
else:
|
|
32
|
+
raise ValueError('item_schema must be a marshmallow.Schema subclass or instance')
|
|
33
|
+
else:
|
|
34
|
+
self.declared_fields['records'] = fields.List(fields.Dict(), metadata={'description': '列表'})
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def PageSchemaFactory(item_schema, custom_name=None):
|
|
38
|
+
# 获取 item_schema 的名称用于生成唯一的 schema 名称
|
|
39
|
+
if custom_name:
|
|
40
|
+
schema_name = custom_name
|
|
41
|
+
else:
|
|
42
|
+
if hasattr(item_schema, '__name__'):
|
|
43
|
+
base_name = item_schema.__name__
|
|
44
|
+
elif hasattr(item_schema, '__class__'):
|
|
45
|
+
base_name = item_schema.__class__.__name__
|
|
46
|
+
else:
|
|
47
|
+
base_name = "Item"
|
|
48
|
+
|
|
49
|
+
schema_name = f"{base_name}Page"
|
|
50
|
+
|
|
51
|
+
# 动态创建带有唯一名称的 schema 类
|
|
52
|
+
class Meta:
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
PageSchemaClass = type(
|
|
56
|
+
schema_name, # 类名
|
|
57
|
+
(PageSchema,), # 基类
|
|
58
|
+
{
|
|
59
|
+
'records': fields.List(fields.Nested(item_schema), metadata={'description': '列表'}),
|
|
60
|
+
'Meta': Meta,
|
|
61
|
+
'__module__': item_schema.__module__ if hasattr(item_schema, '__module__') else __name__
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
return PageSchemaClass
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
"""
|
|
2
|
+
* @Author:cyg
|
|
3
|
+
* @Package:response
|
|
4
|
+
* @Project:Default (Template) Project
|
|
5
|
+
* @name:response
|
|
6
|
+
* @Date:2024/9/26 16:36
|
|
7
|
+
* @Filename:response
|
|
8
|
+
"""
|
|
9
|
+
import http
|
|
10
|
+
import json
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
from flask import request, jsonify, current_app, g
|
|
14
|
+
from marshmallow import Schema, fields
|
|
15
|
+
|
|
16
|
+
from fred_admin.common.Utils import Utils
|
|
17
|
+
from fred_admin.common.SystemLog import SystemLog
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _format_validation_errors(errors, prefix=""):
|
|
21
|
+
"""将 Marshmallow / webargs 的 errors 结构转为可读字符串,供 message 展示。"""
|
|
22
|
+
if errors is None:
|
|
23
|
+
return ""
|
|
24
|
+
if isinstance(errors, dict):
|
|
25
|
+
parts = []
|
|
26
|
+
for key, value in errors.items():
|
|
27
|
+
path = f"{prefix}.{key}" if prefix else str(key)
|
|
28
|
+
if isinstance(value, list):
|
|
29
|
+
for item in value:
|
|
30
|
+
if isinstance(item, str):
|
|
31
|
+
parts.append(f"{path}: {item}")
|
|
32
|
+
elif isinstance(item, dict):
|
|
33
|
+
sub = _format_validation_errors(item, path)
|
|
34
|
+
if sub:
|
|
35
|
+
parts.append(sub)
|
|
36
|
+
else:
|
|
37
|
+
parts.append(f"{path}: {item}")
|
|
38
|
+
elif isinstance(value, dict):
|
|
39
|
+
sub = _format_validation_errors(value, path)
|
|
40
|
+
if sub:
|
|
41
|
+
parts.append(sub)
|
|
42
|
+
else:
|
|
43
|
+
parts.append(f"{path}: {value}")
|
|
44
|
+
return "; ".join(parts)
|
|
45
|
+
if isinstance(errors, list):
|
|
46
|
+
return "; ".join(str(x) for x in errors)
|
|
47
|
+
return str(errors)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Response(Schema):
|
|
51
|
+
code = fields.Int(load_default=200, metadata={'description': '状态码'})
|
|
52
|
+
data = fields.Raw(load_default=None, metadata={'description': '返回数据'})
|
|
53
|
+
message = fields.Str(load_default='', metadata={'description': '说明消息'})
|
|
54
|
+
execution_time = fields.Float(load_default=0.0, metadata={'description': '执行时间'})
|
|
55
|
+
|
|
56
|
+
def format_response(self, json_data, code):
|
|
57
|
+
"""
|
|
58
|
+
格式化输出
|
|
59
|
+
"""
|
|
60
|
+
return_data = Response().dump(json_data)
|
|
61
|
+
return_data['code'] = code
|
|
62
|
+
if code == http.HTTPStatus.OK:
|
|
63
|
+
encrypt = current_app.config.get('ENCRYPT_DATA', False)
|
|
64
|
+
the_data = json_data
|
|
65
|
+
# 检查 json_data 是否为字典类型
|
|
66
|
+
if isinstance(json_data, dict):
|
|
67
|
+
if 'message' in json_data:
|
|
68
|
+
return_data['message'] = json_data['message']
|
|
69
|
+
# 如果只有 message,则 data 设置为空字符串
|
|
70
|
+
if len(json_data) == 1:
|
|
71
|
+
the_data = ""
|
|
72
|
+
else:
|
|
73
|
+
if encrypt:
|
|
74
|
+
the_data = Utils.fernet_encrypt(json.dumps(the_data))
|
|
75
|
+
else:
|
|
76
|
+
if encrypt:
|
|
77
|
+
the_data = Utils.fernet_encrypt(json.dumps(json_data))
|
|
78
|
+
else:
|
|
79
|
+
# 如果 json_data 不是字典(如整数、字符串等),直接作为 data
|
|
80
|
+
if encrypt:
|
|
81
|
+
the_data = Utils.fernet_encrypt(json.dumps(json_data))
|
|
82
|
+
return_data['data'] = the_data
|
|
83
|
+
return return_data
|
|
84
|
+
return return_data
|
|
85
|
+
|
|
86
|
+
def custom_response(self, app):
|
|
87
|
+
"""
|
|
88
|
+
自定义输出返回格式
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
@app.before_request # 新增before_request钩子
|
|
92
|
+
def record_start_time():
|
|
93
|
+
g.start_time = time.time()
|
|
94
|
+
# 保存请求数据用于日志记录
|
|
95
|
+
g.request_body = None
|
|
96
|
+
try:
|
|
97
|
+
if request.is_json:
|
|
98
|
+
g.request_body = request.get_json()
|
|
99
|
+
elif request.form:
|
|
100
|
+
g.request_body = dict(request.form)
|
|
101
|
+
elif request.args:
|
|
102
|
+
g.request_body = dict(request.args)
|
|
103
|
+
except:
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
@app.after_request
|
|
107
|
+
def after_request(response):
|
|
108
|
+
# 检查是否是swagger请求
|
|
109
|
+
|
|
110
|
+
swagger_ui_path = app.config.get('OPENAPI_URL_PREFIX', '') + app.config.get('OPENAPI_SWAGGER_UI_PATH', '')
|
|
111
|
+
if request.path.startswith(swagger_ui_path) or request.path.startswith('/openapi'):
|
|
112
|
+
return response
|
|
113
|
+
# 检查响应是否为JSON类型且非直接文件传输(处理 send_file/send_from_directory 的情况)
|
|
114
|
+
if response.mimetype == 'application/json' and not response.direct_passthrough:
|
|
115
|
+
# 尝试将响应转换为字典
|
|
116
|
+
json_response = response.get_json()
|
|
117
|
+
# 格式化响应
|
|
118
|
+
code = response.status_code
|
|
119
|
+
# 如果 json_response 为 None,设置为空字典
|
|
120
|
+
if json_response is None:
|
|
121
|
+
json_response = {}
|
|
122
|
+
# 非 200:优先用 errors 生成 message(flask-smorest 仅返回 errors、不填 message)
|
|
123
|
+
if code != http.HTTPStatus.OK:
|
|
124
|
+
# 兼容 flask_jwt_extended 等库使用 'msg' 而非 'message'
|
|
125
|
+
if 'message' not in json_response and 'msg' in json_response:
|
|
126
|
+
json_response['message'] = json_response.pop('msg')
|
|
127
|
+
msg = (json_response.get('message') or '').strip()
|
|
128
|
+
if not msg and json_response.get('errors') is not None:
|
|
129
|
+
detail = _format_validation_errors(json_response['errors'])
|
|
130
|
+
json_response['message'] = (
|
|
131
|
+
f'参数校验错误:{detail}' if detail else '参数校验错误'
|
|
132
|
+
)
|
|
133
|
+
elif 'message' not in json_response:
|
|
134
|
+
json_response['message'] = ''
|
|
135
|
+
serialized_response = self.format_response(json_response, code)
|
|
136
|
+
execution_time = time.time() - g.get('start_time', time.time())
|
|
137
|
+
if app.debug:
|
|
138
|
+
serialized_response['execution_time'] = round(execution_time, 5)
|
|
139
|
+
else:
|
|
140
|
+
#先判断execution_time是否存在在移除
|
|
141
|
+
if 'execution_time' in serialized_response:
|
|
142
|
+
del (serialized_response['execution_time'])
|
|
143
|
+
response = jsonify(serialized_response)
|
|
144
|
+
response.status_code = code
|
|
145
|
+
if app.debug:
|
|
146
|
+
response.headers.add('Access-Control-Allow-Origin', '*')
|
|
147
|
+
|
|
148
|
+
# 记录系统日志(所有接口)
|
|
149
|
+
try:
|
|
150
|
+
from flask import session
|
|
151
|
+
from fred_admin.common.Utils import Utils
|
|
152
|
+
# 加载模型模块
|
|
153
|
+
Utils.import_project_models('Admin')
|
|
154
|
+
# 直接导入模型
|
|
155
|
+
from model.model import Admin
|
|
156
|
+
|
|
157
|
+
user_id = 0
|
|
158
|
+
username = ''
|
|
159
|
+
|
|
160
|
+
# 根据不同的模块获取用户信息
|
|
161
|
+
if request.path.startswith('/admin'):
|
|
162
|
+
# admin 模块:从 session['admin_user_info'] 获取
|
|
163
|
+
admin_info = session.get('admin_user_info', None)
|
|
164
|
+
if admin_info:
|
|
165
|
+
if isinstance(admin_info, dict):
|
|
166
|
+
user_id = admin_info.get('id', 0)
|
|
167
|
+
username = admin_info.get('username', '')
|
|
168
|
+
else:
|
|
169
|
+
user_id = getattr(admin_info, 'id', 0)
|
|
170
|
+
username = getattr(admin_info, 'username', '')
|
|
171
|
+
else:
|
|
172
|
+
# 其他模块:从 session 中获取用户ID,然后查询用户名
|
|
173
|
+
# 尝试从不同模块的 session key 获取用户ID
|
|
174
|
+
user_info = None
|
|
175
|
+
if request.path.startswith('/server'):
|
|
176
|
+
user_info = session.get('server_user_info', None)
|
|
177
|
+
elif request.path.startswith('/terminal'):
|
|
178
|
+
user_info = session.get('terminal_user_info', None)
|
|
179
|
+
elif request.path.startswith('/algorithm'):
|
|
180
|
+
user_info = session.get('algorithm_user_info', None)
|
|
181
|
+
elif request.path.startswith('/demo'):
|
|
182
|
+
user_info = session.get('demo_user_info', None)
|
|
183
|
+
else:
|
|
184
|
+
# 尝试从其他可能的 session key 获取
|
|
185
|
+
for key in session.keys():
|
|
186
|
+
if key.endswith('_user_info'):
|
|
187
|
+
user_info = session.get(key, None)
|
|
188
|
+
break
|
|
189
|
+
|
|
190
|
+
# 转换为整数
|
|
191
|
+
if user_info is not None:
|
|
192
|
+
try:
|
|
193
|
+
user_id = int(user_info)
|
|
194
|
+
except (ValueError, TypeError):
|
|
195
|
+
user_id = 0
|
|
196
|
+
|
|
197
|
+
# 如果有用户ID,查询用户名
|
|
198
|
+
if user_id > 0:
|
|
199
|
+
try:
|
|
200
|
+
admin = Admin.query.filter_by(id=user_id).first()
|
|
201
|
+
if admin:
|
|
202
|
+
username = admin.username or ''
|
|
203
|
+
except:
|
|
204
|
+
username = ''
|
|
205
|
+
|
|
206
|
+
# 获取请求数据
|
|
207
|
+
request_body = g.get('request_body')
|
|
208
|
+
# 获取返回数据
|
|
209
|
+
response_body = serialized_response
|
|
210
|
+
# 调用日志记录方法
|
|
211
|
+
SystemLog.save_sys_log(
|
|
212
|
+
user_id=user_id,
|
|
213
|
+
api=request.path,
|
|
214
|
+
method=request.method,
|
|
215
|
+
code=code,
|
|
216
|
+
username=username,
|
|
217
|
+
request_body=request_body,
|
|
218
|
+
response_body=response_body
|
|
219
|
+
)
|
|
220
|
+
except Exception as e:
|
|
221
|
+
# 记录日志失败不影响主流程
|
|
222
|
+
pass
|
|
223
|
+
return response
|
|
224
|
+
|
|
225
|
+
def swagger_responses(self, spec, schemas):
|
|
226
|
+
"""
|
|
227
|
+
定义swagger默认显示的格式
|
|
228
|
+
"""
|
|
229
|
+
for path in spec['paths'].values():
|
|
230
|
+
for method in path.values():
|
|
231
|
+
if type(method) is not dict:
|
|
232
|
+
continue
|
|
233
|
+
responses = method.setdefault('responses', {})
|
|
234
|
+
for key, value in responses.items():
|
|
235
|
+
if key == '200':
|
|
236
|
+
continue
|
|
237
|
+
try:
|
|
238
|
+
code = int(key)
|
|
239
|
+
except ValueError:
|
|
240
|
+
# 处理无法转换的情况,例如赋值一个默认值或者记录日志
|
|
241
|
+
code = 200
|
|
242
|
+
responses[key] = {
|
|
243
|
+
'content': {
|
|
244
|
+
'application/json': {
|
|
245
|
+
'schema': schemas.get('Response'),
|
|
246
|
+
'example': Response().dump({'code': code})
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return None
|