目录

免费基于Python的DjangoVue图书借阅推荐系统论文源码SQL脚本

[免费]基于Python的Django+Vue图书借阅推荐系统【论文+源码+SQL脚本】

大家好,我是python222_小锋老师,看到一个不错的基于Python的Django+Vue图书借阅推荐系统,分享下哈。

项目视频演示

项目介绍

本文旨在设计和实现一种基于Python的图书借阅系统,以满足图书馆和阅读者的管理和借阅需求。该系统采用Python作为主要开发语言,结合Django框架进行后端开发,MySQL数据库用于数据存储,同时利用Vue.js构建前端界面,实现了一个全方位的图书管理平台。

该系统旨在提供用户友好的界面和高效的功能,以便图书管理员能够轻松管理图书信息、借阅记录和用户信息。用户可以通过系统进行图书搜索、借阅、归还等操作,实现了便捷的图书借阅流程。系统还支持用户注册、登录、个人信息管理等功能,提升了用户体验和管理效率。在技术实现方面,系统采用了Python作为开发语言,具有良好的可读性和扩展性,便于团队协作开发。Django框架提供了强大的后端支持,包括路由、模型、视图等功能,简化了开发流程并提高了开发效率。MySQL数据库作为数据存储工具,保证了数据的安全性和稳定性。Vue.js作为前端框架,实现了动态的用户界面,提升了用户交互体验。通过本系统的设计与实现,图书馆管理者可以更加高效地管理图书资源,提供更好的借阅服务;读者可以通过系统方便地查找图书信息、借阅图书,提升了图书借阅的便捷性和效率。同时,系统采用Python、Django、MySQL和Vue等技术,展现了这些技术在实际项目中的应用和价值,为类似系统的开发提供了参考和借鉴。综上所述,基于Python的图书借阅系统结合了多种先进技术,实现了图书管理和借阅的全面化,为图书馆管理和读者提供了便捷、高效的服务平台,具有一定的实用和推广价值。

系统展示

https://i-blog.csdnimg.cn/direct/21ba20303bed4db783e6bd67d0203c02.jpeg

https://i-blog.csdnimg.cn/direct/e40f1de2018d403cb419058ee3993364.jpeg

https://i-blog.csdnimg.cn/direct/6df96c5b84b843ee890bfb43c06195fb.jpeg

部分代码

<template>
  <div class="container">
    <div class="login-page pc-style">
      <img src="@/assets/images/front-logo.png" alt="logo" class="logo-icon">
      <div class="login-tab">
        <div class="tab-selected">
          <span>邮箱登录</span>
          <span class="tabline tabline-width"></span>
        </div>
      </div>
      <div class="mail-login" type="login">
        <div class="common-input">
          <img src="@/assets/images/mail-icon.svg" class="left-icon">
          <div class="input-view">
            <input placeholder="请输入注册邮箱" v-model="loginForm.username" type="text" class="input">
            <p class="err-view">
            </p>
          </div>
          <!---->
        </div>
        <div class="common-input">
          <img src="@/assets/images/pwd-icon.svg" class="left-icon">
          <div class="input-view">
            <input placeholder="请输入密码" v-model="loginForm.password" type="password" class="input">
            <p class="err-view">
            </p>
          </div>
<!--          <img src="@/assets/pwd-hidden.svg" class="right-icon">-->
          <!---->
        </div>
        <div class="next-btn-view">
          <button class="next-btn btn-active" style="margin: 16px 0px;" @click="handleLogin">登录</button>
        </div>
      </div>
      <div class="operation">
        <a @click="$router.push({name:'register'})" class="forget-pwd" style="text-align: left;">注册新帐号</a>
        <a class="forget-pwd" style="text-align: right;">忘记密码?</a>
      </div>
      <div style="margin: 10px">
        
      </div>
    </div>
  </div>
</template>

<script>
import {mapActions} from 'vuex'

