fix: 处理冲突

This commit is contained in:
caoqianming 2024-10-09 13:56:20 +08:00
parent bf2c330c0f
commit e1bb844b99
1 changed files with 15 additions and 3 deletions

View File

@ -23,7 +23,7 @@ from apps.system.filters import DeptFilterSet, UserFilterSet
# from django_q.models import Task as QTask, Schedule as QSchedule
from apps.utils.mixins import (CustomCreateModelMixin, MyLoggingMixin)
from django.conf import settings
from apps.utils.permission import ALL_PERMS, get_user_perms_map
from apps.utils.permission import ALL_PERMS, get_user_perms_map, get_alld_perms
from apps.utils.viewsets import CustomGenericViewSet, CustomModelViewSet
from server.celery import app as celery_app
from .models import (Dept, Dictionary, DictType, File, Permission, Post, PostRole, Role, User,
@ -42,6 +42,7 @@ from cron_descriptor import get_description
import locale
from drf_yasg.utils import swagger_auto_schema
from server.settings import get_sysconfig, update_sysconfig, update_dict
from apps.utils.thread import MyThread
# logger.info('请求成功! response_code:{}response_headers:{}
# response_body:{}'.format(response_code, response_headers, response_body[:251]))
@ -315,7 +316,18 @@ class PermissionViewSet(CustomModelViewSet):
"""
ALL_PERMS.sort()
return Response(ALL_PERMS)
def perform_create(self, serializer):
super().perform_create(serializer)
MyThread(target=get_alld_perms, args=()).start_p()
def perform_update(self, serializer):
super().perform_update(serializer)
MyThread(target=get_alld_perms, args=()).start_p()
def perform_destroy(self, instance):
super().perform_destroy(instance)
MyThread(target=get_alld_perms, args=()).start_p()
class DeptViewSet(CustomModelViewSet):
"""部门-增删改查
@ -480,7 +492,7 @@ class UserViewSet(CustomModelViewSet):
获取登录用户信息
"""
user = request.user
perms = get_user_perms_map(user)
perms = get_user_perms_map(user, update_cache=True)
data = {
'id': user.id,
'username': user.username,