From 959faf6ec41cb62d6559e84960574fd3978f9c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 15:43:54 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E9=87=8D=E6=9E=84(dvadmin):=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=8C=85=E5=BC=95=E5=85=A5=E9=83=BD=E5=8A=A0apps.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/application/urls.py | 2 +- dvadmin-backend/apps/vadmin/celery/apps.py | 2 +- .../apps/vadmin/celery/serializers.py | 4 +- dvadmin-backend/apps/vadmin/celery/views.py | 12 +-- dvadmin-backend/apps/vadmin/monitor/apps.py | 2 +- .../apps/vadmin/monitor/filters.py | 2 +- .../apps/vadmin/monitor/models/__init__.py | 6 +- .../apps/vadmin/monitor/models/monitor.py | 2 +- .../apps/vadmin/monitor/models/sys_files.py | 2 +- .../apps/vadmin/monitor/serializers.py | 4 +- dvadmin-backend/apps/vadmin/monitor/tasks.py | 8 +- dvadmin-backend/apps/vadmin/monitor/urls.py | 2 +- dvadmin-backend/apps/vadmin/monitor/views.py | 14 +-- dvadmin-backend/apps/vadmin/op_drf/apps.py | 4 +- dvadmin-backend/apps/vadmin/op_drf/fields.py | 2 +- dvadmin-backend/apps/vadmin/op_drf/filters.py | 2 +- .../apps/vadmin/op_drf/generics.py | 6 +- .../apps/vadmin/op_drf/logging/handlers.py | 2 - .../op_drf/management/commands/createapp.py | 2 +- .../apps/vadmin/op_drf/middleware.py | 4 +- dvadmin-backend/apps/vadmin/op_drf/mixins.py | 7 +- .../apps/vadmin/op_drf/pagination.py | 1 - .../apps/vadmin/op_drf/response.py | 47 +++++++++- .../apps/vadmin/op_drf/validator.py | 2 +- dvadmin-backend/apps/vadmin/op_drf/views.py | 7 +- .../apps/vadmin/op_drf/viewsets.py | 2 +- .../apps/vadmin/permission/filters.py | 4 +- .../permission/management/commands/init.py | 2 +- .../apps/vadmin/permission/models/__init__.py | 10 +- .../apps/vadmin/permission/models/dept.py | 2 +- .../apps/vadmin/permission/models/menu.py | 2 +- .../apps/vadmin/permission/models/post.py | 2 +- .../apps/vadmin/permission/models/role.py | 4 +- .../apps/vadmin/permission/models/users.py | 5 +- .../apps/vadmin/permission/permissions.py | 4 +- .../apps/vadmin/permission/serializers.py | 8 +- .../apps/vadmin/permission/tasks.py | 4 +- .../apps/vadmin/permission/urls.py | 2 +- .../apps/vadmin/permission/views.py | 16 ++-- dvadmin-backend/apps/vadmin/system/apps.py | 2 +- dvadmin-backend/apps/vadmin/system/filters.py | 4 +- .../apps/vadmin/system/models/__init__.py | 19 ++-- .../apps/vadmin/system/models/celery_log.py | 2 +- .../vadmin/system/models/config_settings.py | 2 +- .../apps/vadmin/system/models/dict_data.py | 2 +- .../apps/vadmin/system/models/dict_details.py | 2 +- .../apps/vadmin/system/models/logininfor.py | 2 +- .../apps/vadmin/system/models/message_push.py | 4 +- .../vadmin/system/models/operation_log.py | 4 +- .../apps/vadmin/system/models/save_file.py | 4 +- .../apps/vadmin/system/serializers.py | 6 +- dvadmin-backend/apps/vadmin/system/urls.py | 2 +- dvadmin-backend/apps/vadmin/system/views.py | 24 ++--- dvadmin-backend/apps/vadmin/template/apps.py | 2 +- dvadmin-backend/apps/vadmin/urls.py | 6 +- .../apps/vadmin/utils/authentication.py | 4 +- dvadmin-backend/apps/vadmin/utils/backends.py | 3 - .../apps/vadmin/utils/decorators.py | 7 +- .../apps/vadmin/utils/exceptions.py | 3 +- .../apps/vadmin/utils/export_excel.py | 4 +- dvadmin-backend/apps/vadmin/utils/login.py | 17 ++-- .../apps/vadmin/utils/model_util.py | 2 +- dvadmin-backend/apps/vadmin/utils/response.py | 91 ------------------- 63 files changed, 185 insertions(+), 248 deletions(-) delete mode 100644 dvadmin-backend/apps/vadmin/utils/response.py diff --git a/dvadmin-backend/application/urls.py b/dvadmin-backend/application/urls.py index 2a3a0ae..9ad09e0 100644 --- a/dvadmin-backend/application/urls.py +++ b/dvadmin-backend/application/urls.py @@ -22,7 +22,7 @@ from django.urls import re_path, include from django.views.static import serve from rest_framework.views import APIView -from apps.vadmin.utils.response import SuccessResponse +from apps.vadmin.op_drf.response import SuccessResponse class CaptchaRefresh(APIView): diff --git a/dvadmin-backend/apps/vadmin/celery/apps.py b/dvadmin-backend/apps/vadmin/celery/apps.py index efafaf1..0d5c929 100644 --- a/dvadmin-backend/apps/vadmin/celery/apps.py +++ b/dvadmin-backend/apps/vadmin/celery/apps.py @@ -2,6 +2,6 @@ from django.apps import AppConfig class DpCmdbConfig(AppConfig): - name = 'vadmin.celery' + name = 'apps.vadmin.celery' diff --git a/dvadmin-backend/apps/vadmin/celery/serializers.py b/dvadmin-backend/apps/vadmin/celery/serializers.py index d2f24b3..c1ab484 100644 --- a/dvadmin-backend/apps/vadmin/celery/serializers.py +++ b/dvadmin-backend/apps/vadmin/celery/serializers.py @@ -1,8 +1,8 @@ from django_celery_beat.models import IntervalSchedule, CrontabSchedule, PeriodicTask from rest_framework import serializers -from ..op_drf.serializers import CustomModelSerializer -from ..utils.exceptions import APIException +from apps.vadmin.op_drf.serializers import CustomModelSerializer +from apps.vadmin.utils.exceptions import APIException class IntervalScheduleSerializer(CustomModelSerializer): diff --git a/dvadmin-backend/apps/vadmin/celery/views.py b/dvadmin-backend/apps/vadmin/celery/views.py index 8c159b8..15fabfc 100644 --- a/dvadmin-backend/apps/vadmin/celery/views.py +++ b/dvadmin-backend/apps/vadmin/celery/views.py @@ -2,13 +2,11 @@ from django_celery_beat.admin import TaskSelectWidget from django_celery_beat.models import IntervalSchedule, CrontabSchedule, PeriodicTask from rest_framework.views import APIView -from ..celery.filters import IntervalScheduleFilter, CrontabScheduleFilter, PeriodicTaskFilter -from ..celery.serializers import IntervalScheduleSerializer, CrontabScheduleSerializer, PeriodicTaskSerializer -from ..op_drf.views import CustomAPIView -from ..op_drf.viewsets import CustomModelViewSet -from ..system.models import DictData -from ..system.serializers import DictDataSerializer -from ..utils.response import SuccessResponse +from apps.vadmin.celery.filters import IntervalScheduleFilter, CrontabScheduleFilter, PeriodicTaskFilter +from apps.vadmin.celery.serializers import IntervalScheduleSerializer, CrontabScheduleSerializer, PeriodicTaskSerializer +from apps.vadmin.op_drf.views import CustomAPIView +from apps.vadmin.op_drf.viewsets import CustomModelViewSet +from apps.vadmin.op_drf.response import SuccessResponse class IntervalScheduleModelViewSet(CustomModelViewSet): diff --git a/dvadmin-backend/apps/vadmin/monitor/apps.py b/dvadmin-backend/apps/vadmin/monitor/apps.py index 13ee922..73a87c9 100644 --- a/dvadmin-backend/apps/vadmin/monitor/apps.py +++ b/dvadmin-backend/apps/vadmin/monitor/apps.py @@ -2,5 +2,5 @@ from django.apps import AppConfig class MonitorConfig(AppConfig): - name = 'vadmin.monitor' + name = 'apps.vadmin.monitor' verbose_name = "系统监控" diff --git a/dvadmin-backend/apps/vadmin/monitor/filters.py b/dvadmin-backend/apps/vadmin/monitor/filters.py index e80748e..3dadbe2 100644 --- a/dvadmin-backend/apps/vadmin/monitor/filters.py +++ b/dvadmin-backend/apps/vadmin/monitor/filters.py @@ -1,6 +1,6 @@ import django_filters -from .models import Server, Monitor +from apps.vadmin.monitor.models import Server, Monitor class ServerFilter(django_filters.rest_framework.FilterSet): diff --git a/dvadmin-backend/apps/vadmin/monitor/models/__init__.py b/dvadmin-backend/apps/vadmin/monitor/models/__init__.py index 0f0d1f8..868c0dc 100644 --- a/dvadmin-backend/apps/vadmin/monitor/models/__init__.py +++ b/dvadmin-backend/apps/vadmin/monitor/models/__init__.py @@ -1,3 +1,3 @@ -from ..models.monitor import Monitor -from ..models.server import Server -from ..models.sys_files import SysFiles +from apps.vadmin.monitor.models.monitor import Monitor +from apps.vadmin.monitor.models.server import Server +from apps.vadmin.monitor.models.sys_files import SysFiles diff --git a/dvadmin-backend/apps/vadmin/monitor/models/monitor.py b/dvadmin-backend/apps/vadmin/monitor/models/monitor.py index 7cf2bb5..4a5ee8d 100644 --- a/dvadmin-backend/apps/vadmin/monitor/models/monitor.py +++ b/dvadmin-backend/apps/vadmin/monitor/models/monitor.py @@ -1,6 +1,6 @@ from django.db.models import CharField, ForeignKey, CASCADE -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class Monitor(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/monitor/models/sys_files.py b/dvadmin-backend/apps/vadmin/monitor/models/sys_files.py index 41557cf..cae5834 100644 --- a/dvadmin-backend/apps/vadmin/monitor/models/sys_files.py +++ b/dvadmin-backend/apps/vadmin/monitor/models/sys_files.py @@ -1,6 +1,6 @@ from django.db.models import CharField, ForeignKey, CASCADE -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class SysFiles(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/monitor/serializers.py b/dvadmin-backend/apps/vadmin/monitor/serializers.py index 69d789e..a34b551 100644 --- a/dvadmin-backend/apps/vadmin/monitor/serializers.py +++ b/dvadmin-backend/apps/vadmin/monitor/serializers.py @@ -1,5 +1,5 @@ -from .models import Server, Monitor -from ..op_drf.serializers import CustomModelSerializer +from apps.vadmin.monitor.models import Server, Monitor +from apps.vadmin.op_drf.serializers import CustomModelSerializer # ================================================= # diff --git a/dvadmin-backend/apps/vadmin/monitor/tasks.py b/dvadmin-backend/apps/vadmin/monitor/tasks.py index 6a6d4a7..fb78e54 100644 --- a/dvadmin-backend/apps/vadmin/monitor/tasks.py +++ b/dvadmin-backend/apps/vadmin/monitor/tasks.py @@ -5,10 +5,10 @@ import time import psutil -from ..monitor.models import Server, Monitor, SysFiles -from ..op_drf.response import SuccessResponse -from ..system.models import ConfigSettings -from ..utils.decorators import BaseCeleryApp +from apps.vadmin.monitor.models import Server, Monitor, SysFiles +from apps.vadmin.op_drf.response import SuccessResponse +from apps.vadmin.system.models import ConfigSettings +from apps.vadmin.utils.decorators import BaseCeleryApp logger = logging.getLogger(__name__) from platform import platform diff --git a/dvadmin-backend/apps/vadmin/monitor/urls.py b/dvadmin-backend/apps/vadmin/monitor/urls.py index 49feeef..98cc85b 100644 --- a/dvadmin-backend/apps/vadmin/monitor/urls.py +++ b/dvadmin-backend/apps/vadmin/monitor/urls.py @@ -1,7 +1,7 @@ from django.urls import re_path from rest_framework.routers import DefaultRouter -from .views import ServerModelViewSet, MonitorModelViewSet +from apps.vadmin.monitor.views import ServerModelViewSet, MonitorModelViewSet router = DefaultRouter() router.register(r'server', ServerModelViewSet) diff --git a/dvadmin-backend/apps/vadmin/monitor/views.py b/dvadmin-backend/apps/vadmin/monitor/views.py index 373bb30..1e393f0 100644 --- a/dvadmin-backend/apps/vadmin/monitor/views.py +++ b/dvadmin-backend/apps/vadmin/monitor/views.py @@ -1,13 +1,13 @@ from django_celery_beat.models import PeriodicTask, IntervalSchedule, CrontabSchedule from rest_framework.request import Request -from .filters import ServerFilter, MonitorFilter -from .models import Server, Monitor, SysFiles -from .serializers import ServerSerializer, MonitorSerializer, UpdateServerSerializer -from ..op_drf.response import SuccessResponse, ErrorResponse -from ..op_drf.viewsets import CustomModelViewSet -from ..permission.permissions import CommonPermission -from ..system.models import ConfigSettings +from apps.vadmin.monitor.filters import ServerFilter, MonitorFilter +from apps.vadmin.monitor.models import Server, Monitor, SysFiles +from apps.vadmin.monitor.serializers import ServerSerializer, MonitorSerializer, UpdateServerSerializer +from apps.vadmin.op_drf.response import SuccessResponse, ErrorResponse +from apps.vadmin.op_drf.viewsets import CustomModelViewSet +from apps.vadmin.permission.permissions import CommonPermission +from apps.vadmin.system.models import ConfigSettings class ServerModelViewSet(CustomModelViewSet): diff --git a/dvadmin-backend/apps/vadmin/op_drf/apps.py b/dvadmin-backend/apps/vadmin/op_drf/apps.py index 9214aed..092f7d9 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/apps.py +++ b/dvadmin-backend/apps/vadmin/op_drf/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig - import logging +from django.apps import AppConfig + logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/op_drf/fields.py b/dvadmin-backend/apps/vadmin/op_drf/fields.py index e1114ff..62a6c7a 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/fields.py +++ b/dvadmin-backend/apps/vadmin/op_drf/fields.py @@ -2,7 +2,7 @@ from django.contrib.auth import get_user_model from django.db import models from django.db.models import SET_NULL -from ..utils.string_util import uuid_8, uuid_16, uuid_32, uuid_36 +from apps.vadmin.utils.string_util import uuid_8, uuid_16, uuid_32, uuid_36 class IdField(models.CharField): diff --git a/dvadmin-backend/apps/vadmin/op_drf/filters.py b/dvadmin-backend/apps/vadmin/op_drf/filters.py index 1703e08..b250cd3 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/filters.py +++ b/dvadmin-backend/apps/vadmin/op_drf/filters.py @@ -10,7 +10,7 @@ from django.utils import six from mongoengine.queryset import visitor from rest_framework.filters import BaseFilterBackend, SearchFilter, OrderingFilter -from ..utils.model_util import get_dept +from apps.vadmin.utils.model_util import get_dept logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/op_drf/generics.py b/dvadmin-backend/apps/vadmin/op_drf/generics.py index 802c111..b9f9c93 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/generics.py +++ b/dvadmin-backend/apps/vadmin/op_drf/generics.py @@ -4,11 +4,11 @@ from django.http import Http404 from django.shortcuts import get_object_or_404 as _get_object_or_404 from rest_framework.settings import api_settings +from apps.vadmin.utils.jsonpath_util import get_jsonpath, filter_json, search_json +from apps.vadmin.utils.sort_util import sortList from . import mixins -from .pagination import Pagination, JsonPagination +from .pagination import JsonPagination from .response import SuccessResponse -from ..utils.jsonpath_util import get_jsonpath, filter_json, search_json -from ..utils.sort_util import sortList from .views import CustomAPIView diff --git a/dvadmin-backend/apps/vadmin/op_drf/logging/handlers.py b/dvadmin-backend/apps/vadmin/op_drf/logging/handlers.py index a3dc12d..f28a97f 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/logging/handlers.py +++ b/dvadmin-backend/apps/vadmin/op_drf/logging/handlers.py @@ -1,5 +1,4 @@ import logging -from django.core.cache import cache class RedisHandler(logging.StreamHandler): @@ -7,4 +6,3 @@ class RedisHandler(logging.StreamHandler): def emit(self, record): msg = self.format(record) print(msg) - diff --git a/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py b/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py index 644b59f..dcdd3ec 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py +++ b/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py @@ -40,7 +40,7 @@ class Command(BaseCommand): class {name.capitalize()}Config(AppConfig): - name = '{name}' + name = 'apps.{name}' verbose_name = "{name}App" """ with open(os.path.join(app_path, "apps.py"), 'w', encoding='UTF-8') as f: diff --git a/dvadmin-backend/apps/vadmin/op_drf/middleware.py b/dvadmin-backend/apps/vadmin/op_drf/middleware.py index 8215c24..b3d4110 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/middleware.py +++ b/dvadmin-backend/apps/vadmin/op_drf/middleware.py @@ -9,11 +9,11 @@ from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.utils.deprecation import MiddlewareMixin +from apps.vadmin.op_drf.response import ErrorJsonResponse from apps.vadmin.permission.models import Menu from apps.vadmin.system.models import OperationLog -from ..utils.request_util import get_request_ip, get_request_data, get_request_path, get_browser, get_os, \ +from apps.vadmin.utils.request_util import get_request_ip, get_request_data, get_request_path, get_browser, get_os, \ get_login_location, get_request_canonical_path, get_request_user, get_verbose_name -from ..utils.response import ErrorJsonResponse logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/op_drf/mixins.py b/dvadmin-backend/apps/vadmin/op_drf/mixins.py index 92f52bb..a46ff34 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/mixins.py +++ b/dvadmin-backend/apps/vadmin/op_drf/mixins.py @@ -5,9 +5,9 @@ from rest_framework import status from rest_framework.relations import ManyRelatedField, RelatedField, PrimaryKeyRelatedField from rest_framework.request import Request +from apps.vadmin.utils.export_excel import excel_to_data, export_excel_save_model +from apps.vadmin.utils.request_util import get_verbose_name from .response import SuccessResponse -from ..utils.export_excel import excel_to_data, export_excel_save_model -from ..utils.request_util import get_verbose_name class CreateModelMixin(mixins.CreateModelMixin): @@ -317,7 +317,8 @@ class ImportSerializerMixin: # 示例数据 queryset = self.filter_queryset(self.get_queryset()) return SuccessResponse( - export_excel_save_model(request, self.import_field_data.values(), [], f'导入{get_verbose_name(queryset)}模板.xls')) + export_excel_save_model(request, self.import_field_data.values(), [], + f'导入{get_verbose_name(queryset)}模板.xls')) updateSupport = request.data.get('updateSupport') # 从excel中组织对应的数据结构,然后使用序列化器保存 data = excel_to_data(request.data.get('file_url'), self.import_field_data) diff --git a/dvadmin-backend/apps/vadmin/op_drf/pagination.py b/dvadmin-backend/apps/vadmin/op_drf/pagination.py index 9c06b37..778ff19 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/pagination.py +++ b/dvadmin-backend/apps/vadmin/op_drf/pagination.py @@ -1,5 +1,4 @@ from collections import OrderedDict -from typing import Any from rest_framework.pagination import PageNumberPagination, _positive_int from rest_framework.utils.urls import replace_query_param diff --git a/dvadmin-backend/apps/vadmin/op_drf/response.py b/dvadmin-backend/apps/vadmin/op_drf/response.py index 0a486ee..d736aa8 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/response.py +++ b/dvadmin-backend/apps/vadmin/op_drf/response.py @@ -1,7 +1,7 @@ """ 常用的Response以及Django的Response、DRF的Response """ -from django.http.response import DjangoJSONEncoder +from django.http.response import DjangoJSONEncoder, JsonResponse from rest_framework.response import Response @@ -26,13 +26,16 @@ class SuccessResponse(Response): def __init__(self, data=None, msg='success', status=None, template_name=None, headers=None, exception=False, content_type=None): - std_data = { + self.std_data = { "code": 200, "data": data, "msg": msg, "status": 'success' } - super().__init__(std_data, status, template_name, headers, exception, content_type) + super().__init__(self.std_data, status, template_name, headers, exception, content_type) + + def __str__(self): + return str(self.std_data) class ErrorResponse(Response): @@ -43,10 +46,46 @@ class ErrorResponse(Response): def __init__(self, data=None, msg='error', code=201, status=None, template_name=None, headers=None, exception=False, content_type=None): + self.std_data = { + "code": code, + "data": data, + "msg": msg, + "status": 'error' + } + super().__init__(self.std_data, status, template_name, headers, exception, content_type) + + def __str__(self): + return str(self.std_data) + + +class SuccessJsonResponse(JsonResponse): + """ + 标准JsonResponse, SuccessJsonResponse(data)SuccessJsonResponse(data=data) + (1)仅SuccessResponse无法使用时才能推荐使用SuccessJsonResponse + """ + + def __init__(self, data, msg='success', encoder=DjangoJSONEncoder, safe=True, json_dumps_params=None, **kwargs): + std_data = { + "code": 200, + "data": data, + "msg": msg, + "status": 'success' + } + super().__init__(std_data, encoder, safe, json_dumps_params, **kwargs) + + +class ErrorJsonResponse(JsonResponse): + """ + 标准JsonResponse, 仅ErrorResponse无法使用时才能使用ErrorJsonResponse + (1)默认错误码返回2001, 也可以指定其他返回码:ErrorJsonResponse(code=xxx) + """ + + def __init__(self, data, msg='error', code=201, encoder=OpDRFJSONEncoder, safe=True, json_dumps_params=None, + **kwargs): std_data = { "code": code, "data": data, "msg": msg, "status": 'error' } - super().__init__(std_data, status, template_name, headers, exception, content_type) + super().__init__(std_data, encoder, safe, json_dumps_params, **kwargs) diff --git a/dvadmin-backend/apps/vadmin/op_drf/validator.py b/dvadmin-backend/apps/vadmin/op_drf/validator.py index 9ee2459..7a3d0db 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/validator.py +++ b/dvadmin-backend/apps/vadmin/op_drf/validator.py @@ -3,7 +3,7 @@ """ from rest_framework.validators import UniqueValidator, qs_exists -from vadmin.utils.exceptions import APIException +from apps.vadmin.utils.exceptions import APIException class CustomUniqueValidator(UniqueValidator): diff --git a/dvadmin-backend/apps/vadmin/op_drf/views.py b/dvadmin-backend/apps/vadmin/op_drf/views.py index 7f5b455..d896d57 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/views.py +++ b/dvadmin-backend/apps/vadmin/op_drf/views.py @@ -6,11 +6,8 @@ from rest_framework.exceptions import APIException as DRFAPIException from rest_framework.request import Request from rest_framework.views import APIView -from ..utils import exceptions -from ..utils.model_util import ModelRelateUtils -from .logging.view_logger import CustomerRelationshipViewLogger -from .response import SuccessResponse, ErrorResponse -from .serializers import CustomModelSerializer +from apps.vadmin.utils import exceptions +from .response import ErrorResponse logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/op_drf/viewsets.py b/dvadmin-backend/apps/vadmin/op_drf/viewsets.py index 5119aa0..aaf8ce3 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/viewsets.py +++ b/dvadmin-backend/apps/vadmin/op_drf/viewsets.py @@ -11,7 +11,7 @@ from rest_framework.request import Request from rest_framework.settings import api_settings from rest_framework.viewsets import ViewSetMixin -from ..utils.exceptions import APIException +from apps.vadmin.utils.exceptions import APIException from . import mixins from .filters import MongoSearchFilter, MongoOrderingFilter, AdvancedSearchFilter, MongoAdvancedSearchFilter from .generics import GenericAPIView diff --git a/dvadmin-backend/apps/vadmin/permission/filters.py b/dvadmin-backend/apps/vadmin/permission/filters.py index 8f8d8da..10ebe37 100644 --- a/dvadmin-backend/apps/vadmin/permission/filters.py +++ b/dvadmin-backend/apps/vadmin/permission/filters.py @@ -1,8 +1,8 @@ import django_filters from django.contrib.auth import get_user_model -from ..permission.models import Menu, Dept, Post, Role -from ..utils.model_util import get_dept +from apps.vadmin.permission.models import Menu, Dept, Post, Role +from apps.vadmin.utils.model_util import get_dept UserProfile = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/permission/management/commands/init.py b/dvadmin-backend/apps/vadmin/permission/management/commands/init.py index ec4a3dc..20487cd 100644 --- a/dvadmin-backend/apps/vadmin/permission/management/commands/init.py +++ b/dvadmin-backend/apps/vadmin/permission/management/commands/init.py @@ -5,7 +5,7 @@ from django.conf import settings from django.core.management.base import BaseCommand from django.db import connection -from ....scripts import getSql +from apps.vadmin.scripts import getSql logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/permission/models/__init__.py b/dvadmin-backend/apps/vadmin/permission/models/__init__.py index 1cbbbe2..f2b3ed9 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/__init__.py +++ b/dvadmin-backend/apps/vadmin/permission/models/__init__.py @@ -1,5 +1,5 @@ -from ..models.dept import Dept -from ..models.menu import Menu -from ..models.post import Post -from ..models.role import Role -from ..models.users import UserProfile +from apps.vadmin.permission.models.dept import Dept +from apps.vadmin.permission.models.menu import Menu +from apps.vadmin.permission.models.post import Post +from apps.vadmin.permission.models.role import Role +from apps.vadmin.permission.models.users import UserProfile diff --git a/dvadmin-backend/apps/vadmin/permission/models/dept.py b/dvadmin-backend/apps/vadmin/permission/models/dept.py index a339650..70115c7 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/dept.py +++ b/dvadmin-backend/apps/vadmin/permission/models/dept.py @@ -1,7 +1,7 @@ from django.db.models import CASCADE from django.db.models import CharField, IntegerField, ForeignKey -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class Dept(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/permission/models/menu.py b/dvadmin-backend/apps/vadmin/permission/models/menu.py index d3677fd..7741a8f 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/menu.py +++ b/dvadmin-backend/apps/vadmin/permission/models/menu.py @@ -1,7 +1,7 @@ from django.core.cache import cache from django.db.models import IntegerField, ForeignKey, CharField, CASCADE, Q -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class Menu(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/permission/models/post.py b/dvadmin-backend/apps/vadmin/permission/models/post.py index 6a19477..b736c90 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/post.py +++ b/dvadmin-backend/apps/vadmin/permission/models/post.py @@ -1,6 +1,6 @@ from django.db.models import IntegerField, BooleanField, CharField, TextField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class Post(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/permission/models/role.py b/dvadmin-backend/apps/vadmin/permission/models/role.py index d34b91e..0a7853d 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/role.py +++ b/dvadmin-backend/apps/vadmin/permission/models/role.py @@ -1,6 +1,6 @@ from django.db.models import IntegerField, BooleanField, CharField, TextField, ManyToManyField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class Role(CoreModel): @@ -16,7 +16,7 @@ class Role(CoreModel): roleSort = IntegerField(verbose_name="角色顺序") status = CharField(max_length=8, verbose_name="角色状态") admin = BooleanField(default=False, verbose_name="是否为admin") - dataScope = CharField(max_length=8,default='1', choices=DATASCOPE_CHOICES, verbose_name="权限范围",) + dataScope = CharField(max_length=8, default='1', choices=DATASCOPE_CHOICES, verbose_name="权限范围", ) remark = TextField(verbose_name="备注", help_text="备注", null=True, blank=True) dept = ManyToManyField(to='permission.Dept', verbose_name='数据权限-关联部门', db_constraint=False) menu = ManyToManyField(to='permission.Menu', verbose_name='关联菜单权限', db_constraint=False) diff --git a/dvadmin-backend/apps/vadmin/permission/models/users.py b/dvadmin-backend/apps/vadmin/permission/models/users.py index b93849c..9bbacae 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/users.py +++ b/dvadmin-backend/apps/vadmin/permission/models/users.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import UserManager, AbstractUser from django.core.cache import cache from django.db.models import IntegerField, ForeignKey, CharField, TextField, ManyToManyField, CASCADE -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class UserProfile(AbstractUser, CoreModel): @@ -25,7 +25,8 @@ class UserProfile(AbstractUser, CoreModel): user_type = IntegerField(default=0, verbose_name="用户类型") post = ManyToManyField(to='permission.Post', verbose_name='关联岗位', db_constraint=False) role = ManyToManyField(to='permission.Role', verbose_name='关联角色', db_constraint=False) - dept = ForeignKey(to='permission.Dept', verbose_name='归属部门', on_delete=CASCADE, db_constraint=False, null=True, blank=True) + dept = ForeignKey(to='permission.Dept', verbose_name='归属部门', on_delete=CASCADE, db_constraint=False, null=True, + blank=True) @property def get_user_interface_dict(self): diff --git a/dvadmin-backend/apps/vadmin/permission/permissions.py b/dvadmin-backend/apps/vadmin/permission/permissions.py index 3c4f374..95f0053 100644 --- a/dvadmin-backend/apps/vadmin/permission/permissions.py +++ b/dvadmin-backend/apps/vadmin/permission/permissions.py @@ -10,8 +10,8 @@ from rest_framework.permissions import (BasePermission, from rest_framework.request import Request from rest_framework.views import APIView -from .models import Dept -from ..utils.model_util import get_dept +from apps.vadmin.permission.models import Dept +from apps.vadmin.utils.model_util import get_dept logger = logging.getLogger(__name__) User = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/permission/serializers.py b/dvadmin-backend/apps/vadmin/permission/serializers.py index f93212c..cecf118 100644 --- a/dvadmin-backend/apps/vadmin/permission/serializers.py +++ b/dvadmin-backend/apps/vadmin/permission/serializers.py @@ -1,10 +1,10 @@ from django.contrib.auth import get_user_model from rest_framework import serializers -from ..op_drf.serializers import CustomModelSerializer -from ..op_drf.validator import CustomUniqueValidator -from ..permission.models import Menu, Dept, Post, Role -from ..system.models import MessagePush +from apps.vadmin.op_drf.serializers import CustomModelSerializer +from apps.vadmin.op_drf.validator import CustomUniqueValidator +from apps.vadmin.permission.models import Menu, Dept, Post, Role +from apps.vadmin.system.models import MessagePush UserProfile = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/permission/tasks.py b/dvadmin-backend/apps/vadmin/permission/tasks.py index 7da3b18..8f1ac43 100644 --- a/dvadmin-backend/apps/vadmin/permission/tasks.py +++ b/dvadmin-backend/apps/vadmin/permission/tasks.py @@ -3,8 +3,8 @@ import logging from captcha.models import CaptchaStore -from ..utils.decorators import BaseCeleryApp -from ..utils.response import SuccessResponse +from apps.vadmin.utils.decorators import BaseCeleryApp +from apps.vadmin.op_drf.response import SuccessResponse logger = logging.getLogger(__name__) @BaseCeleryApp(name='apps.vadmin.permission.tasks.clear_invalid_captcha') diff --git a/dvadmin-backend/apps/vadmin/permission/urls.py b/dvadmin-backend/apps/vadmin/permission/urls.py index 4f40dda..e6feece 100644 --- a/dvadmin-backend/apps/vadmin/permission/urls.py +++ b/dvadmin-backend/apps/vadmin/permission/urls.py @@ -1,7 +1,7 @@ from django.urls import re_path from rest_framework.routers import DefaultRouter -from ..permission.views import MenuModelViewSet, DeptModelViewSet, PostModelViewSet, RoleModelViewSet, \ +from apps.vadmin.permission.views import MenuModelViewSet, DeptModelViewSet, PostModelViewSet, RoleModelViewSet, \ UserProfileModelViewSet router = DefaultRouter() diff --git a/dvadmin-backend/apps/vadmin/permission/views.py b/dvadmin-backend/apps/vadmin/permission/views.py index f11def9..a8129d0 100644 --- a/dvadmin-backend/apps/vadmin/permission/views.py +++ b/dvadmin-backend/apps/vadmin/permission/views.py @@ -2,18 +2,18 @@ from django.contrib.auth import authenticate, get_user_model from rest_framework.request import Request from rest_framework.views import APIView -from .permissions import CommonPermission, DeptDestroyPermission -from ..op_drf.filters import DataLevelPermissionsFilter -from ..op_drf.viewsets import CustomModelViewSet -from ..permission.filters import MenuFilter, DeptFilter, PostFilter, RoleFilter, UserProfileFilter -from ..permission.models import Role, Menu, Dept, Post -from ..permission.serializers import UserProfileSerializer, MenuSerializer, RoleSerializer, \ +from apps.vadmin.op_drf.response import SuccessResponse, ErrorResponse +from apps.vadmin.permission.permissions import CommonPermission, DeptDestroyPermission +from apps.vadmin.op_drf.filters import DataLevelPermissionsFilter +from apps.vadmin.op_drf.viewsets import CustomModelViewSet +from apps.vadmin.permission.filters import MenuFilter, DeptFilter, PostFilter, RoleFilter, UserProfileFilter +from apps.vadmin.permission.models import Role, Menu, Dept, Post +from apps.vadmin.permission.serializers import UserProfileSerializer, MenuSerializer, RoleSerializer, \ MenuCreateUpdateSerializer, DeptSerializer, DeptCreateUpdateSerializer, PostSerializer, PostCreateUpdateSerializer, \ RoleCreateUpdateSerializer, DeptTreeSerializer, MenuTreeSerializer, UserProfileCreateUpdateSerializer, \ PostSimpleSerializer, RoleSimpleSerializer, ExportUserProfileSerializer, ExportRoleSerializer, ExportPostSerializer, \ UserProfileImportSerializer -from ..system.models import DictDetails -from ..utils.response import SuccessResponse, ErrorResponse +from apps.vadmin.system.models import DictDetails UserProfile = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/system/apps.py b/dvadmin-backend/apps/vadmin/system/apps.py index db16c07..0f61048 100644 --- a/dvadmin-backend/apps/vadmin/system/apps.py +++ b/dvadmin-backend/apps/vadmin/system/apps.py @@ -2,5 +2,5 @@ from django.apps import AppConfig class SystemConfig(AppConfig): - name = 'vadmin.system' + name = 'apps.vadmin.system' verbose_name = "系统管理" diff --git a/dvadmin-backend/apps/vadmin/system/filters.py b/dvadmin-backend/apps/vadmin/system/filters.py index e91edaa..ae12133 100644 --- a/dvadmin-backend/apps/vadmin/system/filters.py +++ b/dvadmin-backend/apps/vadmin/system/filters.py @@ -1,7 +1,7 @@ import django_filters -from .models import LoginInfor, OperationLog, CeleryLog -from ..system.models import DictDetails, DictData, ConfigSettings, MessagePush, SaveFile +from apps.vadmin.system.models import DictDetails, DictData, ConfigSettings, MessagePush, SaveFile +from apps.vadmin.system.models import LoginInfor, OperationLog, CeleryLog class DictDataFilter(django_filters.rest_framework.FilterSet): diff --git a/dvadmin-backend/apps/vadmin/system/models/__init__.py b/dvadmin-backend/apps/vadmin/system/models/__init__.py index 1c100d6..d0ebd20 100644 --- a/dvadmin-backend/apps/vadmin/system/models/__init__.py +++ b/dvadmin-backend/apps/vadmin/system/models/__init__.py @@ -1,10 +1,9 @@ -from ..models.config_settings import ConfigSettings -from ..models.dict_data import DictData -from ..models.dict_details import DictDetails -from ..models.save_file import SaveFile -from ..models.message_push import MessagePush -from ..models.message_push import MessagePushUser -from ..models.logininfor import LoginInfor -from ..models.operation_log import OperationLog -from ..models.celery_log import CeleryLog - +from apps.vadmin.system.models.celery_log import CeleryLog +from apps.vadmin.system.models.config_settings import ConfigSettings +from apps.vadmin.system.models.dict_data import DictData +from apps.vadmin.system.models.dict_details import DictDetails +from apps.vadmin.system.models.logininfor import LoginInfor +from apps.vadmin.system.models.message_push import MessagePush +from apps.vadmin.system.models.message_push import MessagePushUser +from apps.vadmin.system.models.operation_log import OperationLog +from apps.vadmin.system.models.save_file import SaveFile diff --git a/dvadmin-backend/apps/vadmin/system/models/celery_log.py b/dvadmin-backend/apps/vadmin/system/models/celery_log.py index ee73430..f7b97b0 100644 --- a/dvadmin-backend/apps/vadmin/system/models/celery_log.py +++ b/dvadmin-backend/apps/vadmin/system/models/celery_log.py @@ -1,6 +1,6 @@ from django.db.models import CharField, BooleanField, TextField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class CeleryLog(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/system/models/config_settings.py b/dvadmin-backend/apps/vadmin/system/models/config_settings.py index b4f6f87..8fd5b3b 100644 --- a/dvadmin-backend/apps/vadmin/system/models/config_settings.py +++ b/dvadmin-backend/apps/vadmin/system/models/config_settings.py @@ -1,6 +1,6 @@ from django.db.models import CharField, ForeignKey, BooleanField, CASCADE -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class ConfigSettings(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/system/models/dict_data.py b/dvadmin-backend/apps/vadmin/system/models/dict_data.py index 483b8f2..7dab886 100644 --- a/dvadmin-backend/apps/vadmin/system/models/dict_data.py +++ b/dvadmin-backend/apps/vadmin/system/models/dict_data.py @@ -1,6 +1,6 @@ from django.db.models import TextField, CharField,ForeignKey -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class DictData(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/system/models/dict_details.py b/dvadmin-backend/apps/vadmin/system/models/dict_details.py index 8cf18ac..58e2462 100644 --- a/dvadmin-backend/apps/vadmin/system/models/dict_details.py +++ b/dvadmin-backend/apps/vadmin/system/models/dict_details.py @@ -1,6 +1,6 @@ from django.db.models import CharField, ForeignKey, BooleanField, CASCADE -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class DictDetails(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/system/models/logininfor.py b/dvadmin-backend/apps/vadmin/system/models/logininfor.py index a1fb94f..bd06f5b 100644 --- a/dvadmin-backend/apps/vadmin/system/models/logininfor.py +++ b/dvadmin-backend/apps/vadmin/system/models/logininfor.py @@ -1,6 +1,6 @@ from django.db.models import CharField, BooleanField, TextField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class LoginInfor(CoreModel): diff --git a/dvadmin-backend/apps/vadmin/system/models/message_push.py b/dvadmin-backend/apps/vadmin/system/models/message_push.py index 37bc089..1b996f7 100644 --- a/dvadmin-backend/apps/vadmin/system/models/message_push.py +++ b/dvadmin-backend/apps/vadmin/system/models/message_push.py @@ -2,8 +2,8 @@ from django.conf import settings from django.db import models from django.db.models import * -from ...op_drf.fields import UpdateDateTimeField, CreateDateTimeField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.fields import UpdateDateTimeField, CreateDateTimeField +from apps.vadmin.op_drf.models import CoreModel """ 消息通知模型 diff --git a/dvadmin-backend/apps/vadmin/system/models/operation_log.py b/dvadmin-backend/apps/vadmin/system/models/operation_log.py index 9257e9a..e9e9d12 100644 --- a/dvadmin-backend/apps/vadmin/system/models/operation_log.py +++ b/dvadmin-backend/apps/vadmin/system/models/operation_log.py @@ -1,6 +1,6 @@ from django.db.models import TextField, CharField, BooleanField -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel class OperationLog(CoreModel): @@ -12,7 +12,7 @@ class OperationLog(CoreModel): request_ip = CharField(max_length=32, verbose_name="请求ip地址", null=True, blank=True) request_browser = CharField(max_length=64, verbose_name="请求浏览器", null=True, blank=True) response_code = CharField(max_length=32, verbose_name="响应状态码", null=True, blank=True) - request_location = CharField(max_length=64,verbose_name="操作地点", null=True, blank=True) + request_location = CharField(max_length=64, verbose_name="操作地点", null=True, blank=True) request_os = CharField(max_length=64, verbose_name="操作系统", null=True, blank=True) json_result = TextField(verbose_name="返回信息", null=True, blank=True) status = BooleanField(default=False, verbose_name="响应状态") diff --git a/dvadmin-backend/apps/vadmin/system/models/save_file.py b/dvadmin-backend/apps/vadmin/system/models/save_file.py index 30407cf..9898a74 100644 --- a/dvadmin-backend/apps/vadmin/system/models/save_file.py +++ b/dvadmin-backend/apps/vadmin/system/models/save_file.py @@ -1,10 +1,10 @@ import os import uuid -from django.db.models import CharField, FileField,BooleanField +from django.db.models import CharField, FileField, BooleanField from django.utils import timezone -from ...op_drf.models import CoreModel +from apps.vadmin.op_drf.models import CoreModel def files_path(instance, filename): diff --git a/dvadmin-backend/apps/vadmin/system/serializers.py b/dvadmin-backend/apps/vadmin/system/serializers.py index e967d1e..2f46ac3 100644 --- a/dvadmin-backend/apps/vadmin/system/serializers.py +++ b/dvadmin-backend/apps/vadmin/system/serializers.py @@ -1,9 +1,9 @@ from django.core.cache import cache from rest_framework import serializers -from .models import LoginInfor, OperationLog, CeleryLog -from ..op_drf.serializers import CustomModelSerializer -from ..system.models import DictData, DictDetails, ConfigSettings, SaveFile, MessagePush, MessagePushUser +from apps.vadmin.op_drf.serializers import CustomModelSerializer +from apps.vadmin.system.models import DictData, DictDetails, ConfigSettings, SaveFile, MessagePush, MessagePushUser +from apps.vadmin.system.models import LoginInfor, OperationLog, CeleryLog # ================================================= # diff --git a/dvadmin-backend/apps/vadmin/system/urls.py b/dvadmin-backend/apps/vadmin/system/urls.py index 654bac5..e66ef2a 100644 --- a/dvadmin-backend/apps/vadmin/system/urls.py +++ b/dvadmin-backend/apps/vadmin/system/urls.py @@ -1,7 +1,7 @@ from django.urls import re_path from rest_framework.routers import DefaultRouter -from ..system.views import DictDataModelViewSet, DictDetailsModelViewSet, \ +from apps.vadmin.system.views import DictDataModelViewSet, DictDetailsModelViewSet, \ ConfigSettingsModelViewSet, SaveFileModelViewSet, MessagePushModelViewSet, LoginInforModelViewSet, \ OperationLogModelViewSet, CeleryLogModelViewSet, SystemInfoApiView diff --git a/dvadmin-backend/apps/vadmin/system/views.py b/dvadmin-backend/apps/vadmin/system/views.py index c2d716b..b80c4de 100644 --- a/dvadmin-backend/apps/vadmin/system/views.py +++ b/dvadmin-backend/apps/vadmin/system/views.py @@ -6,25 +6,25 @@ from django.db.models import Q from rest_framework.request import Request from rest_framework.views import APIView -from .models import LoginInfor, OperationLog, CeleryLog -from ..op_drf.filters import DataLevelPermissionsFilter -from ..op_drf.viewsets import CustomModelViewSet -from ..permission.permissions import CommonPermission -from ..system.filters import DictDetailsFilter, DictDataFilter, ConfigSettingsFilter, MessagePushFilter, \ +from apps.vadmin.op_drf.filters import DataLevelPermissionsFilter +from apps.vadmin.op_drf.response import SuccessResponse +from apps.vadmin.op_drf.viewsets import CustomModelViewSet +from apps.vadmin.permission.permissions import CommonPermission +from apps.vadmin.system.filters import DictDetailsFilter, DictDataFilter, ConfigSettingsFilter, MessagePushFilter, \ SaveFileFilter, LoginInforFilter, OperationLogFilter, CeleryLogFilter -from ..system.models import DictData, DictDetails, ConfigSettings, SaveFile, MessagePush -from ..system.models import MessagePushUser -from ..system.serializers import DictDataSerializer, DictDataCreateUpdateSerializer, DictDetailsSerializer, \ +from apps.vadmin.system.models import DictData, DictDetails, ConfigSettings, SaveFile, MessagePush +from apps.vadmin.system.models import LoginInfor, OperationLog, CeleryLog +from apps.vadmin.system.models import MessagePushUser +from apps.vadmin.system.serializers import DictDataSerializer, DictDataCreateUpdateSerializer, DictDetailsSerializer, \ DictDetailsCreateUpdateSerializer, ConfigSettingsSerializer, \ ConfigSettingsCreateUpdateSerializer, SaveFileSerializer, SaveFileCreateUpdateSerializer, \ ExportConfigSettingsSerializer, ExportDictDataSerializer, ExportDictDetailsSerializer, \ MessagePushSerializer, MessagePushCreateUpdateSerializer, ExportMessagePushSerializer, LoginInforSerializer, \ OperationLogSerializer, ExportOperationLogSerializer, ExportLoginInforSerializer, CeleryLogSerializer, \ ExportCeleryLogSerializer -from ..utils.export_excel import export_excel_save_model -from ..utils.file_util import get_all_files, remove_empty_dir, delete_files -from ..utils.response import SuccessResponse -from ..utils.system_info_utils import get_memory_used_percent, get_cpu_used_percent, get_disk_used_percent +from apps.vadmin.utils.export_excel import export_excel_save_model +from apps.vadmin.utils.file_util import get_all_files, remove_empty_dir, delete_files +from apps.vadmin.utils.system_info_utils import get_memory_used_percent, get_cpu_used_percent, get_disk_used_percent class DictDataModelViewSet(CustomModelViewSet): diff --git a/dvadmin-backend/apps/vadmin/template/apps.py b/dvadmin-backend/apps/vadmin/template/apps.py index de74370..ea04cd1 100644 --- a/dvadmin-backend/apps/vadmin/template/apps.py +++ b/dvadmin-backend/apps/vadmin/template/apps.py @@ -2,5 +2,5 @@ from django.apps import AppConfig class TemplateConfig(AppConfig): - name = 'vadmin.template' + name = 'apps.vadmin.template' verbose_name = "模板App" diff --git a/dvadmin-backend/apps/vadmin/urls.py b/dvadmin-backend/apps/vadmin/urls.py index e1354f6..ce12d06 100644 --- a/dvadmin-backend/apps/vadmin/urls.py +++ b/dvadmin-backend/apps/vadmin/urls.py @@ -22,9 +22,9 @@ from django.urls import re_path, include from rest_framework.documentation import include_docs_urls from rest_framework.views import APIView -from .permission.views import GetUserProfileView, GetRouters -from .utils.login import LoginView, LogoutView -from .utils.response import SuccessResponse +from apps.vadmin.permission.views import GetUserProfileView, GetRouters +from apps.vadmin.utils.login import LoginView, LogoutView +from apps.vadmin.op_drf.response import SuccessResponse class CaptchaRefresh(APIView): diff --git a/dvadmin-backend/apps/vadmin/utils/authentication.py b/dvadmin-backend/apps/vadmin/utils/authentication.py index 4a51ca5..a017e1c 100644 --- a/dvadmin-backend/apps/vadmin/utils/authentication.py +++ b/dvadmin-backend/apps/vadmin/utils/authentication.py @@ -12,8 +12,8 @@ from django.utils.translation import ugettext as _ from rest_framework import exceptions from rest_framework_jwt.utils import jwt_decode_handler -from .jwt_util import jwt_get_session_id -from ..permission.models.users import UserProfile +from apps.vadmin.permission.models.users import UserProfile +from apps.vadmin.utils.jwt_util import jwt_get_session_id logger = logging.getLogger(__name__) User = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/utils/backends.py b/dvadmin-backend/apps/vadmin/utils/backends.py index 8e6e920..19df563 100644 --- a/dvadmin-backend/apps/vadmin/utils/backends.py +++ b/dvadmin-backend/apps/vadmin/utils/backends.py @@ -1,13 +1,10 @@ import logging -from captcha.models import CaptchaStore -from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.backends import ModelBackend from django.utils import timezone from rest_framework.authentication import SessionAuthentication as DjangoSessionAuthentication - logger = logging.getLogger(__name__) UserModel = get_user_model() diff --git a/dvadmin-backend/apps/vadmin/utils/decorators.py b/dvadmin-backend/apps/vadmin/utils/decorators.py index 48b7868..af18f5f 100644 --- a/dvadmin-backend/apps/vadmin/utils/decorators.py +++ b/dvadmin-backend/apps/vadmin/utils/decorators.py @@ -15,8 +15,8 @@ from rest_framework.response import Response from rest_framework_extensions.settings import extensions_api_settings from application.celery import app -from .string_util import bas64_encode_text, bas64_decode_text -from ..system.models import CeleryLog +from apps.vadmin.system.models import CeleryLog +from apps.vadmin.utils.string_util import bas64_encode_text, bas64_decode_text def get_cache(alias=None): @@ -34,12 +34,13 @@ def BaseCeleryApp(name, save_success_logs=True): :param save_success_logs: 是否保存成功的日志(适用于频率高的celery任务,成功不需要保存日志,则传False) :return: """ + def wraps(func): @app.task(name=name) @functools.wraps(func) def wrapper(*args, **kwargs): obj = CeleryLog() - obj.name = ''.join(str(func.__doc__).replace(' ','').split('\n')[:2]) + obj.name = ''.join(str(func.__doc__).replace(' ', '').split('\n')[:2]) obj.func_name = str(func.__name__) obj.kwargs = f"*args:{args}\n**kwargs:{kwargs}" start_time = datetime.now() diff --git a/dvadmin-backend/apps/vadmin/utils/exceptions.py b/dvadmin-backend/apps/vadmin/utils/exceptions.py index f018592..b68f4a0 100644 --- a/dvadmin-backend/apps/vadmin/utils/exceptions.py +++ b/dvadmin-backend/apps/vadmin/utils/exceptions.py @@ -4,8 +4,7 @@ import traceback from rest_framework import exceptions from rest_framework.views import set_rollback -from .request_util import get_verbose_name -from .response import ErrorResponse +from apps.vadmin.op_drf.response import ErrorResponse logger = logging.getLogger(__name__) diff --git a/dvadmin-backend/apps/vadmin/utils/export_excel.py b/dvadmin-backend/apps/vadmin/utils/export_excel.py index eda0567..d84f19c 100644 --- a/dvadmin-backend/apps/vadmin/utils/export_excel.py +++ b/dvadmin-backend/apps/vadmin/utils/export_excel.py @@ -7,8 +7,8 @@ import xlrd import xlwt from django.conf import settings -from ..system.models import SaveFile -from ..system.serializers import SaveFileSerializer +from apps.vadmin.system.models import SaveFile +from apps.vadmin.system.serializers import SaveFileSerializer def len_byte(value): diff --git a/dvadmin-backend/apps/vadmin/utils/login.py b/dvadmin-backend/apps/vadmin/utils/login.py index 4e83c91..bd82690 100644 --- a/dvadmin-backend/apps/vadmin/utils/login.py +++ b/dvadmin-backend/apps/vadmin/utils/login.py @@ -10,12 +10,11 @@ from rest_framework.permissions import IsAuthenticated from rest_framework.views import APIView from rest_framework_jwt.views import ObtainJSONWebToken, jwt_response_payload_handler -from .exceptions import GenException -from .jwt_util import jwt_get_session_id -from .request_util import get_request_ip, get_os, get_browser, get_login_location -from .response import SuccessResponse, ErrorResponse -# from .jwt_util import jwt_response_payload_handler -from ..system.models.logininfor import LoginInfor +from apps.vadmin.system.models.logininfor import LoginInfor +from apps.vadmin.utils.exceptions import GenException +from apps.vadmin.utils.jwt_util import jwt_get_session_id +from apps.vadmin.utils.request_util import get_request_ip, get_os, get_browser, get_login_location +from apps.vadmin.op_drf.response import SuccessResponse, ErrorResponse logger = logging.getLogger(__name__) @@ -62,7 +61,7 @@ class LoginView(ObtainJSONWebToken): else: raise GenException(message='验证码错误') - def save_login_infor(self, request, msg='',status=True,session_id=''): + def save_login_infor(self, request, msg='', status=True, session_id=''): User = get_user_model() instance = LoginInfor() instance.session_id = session_id @@ -89,7 +88,7 @@ class LoginView(ObtainJSONWebToken): session_id = jwt_get_session_id(token) key = f"{self.prefix}_{session_id}_{username}" cache.set(key, token, self.ex.total_seconds()) - self.save_login_infor(request, '登录成功',session_id=session_id) + self.save_login_infor(request, '登录成功', session_id=session_id) if self.JWT_AUTH_COOKIE and token: expiration = (datetime.datetime.utcnow() + self.ex) response.set_cookie(self.JWT_AUTH_COOKIE, @@ -98,7 +97,7 @@ class LoginView(ObtainJSONWebToken): domain=settings.SESSION_COOKIE_DOMAIN, httponly=False) return response - self.save_login_infor(request, '登录失败,账户/密码不正确',False) + self.save_login_infor(request, '登录失败,账户/密码不正确', False) return ErrorResponse(data=serializer.errors, msg='账户/密码不正确') # def handle_exception(self, exc): diff --git a/dvadmin-backend/apps/vadmin/utils/model_util.py b/dvadmin-backend/apps/vadmin/utils/model_util.py index e05094a..1de17ab 100644 --- a/dvadmin-backend/apps/vadmin/utils/model_util.py +++ b/dvadmin-backend/apps/vadmin/utils/model_util.py @@ -6,7 +6,7 @@ from django.apps.config import AppConfig from django.db.models.fields import Field from rest_framework.renderers import JSONRenderer -from ..permission.models import Dept +from apps.vadmin.permission.models import Dept def get_primary_field(model, many=False): diff --git a/dvadmin-backend/apps/vadmin/utils/response.py b/dvadmin-backend/apps/vadmin/utils/response.py deleted file mode 100644 index ccfb35d..0000000 --- a/dvadmin-backend/apps/vadmin/utils/response.py +++ /dev/null @@ -1,91 +0,0 @@ -""" -常用的Response以及Django的Response、DRF的Response -""" -from django.http.response import DjangoJSONEncoder, JsonResponse -from rest_framework.response import Response - - -class OpDRFJSONEncoder(DjangoJSONEncoder): - """ - 重写DjangoJSONEncoder - (1)默认返回支持中文格式的json字符串 - """ - - def __init__(self, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, - indent=None, separators=None, default=None): - super().__init__(skipkeys=skipkeys, ensure_ascii=False, check_circular=check_circular, - allow_nan=allow_nan, sort_keys=sort_keys, indent=indent, separators=separators, - default=default) - - -class SuccessResponse(Response): - """ - 标准响应成功的返回, SuccessResponse(data)或者SuccessResponse(data=data) - (1)默认错误码返回2000, 不支持指定其他返回码 - """ - - def __init__(self, data=None, msg='success', status=None, template_name=None, headers=None, exception=False, - content_type=None): - self.std_data = { - "code": 200, - "data": data, - "msg": msg, - "status": 'success' - } - super().__init__(self.std_data, status, template_name, headers, exception, content_type) - - def __str__(self): - return str(self.std_data) - - -class ErrorResponse(Response): - """ - 标准响应错误的返回,ErrorResponse(msg='xxx') - (1)默认错误码返回2001, 也可以指定其他返回码:ErrorResponse(code=xxx) - """ - - def __init__(self, data=None, msg='error', code=201, status=None, template_name=None, headers=None, - exception=False, content_type=None): - self.std_data = { - "code": code, - "data": data, - "msg": msg, - "status": 'error' - } - super().__init__(self.std_data, status, template_name, headers, exception, content_type) - - def __str__(self): - return str(self.std_data) - - -class SuccessJsonResponse(JsonResponse): - """ - 标准JsonResponse, SuccessJsonResponse(data)SuccessJsonResponse(data=data) - (1)仅SuccessResponse无法使用时才能推荐使用SuccessJsonResponse - """ - - def __init__(self, data, msg='success', encoder=DjangoJSONEncoder, safe=True, json_dumps_params=None, **kwargs): - std_data = { - "code": 200, - "data": data, - "msg": msg, - "status": 'success' - } - super().__init__(std_data, encoder, safe, json_dumps_params, **kwargs) - - -class ErrorJsonResponse(JsonResponse): - """ - 标准JsonResponse, 仅ErrorResponse无法使用时才能使用ErrorJsonResponse - (1)默认错误码返回2001, 也可以指定其他返回码:ErrorJsonResponse(code=xxx) - """ - - def __init__(self, data, msg='error', code=201, encoder=OpDRFJSONEncoder, safe=True, json_dumps_params=None, - **kwargs): - std_data = { - "code": code, - "data": data, - "msg": msg, - "status": 'error' - } - super().__init__(std_data, encoder, safe, json_dumps_params, **kwargs) From e17e5cc513d54a52940f5d67ec13b9e31c920922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 15:54:35 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=E6=8E=A5=E5=85=A5drf-yasg=EF=BC=8C=E8=BF=9B=E8=A1=8Cswagger?= =?UTF-8?q?=E5=BD=A2=E5=BC=8F=E7=9A=84api=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/application/settings.py | 3 ++- dvadmin-backend/application/urls.py | 20 +++++++++++++++++++- dvadmin-backend/apps/vadmin/urls.py | 1 - 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dvadmin-backend/application/settings.py b/dvadmin-backend/application/settings.py index 46b6586..ee46814 100644 --- a/dvadmin-backend/application/settings.py +++ b/dvadmin-backend/application/settings.py @@ -46,6 +46,7 @@ INSTALLED_APPS = [ 'corsheaders', 'captcha', 'django_celery_beat', + 'drf_yasg', # swagger 接口 # 自定义app 'apps.vadmin.permission', 'apps.vadmin.op_drf', @@ -332,4 +333,4 @@ CELERYBEAT_SCHEDULER = 'django_celery_beat.schedulers.DatabaseScheduler' # Back # 接口权限 INTERFACE_PERMISSION = locals().get("INTERFACE_PERMISSION", False) DJANGO_CELERY_BEAT_TZ_AWARE = False -CELERY_TIMEZONE = 'Asia/Shanghai' # celery 时区问题 +CELERY_TIMEZONE = 'Asia/Shanghai' # celery 时区问题 diff --git a/dvadmin-backend/application/urls.py b/dvadmin-backend/application/urls.py index 9ad09e0..3e29ae4 100644 --- a/dvadmin-backend/application/urls.py +++ b/dvadmin-backend/application/urls.py @@ -23,7 +23,21 @@ from django.views.static import serve from rest_framework.views import APIView from apps.vadmin.op_drf.response import SuccessResponse - +from rest_framework import permissions +from drf_yasg.views import get_schema_view +from drf_yasg import openapi +schema_view = get_schema_view( + openapi.Info( + title="Snippets API", + default_version='v1', + description="Test description", + terms_of_service="https://www.google.com/policies/terms/", + contact=openapi.Contact(email="contact@snippets.local"), + license=openapi.License(name="BSD License"), + ), + public=True, + permission_classes=[permissions.AllowAny], +) class CaptchaRefresh(APIView): authentication_classes = [] @@ -42,4 +56,8 @@ class CaptchaRefresh(APIView): urlpatterns = [ re_path(r'media/(?P.*)', serve, {"document_root": settings.MEDIA_ROOT}), re_path(r'^admin/', include('apps.vadmin.urls')), + re_path(r'^$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + re_path(r'^swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), + re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), + re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), ] diff --git a/dvadmin-backend/apps/vadmin/urls.py b/dvadmin-backend/apps/vadmin/urls.py index ce12d06..622b222 100644 --- a/dvadmin-backend/apps/vadmin/urls.py +++ b/dvadmin-backend/apps/vadmin/urls.py @@ -44,7 +44,6 @@ class CaptchaRefresh(APIView): urlpatterns = [ re_path('api-token-auth/', LoginView.as_view(), name='api_token_auth'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), - url(r'docs/', include_docs_urls(title='接口文档')), re_path(r'^login/$', LoginView.as_view()), re_path(r'^logout/$', LogoutView.as_view()), re_path(r'^getInfo/$', GetUserProfileView.as_view()), From a56e06492488a777ec9a3b7d10ac46190caf666a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 17:10:31 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=8F=96=E6=B6=88redis=EF=BC=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/vadmin/permission/models/menu.py | 10 ++++--- .../apps/vadmin/permission/models/users.py | 7 +++-- .../apps/vadmin/system/serializers.py | 12 ++++++--- dvadmin-backend/apps/vadmin/system/views.py | 27 +++++++++++++------ .../apps/vadmin/utils/authentication.py | 2 +- .../apps/vadmin/utils/decorators.py | 11 ++++---- dvadmin-backend/apps/vadmin/utils/login.py | 6 +++-- .../apps/vadmin/utils/request_util.py | 7 +++-- dvadmin-backend/conf/env.example.py | 2 ++ 9 files changed, 58 insertions(+), 26 deletions(-) diff --git a/dvadmin-backend/apps/vadmin/permission/models/menu.py b/dvadmin-backend/apps/vadmin/permission/models/menu.py index 7741a8f..1e4dc2e 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/menu.py +++ b/dvadmin-backend/apps/vadmin/permission/models/menu.py @@ -1,6 +1,7 @@ from django.core.cache import cache from django.db.models import IntegerField, ForeignKey, CharField, CASCADE, Q +from application import settings from apps.vadmin.op_drf.models import CoreModel @@ -42,7 +43,8 @@ class Menu(CoreModel): :return: """ try: - interface_dict = cache.get('permission_interface_dict', {}) + interface_dict = cache.get('permission_interface_dict', {}) if getattr(settings, "REDIS_ENABLE", + False) else {} except: interface_dict = {} if not interface_dict: @@ -52,7 +54,8 @@ class Menu(CoreModel): interface_dict[ele.get('interface_method', '')].append(ele.get('interface_path')) else: interface_dict[ele.get('interface_method', '')] = [ele.get('interface_path')] - cache.set('permission_interface_dict', interface_dict, 84600) + if getattr(settings, "REDIS_ENABLE", False): + cache.set('permission_interface_dict', interface_dict, 84600) return interface_dict @classmethod @@ -61,7 +64,8 @@ class Menu(CoreModel): 清空缓存中的接口列表 :return: """ - cache.delete('permission_interface_dict') + if getattr(settings, "REDIS_ENABLE", False): + cache.delete('permission_interface_dict') class Meta: verbose_name = '菜单管理' diff --git a/dvadmin-backend/apps/vadmin/permission/models/users.py b/dvadmin-backend/apps/vadmin/permission/models/users.py index 9bbacae..905711b 100644 --- a/dvadmin-backend/apps/vadmin/permission/models/users.py +++ b/dvadmin-backend/apps/vadmin/permission/models/users.py @@ -30,7 +30,8 @@ class UserProfile(AbstractUser, CoreModel): @property def get_user_interface_dict(self): - interface_dict = cache.get(f'permission_interface_dict_{self.username}', {}) + interface_dict = cache.get(f'permission_interface_dict_{self.username}', {}) if \ + getattr(settings, "REDIS_ENABLE", False) else {} if not interface_dict: for ele in self.role.filter(status='1', menu__status='1').values('menu__interface_path', 'menu__interface_method').distinct(): @@ -41,7 +42,8 @@ class UserProfile(AbstractUser, CoreModel): interface_dict[ele.get('menu__interface_method', '')].append(interface_path) else: interface_dict[ele.get('menu__interface_method', '')] = [interface_path] - cache.set(f'permission_interface_dict_{self.username}', interface_dict, 84600) + if getattr(settings, "REDIS_ENABLE", False): + cache.set(f'permission_interface_dict_{self.username}', interface_dict, 84600) return interface_dict @property @@ -50,6 +52,7 @@ class UserProfile(AbstractUser, CoreModel): 清空缓存中的接口列表 :return: """ + if not getattr(settings, "REDIS_ENABLE", False): return "" return cache.delete(f'permission_interface_dict_{self.username}') class Meta: diff --git a/dvadmin-backend/apps/vadmin/system/serializers.py b/dvadmin-backend/apps/vadmin/system/serializers.py index 2f46ac3..f4ad391 100644 --- a/dvadmin-backend/apps/vadmin/system/serializers.py +++ b/dvadmin-backend/apps/vadmin/system/serializers.py @@ -1,6 +1,7 @@ from django.core.cache import cache from rest_framework import serializers +from application import settings from apps.vadmin.op_drf.serializers import CustomModelSerializer from apps.vadmin.system.models import DictData, DictDetails, ConfigSettings, SaveFile, MessagePush, MessagePushUser from apps.vadmin.system.models import LoginInfor, OperationLog, CeleryLog @@ -81,7 +82,8 @@ class DictDetailsCreateUpdateSerializer(CustomModelSerializer): """ def save(self, **kwargs): - cache.delete('system_dict_details') + if getattr(settings, "REDIS_ENABLE", False): + cache.delete('system_dict_details') return super().save(**kwargs) class Meta: @@ -120,7 +122,8 @@ class ConfigSettingsCreateUpdateSerializer(CustomModelSerializer): """ def save(self, **kwargs): - cache.delete('system_configKey') + if getattr(settings, "REDIS_ENABLE", False): + cache.delete('system_configKey') return super().save(**kwargs) class Meta: @@ -147,7 +150,10 @@ class SaveFileCreateUpdateSerializer(CustomModelSerializer): """ 文件管理 创建/更新时的列化器 """ - file_url = serializers.CharField(source='file.url', read_only=True) + file_url = serializers.SerializerMethodField(read_only=True) + + def get_file_url(self, obj: SaveFile): + return getattr(obj.file, "url", obj.file) if hasattr(obj, "file") else "" def save(self, **kwargs): files = self.context.get('request').FILES.get('file') diff --git a/dvadmin-backend/apps/vadmin/system/views.py b/dvadmin-backend/apps/vadmin/system/views.py index b80c4de..27475b5 100644 --- a/dvadmin-backend/apps/vadmin/system/views.py +++ b/dvadmin-backend/apps/vadmin/system/views.py @@ -72,7 +72,7 @@ class DictDetailsModelViewSet(CustomModelViewSet): :param kwargs: :return: """ - dict_details_dic = cache.get('system_dict_details', {}) + dict_details_dic = cache.get('system_dict_details', {}) if getattr(settings, "REDIS_ENABLE", False) else {} if not dict_details_dic: queryset = self.filter_queryset(self.get_queryset()) queryset_dic = queryset.order_by('sort').values('dict_data__dictType', 'dictLabel', 'dictValue', @@ -83,7 +83,8 @@ class DictDetailsModelViewSet(CustomModelViewSet): dict_details_dic[dictType].append(ele) else: dict_details_dic[dictType] = [ele] - cache.set('system_dict_details', dict_details_dic, 84600) + if getattr(settings, "REDIS_ENABLE", False): + cache.set('system_dict_details', dict_details_dic, 84600) return SuccessResponse(dict_details_dic.get(kwargs.get('pk'), [])) def clearCache(self, request: Request, *args, **kwargs): @@ -94,7 +95,8 @@ class DictDetailsModelViewSet(CustomModelViewSet): :param kwargs: :return: """ - cache.delete('system_dict_details') + if getattr(settings, "REDIS_ENABLE", False): + cache.delete('system_dict_details') return SuccessResponse(msg='清理成功!') def export(self, request: Request, *args, **kwargs): @@ -137,12 +139,13 @@ class ConfigSettingsModelViewSet(CustomModelViewSet): :param kwargs: :return: """ - config_key_dic = cache.get('system_configKey') + config_key_dic = cache.get('system_configKey') if getattr(settings, "REDIS_ENABLE", False) else "" if not config_key_dic: queryset = self.filter_queryset(self.get_queryset()) config_key_dic = {ele.get('configKey'): ele.get('configValue') for ele in queryset.values('configValue', 'configKey')} - cache.set('system_configKey', config_key_dic, 84600) + if getattr(settings, "REDIS_ENABLE", False): + cache.set('system_configKey', config_key_dic, 84600) return SuccessResponse(msg=config_key_dic.get(kwargs.get('pk'), '')) def clearCache(self, request: Request, *args, **kwargs): @@ -153,7 +156,8 @@ class ConfigSettingsModelViewSet(CustomModelViewSet): :param kwargs: :return: """ - cache.delete('system_configKey') + if getattr(settings, "REDIS_ENABLE", False): + cache.delete('system_configKey') return SuccessResponse(msg='清理成功!') @@ -173,6 +177,13 @@ class SaveFileModelViewSet(CustomModelViewSet): search_fields = ('configName',) ordering = '-create_datetime' # 默认排序 + def create(self, request: Request, *args, **kwargs): + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + self.perform_create(serializer) + headers = self.get_success_headers(serializer.data) + return SuccessResponse(serializer.data, status=201, headers=headers) + def clearsavefile(self, request: Request, *args, **kwargs): """ 清理废弃文件 @@ -185,8 +196,8 @@ class SaveFileModelViewSet(CustomModelViewSet): file_list = get_all_files(os.path.join(settings.MEDIA_ROOT, 'system')) queryset_files = [os.path.join(os.path.join(settings.MEDIA_ROOT) + os.sep, ele) for ele in list(self.get_queryset().values_list('file', flat=True))] - - delete_list = list(set(file_list) - set(queryset_files)) + queryset_files_dir = set(map(lambda absdir: os.path.abspath(absdir), queryset_files)) + delete_list = list(set(file_list) - queryset_files_dir) # 进行文件删除操作 delete_files(delete_list) # 递归删除空文件 diff --git a/dvadmin-backend/apps/vadmin/utils/authentication.py b/dvadmin-backend/apps/vadmin/utils/authentication.py index a017e1c..48bd86a 100644 --- a/dvadmin-backend/apps/vadmin/utils/authentication.py +++ b/dvadmin-backend/apps/vadmin/utils/authentication.py @@ -92,7 +92,7 @@ class RedisOpAuthJwtAuthentication(OpAuthJwtAuthentication): def authenticate(self, request): res = super().authenticate(request) - if res: + if res and getattr(settings, "REDIS_ENABLE", False): user, token = res session_id = jwt_get_session_id(token) key = f"{self.prefix}_{session_id}_{user.username}" diff --git a/dvadmin-backend/apps/vadmin/utils/decorators.py b/dvadmin-backend/apps/vadmin/utils/decorators.py index af18f5f..dd9cbc6 100644 --- a/dvadmin-backend/apps/vadmin/utils/decorators.py +++ b/dvadmin-backend/apps/vadmin/utils/decorators.py @@ -306,7 +306,7 @@ class CacheResponse(object): is_no_cache = True response = None if not is_no_cache: - response = self.cache.get(key) + response = self.cache.get(key) if getattr(settings, "REDIS_ENABLE", False) else None if not response: response = view_method(view_instance, request, *args, **kwargs) response = view_instance.finalize_response(request, response, *args, **kwargs) @@ -314,10 +314,11 @@ class CacheResponse(object): if not response.status_code >= 400 or self.cache_errors: if not is_no_cache: - if isinstance(response, Response): - self.cache.set(key, response.data, self.timeout) - else: - self.cache.set(key, response, self.timeout) + if getattr(settings, "REDIS_ENABLE", False): + if isinstance(response, Response): + self.cache.set(key, response.data, self.timeout) + else: + self.cache.set(key, response, self.timeout) handle_refresh_cache_fun = getattr(view_instance, 'handle_refresh_cache', None) if handle_refresh_cache_fun: handle_refresh_cache_fun(request=request, key=key, cache=self.cache) diff --git a/dvadmin-backend/apps/vadmin/utils/login.py b/dvadmin-backend/apps/vadmin/utils/login.py index bd82690..1b8b1bf 100644 --- a/dvadmin-backend/apps/vadmin/utils/login.py +++ b/dvadmin-backend/apps/vadmin/utils/login.py @@ -31,7 +31,8 @@ class LogoutView(APIView): user.user_secret = uuid4() user.save() key = f"{self.prefix}_{user.username}" - cache.delete(key) + if getattr(settings, "REDIS_ENABLE", False): + cache.delete(key) return SuccessResponse() @@ -87,7 +88,8 @@ class LoginView(ObtainJSONWebToken): username = user.username session_id = jwt_get_session_id(token) key = f"{self.prefix}_{session_id}_{username}" - cache.set(key, token, self.ex.total_seconds()) + if getattr(settings, "REDIS_ENABLE", False): + cache.set(key, token, self.ex.total_seconds()) self.save_login_infor(request, '登录成功', session_id=session_id) if self.JWT_AUTH_COOKIE and token: expiration = (datetime.datetime.utcnow() + self.ex) diff --git a/dvadmin-backend/apps/vadmin/utils/request_util.py b/dvadmin-backend/apps/vadmin/utils/request_util.py index 24965ed..1bdb709 100644 --- a/dvadmin-backend/apps/vadmin/utils/request_util.py +++ b/dvadmin-backend/apps/vadmin/utils/request_util.py @@ -10,6 +10,7 @@ from django.core.cache import cache from django.urls.resolvers import ResolverMatch from user_agents import parse +from application import settings from apps.vadmin.utils.authentication import OpAuthJwtAuthentication logger = logging.getLogger(__name__) @@ -161,11 +162,12 @@ def get_login_location(request, *args, **kwargs): :param kwargs: :return: """ + if not getattr(settings, "ENABLE_LOGIN_LOCATION", False): return "" import requests import eventlet # 导入eventlet这个模块 request_ip = get_request_ip(request) # 从缓存中获取 - location = cache.get(request_ip) + location = cache.get(request_ip) if getattr(settings, "REDIS_ENABLE", False) else "" if location: return location # 通过api 获取,再缓存redis @@ -176,7 +178,8 @@ def get_login_location(request, *args, **kwargs): r = requests.get(apiurl) content = r.content.decode('GBK') location = str(content).replace('\r', '').replace('\n', '')[:64] - cache.set(request_ip, location, 86400) + if getattr(settings, "REDIS_ENABLE", False): + cache.set(request_ip, location, 86400) return location except Exception as e: pass diff --git a/dvadmin-backend/conf/env.example.py b/dvadmin-backend/conf/env.example.py index ec74c6a..8e7f4be 100644 --- a/dvadmin-backend/conf/env.example.py +++ b/dvadmin-backend/conf/env.example.py @@ -44,3 +44,5 @@ API_LOG_ENABLE = True API_LOG_METHODS = ['POST', 'DELETE', 'PUT'] # 'ALL' or ['POST', 'DELETE'] # 接口权限 INTERFACE_PERMISSION = True +# 是否开启 +ENABLE_LOGIN_LOCATION = False From 306a72e8be57eb22b5bb1e429b33a29e2d1efa07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 17:26:01 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE=E5=8F=96=E6=B6=88redis=EF=BC=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/apps/vadmin/utils/authentication.py | 2 +- dvadmin-backend/conf/env.example.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dvadmin-backend/apps/vadmin/utils/authentication.py b/dvadmin-backend/apps/vadmin/utils/authentication.py index 48bd86a..3187058 100644 --- a/dvadmin-backend/apps/vadmin/utils/authentication.py +++ b/dvadmin-backend/apps/vadmin/utils/authentication.py @@ -101,4 +101,4 @@ class RedisOpAuthJwtAuthentication(OpAuthJwtAuthentication): return user, token else: raise exceptions.AuthenticationFailed("登录信息失效,请重新登录!") - return None + return res diff --git a/dvadmin-backend/conf/env.example.py b/dvadmin-backend/conf/env.example.py index 8e7f4be..8671dd2 100644 --- a/dvadmin-backend/conf/env.example.py +++ b/dvadmin-backend/conf/env.example.py @@ -44,5 +44,5 @@ API_LOG_ENABLE = True API_LOG_METHODS = ['POST', 'DELETE', 'PUT'] # 'ALL' or ['POST', 'DELETE'] # 接口权限 INTERFACE_PERMISSION = True -# 是否开启 -ENABLE_LOGIN_LOCATION = False +# 是否开启登录ip转换成城市位置 +ENABLE_LOGIN_LOCATION = True From 164e13fe50cd1593708a30144201cac153d6ef67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 19:33:36 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/apps/vadmin/utils/export_excel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvadmin-backend/apps/vadmin/utils/export_excel.py b/dvadmin-backend/apps/vadmin/utils/export_excel.py index d84f19c..d74d8b7 100644 --- a/dvadmin-backend/apps/vadmin/utils/export_excel.py +++ b/dvadmin-backend/apps/vadmin/utils/export_excel.py @@ -152,7 +152,7 @@ def excel_to_data(file_url, field_data): :return: """ # 读取excel 文件 - data = xlrd.open_workbook(os.path.join(settings.BASE_DIR, *file_url.split(os.sep))) + data = xlrd.open_workbook(os.path.join(settings.BASE_DIR.replace('\\', os.sep), *file_url.split(os.sep))) table = data.sheets()[0] # 创建一个空列表,存储Excel的数据 tables = [] From 97c3ff60c371bfb92679a4aec48a6999ed5e2ff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 3 Jul 2021 19:50:15 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=20python=20manage.py=20createapp=20=E4=B8=80=E7=BA=A7=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D/app01=20...=20=20#=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=9A=E7=BA=A7=E7=9B=AE=E5=BD=95=E5=BB=BAapp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op_drf/management/commands/createapp.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py b/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py index dcdd3ec..02e0b56 100644 --- a/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py +++ b/dvadmin-backend/apps/vadmin/op_drf/management/commands/createapp.py @@ -13,6 +13,7 @@ class Command(BaseCommand): 创建App命令: python manage.py createapp app名 python manage.py createapp app01 app02 ... + python manage.py createapp 一级文件名/app01 ... # 支持多级目录建app """ def add_arguments(self, parser): @@ -21,7 +22,9 @@ class Command(BaseCommand): def handle(self, *args, **options): app_name = options.get('app_name') for name in app_name: - app_path = os.path.join(BASE_DIR, "apps", name) + names = name.split('/') + dnames = ".".join(names) + app_path = os.path.join(BASE_DIR, "apps", *names) # 判断app是否存在 if os.path.exists(app_path): print(f"创建失败,App {name} 已存在!") @@ -39,20 +42,20 @@ class Command(BaseCommand): content = f"""from django.apps import AppConfig -class {name.capitalize()}Config(AppConfig): - name = 'apps.{name}' - verbose_name = "{name}App" +class {name[-1].capitalize()}Config(AppConfig): + name = 'apps.{dnames}' + verbose_name = "{names[-1]}App" """ with open(os.path.join(app_path, "apps.py"), 'w', encoding='UTF-8') as f: f.write(content) f.close() # 注册app到 settings.py 中 - injection(os.path.join(BASE_DIR, "application", "settings.py"), f" 'apps.{name}',\n", "INSTALLED_APPS", + injection(os.path.join(BASE_DIR, "application", "settings.py"), f" 'apps.{dnames}',\n", "INSTALLED_APPS", "]") # 注册app到 urls.py 中 injection(os.path.join(BASE_DIR, "application", "urls.py"), - f" re_path(r'^{name}/', include('apps.{name}.urls')),\n", "urlpatterns = [", + f" re_path(r'^{name}/', include('apps.{dnames}.urls')),\n", "urlpatterns = [", "]") print(f"创建 {name} App成功") From f95fee577171205ba9754d9d56ba077869167696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sun, 4 Jul 2021 16:28:54 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E6=96=B0=E5=8A=9F=E8=83=BD(dvadmin):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20drf-yasg=20pip=20=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dvadmin-backend/requirements.txt b/dvadmin-backend/requirements.txt index 2ea4f69..d262086 100644 --- a/dvadmin-backend/requirements.txt +++ b/dvadmin-backend/requirements.txt @@ -27,3 +27,4 @@ coreapi==2.3.3 user-agents==2.2.0 eventlet==0.30.2 psutil==5.8.0 +drf-yasg ==1.20.0 From 301f93cfd9996c12f3fdbf98b78e53d61365ea47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Sat, 10 Jul 2021 09:29:13 +0800 Subject: [PATCH 08/18] =?UTF-8?q?fix=20#I3UP7W=20=E4=BF=AE=E5=A4=8DBUG(dva?= =?UTF-8?q?dmin):=20=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA10=E6=9D=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvadmin-backend/apps/vadmin/celery/views.py | 2 +- .../celery/crontab-task/crontab-index.vue | 2 +- .../celery/interval-task/interval-index.vue | 2 +- .../celery/periodic-task/periodic-index.vue | 26 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dvadmin-backend/apps/vadmin/celery/views.py b/dvadmin-backend/apps/vadmin/celery/views.py index 15fabfc..cc93e5e 100644 --- a/dvadmin-backend/apps/vadmin/celery/views.py +++ b/dvadmin-backend/apps/vadmin/celery/views.py @@ -57,7 +57,7 @@ class PeriodicTaskModelViewSet(CustomModelViewSet): enabled 是否开启 """ - queryset = PeriodicTask.objects.all() + queryset = PeriodicTask.objects.exclude(name="celery.backend_cleanup") serializer_class = PeriodicTaskSerializer filter_class = PeriodicTaskFilter search_fields = ('name', 'task', 'date_changed') diff --git a/dvadmin-ui/src/views/vadmin/monitor/celery/crontab-task/crontab-index.vue b/dvadmin-ui/src/views/vadmin/monitor/celery/crontab-task/crontab-index.vue index c49d01a..e040788 100644 --- a/dvadmin-ui/src/views/vadmin/monitor/celery/crontab-task/crontab-index.vue +++ b/dvadmin-ui/src/views/vadmin/monitor/celery/crontab-task/crontab-index.vue @@ -80,7 +80,7 @@ }, methods: { initData() { - SyncDataApi.listCrontabSchedule({ page_size: 1000 }).then((response) => { + SyncDataApi.listCrontabSchedule({ pageSize: 1000 }).then((response) => { this.detail = response.data.results || []; this.$store.state.Crontab = this.detail; }); diff --git a/dvadmin-ui/src/views/vadmin/monitor/celery/interval-task/interval-index.vue b/dvadmin-ui/src/views/vadmin/monitor/celery/interval-task/interval-index.vue index ff561b7..5d6ddcf 100644 --- a/dvadmin-ui/src/views/vadmin/monitor/celery/interval-task/interval-index.vue +++ b/dvadmin-ui/src/views/vadmin/monitor/celery/interval-task/interval-index.vue @@ -77,7 +77,7 @@ }, methods: { initData() { - SyncDataApi.listIntervalschedule({ page_size: 1000 }).then((response) => { + SyncDataApi.listIntervalschedule({ pageSize: 1000 }).then((response) => { this.detail = response.data.results || []; this.$store.state.Interval = this.detail; }); diff --git a/dvadmin-ui/src/views/vadmin/monitor/celery/periodic-task/periodic-index.vue b/dvadmin-ui/src/views/vadmin/monitor/celery/periodic-task/periodic-index.vue index a4f81c2..f4a9e15 100644 --- a/dvadmin-ui/src/views/vadmin/monitor/celery/periodic-task/periodic-index.vue +++ b/dvadmin-ui/src/views/vadmin/monitor/celery/periodic-task/periodic-index.vue @@ -33,18 +33,18 @@ - + + + + + + + + + + + + diff --git a/dvadmin-ui/src/api/vadmin/login.js b/dvadmin-ui/src/api/vadmin/login.js index 2b05380..36ce2d8 100755 --- a/dvadmin-ui/src/api/vadmin/login.js +++ b/dvadmin-ui/src/api/vadmin/login.js @@ -1,4 +1,4 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 登录方法 export function login(username, password, code, uuid) { @@ -7,34 +7,34 @@ export function login(username, password, code, uuid) { password, idValueC: code, idKeyC: uuid - } + }; return request({ - url: '/admin/login/', - method: 'post', + url: "/admin/login/", + method: "post", data: data - }) + }); } // 获取用户详细信息 export function getInfo() { return request({ - url: '/admin/getInfo/', - method: 'get' - }) + url: "/admin/getInfo/", + method: "get" + }); } // 退出方法 export function logout() { return request({ - url: '/admin/logout/', - method: 'post' - }) + url: "/admin/logout/", + method: "post" + }); } // 获取验证码 export function getCodeImg() { return request({ - url: '/admin/captcha/refresh/', - method: 'get' - }) + url: "/admin/captcha/refresh/", + method: "get" + }); } diff --git a/dvadmin-ui/src/api/vadmin/menu.js b/dvadmin-ui/src/api/vadmin/menu.js index 205e8dd..ae002ea 100755 --- a/dvadmin-ui/src/api/vadmin/menu.js +++ b/dvadmin-ui/src/api/vadmin/menu.js @@ -1,9 +1,9 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 获取路由 export const getRouters = () => { return request({ - url: '/admin/getRouters/', - method: 'get' - }) -} + url: "/admin/getRouters/", + method: "get" + }); +}; diff --git a/dvadmin-ui/src/api/vadmin/monitor/cache.js b/dvadmin-ui/src/api/vadmin/monitor/cache.js index 59d3505..8eb7c1b 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/cache.js +++ b/dvadmin-ui/src/api/vadmin/monitor/cache.js @@ -1,9 +1,9 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询缓存详细 export function getCache() { return request({ - url: '/monitor/cache', - method: 'get' - }) + url: "/monitor/cache", + method: "get" + }); } diff --git a/dvadmin-ui/src/api/vadmin/monitor/celery.js b/dvadmin-ui/src/api/vadmin/monitor/celery.js index 98d0a04..11b8c50 100644 --- a/dvadmin-ui/src/api/vadmin/monitor/celery.js +++ b/dvadmin-ui/src/api/vadmin/monitor/celery.js @@ -1,15 +1,15 @@ -import request from '@/utils/request' +import request from "@/utils/request"; /** * 封装celery任务信息接口请求 */ // 获取 -export const sync_data_prefix = '/admin/celery'; +export const sync_data_prefix = "/admin/celery"; // 获取 export function getIntervalschedulea(id) { return request({ url: `${sync_data_prefix}/intervalschedule/${id}/`, - method: 'get' + method: "get" }); } @@ -17,7 +17,7 @@ export function getIntervalschedulea(id) { export function listIntervalschedule(params) { return request({ url: `${sync_data_prefix}/intervalschedule/`, - method: 'get', + method: "get", params }); } @@ -26,7 +26,7 @@ export function listIntervalschedule(params) { export function updateIntervalschedule(data) { return request({ url: `${sync_data_prefix}/intervalschedule/${data.id}/`, - method: 'put', + method: "put", data }); } @@ -34,7 +34,7 @@ export function updateIntervalschedule(data) { export function createIntervalschedule(data) { return request({ url: `${sync_data_prefix}/intervalschedule/`, - method: 'post', + method: "post", data }); } @@ -42,7 +42,7 @@ export function createIntervalschedule(data) { export function deleteIntervalschedule(id) { return request({ url: `${sync_data_prefix}/intervalschedule/${id}/`, - method: 'delete' + method: "delete" }); } @@ -50,7 +50,7 @@ export function deleteIntervalschedule(id) { export function getCrontabSchedule(id) { return request({ url: `${sync_data_prefix}/crontabschedule/${id}/`, - method: 'get' + method: "get" }); } @@ -58,7 +58,7 @@ export function getCrontabSchedule(id) { export function listCrontabSchedule(params) { return request({ url: `${sync_data_prefix}/crontabschedule/`, - method: 'get', + method: "get", params }); } @@ -67,7 +67,7 @@ export function listCrontabSchedule(params) { export function updateCrontabSchedule(data) { return request({ url: `${sync_data_prefix}/crontabschedule/${data.id}/`, - method: 'put', + method: "put", data }); } @@ -75,7 +75,7 @@ export function updateCrontabSchedule(data) { export function createCrontabSchedule(data) { return request({ url: `${sync_data_prefix}/crontabschedule/`, - method: 'post', + method: "post", data }); } @@ -83,7 +83,7 @@ export function createCrontabSchedule(data) { export function deleteCrontabSchedule(id) { return request({ url: `${sync_data_prefix}/crontabschedule/${id}/`, - method: 'delete' + method: "delete" }); } @@ -91,7 +91,7 @@ export function deleteCrontabSchedule(id) { export function getPeriodicTask(id) { return request({ url: `${sync_data_prefix}/periodictask/${id}/`, - method: 'get' + method: "get" }); } @@ -99,7 +99,7 @@ export function getPeriodicTask(id) { export function listPeriodicTask(params) { return request({ url: `${sync_data_prefix}/periodictask/`, - method: 'get', + method: "get", params }); } @@ -107,7 +107,7 @@ export function listPeriodicTask(params) { export function TasksAsChoices(params) { return request({ url: `${sync_data_prefix}/tasks_as_choices/`, - method: 'get', + method: "get", params }); } @@ -116,7 +116,7 @@ export function TasksAsChoices(params) { export function updatePeriodicTask(data) { return request({ url: `${sync_data_prefix}/periodictask/${data.id}/`, - method: 'put', + method: "put", data }); } @@ -124,7 +124,7 @@ export function updatePeriodicTask(data) { export function createPeriodicTask(data) { return request({ url: `${sync_data_prefix}/periodictask/`, - method: 'post', + method: "post", data }); } @@ -132,7 +132,7 @@ export function createPeriodicTask(data) { export function deletePeriodicTask(id) { return request({ url: `${sync_data_prefix}/periodictask/${id}/`, - method: 'delete' + method: "delete" }); } @@ -140,7 +140,7 @@ export function deletePeriodicTask(id) { export function operatesyncdata(data) { return request({ url: `${sync_data_prefix}/operate_celery/`, - method: 'post', + method: "post", data }); } @@ -148,33 +148,33 @@ export function operatesyncdata(data) { // 查询定时任务日志列表 export function list(query) { return request({ - url: '/admin/system/celery_log/', - method: 'get', + url: "/admin/system/celery_log/", + method: "get", params: query - }) + }); } // 删除定时任务日志 export function delCeleryLog(infoId) { return request({ url: `/admin/system/celery_log/${infoId}/`, - method: 'delete' - }) + method: "delete" + }); } // 清空定时任务日志 export function cleanCeleryLog() { return request({ - url: '/admin/system/celery_log/clean', - method: 'delete' - }) + url: "/admin/system/celery_log/clean", + method: "delete" + }); } // 导出定时任务日志 export function exportCeleryLog(query) { return request({ - url: '/admin/system/celery_log/export', - method: 'get', + url: "/admin/system/celery_log/export", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/monitor/job.js b/dvadmin-ui/src/api/vadmin/monitor/job.js index 58c4343..b7241b5 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/job.js +++ b/dvadmin-ui/src/api/vadmin/monitor/job.js @@ -1,55 +1,55 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询定时任务调度列表 export function listJob(query) { return request({ - url: '/monitor/job/list', - method: 'get', + url: "/monitor/job/list", + method: "get", params: query - }) + }); } // 查询定时任务调度详细 export function getJob(jobId) { return request({ - url: '/monitor/job/' + jobId, - method: 'get' - }) + url: "/monitor/job/" + jobId, + method: "get" + }); } // 新增定时任务调度 export function addJob(data) { return request({ - url: '/monitor/job', - method: 'post', + url: "/monitor/job", + method: "post", data: data - }) + }); } // 修改定时任务调度 export function updateJob(data) { return request({ - url: '/monitor/job', - method: 'put', + url: "/monitor/job", + method: "put", data: data - }) + }); } // 删除定时任务调度 export function delJob(jobId) { return request({ - url: '/monitor/job/' + jobId, - method: 'delete' - }) + url: "/monitor/job/" + jobId, + method: "delete" + }); } // 导出定时任务调度 export function exportJob(query) { return request({ - url: '/monitor/job/export', - method: 'get', + url: "/monitor/job/export", + method: "get", params: query - }) + }); } // 任务状态修改 @@ -57,24 +57,23 @@ export function changeJobStatus(jobId, status) { const data = { jobId, status - } + }; return request({ - url: '/monitor/job/changeStatus', - method: 'put', + url: "/monitor/job/changeStatus", + method: "put", data: data - }) + }); } - // 定时任务立即执行一次 export function runJob(jobId, jobGroup) { const data = { jobId, jobGroup - } + }; return request({ - url: '/monitor/job/run', - method: 'put', + url: "/monitor/job/run", + method: "put", data: data - }) -} \ No newline at end of file + }); +} diff --git a/dvadmin-ui/src/api/vadmin/monitor/jobLog.js b/dvadmin-ui/src/api/vadmin/monitor/jobLog.js index be1fffd..e26c981 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/jobLog.js +++ b/dvadmin-ui/src/api/vadmin/monitor/jobLog.js @@ -1,35 +1,35 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询调度日志列表 export function listJobLog(query) { return request({ - url: '/monitor/jobLog/list', - method: 'get', + url: "/monitor/jobLog/list", + method: "get", params: query - }) + }); } // 删除调度日志 export function delJobLog(jobLogId) { return request({ - url: '/monitor/jobLog/' + jobLogId, - method: 'delete' - }) + url: "/monitor/jobLog/" + jobLogId, + method: "delete" + }); } // 清空调度日志 export function cleanJobLog() { return request({ - url: '/monitor/jobLog/clean', - method: 'delete' - }) + url: "/monitor/jobLog/clean", + method: "delete" + }); } // 导出调度日志 export function exportJobLog(query) { return request({ - url: '/monitor/jobLog/export', - method: 'get', + url: "/monitor/jobLog/export", + method: "get", params: query - }) -} \ No newline at end of file + }); +} diff --git a/dvadmin-ui/src/api/vadmin/monitor/logininfor.js b/dvadmin-ui/src/api/vadmin/monitor/logininfor.js index 1dc21d4..df440dc 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/logininfor.js +++ b/dvadmin-ui/src/api/vadmin/monitor/logininfor.js @@ -1,35 +1,35 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询登录日志列表 export function list(query) { return request({ - url: '/admin/system/logininfor/', - method: 'get', + url: "/admin/system/logininfor/", + method: "get", params: query - }) + }); } // 删除登录日志 export function delLogininfor(infoId) { return request({ url: `/admin/system/logininfor/${infoId}/`, - method: 'delete' - }) + method: "delete" + }); } // 清空登录日志 export function cleanLogininfor() { return request({ - url: '/admin/system/logininfor/clean', - method: 'delete' - }) + url: "/admin/system/logininfor/clean", + method: "delete" + }); } // 导出登录日志 export function exportLogininfor(query) { return request({ - url: '/admin/system/logininfor/export', - method: 'get', + url: "/admin/system/logininfor/export", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/monitor/online.js b/dvadmin-ui/src/api/vadmin/monitor/online.js index ca3348b..df987bc 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/online.js +++ b/dvadmin-ui/src/api/vadmin/monitor/online.js @@ -1,18 +1,18 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询在线用户列表 export function list(query) { return request({ - url: '/admin/monitor/online/list', - method: 'get', + url: "/admin/monitor/online/list", + method: "get", params: query - }) + }); } // 强退用户 export function forceLogout(tokenId) { return request({ - url: '/admin/monitor/online/' + tokenId, - method: 'delete' - }) + url: "/admin/monitor/online/" + tokenId, + method: "delete" + }); } diff --git a/dvadmin-ui/src/api/vadmin/monitor/operlog.js b/dvadmin-ui/src/api/vadmin/monitor/operlog.js index f09b8ed..0f64087 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/operlog.js +++ b/dvadmin-ui/src/api/vadmin/monitor/operlog.js @@ -1,35 +1,35 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询操作日志列表 export function list(query) { return request({ - url: '/monitor/operlog/list', - method: 'get', + url: "/monitor/operlog/list", + method: "get", params: query - }) + }); } // 删除操作日志 export function delOperlog(operId) { return request({ - url: '/monitor/operlog/' + operId, - method: 'delete' - }) + url: "/monitor/operlog/" + operId, + method: "delete" + }); } // 清空操作日志 export function cleanOperlog() { return request({ - url: '/monitor/operlog/clean', - method: 'delete' - }) + url: "/monitor/operlog/clean", + method: "delete" + }); } // 导出操作日志 export function exportOperlog(query) { return request({ - url: '/monitor/operlog/export', - method: 'get', + url: "/monitor/operlog/export", + method: "get", params: query - }) -} \ No newline at end of file + }); +} diff --git a/dvadmin-ui/src/api/vadmin/monitor/server.js b/dvadmin-ui/src/api/vadmin/monitor/server.js index e25be29..beac0af 100755 --- a/dvadmin-ui/src/api/vadmin/monitor/server.js +++ b/dvadmin-ui/src/api/vadmin/monitor/server.js @@ -1,50 +1,50 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询服务器信息详细 export function getServerList(params) { return request({ - url: 'admin/monitor/server/', + url: "admin/monitor/server/", params, - method: 'get' - }) + method: "get" + }); } // 修改服务器信息 export function updateServerInfo(id, data) { - let {name, remark} = data; + const { name, remark } = data; return request({ url: `admin/monitor/server/${id}/`, data: { name, remark }, - method: 'PUT' - }) + method: "PUT" + }); } // 获取监控配置信息 export function getMonitorStatusInfo() { return request({ - url: 'admin/monitor/monitor/enabled/', - method: 'get' - }) + url: "admin/monitor/monitor/enabled/", + method: "get" + }); } // 更新监控配置信息 export function updateMonitorStatusInfo(params) { return request({ - url: 'admin/monitor/monitor/enabled/', + url: "admin/monitor/monitor/enabled/", params, - method: 'get' - }) + method: "get" + }); } // 清空记录 export function cleanMonitorLog() { return request({ - url: 'admin/monitor/monitor/clean/', - method: 'delete' - }) + url: "admin/monitor/monitor/clean/", + method: "delete" + }); } // 获取监控记录 @@ -52,14 +52,14 @@ export function getMonitorLogs(id, params) { return request({ url: `admin/monitor/monitor/rate/${id}/`, params, - method: 'get' - }) + method: "get" + }); } // 获取服务器最新监控日志信息 export function getServerLatestLog(id) { return request({ url: `admin/monitor/monitor/info/${id}/`, - method: 'get' - }) + method: "get" + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/dept.js b/dvadmin-ui/src/api/vadmin/permission/dept.js index 17918b1..085052d 100755 --- a/dvadmin-ui/src/api/vadmin/permission/dept.js +++ b/dvadmin-ui/src/api/vadmin/permission/dept.js @@ -1,68 +1,68 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询部门列表 export function listDept(query) { return request({ - url: '/admin/permission/dept/', - method: 'get', + url: "/admin/permission/dept/", + method: "get", params: query - }) + }); } // 查询部门列表(排除节点) export function listDeptExcludeChild(deptId) { return request({ - url: '/admin/permission/dept/exclude/' + deptId + '/', - method: 'get' - }) + url: "/admin/permission/dept/exclude/" + deptId + "/", + method: "get" + }); } // 查询部门详细 export function getDept(deptId) { return request({ - url: '/admin/permission/dept/' + deptId + '/', - method: 'get' - }) + url: "/admin/permission/dept/" + deptId + "/", + method: "get" + }); } // 查询部门下拉树结构 export function treeselect() { return request({ - url: '/admin/permission/dept/treeselect/?status=1', - method: 'get' - }) + url: "/admin/permission/dept/treeselect/?status=1", + method: "get" + }); } // 根据角色ID查询部门树结构 export function roleDeptTreeselect(roleId) { return request({ - url: '/admin/permission/dept/roleDeptTreeselect/' + roleId + '/?status=1', - method: 'get' - }) + url: "/admin/permission/dept/roleDeptTreeselect/" + roleId + "/?status=1", + method: "get" + }); } // 新增部门 export function addDept(data) { return request({ - url: '/admin/permission/dept/', - method: 'post', + url: "/admin/permission/dept/", + method: "post", data: data - }) + }); } // 修改部门 export function updateDept(data) { return request({ - url: '/admin/permission/dept/' + data.id + '/', - method: 'put', + url: "/admin/permission/dept/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除部门 export function delDept(deptId) { return request({ - url: '/admin/permission/dept/' + deptId + '', - method: 'delete' - }) + url: "/admin/permission/dept/" + deptId + "", + method: "delete" + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/menu.js b/dvadmin-ui/src/api/vadmin/permission/menu.js index cd1cceb..af4b2b3 100755 --- a/dvadmin-ui/src/api/vadmin/permission/menu.js +++ b/dvadmin-ui/src/api/vadmin/permission/menu.js @@ -1,60 +1,60 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询菜单列表 export function listMenu(query) { return request({ - url: '/admin/permission/menus/', - method: 'get', + url: "/admin/permission/menus/", + method: "get", params: query - }) + }); } // 查询菜单详细 export function getMenu(menuId) { return request({ - url: '/admin/permission/menus/' + menuId, - method: 'get' - }) + url: "/admin/permission/menus/" + menuId, + method: "get" + }); } // 查询菜单下拉树结构 export function treeselect() { return request({ - url: '/admin/permission/menus/treeselect/?status=1', - method: 'get' - }) + url: "/admin/permission/menus/treeselect/?status=1", + method: "get" + }); } // 根据角色ID查询菜单下拉树结构 export function roleMenuTreeselect(roleId) { return request({ - url: '/admin/permission/menus/roleMenuTreeselect/' + roleId + '/?status=1', - method: 'get' - }) + url: "/admin/permission/menus/roleMenuTreeselect/" + roleId + "/?status=1", + method: "get" + }); } // 新增菜单 export function addMenu(data) { return request({ - url: '/admin/permission/menus/', - method: 'post', + url: "/admin/permission/menus/", + method: "post", data: data - }) + }); } // 修改菜单 export function updateMenu(data) { return request({ - url: '/admin/permission/menus/'+ data.id + '/', - method: 'put', + url: "/admin/permission/menus/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除菜单 export function delMenu(menuId) { return request({ - url: '/admin/permission/menus/' + menuId + '/', - method: 'delete' - }) + url: "/admin/permission/menus/" + menuId + "/", + method: "delete" + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/msg.js b/dvadmin-ui/src/api/vadmin/permission/msg.js index f0d68f8..54e5fe7 100644 --- a/dvadmin-ui/src/api/vadmin/permission/msg.js +++ b/dvadmin-ui/src/api/vadmin/permission/msg.js @@ -6,23 +6,23 @@ * @Description: In User Settings Edit * @FilePath: \dvadmin-ui\src\api\permission\msg.js */ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询消息列表 export function getList(query) { return request({ - url: '/admin/system/config/', - method: 'get', + url: "/admin/system/config/", + method: "get", params: query - }) + }); } // 查看详情 export function getDesc(configId) { return request({ - url: '/admin/system/config/' + configId + '/', - method: 'get' - }) + url: "/admin/system/config/" + configId + "/", + method: "get" + }); } // // 根据消息标题查询 @@ -36,35 +36,34 @@ export function getDesc(configId) { // 新增消息 export function addMsg(data) { return request({ - url: '/admin/system/config/', - method: 'post', + url: "/admin/system/config/", + method: "post", data: data - }) + }); } // 修改消息 export function updateMsg(data) { return request({ - url: '/admin/system/config/' + data.id + '/', - method: 'put', + url: "/admin/system/config/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除消息 export function delMsg(configId) { return request({ - url: '/admin/system/config/' + configId + '/', - method: 'delete' - }) + url: "/admin/system/config/" + configId + "/", + method: "delete" + }); } - // 导出消息 export function exportMsg(query) { return request({ - url: '/admin/system/config/export/', - method: 'get', + url: "/admin/system/config/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/post.js b/dvadmin-ui/src/api/vadmin/permission/post.js index 1bde3a6..8c2a4ca 100755 --- a/dvadmin-ui/src/api/vadmin/permission/post.js +++ b/dvadmin-ui/src/api/vadmin/permission/post.js @@ -1,53 +1,53 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询岗位列表 export function listPost(query) { return request({ - url: '/admin/permission/post/', - method: 'get', + url: "/admin/permission/post/", + method: "get", params: query - }) + }); } // 查询岗位详细 export function getPost(postId) { return request({ - url: '/admin/permission/post/' + postId + '/', - method: 'get' - }) + url: "/admin/permission/post/" + postId + "/", + method: "get" + }); } // 新增岗位 export function addPost(data) { return request({ - url: '/admin/permission/post/', - method: 'post', + url: "/admin/permission/post/", + method: "post", data: data - }) + }); } // 修改岗位 export function updatePost(data) { return request({ - url: '/admin/permission/post/' + data.id + '/', - method: 'put', + url: "/admin/permission/post/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除岗位 export function delPost(postId) { return request({ - url: '/admin/permission/post/' + postId + '/', - method: 'delete' - }) + url: "/admin/permission/post/" + postId + "/", + method: "delete" + }); } // 导出岗位 export function exportPost(query) { return request({ - url: '/admin/permission/post/export/', - method: 'get', + url: "/admin/permission/post/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/role.js b/dvadmin-ui/src/api/vadmin/permission/role.js index 73bcbb9..48acc74 100755 --- a/dvadmin-ui/src/api/vadmin/permission/role.js +++ b/dvadmin-ui/src/api/vadmin/permission/role.js @@ -1,47 +1,47 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询角色列表 export function listRole(query) { return request({ - url: '/admin/permission/role/', - method: 'get', + url: "/admin/permission/role/", + method: "get", params: query - }) + }); } // 查询角色详细 export function getRole(roleId) { return request({ - url: '/admin/permission/role/' + roleId + '/', - method: 'get' - }) + url: "/admin/permission/role/" + roleId + "/", + method: "get" + }); } // 新增角色 export function addRole(data) { return request({ - url: '/admin/permission/role/', - method: 'post', + url: "/admin/permission/role/", + method: "post", data: data - }) + }); } // 修改角色 export function updateRole(data) { return request({ - url: '/admin/permission/role/' + data.id + '/', - method: 'put', + url: "/admin/permission/role/" + data.id + "/", + method: "put", data: data - }) + }); } // 角色数据权限 export function dataScope(data) { return request({ - url: '/admin/permission/role/' + data.id + '/', - method: 'put', + url: "/admin/permission/role/" + data.id + "/", + method: "put", data: data - }) + }); } // 角色状态修改 @@ -49,27 +49,27 @@ export function changeRoleStatus(roleId, status) { const data = { roleId, status - } + }; return request({ - url: '/admin/permission/role/changeStatus/', - method: 'put', + url: "/admin/permission/role/changeStatus/", + method: "put", data: data - }) + }); } // 删除角色 export function delRole(roleId) { return request({ - url: '/admin/permission/role/' + roleId + '/', - method: 'delete' - }) + url: "/admin/permission/role/" + roleId + "/", + method: "delete" + }); } // 导出角色 export function exportRole(query) { return request({ - url: '/admin/permission/role/export/', - method: 'get', + url: "/admin/permission/role/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/permission/user.js b/dvadmin-ui/src/api/vadmin/permission/user.js index fa01c92..819e38e 100755 --- a/dvadmin-ui/src/api/vadmin/permission/user.js +++ b/dvadmin-ui/src/api/vadmin/permission/user.js @@ -1,56 +1,56 @@ -import request from '@/utils/request' -import {praseStrEmpty} from "@/utils/ruoyi"; +import request from "@/utils/request"; +import { praseStrEmpty } from "@/utils/ruoyi"; // 查询用户列表 export function listUser(query) { return request({ - url: '/admin/permission/user/', - method: 'get', + url: "/admin/permission/user/", + method: "get", params: query - }) + }); } // 查询用户详细 export function getUser(userId) { return request({ - url: '/admin/permission/user/details/?userId=' + praseStrEmpty(userId), - method: 'get' - }) + url: "/admin/permission/user/details/?userId=" + praseStrEmpty(userId), + method: "get" + }); } // 新增用户 export function addUser(data) { return request({ - url: '/admin/permission/user/', - method: 'post', + url: "/admin/permission/user/", + method: "post", data: data - }) + }); } // 修改用户 export function updateUser(data) { return request({ - url: '/admin/permission/user/' + data.id + '/', - method: 'put', + url: "/admin/permission/user/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除用户 export function delUser(userId) { return request({ - url: '/admin/permission/user/' + userId + '/', - method: 'delete' - }) + url: "/admin/permission/user/" + userId + "/", + method: "delete" + }); } // 导出用户 export function exportUser(query) { return request({ - url: '/admin/permission/user/export/', - method: 'get', + url: "/admin/permission/user/export/", + method: "get", params: query - }) + }); } // 用户密码重置 @@ -58,12 +58,12 @@ export function resetUserPwd(userId, password) { const data = { userId, password - } + }; return request({ - url: '/admin/permission/user/resetPwd/', - method: 'put', + url: "/admin/permission/user/resetPwd/", + method: "put", data: data - }) + }); } // 用户状态修改 @@ -71,29 +71,29 @@ export function changeUserStatus(userId, status) { const data = { userId, status - } + }; return request({ - url: '/admin/permission/user/changeStatus/', - method: 'put', + url: "/admin/permission/user/changeStatus/", + method: "put", data: data - }) + }); } // 查询用户个人信息 export function getUserProfile() { return request({ - url: '/admin/permission/user/profile/', - method: 'get' - }) + url: "/admin/permission/user/profile/", + method: "get" + }); } // 修改用户个人信息 export function updateUserProfile(data) { return request({ - url: '/admin/permission/user/profile/', - method: 'put', + url: "/admin/permission/user/profile/", + method: "put", data: data - }) + }); } // 用户密码重置 @@ -101,36 +101,36 @@ export function updateUserPwd(oldPassword, newPassword) { const data = { oldPassword, newPassword - } + }; return request({ - url: '/admin/permission/user/profile/updatePwd/', - method: 'put', + url: "/admin/permission/user/profile/updatePwd/", + method: "put", data: data - }) + }); } // 用户头像上传 export function uploadAvatar(data) { return request({ - url: '/admin/permission/user/profile/avatar/', - method: 'put', + url: "/admin/permission/user/profile/avatar/", + method: "put", data: data - }) + }); } // 下载用户导入模板 export function importTemplate() { return request({ - url: '/admin/permission/user/importTemplate/', - method: 'get' - }) + url: "/admin/permission/user/importTemplate/", + method: "get" + }); } // 用户导入 export function importsUser(data) { return request({ - url: '/admin/permission/user/importTemplate/', - method: 'post', + url: "/admin/permission/user/importTemplate/", + method: "post", data: data - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/config.js b/dvadmin-ui/src/api/vadmin/system/config.js index beaf681..74b50a5 100755 --- a/dvadmin-ui/src/api/vadmin/system/config.js +++ b/dvadmin-ui/src/api/vadmin/system/config.js @@ -1,69 +1,69 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询参数列表 export function listConfig(query) { return request({ - url: '/admin/system/config/', - method: 'get', + url: "/admin/system/config/", + method: "get", params: query - }) + }); } // 查询参数详细 export function getConfig(configId) { return request({ - url: '/admin/system/config/' + configId + '/', - method: 'get' - }) + url: "/admin/system/config/" + configId + "/", + method: "get" + }); } // 根据参数键名查询参数值 export function getConfigKey(configKey) { return request({ - url: '/admin/system/config/configKey/' + configKey + '/?status=1', - method: 'get' - }) + url: "/admin/system/config/configKey/" + configKey + "/?status=1", + method: "get" + }); } // 新增参数配置 export function addConfig(data) { return request({ - url: '/admin/system/config/', - method: 'post', + url: "/admin/system/config/", + method: "post", data: data - }) + }); } // 修改参数配置 export function updateConfig(data) { return request({ - url: '/admin/system/config/' + data.id + '/', - method: 'put', + url: "/admin/system/config/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除参数配置 export function delConfig(configId) { return request({ - url: '/admin/system/config/' + configId + '/', - method: 'delete' - }) + url: "/admin/system/config/" + configId + "/", + method: "delete" + }); } // 清理参数缓存 export function clearCache() { return request({ - url: '/admin/system/config/clearCache/', - method: 'delete' - }) + url: "/admin/system/config/clearCache/", + method: "delete" + }); } // 导出参数 export function exportConfig(query) { return request({ - url: '/admin/system/config/export/', - method: 'get', + url: "/admin/system/config/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/dict/data.js b/dvadmin-ui/src/api/vadmin/system/dict/data.js index cdbef01..b8cd6a9 100755 --- a/dvadmin-ui/src/api/vadmin/system/dict/data.js +++ b/dvadmin-ui/src/api/vadmin/system/dict/data.js @@ -1,61 +1,61 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询字典数据列表 export function listData(query) { return request({ - url: '/admin/system/dict/data/', - method: 'get', + url: "/admin/system/dict/data/", + method: "get", params: query - }) + }); } // 查询字典数据详细 export function getData(dictCode) { return request({ - url: '/admin/system/dict/data/' + dictCode + '/', - method: 'get' - }) + url: "/admin/system/dict/data/" + dictCode + "/", + method: "get" + }); } // 根据字典类型查询字典数据信息 export function getDicts(dictType) { return request({ - url: '/admin/system/dict/get/type/' + dictType + '/?status=1', - method: 'get' - }) + url: "/admin/system/dict/get/type/" + dictType + "/?status=1", + method: "get" + }); } // 新增字典数据 export function addData(data) { return request({ - url: '/admin/system/dict/data' + '/', - method: 'post', + url: "/admin/system/dict/data" + "/", + method: "post", data: data - }) + }); } // 修改字典数据 export function updateData(data) { return request({ - url: '/admin/system/dict/data/' + data.id + '/', - method: 'put', + url: "/admin/system/dict/data/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除字典数据 export function delData(dictCode) { return request({ - url: '/admin/system/dict/data/' + dictCode + '/', - method: 'delete' - }) + url: "/admin/system/dict/data/" + dictCode + "/", + method: "delete" + }); } // 导出字典数据 export function exportData(query) { return request({ - url: '/admin/system/dict/data/export/', - method: 'get', + url: "/admin/system/dict/data/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/dict/type.js b/dvadmin-ui/src/api/vadmin/system/dict/type.js index c0867ff..96edacc 100755 --- a/dvadmin-ui/src/api/vadmin/system/dict/type.js +++ b/dvadmin-ui/src/api/vadmin/system/dict/type.js @@ -1,69 +1,69 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询字典类型列表 export function listType(query) { return request({ - url: '/admin/system/dict/type/', - method: 'get', + url: "/admin/system/dict/type/", + method: "get", params: query - }) + }); } // 查询字典类型详细 export function getType(dictId) { return request({ - url: '/admin/system/dict/type/' + dictId + '/', - method: 'get' - }) + url: "/admin/system/dict/type/" + dictId + "/", + method: "get" + }); } // 新增字典类型 export function addType(data) { return request({ - url: '/admin/system/dict/type/', - method: 'post', + url: "/admin/system/dict/type/", + method: "post", data: data - }) + }); } // 修改字典类型 export function updateType(data) { return request({ - url: '/admin/system/dict/type/' + data.id + '/', - method: 'put', + url: "/admin/system/dict/type/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除字典类型 export function delType(dictId) { return request({ - url: '/admin/system/dict/type/' + dictId + '/', - method: 'delete' - }) + url: "/admin/system/dict/type/" + dictId + "/", + method: "delete" + }); } // 清理参数缓存 export function clearCache() { return request({ - url: '/admin/system/dict/type/clearCache/', - method: 'delete' - }) + url: "/admin/system/dict/type/clearCache/", + method: "delete" + }); } // 导出字典类型 export function exportType(query) { return request({ - url: '/admin/system/dict/type/export/', - method: 'get', + url: "/admin/system/dict/type/export/", + method: "get", params: query - }) + }); } // 获取字典选择框列表 export function optionselect() { return request({ - url: '/admin/system/dict/type/optionselect', - method: 'get' - }) + url: "/admin/system/dict/type/optionselect", + method: "get" + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/message.js b/dvadmin-ui/src/api/vadmin/system/message.js index 986fb76..9afb095 100755 --- a/dvadmin-ui/src/api/vadmin/system/message.js +++ b/dvadmin-ui/src/api/vadmin/system/message.js @@ -1,71 +1,70 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询通知列表 export function listMessage(query) { return request({ - url: '/admin/system/message/', - method: 'get', + url: "/admin/system/message/", + method: "get", params: query - }) + }); } // 查询通知详细 export function getMessage(messageId) { return request({ - url: '/admin/system/message/' + messageId + '/', - method: 'get' - }) + url: "/admin/system/message/" + messageId + "/", + method: "get" + }); } // 新增通知配置 export function addMessage(data) { return request({ - url: '/admin/system/message/', - method: 'post', + url: "/admin/system/message/", + method: "post", data: data - }) + }); } // 修改通知配置 export function updateMessage(data) { return request({ - url: '/admin/system/message/' + data.id + '/', - method: 'put', + url: "/admin/system/message/" + data.id + "/", + method: "put", data: data - }) + }); } // 删除通知配置 export function delMessage(messageId) { return request({ - url: '/admin/system/message/' + messageId + '/', - method: 'delete' - }) + url: "/admin/system/message/" + messageId + "/", + method: "delete" + }); } - // 导出通知 export function exportMessage(query) { return request({ - url: '/admin/system/message/export/', - method: 'get', + url: "/admin/system/message/export/", + method: "get", params: query - }) + }); } // 获取用户通知列表 export function userMessage(query) { return request({ - url: '/admin/system/message/user_messages/', - method: 'get', + url: "/admin/system/message/user_messages/", + method: "get", params: query - }) + }); } // 修改通知为已读 export function updateIsRead(data) { return request({ - url: '/admin/system/message/is_read/'+ data.id + '/', - method: 'put', - }) + url: "/admin/system/message/is_read/" + data.id + "/", + method: "put" + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/notice.js b/dvadmin-ui/src/api/vadmin/system/notice.js index af4b266..9263bb2 100755 --- a/dvadmin-ui/src/api/vadmin/system/notice.js +++ b/dvadmin-ui/src/api/vadmin/system/notice.js @@ -1,44 +1,44 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询公告列表 export function listNotice(query) { return request({ - url: '/admin/system/notice/list', - method: 'get', + url: "/admin/system/notice/list", + method: "get", params: query - }) + }); } // 查询公告详细 export function getNotice(noticeId) { return request({ - url: '/admin/system/notice/' + noticeId, - method: 'get' - }) + url: "/admin/system/notice/" + noticeId, + method: "get" + }); } // 新增公告 export function addNotice(data) { return request({ - url: '/admin/system/notice', - method: 'post', + url: "/admin/system/notice", + method: "post", data: data - }) + }); } // 修改公告 export function updateNotice(data) { return request({ - url: '/admin/system/notice', - method: 'put', + url: "/admin/system/notice", + method: "put", data: data - }) + }); } // 删除公告 export function delNotice(noticeId) { return request({ - url: '/admin/system/notice/' + noticeId, - method: 'delete' - }) + url: "/admin/system/notice/" + noticeId, + method: "delete" + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/operationlog.js b/dvadmin-ui/src/api/vadmin/system/operationlog.js index 7971fc7..2766fac 100755 --- a/dvadmin-ui/src/api/vadmin/system/operationlog.js +++ b/dvadmin-ui/src/api/vadmin/system/operationlog.js @@ -1,35 +1,35 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询操作日志列表 export function list(query) { return request({ - url: '/admin/system/operation_log/', - method: 'get', + url: "/admin/system/operation_log/", + method: "get", params: query - }) + }); } // 删除操作日志 export function delOperationLog(operId) { return request({ - url: '/admin/system/operation_log/' + operId + '/', - method: 'delete' - }) + url: "/admin/system/operation_log/" + operId + "/", + method: "delete" + }); } // 清空操作日志 export function cleanOperationLog() { return request({ - url: '/admin/system/operation_log/clean/', - method: 'delete' - }) + url: "/admin/system/operation_log/clean/", + method: "delete" + }); } // 导出操作日志 export function exportOperationLog(query) { return request({ - url: '/admin/system/operation_log/export/', - method: 'get', + url: "/admin/system/operation_log/export/", + method: "get", params: query - }) + }); } diff --git a/dvadmin-ui/src/api/vadmin/system/savefile.js b/dvadmin-ui/src/api/vadmin/system/savefile.js index 77f1820..9249ceb 100644 --- a/dvadmin-ui/src/api/vadmin/system/savefile.js +++ b/dvadmin-ui/src/api/vadmin/system/savefile.js @@ -1,36 +1,35 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询文件列表 export function listSaveFile(query) { return request({ - url: '/admin/system/savefile/', - method: 'get', + url: "/admin/system/savefile/", + method: "get", params: query - }) + }); } // 新增文件 export function addSaveFile(data) { return request({ - url: '/admin/system/savefile/', - method: 'post', + url: "/admin/system/savefile/", + method: "post", data: data - }) + }); } - // 删除文件 export function delSaveFile(menuId) { return request({ - url: '/admin/system/savefile/' + menuId + '/', - method: 'delete' - }) + url: "/admin/system/savefile/" + menuId + "/", + method: "delete" + }); } // 清理废弃文件 export function clearSaveFile() { return request({ - url: '/admin/system/clearsavefile/', - method: 'post' - }) + url: "/admin/system/clearsavefile/", + method: "post" + }); } diff --git a/dvadmin-ui/src/api/vadmin/tool/gen.js b/dvadmin-ui/src/api/vadmin/tool/gen.js index 4506927..91fd24e 100755 --- a/dvadmin-ui/src/api/vadmin/tool/gen.js +++ b/dvadmin-ui/src/api/vadmin/tool/gen.js @@ -1,76 +1,76 @@ -import request from '@/utils/request' +import request from "@/utils/request"; // 查询生成表数据 export function listTable(query) { return request({ - url: '/tool/gen/list', - method: 'get', + url: "/tool/gen/list", + method: "get", params: query - }) + }); } // 查询db数据库列表 export function listDbTable(query) { return request({ - url: '/tool/gen/db/list', - method: 'get', + url: "/tool/gen/db/list", + method: "get", params: query - }) + }); } // 查询表详细信息 export function getGenTable(tableId) { return request({ - url: '/tool/gen/' + tableId, - method: 'get' - }) + url: "/tool/gen/" + tableId, + method: "get" + }); } // 修改代码生成信息 export function updateGenTable(data) { return request({ - url: '/tool/gen', - method: 'put', + url: "/tool/gen", + method: "put", data: data - }) + }); } // 导入表 export function importTable(data) { return request({ - url: '/tool/gen/importTable', - method: 'post', + url: "/tool/gen/importTable", + method: "post", params: data - }) + }); } // 预览生成代码 export function previewTable(tableId) { return request({ - url: '/tool/gen/preview/' + tableId, - method: 'get' - }) + url: "/tool/gen/preview/" + tableId, + method: "get" + }); } // 删除表数据 export function delTable(tableId) { return request({ - url: '/tool/gen/' + tableId, - method: 'delete' - }) + url: "/tool/gen/" + tableId, + method: "delete" + }); } // 生成代码(自定义路径) export function genCode(tableName) { return request({ - url: '/tool/gen/genCode/' + tableName, - method: 'get' - }) + url: "/tool/gen/genCode/" + tableName, + method: "get" + }); } // 同步数据库 export function synchDb(tableName) { return request({ - url: '/tool/gen/synchDb/' + tableName, - method: 'get' - }) + url: "/tool/gen/synchDb/" + tableName, + method: "get" + }); } diff --git a/dvadmin-ui/src/components/Breadcrumb/index.vue b/dvadmin-ui/src/components/Breadcrumb/index.vue index 2e0c775..00590e9 100755 --- a/dvadmin-ui/src/components/Breadcrumb/index.vue +++ b/dvadmin-ui/src/components/Breadcrumb/index.vue @@ -14,49 +14,49 @@ export default { data() { return { levelList: null - } + }; }, watch: { $route(route) { // if you go to the redirect page, do not update the breadcrumbs - if (route.path.startsWith('/redirect/')) { - return + if (route.path.startsWith("/redirect/")) { + return; } - this.getBreadcrumb() + this.getBreadcrumb(); } }, created() { - this.getBreadcrumb() + this.getBreadcrumb(); }, methods: { getBreadcrumb() { // only show routes with meta.title - let matched = this.$route.matched.filter(item => item.meta && item.meta.title) - const first = matched[0] + const matched = this.$route.matched.filter(item => item.meta && item.meta.title); + const first = matched[0]; if (!this.isDashboard(first)) { // matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched) } - this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) + this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false); }, isDashboard(route) { - const name = route && route.name + const name = route && route.name; if (!name) { - return false + return false; } - return name.trim() === '首页' + return name.trim() === "首页"; }, handleLink(item) { - const { redirect, path } = item + const { redirect, path } = item; if (redirect) { - this.$router.push(redirect) - return + this.$router.push(redirect); + return; } - this.$router.push(path) + this.$router.push(path); } } -} +}; \ No newline at end of file + diff --git a/dvadmin-ui/src/components/FileUpload/index.vue b/dvadmin-ui/src/components/FileUpload/index.vue index 32bce09..b2be5e8 100755 --- a/dvadmin-ui/src/components/FileUpload/index.vue +++ b/dvadmin-ui/src/components/FileUpload/index.vue @@ -1,6 +1,7 @@ diff --git a/dvadmin-ui/src/components/Hamburger/index.vue b/dvadmin-ui/src/components/Hamburger/index.vue index 368b002..243e5e9 100755 --- a/dvadmin-ui/src/components/Hamburger/index.vue +++ b/dvadmin-ui/src/components/Hamburger/index.vue @@ -15,7 +15,7 @@ \ No newline at end of file + diff --git a/dvadmin-ui/src/components/Modal/DetailFormDialog.vue b/dvadmin-ui/src/components/Modal/DetailFormDialog.vue index 1300f1c..6d63a69 100644 --- a/dvadmin-ui/src/components/Modal/DetailFormDialog.vue +++ b/dvadmin-ui/src/components/Modal/DetailFormDialog.vue @@ -1,22 +1,23 @@