export default {
  name: 'Login',
  data () {
    return {
      loginForm: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    ...mapActions(['Login']),

    handleLogin () {
      console.log('login')
      this.Login({
        username: this.loginForm.username,
        password: this.loginForm.password
      }).then(() => {
        this.loginSuccess()
      }).catch(error => {
        this.requestFailed(error)
      })
    },
    loginSuccess () {
      this.$router.push({ name: 'portal' })
      this.$message.success('登录成功!')
    },
    requestFailed (err) {
      console.log(err)
      this.$message.error(err.msg || '登录失败')
    }
  }
}

</script>
<style scoped lang="less">
div {
  display: block;
}

.container {
  //background-color: #f1f1f1;
  background-image: url('~@/assets/images/login.png');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  height: 100%;
  max-width: 100%;
  display:flex;
  justify-content: center;
  align-items:center;
}

.new-content {
  position: absolute;
  left: 0;
  right: 0;
  margin: 80px auto 0;
  width: 980px;
}

.logo-img {
  width: 125px;
  display: block;
  margin-left: 137.5px;
}

.login-page {
  overflow: hidden;
  background: #fff;

  .logo-icon {
    margin-top: 20px;
    margin-left: 175px;
    width: 48px;
    height: 48px;
  }
}

.pc-style {
  position: relative;
  width: 400px;
  height: 464px;
  background: #fff;
  border-radius: 4px;
}

.login-tab {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  color: #1e1e1e;
  font-size: 14px;
  color: #1e1e1e;
  font-weight: 500;
  height: 46px;
  line-height: 44px;
  margin-bottom: 40px;
  border-bottom: 1px solid #c3c9d5;

  div {
    position: relative;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    text-align: center;
    cursor: pointer;
  }

  .tabline {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    display: inline-block;
    width: 0;
    height: 2px;
    background: #3d5b96;
    -webkit-transition: width .5s cubic-bezier(.46, 1, .23, 1.52);
    transition: width .5s cubic-bezier(.46, 1, .23, 1.52);
  }

  tab-selected {
    color: #1e1e1e;
    font-weight: 500;
  }

  .mail-login, .tel-login {
    padding: 0 28px;
  }

}

.mail-login {
  margin: 0px 24px;
}

.common-input {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;

  .left-icon {
    margin-right: 12px;
    width: 24px;
  }

  .input-view {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;

    .input {
      font-weight: 500;
      font-size: 14px;
      color: #1e1e1e;
      height: 26px;
      line-height: 26px;
      border: none;
      padding: 0;
      display: block;
      width: 100%;
      letter-spacing: 1.5px;
    }

    err-view {
      margin-top: 4px;
      height: 16px;
      line-height: 16px;
      font-size: 12px;
      color: #f62a2a;
    }
  }
}

.next-btn {
  background: #3d5b96;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  height: 40px;
  line-height: 40px;
  text-align: center;
  width: 100%;
  outline: none;
  cursor: pointer;
}

button {
  background: transparent;
  padding: 0;
  border-width: 0px;
}

button, input, select, textarea {
  margin: 0;
  padding: 0;
  outline: none;
}

.operation {
  display: flex;
  flex-direction: row;
  margin: 0 24px;
}

.forget-pwd {
  //text-align: center;
  display: block;
  overflow: hidden;
  flex:1;
  margin: 0 auto;
  color: #3d5b96;
  font-size: 14px;
  cursor: pointer;
}

</style>
# Create your views here.
import datetime

from rest_framework.decorators import api_view, authentication_classes

from myapp.auth.authentication import TokenAuthtication
from myapp.handler import APIResponse
from myapp.models import Borrow, Book
from myapp.serializers import BorrowSerializer


@api_view(['GET'])
def list_api(request):
    if request.method == 'GET':
        userId = request.GET.get('userId', -1)
        borrowStatus = request.GET.get('borrowStatus', '')

        borrows = Borrow.objects.all().filter(user=userId).filter(status__contains=borrowStatus).order_by('-borrow_time')
        serializer = BorrowSerializer(borrows, many=True)
        return APIResponse(code=0, msg='查询成功', data=serializer.data)


@api_view(['POST'])
@authentication_classes([TokenAuthtication])
def create(request):
    """
    创建借书
    """

    data = request.data.copy()
    if data['user'] is None or data['book'] is None:
        return APIResponse(code=1, msg='参数错误')

    book = Book.objects.get(pk=data['book'])
    if book.repertory <= 0:
        return APIResponse(code=1, msg='库存不足')

    borrows = Borrow.objects.filter(book=data['book']).filter(user=data['user']).filter(status='1')
    if len(borrows) > 0:
        return APIResponse(code=1, msg='您已经借过该书了')

    create_time = datetime.datetime.now()

    data['status'] = '1'
    data['delayed'] = False
    data['create_time'] = create_time
    data['expect_time'] = create_time + datetime.timedelta(days=60)
    serializer = BorrowSerializer(data=data)
    if serializer.is_valid():
        serializer.save()
        # 减库存
        book.repertory = book.repertory - 1
        book.save()

        return APIResponse(code=0, msg='借书成功', data=serializer.data)
    else:
        print(serializer.errors)
        return APIResponse(code=1, msg='借书失败')


@api_view(['POST'])
@authentication_classes([TokenAuthtication])
def return_book(request):
    """
    还书
    """
    try:
        pk = request.GET.get('id', -1)
        borrow = Borrow.objects.get(pk=pk)
    except Borrow.DoesNotExist:
        return APIResponse(code=1, msg='对象不存在')

    data = {
        'status': 2
    }
    serializer = BorrowSerializer(borrow, data=data)
    if serializer.is_valid():
        serializer.save()
        # 加库存
        bookId = request.data['book']
        book = Book.objects.get(pk=bookId)
        book.repertory = book.repertory + 1
        book.save()

        # 加积分
        borrow.user.score = borrow.user.score + 1
        borrow.user.save()

        return APIResponse(code=0, msg='还书成功', data=serializer.data)
    else:
        print(serializer.errors)
        return APIResponse(code=1, msg='更新失败')


@api_view(['POST'])
@authentication_classes([TokenAuthtication])
def delay(request):

    try:
        pk = request.GET.get('id', -1)
        borrow = Borrow.objects.get(pk=pk)
    except Borrow.DoesNotExist:
        return APIResponse(code=1, msg='对象不存在')

    if borrow.delayed:
        return APIResponse(code=1, msg='已超最大延期次数')
    else:
        data = {
            "delayed": True,
            "expect_time": borrow.expect_time + datetime.timedelta(days=30)
        }
        serializer = BorrowSerializer(borrow, data=data)
        if serializer.is_valid():
            serializer.save()
            return APIResponse(code=0, msg='延期成功', data=serializer.data)
        else:
            print(serializer.errors)
            return APIResponse(code=1, msg='延期失败')

源码下载

链接:
提取码:1234

https://i-blog.csdnimg.cn/direct/6e930f3dde3c4f2bb9cf4501c8642e1c.jpeg