diff --git a/front/src/components/Home.vue b/front/src/components/Home.vue index a771bd9174d062dc50de0791292f7c816754900e..15de6b49319b4dc22d655f65971ba903e6cebde7 100644 --- a/front/src/components/Home.vue +++ b/front/src/components/Home.vue @@ -2,13 +2,9 @@ export default { data() { - return { - - } - }, - methods: { - + return {} }, + methods: {}, } @@ -25,7 +21,9 @@ export default {
- +
+ +
@@ -43,9 +41,7 @@ $bgColor: #ECFBFB; .banner { width: 100%; - //height: calc(100vh - 80px * 2); overflow: hidden; - padding: 20px 0; border-radius: 20px; background: $bgColor; text-align: center; @@ -60,7 +56,7 @@ $bgColor: #ECFBFB; } } - .des{ + .des { opacity: 0; animation: downIn .5s ease-in forwards; animation-delay: .6s; @@ -77,15 +73,19 @@ $bgColor: #ECFBFB; justify-content: space-between; .right, - .left{ + .left { transition: all .4s ease; transform: scale(1); } .middle { - transition: all .4s ease; animation: upMove .5s linear forwards; - &:hover{ + + img { + transition: all .4s ease; + } + + img:hover { transform: scale(1.1); } } diff --git a/front/src/components/nav/nav.vue b/front/src/components/nav/nav.vue index daecc5fbced7ee733772ff942bed18b3635cf968..1acc26eddce2691cabb86d194280bdbfe8a9a44b 100644 --- a/front/src/components/nav/nav.vue +++ b/front/src/components/nav/nav.vue @@ -1,11 +1,13 @@ + + + + \ No newline at end of file diff --git a/front/src/components/secondary/table.vue b/front/src/components/secondary/table.vue index e4090f6dfbedb5531853d50b3dae1e8410140dcd..d14faa506f56ce7ae7ab22688c32771cbbda5219 100644 --- a/front/src/components/secondary/table.vue +++ b/front/src/components/secondary/table.vue @@ -39,6 +39,7 @@ export default { this.borrow = false; this.buy = false this.fix = true + this.$router.push('/table/fixBook') } }, getRecord(type) { @@ -48,8 +49,6 @@ export default { axios .post(url, formData) .then((res) => { - // console.log(res.data) - // console.log(res.data.records) this.borrowData = res.data.records }) .catch((err) => { @@ -74,7 +73,7 @@ export default {
-
+
@@ -99,7 +98,7 @@ export default {
-
+
@@ -124,8 +123,8 @@ export default {
-
-

暂未开启

+
+
@@ -171,8 +170,11 @@ $bgColor: #ECFBFB; margin-left: 30px; width: calc(100% - 80px * 2 - 30px); height: 500px; - .borrow_view{ - //padding: 30px 0; + .view{ + opacity: 0; + transition: all .5s linear; + animation: downIn .3s ease-in forwards; + //animation: upMove .3s ease-in forwards; } table{ border-spacing: 3px; diff --git a/front/src/main.js b/front/src/main.js index f4b14072d483eb2f54f40f9df4bee3f5866edbed..6360c7c09a91fa55fad300d47c2fb9818d1f605f 100644 --- a/front/src/main.js +++ b/front/src/main.js @@ -30,6 +30,7 @@ import axios from "axios"; axios.interceptors.request.use( (config) => { const token = localStorage.getItem('token'); + console.log(token) if (token) { config.headers.Authorization = `Token ${token}`; } diff --git a/front/src/router/router.js b/front/src/router/router.js index 1297cba195c0a9ad57a29d7c75b20557efa178f9..792f9dde9be08347d33c7e90c8b956ec9527c353 100644 --- a/front/src/router/router.js +++ b/front/src/router/router.js @@ -5,6 +5,7 @@ import BookList from "../components/secondary/bookList.vue"; import Borrowing from "../components/secondary/borrowing.vue"; import Table from "../components/secondary/table.vue" import Details from "../components/secondary/details.vue"; +import FixBook from "../components/secondary/fixBook.vue"; const router = createRouter({ @@ -14,7 +15,12 @@ const router = createRouter({ {path: '/login', component: Login}, {path: '/bookList', component: BookList}, {path: '/borrowing', component: Borrowing,meta: {requiresAuth: true}}, - {path: '/table', component: Table, meta: {requiresAuth: true}}, + {path: '/table', component: Table, + meta: {requiresAuth: true}, + children:[ + {path:'fixBook',component:FixBook} + ] + }, // meta: {requiresAuth: true} 需要身份认证的路由 {path:'/details',component:Details,meta:{requiresAuth: true}} ], diff --git a/last/end/books/__pycache__/views.cpython-310.pyc b/last/end/books/__pycache__/views.cpython-310.pyc index 62be69ee3e1f3c1e6ec759af9fe42a7c2f50fd44..257daed7c43c9ec1539f5e5e0069307ab35087e4 100644 Binary files a/last/end/books/__pycache__/views.cpython-310.pyc and b/last/end/books/__pycache__/views.cpython-310.pyc differ diff --git a/last/end/books/views.py b/last/end/books/views.py index b62c0457541778b0880ecea035fb31682bc5ec6e..8b0e2a45f8f005e480cd7dffe85bd0b6b106a4ea 100644 --- a/last/end/books/views.py +++ b/last/end/books/views.py @@ -8,7 +8,7 @@ import json def all_view(request): - books = Book.objects.all() + books = Book.objects.all().order_by('id') paginator = Paginator(books, 4) page_number = request.GET.get('page', 1) diff --git a/last/end/record/__pycache__/views.cpython-310.pyc b/last/end/record/__pycache__/views.cpython-310.pyc index e175cfde79b51aa48238795f6a81a1641b0336fd..05487ee2499c0b613df73c28be25418d77571e01 100644 Binary files a/last/end/record/__pycache__/views.cpython-310.pyc and b/last/end/record/__pycache__/views.cpython-310.pyc differ diff --git a/last/end/record/views.py b/last/end/record/views.py index 6323c65016d49a9617973d9c60890019ac4064c1..51cfb74942c9012634c0815b6bf57941cd76f9c5 100644 --- a/last/end/record/views.py +++ b/last/end/record/views.py @@ -9,7 +9,6 @@ import json from books.models import Book from user.models import UserInfo - from record.models import Record @@ -30,8 +29,14 @@ def borrow_view(request): isbn = request.data.get('isbn') type = request.data.get('type') user_id = request.user.id # 从令牌中解析出user_id - print(isbn,type,user_id) + # print(isbn,type,user_id) + + # 在数据库中查找是否已存在匹配的记录 + existing_record = Record.objects.filter(user_id=user_id, book__isbn=isbn, type=type).first() + if existing_record: + # 如果已存在匹配记录,则返回相应的错误消息 + return Response({'error': 'Record already exists'}, status=status.HTTP_400_BAD_REQUEST) # 在Book模型中查找具有匹配ISBN的书籍记录 try: book = Book.objects.get(isbn=isbn) diff --git a/last/end/static/books/9787100184168.jpg b/last/end/static/books/9787100184168.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5583cdf855e3c325b79e8d5b98113d15a89cd377 Binary files /dev/null and b/last/end/static/books/9787100184168.jpg differ diff --git a/last/end/static/books/9787108059345.jpg b/last/end/static/books/9787108059345.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3572d92eb2a6c95cce3097d0f9f26acc20d444e9 Binary files /dev/null and b/last/end/static/books/9787108059345.jpg differ diff --git a/last/end/static/books/9787108064370.jpg b/last/end/static/books/9787108064370.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8674a0dab5622648fb6a3f03be22fa032c85152a Binary files /dev/null and b/last/end/static/books/9787108064370.jpg differ diff --git a/last/end/static/books/9787108075864.jpg b/last/end/static/books/9787108075864.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ef6a1657e92964f3cf957675556ffffddb12fd1e Binary files /dev/null and b/last/end/static/books/9787108075864.jpg differ diff --git a/last/end/static/books/9787208182721.jpg b/last/end/static/books/9787208182721.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d2aebd3ccc36052db859b612819136427eac1675 Binary files /dev/null and b/last/end/static/books/9787208182721.jpg differ diff --git a/last/end/static/books/9787308235372.jpg b/last/end/static/books/9787308235372.jpg new file mode 100644 index 0000000000000000000000000000000000000000..acc70884664259ce1cc27517eeb983b5c5f2ec16 Binary files /dev/null and b/last/end/static/books/9787308235372.jpg differ diff --git a/last/end/static/books/9787553818016.jpg b/last/end/static/books/9787553818016.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0d729df44f9f8587ccc07aff7c28d8565c49e99c Binary files /dev/null and b/last/end/static/books/9787553818016.jpg differ diff --git a/last/end/static/books/9787559858184.jpg b/last/end/static/books/9787559858184.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c71e149b90718cb688b632aea1d22831b2ea56f7 Binary files /dev/null and b/last/end/static/books/9787559858184.jpg differ diff --git a/last/end/static/books/9787559861030.jpg b/last/end/static/books/9787559861030.jpg new file mode 100644 index 0000000000000000000000000000000000000000..38af49110e1bca3792aa3e0bfbd6fa5113dd3526 Binary files /dev/null and b/last/end/static/books/9787559861030.jpg differ diff --git a/last/end/static/books/9787568938945.jpg b/last/end/static/books/9787568938945.jpg new file mode 100644 index 0000000000000000000000000000000000000000..94a10bb9fe48a2f48128a9327f30a6b4984f0b4f Binary files /dev/null and b/last/end/static/books/9787568938945.jpg differ diff --git a/last/end/user/__pycache__/models.cpython-310.pyc b/last/end/user/__pycache__/models.cpython-310.pyc index 2d2a0cb1356688b655dbf6f408342aea0b4a5153..984b353c3a379bdeb8dc25474569785746587be0 100644 Binary files a/last/end/user/__pycache__/models.cpython-310.pyc and b/last/end/user/__pycache__/models.cpython-310.pyc differ diff --git a/last/end/user/__pycache__/urls.cpython-310.pyc b/last/end/user/__pycache__/urls.cpython-310.pyc index 5ad09ab9c82417ee49ab60523dae78f503c6586b..5c5bca276754b01ce692dfffbe824c8bd7688042 100644 Binary files a/last/end/user/__pycache__/urls.cpython-310.pyc and b/last/end/user/__pycache__/urls.cpython-310.pyc differ diff --git a/last/end/user/__pycache__/views.cpython-310.pyc b/last/end/user/__pycache__/views.cpython-310.pyc index fe5054dcd4cd01d7da191a9fa505941052dc0db4..e73c97ca6b5c82586c196c534a609737c1371852 100644 Binary files a/last/end/user/__pycache__/views.cpython-310.pyc and b/last/end/user/__pycache__/views.cpython-310.pyc differ diff --git a/last/end/user/migrations/0002_rename_pichead_userinfo_pic.py b/last/end/user/migrations/0002_rename_pichead_userinfo_pic.py new file mode 100644 index 0000000000000000000000000000000000000000..3bfb247d25258b467f1cc289f151f62d011c3df6 --- /dev/null +++ b/last/end/user/migrations/0002_rename_pichead_userinfo_pic.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2023-09-17 14:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('user', '0001_initial'), + ] + + operations = [ + migrations.RenameField( + model_name='userinfo', + old_name='picHead', + new_name='pic', + ), + ] diff --git a/last/end/user/migrations/__pycache__/0002_rename_pichead_userinfo_pic.cpython-310.pyc b/last/end/user/migrations/__pycache__/0002_rename_pichead_userinfo_pic.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cc586c8cc809fd8cb856bf1267a3e28b62405a41 Binary files /dev/null and b/last/end/user/migrations/__pycache__/0002_rename_pichead_userinfo_pic.cpython-310.pyc differ diff --git a/last/end/user/models.py b/last/end/user/models.py index a452ba0c219b0a4a328a37f333405376904a282e..43b4594e392c7be58d45a51c266fd3f7337c17e7 100644 --- a/last/end/user/models.py +++ b/last/end/user/models.py @@ -4,4 +4,4 @@ from django.contrib.auth.models import AbstractUser class UserInfo(AbstractUser): career = models.CharField("职业", max_length=24, default="") - picHead = models.CharField("头像", max_length=64, default="") + pic = models.CharField("头像", max_length=64, default="") diff --git a/last/end/user/urls.py b/last/end/user/urls.py index b5b7d96e3fd5fd08f39200f4d3817f31092a95b2..9cb547d9c8d8628cb0e941181b4d2fbbfee92cda 100644 --- a/last/end/user/urls.py +++ b/last/end/user/urls.py @@ -4,4 +4,6 @@ from . import views urlpatterns = [ path('login/', views.login_view), path('register/', views.register_view), + path('logout/', views.logout_view), + path('manage/', views.manage_view), ] diff --git a/last/end/user/views.py b/last/end/user/views.py index 416809565566224b05b370ebd5894ec2c02f0140..913e7c3afa3c02afda08b0f273d451d663057ba6 100644 --- a/last/end/user/views.py +++ b/last/end/user/views.py @@ -1,11 +1,15 @@ -from django.contrib.auth.models import User -from user.models import UserInfo -from django.contrib.auth import authenticate, login from django.http import JsonResponse +from rest_framework.decorators import api_view, authentication_classes, permission_classes +from rest_framework.authentication import TokenAuthentication +from rest_framework.permissions import IsAuthenticated +from rest_framework.response import Response +from rest_framework import status -from rest_framework.authtoken.models import Token +from user.models import UserInfo +from django.contrib.auth import authenticate, login, logout +from django.http import JsonResponse, HttpResponse -from rest_framework.decorators import api_view +from rest_framework.authtoken.models import Token @api_view(['POST']) @@ -65,3 +69,32 @@ def register_view(request): # 创建用户 UserInfo.objects.create_user(username=username, password=password) return JsonResponse({'code': 201, 'msg': '用户创建成功'}) + + +def logout_view(request): + logout(request) + return JsonResponse({'code': 200, 'msg': '退出登录'}) + + +@api_view(['POST']) +@authentication_classes([TokenAuthentication]) +@permission_classes([IsAuthenticated]) +def manage_view(request): + if request.method == 'POST': + user_id = request.user.id # 从令牌中解析出user_id + # 获取用户对象,如果不存在则返回404错误页面 + print(user_id) + try: + user = UserInfo.objects.get(id=user_id) + except UserInfo.DoesNotExist: + return JsonResponse({'code': 404, "msg": "当前用户不存在"}) + + # 检查用户是否具有管理权限 + if user.is_staff: + # 如果用户具有管理权限,执行相应的操作 + # 例如,返回一个成功的响应或执行其他逻辑 + return JsonResponse({'code': 200, "msg": "用户具有管理权限"}) + else: + # 如果用户没有管理权限,执行相应的操作 + # 例如,返回一个错误的响应或执行其他逻辑 + return JsonResponse({'code': 401, "msg": "用户权限不足"})