This commit is contained in:
chenyang
2022-07-01 18:12:01 +08:00
parent 132432c7d5
commit 1b621f7bc4
4 changed files with 107 additions and 16 deletions
+2
View File
@@ -3,6 +3,7 @@ from django.urls import path
from server.views.mind_map import *
from server.views.user import *
from server.view_test import *
from server_auth.lib.auth import *
urlpatterns = [
# ---------------------------------------------------
@@ -21,5 +22,6 @@ urlpatterns = [
# ---------------------------------------------------
path('register', MindUserView.as_view()), # 用户注册
path('login', LoginView.as_view()), # 用户登录
]
+8 -1
View File
@@ -1,6 +1,7 @@
from django.http.response import JsonResponse
from rest_framework.views import APIView
from server.util.mix_util import build_response
from server_auth.models import MindUser
@@ -14,5 +15,11 @@ class MindUserView(APIView):
user_name = data_dict.get('userName')
input_password = data_dict.get('inputPassword')
print('userName:%s,inputPassword:%s' % (user_name, input_password))
# 根据用户名查询 MindUser
db_user = MindUser.objects.filter(username=user_name).first()
if db_user is not None:
return build_response(code=-1, msg='用户名:%s 已经存在,请更换!' % user_name)
MindUser.objects.create_user(username=user_name, password=input_password, email='')
return JsonResponse({"code": 0, "msg": "success"})
return JsonResponse({"code": 0, "msg": "注册成功,跳转登录界面中"})