!36 新功能及若干bug修复优化

Merge pull request !36 from 李强/dvadmin-liqianglog
pull/37/head
李强 2021-07-11 07:40:51 +00:00 committed by Gitee
commit b828ceea51
233 changed files with 8257 additions and 7941 deletions

View File

@ -2,7 +2,7 @@
[![img](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitee.com/liqianglog/django-vue-admin/blob/master/LICENSE) [![img](https://img.shields.io/badge/python-%3E=3.6.x-green.svg)](https://python.org/) [![PyPI - Django Version badge](https://img.shields.io/badge/django%20versions-2.2-blue)](https://docs.djangoproject.com/zh-hans/2.2/) [![img](https://img.shields.io/badge/node-%3E%3D%2012.0.0-brightgreen)](https://nodejs.org/zh-cn/) [![img](https://gitee.com/liqianglog/django-vue-admin/badge/star.svg?theme=dark)](https://gitee.com/liqianglog/django-vue-admin)
[预 览](https://demo.django-vue-admin.com) | [官 网文档](https://www.django-vue-admin.com) | [群聊](https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi) | [社区](https://bbs.django-vue-admin.com/) | [Github](https://github.com/liqianglog/django-vue-admin)
## 平台简介
@ -14,9 +14,11 @@ Django-Vue-Admin 是一套全部开源的快速开发平台,毫无保留给个
* 支持加载动态权限菜单,多方式轻松权限控制。
* 特别鸣谢:<u>[Gin-Vue-Admin](https://www.gin-vue-admin.com/)</u>[RuoYi](https://gitee.com/y_project/RuoYi-Vue) [Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin)。
## QQ群
## 交流
- QQ群号812482043
- 社区:[戳我](https://bbs.django-vue-admin.com)
- QQ群号812482043 <a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=fOdnHhC8DJlRHGYSnyhoB8P5rgogA6Vs&jump_from=webapi"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="django-vue-admin交流01群" title="django-vue-admin交流01群"></a>
- 二维码

View File

@ -88,8 +88,6 @@ services:
volumes:
- ./dvadmin-backend:/dvadmin-backend
- ./logs/log:/var/log
env_file:
- ./.env
ports:
- "8000:8000"
expose:

View File

@ -1,7 +1,7 @@
"""
Django settings for application project.
Generated by 'django-admin startproject' using Django 1.11.21.
Generated by 'django-admin startproject' using Django 2.2.16.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
@ -46,6 +46,7 @@ INSTALLED_APPS = [
'corsheaders',
'captcha',
'django_celery_beat',
'drf_yasg', # swagger 接口
# 自定义app
'apps.vadmin.permission',
'apps.vadmin.op_drf',
@ -70,7 +71,7 @@ MIDDLEWARE = [
CORS_ORIGIN_ALLOW_ALL = CORS_ORIGIN_ALLOW_ALL
# 允许ajax请求携带cookie
CORS_ALLOW_CREDENTIALS = CORS_ALLOW_CREDENTIALS
X_FRAME_OPTIONS = "ALLOW-FROM"
ROOT_URLCONF = 'application.urls'
TEMPLATES = [
@ -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 时区问题

View File

@ -22,8 +22,22 @@ 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
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<path>.*)', 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<format>\.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'),
]

View File

@ -2,6 +2,6 @@ from django.apps import AppConfig
class DpCmdbConfig(AppConfig):
name = 'vadmin.celery'
name = 'apps.vadmin.celery'

View File

@ -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):

View File

@ -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):
@ -59,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')

View File

@ -2,5 +2,5 @@ from django.apps import AppConfig
class MonitorConfig(AppConfig):
name = 'vadmin.monitor'
name = 'apps.vadmin.monitor'
verbose_name = "系统监控"

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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
# ================================================= #

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -1,7 +1,7 @@
from django.apps import AppConfig
import logging
from django.apps import AppConfig
logger = logging.getLogger(__name__)

View File

@ -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):

View File

@ -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__)

View File

@ -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

View File

@ -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)

View File

@ -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 = '{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成功")

View File

@ -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__)

View File

@ -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)

View File

@ -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

View File

@ -1,7 +1,7 @@
"""
常用的Response以及Django的ResponseDRF的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)

View File

@ -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):

View File

@ -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__)

View File

@ -11,12 +11,11 @@ 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
from .logging.view_logger import CustomerModelViewLogger
from .pagination import Pagination
from .serializers import CustomModelSerializer
@ -173,8 +172,122 @@ class MongoGenericAPIView(GenericAPIView):
class MongoGenericViewSet(ViewSetMixin, MongoGenericAPIView):
pagination_class = Pagination
pass
extra_filter_backends = []
pagination_class = api_settings.DEFAULT_PAGINATION_CLASS
filter_backends = [DjangoFilterBackend, OrderingFilter, SearchFilter, AdvancedSearchFilter]
view_logger_classes = (CustomerModelViewLogger,)
def handle_logging(self, request: Request, *args, **kwargs):
view_loggers = self.get_view_loggers(request, *args, **kwargs)
for view_logger in view_loggers:
handle_action = getattr(view_logger, f'handle_{self.action}', None)
if handle_action and isinstance(handle_action, (FunctionType, MethodType)):
handle_action(request, *args, **kwargs)
def get_serializer(self, *args, **kwargs):
serializer_class = self.get_serializer_class()
kwargs['context'] = self.get_serializer_context()
serializer = serializer_class(*args, **kwargs)
if isinstance(serializer, CustomModelSerializer):
serializer.request = self.request
return serializer
def filter_queryset(self, queryset):
for backend in set(set(self.filter_backends) | set(self.extra_filter_backends or [])):
queryset = backend().filter_queryset(self.request, queryset, self)
queryset = self.action_extra_filter_queryset(queryset)
return queryset
def action_extra_filter_queryset(self, queryset):
action__extra_filter_backends = getattr(self, f"{self.action}_extra_filter_backends", None)
if not action__extra_filter_backends:
return queryset
for backend in action__extra_filter_backends:
queryset = backend().filter_queryset(self.request, queryset, self)
return queryset
def get_serializer_class(self):
action_serializer_name = f"{self.action}_serializer_class"
action_serializer_class = getattr(self, action_serializer_name, None)
if action_serializer_class:
return action_serializer_class
return super().get_serializer_class()
def reverse_action(self, url_name, *args, **kwargs):
return super().reverse_action(url_name, *args, **kwargs)
def get_action_extra_permissions(self):
"""
获取已配置的action权限校验,并且实例化其对象
:return:
"""
action_extra_permission_classes = getattr(self, f"{self.action}_extra_permission_classes", None)
if not action_extra_permission_classes:
return []
return [permission() for permission in action_extra_permission_classes]
def check_action_extra_permissions(self, request):
"""
逐个校验action权限校验
:param request:
:return:
"""
for permission in self.get_action_extra_permissions():
if not permission.has_permission(request, self):
self.permission_denied(
request, message=getattr(permission, 'message', None)
)
def check_action_extra_object_permissions(self, request, obj):
"""
action方法的专属对象权限校验
:param request:
:param obj:
:return:
"""
for permission in self.get_action_extra_permissions():
if not permission.has_object_permission(request, self, obj):
self.permission_denied(
request, message=getattr(permission, 'message', None)
)
def initial(self, request, *args, **kwargs):
"""
重写initial方法
(1)新增action的权限校验
:param request:
:param args:
:param kwargs:
:return:
"""
super().initial(request, *args, **kwargs)
self.check_action_extra_permissions(request)
def get_object(self):
queryset = self.filter_queryset(self.get_queryset())
lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
assert lookup_url_kwarg in self.kwargs, (
'Expected view %s to be called with a URL keyword argument '
'named "%s". Fix your URL conf, or set the `.lookup_field` '
'attribute on the view correctly.' %
(self.__class__.__name__, lookup_url_kwarg)
)
filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
obj = get_object_or_404(queryset, **filter_kwargs)
self.check_object_permissions(self.request, obj)
return obj
def check_object_permissions(self, request, obj):
"""
重新check_object_permissions
(1)新增action方法的专属对象权限检查入口
(2)先校验共同的object_permissions, 再校验action的object_permissions
:param request:
:param obj:
:return:
"""
super().check_object_permissions(request, obj)
self.check_action_extra_object_permissions(request, obj)
class ReadOnlyModelViewSet(mixins.RetrieveModelMixin,

View File

@ -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()

View File

@ -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__)

View File

@ -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

View File

@ -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):

View File

@ -1,7 +1,8 @@
from django.core.cache import cache
from django.db.models import IntegerField, ForeignKey, CharField, CASCADE, Q
from ...op_drf.models import CoreModel
from application import settings
from apps.vadmin.op_drf.models import CoreModel
class Menu(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 = '菜单管理'

View File

@ -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):

View File

@ -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)

View File

@ -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,11 +25,13 @@ 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):
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():
@ -40,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
@ -49,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:

View File

@ -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()

View File

@ -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()

View File

@ -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')

View File

@ -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()

View File

@ -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()

View File

@ -25,18 +25,18 @@
-- Records of permission_dept
-- ----------------------------
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (1, '', 'admin', '2021-02-27 07:26:20.518695', '2021-02-27 15:18:39.000000', 'XX创新科技', 1, NULL, '15888888888', 'cxkj@qq.com', '1', 1,NULL, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (2, '', 'admin', '2021-02-27 07:25:09.041807', '2021-02-27 07:25:09.041853', '北京总公司', 1, NULL, NULL, NULL, '1', 1, 1, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (3, '', 'admin', '2021-02-27 07:26:14.418894', '2021-02-27 07:25:25.195849', '上海分公司', 2, NULL, NULL, NULL, '1', 1, 1, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (4, '', 'admin', '2021-02-27 07:26:01.993095', '2021-02-27 07:25:38.904644', '杭州分公司', 4, NULL, NULL, NULL, '1', 1, 1, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (5, '', 'admin', '2021-02-27 07:28:15.854856', '2021-02-27 07:25:54.379081', '深圳分公司', 3, NULL, NULL, NULL, '0', 1, 1, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (6, '', 'admin', '2021-02-27 07:26:37.589741', '2021-02-27 07:26:37.589780', '研发部门', 1, NULL, NULL, NULL, '1', 1, 2, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (7, '', 'admin', '2021-02-27 07:26:47.781467', '2021-02-27 07:26:47.781511', '市场部门', 2, NULL, NULL, NULL, '1', 1, 2, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (8, '', 'admin', '2021-02-27 07:26:57.059878', '2021-02-27 07:26:57.059923', '测试部门', 3, NULL, NULL, NULL, '1', 1, 2, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (9, '', 'admin', '2021-02-27 07:27:06.088134', '2021-02-27 07:27:06.088178', '财务部门', 4, NULL, NULL, NULL, '1', 1, 2, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (10, '', 'admin', '2021-02-27 07:27:15.287731', '2021-02-27 07:27:15.287772', '运维部门', 5, NULL, NULL, NULL, '1', 1, 2, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (11, '', 'admin', '2021-02-27 07:27:24.834369', '2021-02-27 07:27:24.834413', '市场部门', 1, NULL, NULL, NULL, '1', 1, 3, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (12, '', 'admin', '2021-02-27 07:27:34.161898', '2021-02-27 07:27:34.161944', '财务部门', 2, NULL, NULL, NULL, '1', 1, 3, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (13, '', 'admin', '2021-02-27 07:28:20.474025', '2021-02-27 07:27:47.938676', '市场部门', 1, NULL, NULL, NULL, '0', 1, 5, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (14, '', 'admin', '2021-02-27 07:28:23.394188', '2021-02-27 07:27:53.794331', '财务部门', 2, NULL, NULL, NULL, '0', 1, 5, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (15, '', 'admin', '2021-02-27 07:28:03.368497', '2021-02-27 07:28:03.368540', '市场部门', 1, NULL, NULL, NULL, '1', 1, 4, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (16, '', 'admin', '2021-02-27 07:28:10.532392', '2021-02-27 07:28:10.532436', '财务部门', 2, NULL, NULL, NULL, '1', 1, 4, 1);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (2, '', 'admin', '2021-02-27 07:25:09.041807', '2021-02-27 07:25:09.041853', '北京总公司', 1, NULL, NULL, NULL, '1', 1, 1, 2);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (3, '', 'admin', '2021-02-27 07:26:14.418894', '2021-02-27 07:25:25.195849', '上海分公司', 2, NULL, NULL, NULL, '1', 1, 1, 3);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (4, '', 'admin', '2021-02-27 07:26:01.993095', '2021-02-27 07:25:38.904644', '杭州分公司', 4, NULL, NULL, NULL, '1', 1, 1, 4);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (5, '', 'admin', '2021-02-27 07:28:15.854856', '2021-02-27 07:25:54.379081', '深圳分公司', 3, NULL, NULL, NULL, '0', 1, 1, 5);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (6, '', 'admin', '2021-02-27 07:26:37.589741', '2021-02-27 07:26:37.589780', '研发部门', 1, NULL, NULL, NULL, '1', 1, 2, 6);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (7, '', 'admin', '2021-02-27 07:26:47.781467', '2021-02-27 07:26:47.781511', '市场部门', 2, NULL, NULL, NULL, '1', 1, 2, 7);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (8, '', 'admin', '2021-02-27 07:26:57.059878', '2021-02-27 07:26:57.059923', '测试部门', 3, NULL, NULL, NULL, '1', 1, 2, 8);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (9, '', 'admin', '2021-02-27 07:27:06.088134', '2021-02-27 07:27:06.088178', '财务部门', 4, NULL, NULL, NULL, '1', 1, 2, 9);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (10, '', 'admin', '2021-02-27 07:27:15.287731', '2021-02-27 07:27:15.287772', '运维部门', 5, NULL, NULL, NULL, '1', 1, 2, 10);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (11, '', 'admin', '2021-02-27 07:27:24.834369', '2021-02-27 07:27:24.834413', '市场部门', 1, NULL, NULL, NULL, '1', 1, 3, 11);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (12, '', 'admin', '2021-02-27 07:27:34.161898', '2021-02-27 07:27:34.161944', '财务部门', 2, NULL, NULL, NULL, '1', 1, 3, 12);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (13, '', 'admin', '2021-02-27 07:28:20.474025', '2021-02-27 07:27:47.938676', '市场部门', 1, NULL, NULL, NULL, '0', 1, 5, 13);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (14, '', 'admin', '2021-02-27 07:28:23.394188', '2021-02-27 07:27:53.794331', '财务部门', 2, NULL, NULL, NULL, '0', 1, 5, 14);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (15, '', 'admin', '2021-02-27 07:28:03.368497', '2021-02-27 07:28:03.368540', '市场部门', 1, NULL, NULL, NULL, '1', 1, 4, 15);
INSERT INTO `permission_dept` (id, description, modifier, update_datetime, create_datetime, deptName, orderNum, owner, phone, email, status, creator_id, parentId_id, dept_belong_id) VALUES (16, '', 'admin', '2021-02-27 07:28:10.532392', '2021-02-27 07:28:10.532436', '财务部门', 2, NULL, NULL, NULL, '1', 1, 4, 16);

View File

@ -97,9 +97,9 @@ INSERT INTO `permission_menu` (id, description, modifier, update_datetime, creat
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (64, '', 'admin', '2021-03-16 14:31:27.618230', '2021-03-16 14:31:01.026470', '2', NULL, '登录日志查询', 1, '1', NULL, NULL, '/admin/system/logininfor/', 'GET', 'admin:system:logininfor:get', '1', '1', '1', 1, 62, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (65, '', 'admin', '2021-03-16 14:31:44.112525', '2021-03-16 14:31:44.112572', '2', NULL, '操作日志查询', 1, '1', NULL, NULL, '/admin/system/operlog/', 'GET', 'admin:system:operlog:get', '1', '1', '1', 1, 63, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (66, '', 'admin', '2021-03-26 00:47:50.628148', '2021-03-16 14:33:05.483003', '0', 'monitor', '系统监控', 3, '1', '/monitor', NULL, NULL, 'GET', NULL, '1', '1', '1', 1, NULL, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (67, '', 'admin', '2021-03-16 14:49:59.260322', '2021-03-16 14:34:59.165065', '1', 'online', '在线用户', 1, '1', 'online', 'vadmin/monitor/online/index', '', 'GET', '', '1', '1', '1', 1, 66, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (68, '', 'admin', '2021-03-16 14:36:00.989981', '2021-03-16 14:35:50.894454', '2', NULL, '在线用户查询', 1, '1', NULL, NULL, '/admin/monitor/online/', 'GET', 'admin:monitor:online:get', '1', '1', '1', 1, 67, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (69, '', 'admin', '2021-03-16 14:37:10.577186', '2021-03-16 14:37:10.577231', '2', NULL, '用户强退', 2, '1', NULL, NULL, '/admin/monitor/online/{id}/', 'PUT', 'admin:monitor:online:{id}:put', '1', '1', '1', 1, 67, '1');
-- INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (67, '', 'admin', '2021-03-16 14:49:59.260322', '2021-03-16 14:34:59.165065', '1', 'online', '在线用户', 1, '1', 'online', 'vadmin/monitor/online/index', '', 'GET', '', '1', '1', '1', 1, 66, '1');
-- INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (68, '', 'admin', '2021-03-16 14:36:00.989981', '2021-03-16 14:35:50.894454', '2', NULL, '在线用户查询', 1, '1', NULL, NULL, '/admin/monitor/online/', 'GET', 'admin:monitor:online:get', '1', '1', '1', 1, 67, '1');
-- INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (69, '', 'admin', '2021-03-16 14:37:10.577186', '2021-03-16 14:37:10.577231', '2', NULL, '用户强退', 2, '1', NULL, NULL, '/admin/monitor/online/{id}/', 'PUT', 'admin:monitor:online:{id}:put', '1', '1', '1', 1, 67, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (70, '', 'admin', '2021-03-26 00:49:56.410579', '2021-03-16 14:45:51.507961', '1', 'job', '定时任务', 2, '1', 'celery', 'vadmin/monitor/celery/index', '', 'GET', NULL, '1', '1', '1', 1, 66, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (71, '', 'admin', '2021-03-16 15:04:11.799260', '2021-03-16 14:59:53.619219', '2', NULL, '任务查询', 1, '1', NULL, NULL, '/admin/monitor/celery/', 'GET', 'admin:monitor:celery:get', '1', '1', '1', 1, 70, '1');
INSERT INTO `permission_menu` (id, description, modifier, update_datetime, create_datetime, menuType, icon, name, orderNum, isFrame, web_path, component_path, interface_path, interface_method, perms, status, visible, isCache, creator_id, parentId_id, dept_belong_id) VALUES (72, '', 'admin', '2021-03-16 15:04:06.645135', '2021-03-16 15:00:21.809600', '2', NULL, '任务新增', 2, '1', NULL, NULL, '/admin/monitor/celery/', 'POST', 'admin:monitor:celery:post', '1', '1', '1', 1, 70, '1');

View File

@ -103,6 +103,16 @@ INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (7, 1, 7);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (8, 1, 8);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (9, 1, 9);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (10, 1, 10);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (11, 2, 1);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (12, 2, 2);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (13, 2, 3);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (14, 2, 4);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (15, 2, 5);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (16, 2, 6);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (17, 2, 7);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (18, 2, 8);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (19, 2, 9);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (20, 2, 10);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (21, 1, 11);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (22, 1, 13);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (23, 1, 14);
@ -178,13 +188,5 @@ INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (95, 1, 87);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (96, 1, 88);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (97, 1, 90);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (98, 1, 91);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (11, 2, 1);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (12, 2, 2);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (13, 2, 3);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (14, 2, 4);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (15, 2, 5);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (16, 2, 6);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (17, 2, 7);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (18, 2, 8);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (19, 2, 9);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (20, 2, 10);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (99, 2, 97);
INSERT INTO `permission_role_menu` (id, role_id, menu_id) VALUES (100, 1, 97);

View File

@ -2,5 +2,5 @@ from django.apps import AppConfig
class SystemConfig(AppConfig):
name = 'vadmin.system'
name = 'apps.vadmin.system'
verbose_name = "系统管理"

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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
"""
消息通知模型

View File

@ -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="响应状态")

View File

@ -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):

View File

@ -1,9 +1,10 @@
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 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')

View File

@ -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

View File

@ -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):
@ -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)
# 递归删除空文件

View File

@ -2,5 +2,5 @@ from django.apps import AppConfig
class TemplateConfig(AppConfig):
name = 'vadmin.template'
name = 'apps.vadmin.template'
verbose_name = "模板App"

View File

@ -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):
@ -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()),

View File

@ -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()
@ -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}"
@ -101,4 +101,4 @@ class RedisOpAuthJwtAuthentication(OpAuthJwtAuthentication):
return user, token
else:
raise exceptions.AuthenticationFailed("登录信息失效,请重新登录!")
return None
return res

View File

@ -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()

View File

@ -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()
@ -305,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)
@ -313,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)

View File

@ -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__)

View File

@ -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):
@ -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 = []

View File

@ -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__)
@ -32,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()
@ -62,7 +62,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
@ -88,8 +88,9 @@ 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())
self.save_login_infor(request, '登录成功',session_id=session_id)
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)
response.set_cookie(self.JWT_AUTH_COOKIE,
@ -98,7 +99,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):

View File

@ -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):

View File

@ -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

View File

@ -1,91 +0,0 @@
"""
常用的Response以及Django的ResponseDRF的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)

View File

@ -44,3 +44,5 @@ API_LOG_ENABLE = True
API_LOG_METHODS = ['POST', 'DELETE', 'PUT'] # 'ALL' or ['POST', 'DELETE']
# 接口权限
INTERFACE_PERMISSION = True
# 是否开启登录ip转换成城市位置
ENABLE_LOGIN_LOCATION = True

View File

@ -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

View File

@ -5,6 +5,7 @@ src/assets
# 忽略public目录下文件的语法检查
public
# 忽略当前目录下为js的文件的语法检查
*.js
# *.js
# 忽略当前目录下为vue的文件的语法检查
*.vue
# *.vue
vue.config.js

View File

@ -2,18 +2,18 @@
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
parser: "babel-eslint",
sourceType: "module"
},
env: {
browser: true,
node: true,
es6: true,
es6: true
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
extends: ["plugin:vue/recommended", "eslint:recommended"],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
// it is base on https://github.com/vuejs/eslint-config-vue
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
@ -23,177 +23,199 @@ module.exports = {
}
}],
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline":"off",
"vue/multiline-html-element-content-newline": "off",
"vue/name-property-casing": ["error", "PascalCase"],
"vue/no-v-html": "off",
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
"accessor-pairs": 2,
"arrow-spacing": [2, {
"before": true,
"after": true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", {
"allowSingleLine": true
}],
'camelcase': [0, {
'properties': 'always'
"camelcase": [0, {
"properties": "always"
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
"comma-dangle": [2, "never"],
"comma-spacing": [2, {
"before": false,
"after": true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': ["error", "always", {"null": "ignore"}],
'generator-star-spacing': [2, {
'before': true,
'after': true
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": 0,
"generator-star-spacing": [2, {
"before": true,
"after": true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': [2, 2, {
'SwitchCase': 1
"handle-callback-err": [2, "^(err|error)$"],
"indent": [2, 2, {
"SwitchCase": 2
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
"jsx-quotes": [2, "prefer-single"],
"key-spacing": [2, {
"beforeColon": false,
"afterColon": true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
"keyword-spacing": [2, {
"before": true,
"after": true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
"new-cap": [2, {
"newIsCap": true,
"capIsNew": false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-console": "off",
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 0,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": [2, {
"allowLoop": false,
"allowSwitch": false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, {
"max": 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-symbol": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-path-concat": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": [2, "except-parens"],
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unneeded-ternary": [2, {
"defaultAssignment": false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unused-vars": [2, {
"vars": "all",
"args": "none"
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-constructor": 2,
"no-useless-escape": 0,
"no-whitespace-before-property": 2,
"no-with": 2,
"one-var": [2, {
"initialized": "never"
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
"operator-linebreak": [2, "after", {
"overrides": {
"?": "before",
":": "before"
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
"padded-blocks": [2, "never"],
"quotes": [2, "double", {
"avoidEscape": true,
"allowTemplateLiterals": true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
"semi": [2, "always"],
"semi-spacing": [2, {
"before": false,
"after": true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, {
"words": true,
"nonwords": false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
"spaced-comment": [2, "always", {
"markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","]
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
"template-curly-spacing": [2, "never"],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yield-star-spacing": [2, "both"],
"yoda": [2, "never"],
"prefer-const": 2,
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
"object-curly-spacing": [2, "always", {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
"array-bracket-spacing": [2, "never"],
"vue/no-unused-components": 0,
// 对component中的组件命名样式实施特定的大小写
"vue/component-name-in-template-casing": 0,
// 允许HTML未闭合标签
"vue/html-self-closing": 0,
// 允许props修改
"vue/no-mutating-props": 0,
// 允许computed修改名称
"vue/no-side-effects-in-computed-properties": 0,
// $emit不校验kebab-case
"vue/custom-event-name-casing": 0,
// 允许v-for和v-if一起用
"vue/no-use-v-if-with-v-for": 0,
"vue/require-default-prop": 0,
"vue/require-valid-default-prop": 0,
"vue/require-prop-types": 0,
"vue/no-lone-template": 0,
"vue/no-template-shadow": 0,
"vue/this-in-template": 0,
"vue/prop-name-casing": 0,
// 允许在 case 子句中使用词法声明
"no-case-declarations": 0
}
}
};

View File

@ -9,7 +9,8 @@
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src"
"lint": "eslint --fix --ext .js --ext .jsx --ext .vue src",
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src"
},
"husky": {
"hooks": {
@ -43,7 +44,6 @@
"core-js": "3.8.1",
"echarts": "^4.9.0",
"element-ui": "2.15.0",
"eslint-loader": "^4.0.2",
"file-saver": "2.0.4",
"fuse.js": "6.4.3",
"highlight.js": "9.18.5",
@ -69,10 +69,17 @@
"@vue/cli-plugin-eslint": "4.4.6",
"@vue/cli-service": "4.4.6",
"@vue/composition-api": "^1.0.0-rc.6",
"babel-eslint": "10.1.0",
"babel-eslint": "^10.1.0",
"chalk": "4.1.0",
"connect": "3.6.6",
"eslint": "7.15.0",
"eslint": "^7.15.0",
"eslint-config-standard": "^16.0.3",
"eslint-loader": "^4.0.2",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "7.2.0",
"lint-staged": "10.5.3",
"runjs": "4.4.2",

View File

@ -5,7 +5,7 @@
</template>
<script>
export default {
name: 'App'
}
export default {
name: "App"
};
</script>

View File

@ -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"
});
}

View File

@ -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"
});
};

View File

@ -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"
});
}

View File

@ -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
})
});
}

View File

@ -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
})
}
});
}

View File

@ -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
})
}
});
}

View File

@ -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
})
});
}

View File

@ -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"
});
}

View File

@ -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
})
}
});
}

View File

@ -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"
});
}

View File

@ -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"
});
}

View File

@ -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"
});
}

View File

@ -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
})
});
}

View File

@ -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
})
});
}

View File

@ -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
})
});
}

View File

@ -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
})
});
}

View File

@ -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
})
});
}

View File

@ -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
})
});
}

View File

@ -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"
});
}

View File

@ -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"
});
}

View File

@ -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"
});
}

View File

@ -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
})
});
}

View File

@ -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"
});
}

View File

@ -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"
});
}

Some files were not shown because too many files have changed in this diff Show More