diff --git a/dvadmin-backend/apps/permission/urls.py b/dvadmin-backend/apps/permission/urls.py index 4ff7cb0..8d6364d 100644 --- a/dvadmin-backend/apps/permission/urls.py +++ b/dvadmin-backend/apps/permission/urls.py @@ -24,7 +24,12 @@ urlpatterns = [ re_path('user/changeStatus/', UserProfileModelViewSet.as_view({'put': 'change_status'})), # 获取用户详情 re_path('user/details/', UserProfileModelViewSet.as_view({'get': 'get_user_details'})), + # 后台重置密码 re_path('user/resetPwd/', UserProfileModelViewSet.as_view({'put': 'reset_pwd'})), + # 用户自己重置密码 + re_path('user/profile/updatePwd/', UserProfileModelViewSet.as_view({'put': 'update_pwd'})), + # 获取、更新用户个人信息 + re_path('user/profile/', UserProfileModelViewSet.as_view({'get': 'profile','put': 'put_profile'})), ] urlpatterns += router.urls diff --git a/dvadmin-backend/apps/permission/views.py b/dvadmin-backend/apps/permission/views.py index b5b148c..e0596b6 100644 --- a/dvadmin-backend/apps/permission/views.py +++ b/dvadmin-backend/apps/permission/views.py @@ -1,3 +1,4 @@ +from django.contrib.auth import authenticate from rest_framework.request import Request from rest_framework.views import APIView @@ -8,7 +9,7 @@ from apps.permission.serializers import UserProfileSerializer, MenuSerializer, R MenuCreateUpdateSerializer, DeptSerializer, DeptCreateUpdateSerializer, PostSerializer, PostCreateUpdateSerializer, \ RoleCreateUpdateSerializer, DeptTreeSerializer, MenuTreeSerializer, UserProfileCreateUpdateSerializer, \ PostSimpleSerializer, RoleSimpleSerializer -from utils.response import SuccessResponse +from utils.response import SuccessResponse, ErrorResponse class GetUserProfileView(APIView): @@ -279,3 +280,56 @@ class UserProfileModelViewSet(CustomModelViewSet): if hasattr(self, 'handle_logging'): self.handle_logging(request, instance=instance, *args, **kwargs) return SuccessResponse(serializer.data) + + def profile(self, request: Request, *args, **kwargs): + """ + 获取用户个人信息 + :param request: + :param args: + :param kwargs: + :return: + """ + instance = self.queryset.get(id=request.user.id) + serializer = self.get_serializer(instance) + if hasattr(self, 'handle_logging'): + self.handle_logging(request, instance=instance, *args, **kwargs) + return SuccessResponse(serializer.data) + + def put_profile(self, request: Request, *args, **kwargs): + """ + 更新用户个人信息 + :param request: + :param args: + :param kwargs: + :return: + """ + instance = self.queryset.get(id=request.user.id) + instance.name = request.data.get('name',None) + instance.mobile = request.data.get('mobile',None) + instance.email = request.data.get('email',None) + instance.gender = request.data.get('gender',None) + instance.save() + serializer = self.get_serializer(instance) + if hasattr(self, 'handle_logging'): + self.handle_logging(request, instance=instance, *args, **kwargs) + return SuccessResponse(serializer.data) + + + def update_pwd(self, request: Request, *args, **kwargs): + """ + 个人修改密码 + :param request: + :param args: + :param kwargs: + :return: + """ + instance = self.queryset.get(id=request.user.id) + instance.mobile = request.data.get('newPassword',None) + if not authenticate(username=request.user.username, password=request.data.get('oldPassword',None)): + return ErrorResponse(msg='旧密码不正确!') + instance.set_password(request.data.get('newPassword')) + instance.save() + serializer = self.get_serializer(instance) + if hasattr(self, 'handle_logging'): + self.handle_logging(request, instance=instance, *args, **kwargs) + return SuccessResponse(serializer.data) diff --git a/dvadmin-ui/src/api/permission/user.js b/dvadmin-ui/src/api/permission/user.js index 91e5219..19a1fcc 100755 --- a/dvadmin-ui/src/api/permission/user.js +++ b/dvadmin-ui/src/api/permission/user.js @@ -90,7 +90,7 @@ export function getUserProfile() { // 修改用户个人信息 export function updateUserProfile(data) { return request({ - url: '/permission/user/profile', + url: '/permission/user/profile/', method: 'put', data: data }) @@ -105,7 +105,7 @@ export function updateUserPwd(oldPassword, newPassword) { return request({ url: '/permission/user/profile/updatePwd/', method: 'put', - params: data + data: data }) } diff --git a/dvadmin-ui/src/views/monitor/job/index.vue b/dvadmin-ui/src/views/monitor/job/index.vue index a5dc8c7..6b50f44 100755 --- a/dvadmin-ui/src/views/monitor/job/index.vue +++ b/dvadmin-ui/src/views/monitor/job/index.vue @@ -225,7 +225,7 @@ {{ jobGroupFormat(form) }} - {{ form.createTime }} + {{ form.create_datetime }} {{ form.cronExpression }} @@ -485,4 +485,4 @@ export default { } } }; - \ No newline at end of file + diff --git a/dvadmin-ui/src/views/monitor/job/log.vue b/dvadmin-ui/src/views/monitor/job/log.vue index e34b635..363e62f 100755 --- a/dvadmin-ui/src/views/monitor/job/log.vue +++ b/dvadmin-ui/src/views/monitor/job/log.vue @@ -104,9 +104,9 @@ - + @@ -140,7 +140,7 @@ {{ form.jobGroup }} - {{ form.createTime }} + {{ form.create_datetime }} {{ form.invokeTarget }} @@ -296,4 +296,4 @@ export default { } } }; - \ No newline at end of file + diff --git a/dvadmin-ui/src/views/permission/post/index.vue b/dvadmin-ui/src/views/permission/post/index.vue index dadaeb0..ea63c21 100755 --- a/dvadmin-ui/src/views/permission/post/index.vue +++ b/dvadmin-ui/src/views/permission/post/index.vue @@ -88,9 +88,9 @@ - + diff --git a/dvadmin-ui/src/views/permission/role/index.vue b/dvadmin-ui/src/views/permission/role/index.vue index aabf62d..3cb3bbc 100755 --- a/dvadmin-ui/src/views/permission/role/index.vue +++ b/dvadmin-ui/src/views/permission/role/index.vue @@ -118,9 +118,9 @@ > - + diff --git a/dvadmin-ui/src/views/permission/user/index.vue b/dvadmin-ui/src/views/permission/user/index.vue index feb27c8..930d068 100755 --- a/dvadmin-ui/src/views/permission/user/index.vue +++ b/dvadmin-ui/src/views/permission/user/index.vue @@ -153,7 +153,7 @@ > - + diff --git a/dvadmin-ui/src/views/permission/user/profile/index.vue b/dvadmin-ui/src/views/permission/user/profile/index.vue index ec10e54..48b6c35 100755 --- a/dvadmin-ui/src/views/permission/user/profile/index.vue +++ b/dvadmin-ui/src/views/permission/user/profile/index.vue @@ -8,32 +8,38 @@
- +
  • - 用户名称 -
    {{ user.userName }}
    + + 用户名称 +
    {{ user.username }}
  • - 手机号码 -
    {{ user.phonenumber }}
    + + 手机号码 +
    {{ user.mobile }}
  • - 用户邮箱 + + 用户邮箱
    {{ user.email }}
  • - 所属部门 + + 所属部门
    {{ user.dept.deptName }} / {{ postGroup }}
  • - 所属角色 + + 所属角色
    {{ roleGroup }}
  • - 创建日期 -
    {{ user.createTime }}
    + + 创建日期 +
    {{ user.create_datetime }}
@@ -46,10 +52,10 @@ - + - + @@ -59,33 +65,37 @@ diff --git a/dvadmin-ui/src/views/permission/user/profile/userInfo.vue b/dvadmin-ui/src/views/permission/user/profile/userInfo.vue index 5aebb61..4d90228 100755 --- a/dvadmin-ui/src/views/permission/user/profile/userInfo.vue +++ b/dvadmin-ui/src/views/permission/user/profile/userInfo.vue @@ -1,18 +1,21 @@