图书管理系统(基于Java和MySQL)

项目名称

   图书管理系统

项目介绍

      图书管理系统主要是针对管理员的,管理员首次登录需要注册,登录进去之后,管理员可以对学生的借书,还书的信息进行     管理,也可以对学生,班级和图书进行不同的分类和管理,达到方便,快速管理书籍的目的。

开发环境与涉及到的知识

     Windows                                                                                                                                                                                              idea                                                                                                                                                                                                    Maven                                                                                                                                                                                                Servlet                                                                                                                                                                                                MySQL

项目功能

  主要业务:管理学校图书信息,记录并管理学生借阅图书信息                                                                                                                  用户登录                                                                                                                                                                                              图书借阅信息管理

功能演示

   管理员登录      

                                                                                                     

  用户管理

图书借阅管理

  借阅信息查询

新增借阅信息

修改借阅信息

删除借阅信息

数据库相关设计

数据库表关系图

(1)学生表和班级表为多对一                                                                                                                                                          (2)学生表和图书借阅信息表为一对多                                                                                                                                            (3)图书表和图书借阅信息表为一对多                                                                                                                                             (4)数据字典表和数据字典标签表为一对多

字典表说明

数据字典表和数据字典标签表主要用在一些下拉菜单选项中。                                                                                                                 如学生是哪一届的,一般考虑为两张表:数据字典表和数据字典标签表(一对多关系)来保存。两张表都是key、value的形式,字典表是父节点,字典标签表是子节点,下拉菜单通过父节点的key查询出所有关联的子节点,再使用子节点的key、value进行下拉菜单选项的初始化

创建数据库及表

drop database if exists book;
create database book character set utf8mb4;

use book;

drop table if exists user;
create table user(
    id int primary key auto_increment,
    username varchar(20) not null unique comment '用户账号',
    password varchar(20) not null comment '密码',
    nickname varchar(20) comment '用户昵称',
    email varchar(50) comment '邮箱',
    create_time timestamp default NOW() comment '创建时间'
) comment '用户表';

drop table if exists dictionary;
create table dictionary(
    id int primary key auto_increment,
    dictionary_key varchar(20) not null unique comment '键',
    dictionary_value varchar(20) not null comment '值',
    dictionary_desc varchar(20) comment '备注',
    create_time timestamp default NOW() comment '创建时间'
) comment '数据字典';

drop table if exists dictionary_tag;
create table dictionary_tag(
    id int primary key auto_increment,
    dictionary_tag_key varchar(20) not null comment '键',
    dictionary_tag_value varchar(20) not null comment '值',
    dictionary_tag_desc varchar(20) comment '备注',
    dictionary_id int comment '数据字典id',
    create_time timestamp default NOW() comment '创建时间',
    foreign key (dictionary_id) references dictionary(id)
) comment '数据字典标签';

drop table if exists classes;
create table classes(
    id int primary key auto_increment,
    classes_name varchar(20) not null comment '班级名称',
    classes_graduate_year varchar(20) comment '毕业年份,数据字典000001',
    classes_major varchar(20) comment '专业,数据字典000002',
    classes_desc varchar(50) comment '备注',
    create_time timestamp default NOW() comment '创建时间'
) comment '班级表';

drop table if exists student;
create table student(
    id int primary key auto_increment,
    student_name varchar(20) not null comment '姓名',
    student_no varchar(20) comment '学号',
    id_card varchar(20) comment '身份证号',
    student_email varchar(50) comment '邮箱',
    classes_id int comment '班级id',
    create_time timestamp default NOW() comment '创建时间',
    foreign key (classes_id) references classes(id)
) comment '学生表';

drop table if exists book;
create table book(
   id int primary key auto_increment,
   book_name varchar(50) not null comment '图书名称',
   author varchar(20) comment '作者',
   price decimal(10,2) comment '价格',
   create_time timestamp default NOW() comment '创建时间'
) comment '图书信息';

drop table if exists borrow_record;
create table borrow_record(
   id int primary key auto_increment,
   book_id int comment '图书id',
   student_id int comment '学生id',
   start_time timestamp not null comment '借阅日期',
   end_time timestamp null default null comment '归还日期',
   create_time timestamp default NOW() comment '创建时间'
) comment '图书借阅信息';

前后端实现

要实现功能,要先明确前后端约定好的接口,主要是实现图书借阅信息管理。

查询专业字典

请求

GET dict/tag/query?dictionaryKey=000002

响应

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : [ {
    "dictionaryTagKey" : "000002001",
    "dictionaryTagValue" : "中文系"
  }, {
    "dictionaryTagKey" : "000002002",
    "dictionaryTagValue" : "英语系"
  }, {
    "dictionaryTagKey" : "000002003",
    "dictionaryTagValue" : "计算机科学与技术"
  } ]
}

查询毕业年份字典

 请求 

GET dict/tag/query?dictionaryKey=000001

响应

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : [ {
    "dictionaryTagKey" : "000001001",
    "dictionaryTagValue" : "2020届"
  }, {
    "dictionaryTagKey" : "000001002",
    "dictionaryTagValue" : "2021届"
  }, {
    "dictionaryTagKey" : "000001003",
    "dictionaryTagValue" : "2022届"
  }, {
    "dictionaryTagKey" : "000001004",
    "dictionaryTagValue" : "2023届"
  } ]
}

查询图书借阅信息

请求 

GET borrowRecord/query?searchText=&sortOrder=asc&pageSize=7&pageNumber=1

响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "total" : 9,
  "data" : [ {
    "id" : 1,
    "startTime" : "2020-01-01 14:20:00",
    "endTime" : "2020-02-01 14:20:00",
    "createTime" : "2020-06-17 15:52:33",
    "book" : {
      "id" : 1,
      "bookName" : "高等数学",
      "author" : "马拉司机",
      "price" : 115.20
    },
    "classes" : {
      "id" : 1,
      "classesName" : "幼儿园\uD83D\uDE02大班",
      "classesGraduateYear" : "000001001",
      "classesMajor" : "000002002",
      "classesDesc" : "已经4岁,即将成为大人的大班同学,不再是3岁小孩子了呀"
    },
    "student" : {
      "id" : 1,
      "studentName" : "小小的梦想\uD83D\uDC37A1",
      "studentNo" : "s00001",
      "idCard" : "222222222222222222",
      "studentEmail" : "123@qq.com"
    }
  }, {
    "id" : 7,
    "startTime" : "2020-02-01 14:20:00",
    "endTime" : "2020-02-21 14:20:00",
    "createTime" : "2020-06-17 15:52:33",
    "book" : {
      "id" : 3,
      "bookName" : "柴米油盐",
      "author" : "家庭妇男",
      "price" : 33.00
    },
    "classes" : {
      "id" : 1,
      "classesName" : "幼儿园\uD83D\uDE02大班",
      "classesGraduateYear" : "000001001",
      "classesMajor" : "000002002",
      "classesDesc" : "已经4岁,即将成为大人的大班同学,不再是3岁小孩子了呀"
    },
    "student" : {
      "id" : 3,
      "studentName" : "小小的梦想\uD83D\uDC37A3",
      "studentNo" : "s00003",
      "idCard" : "222222222222222224",
      "studentEmail" : "123@qq.com"
    }
  } ]
}

查询班级 (使用下拉菜单)

请求

GET http://localhost:8080/classes/queryAsDict

响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : [ {
    "dictionaryTagKey" : "1",
    "dictionaryTagValue" : "幼儿园\uD83D\uDE02大班",
    "classesGraduateYear" : "000001001",
    "classesMajor" : "000002003"
  }, {
    "dictionaryTagKey" : "2",
    "dictionaryTagValue" : "幼儿园\uD83D\uDE02中班",
    "classesGraduateYear" : "000001002",
    "classesMajor" : "000002003"
  }, {
    "dictionaryTagKey" : "3",
    "dictionaryTagValue" : "幼儿园\uD83D\uDE02小班",
    "classesGraduateYear" : "000001003",
    "classesMajor" : "000002003"
  } ]
}

查询图书 (下拉菜单)

请求

GET book/queryAsDict

响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : [ {
    "dictionaryTagKey" : "1",
    "dictionaryTagValue" : "高等数学",
    "author" : "马拉司机",
    "price" : 115.20
  }, {
    "dictionaryTagKey" : "2",
    "dictionaryTagValue" : "诗和远方",
    "author" : "老湿",
    "price" : 61.50
  }, {
    "dictionaryTagKey" : "3",
    "dictionaryTagValue" : "柴米油盐",
    "author" : "家庭妇男",
    "price" : 33.00
  }, {
    "dictionaryTagKey" : "4",
    "dictionaryTagValue" : "▄︻┻┳═一∵∴∷∶∵(∵_,∵)>>>>散弹发射!!",
    "author" : "蚷神",
    "price" : 33.00
  } ]
}

查询学生

级联下拉菜单:选择班级下拉选项之后,根据选择的班级id查询所有学生。

 请求

GET student/queryAsDict?dictionaryKey=2

 响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : [ {
    "dictionaryTagKey" : "6",
    "dictionaryTagValue" : "小小的梦想\uD83D\uDC37B1",
    "studentNo" : "s00006",
    "idCard" : "222222222222222227"
  }, {
    "dictionaryTagKey" : "7",
    "dictionaryTagValue" : "小小的梦想\uD83D\uDC37B2",
    "studentNo" : "s00007",
    "idCard" : "222222222222222228"
  } ]
}

新增图书借阅信息

  请求 

POST borrowRecord/add
Content-Type: application/json

{"studentId":"7","bookId":"3","startTime":"2020-06-10 19:40:56","endTime":""}

  响应  

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功"
}

删除图书借阅信息

 请求 

GET borrowRecord/delete?ids=2&ids=3

  响应

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功"
}

查询图书借阅详情

 请求 

GET borrowRecord/queryById?id=1

  响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功",
  "data" : {
    "id" : 1,
    "startTime" : "2020-01-01 14:20:00",
    "endTime" : "2020-02-01 14:20:00",
    "createTime" : "2020-06-17 15:52:33",
    "book" : {
      "id" : 1,
      "bookName" : "高等数学",
      "author" : "马拉司机",
      "price" : 115.20
    },
    "classes" : {
      "id" : 1,
      "classesName" : "幼儿园\uD83D\uDE02大班",
      "classesGraduateYear" : "000001001",
      "classesMajor" : "000002002",
      "classesDesc" : "已经4岁,即将成为大人的大班同学,不再是3岁小孩子了呀"
    },
    "student" : {
      "id" : 1,
      "studentName" : "小小的梦想\uD83D\uDC37A1",
      "studentNo" : "s00001",
      "idCard" : "222222222222222222",
      "studentEmail" : "123@qq.com"
    }
  }
}

修改图书借阅信息

  请求 

POST borrowRecord/update
Content-Type: application/json

{"id":"10","studentId":"3","bookId":"4","startTime":"2020-06-11 19:24:46","endTime":"2020-06-18 19:54:49"}

   响应 

{
  "success" : true,
  "code" : "200",
  "message" : "操作成功"
}

代码设计 

  设计http请求基类                                                                                                                                                                                     主要针对前段表格中,可以输入文本搜索,并根据页码显示列表数据

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class BaseEntity {

    private Integer pageNumber;

    private Integer pageSize;

    private String searchText;

    private String sortOrder;
}

 设计统一响应类 

import com.github.pagehelper.Page;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.PrintWriter;
import java.io.StringWriter;

@Getter
@Setter
@ToString
public class ResponseResult {

    private boolean success;

    private String code;

    private String message;

    private Long total;

    private Object data;

    private String stackTrace;
}

 

 

 

 

  • 11
    点赞
  • 127
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值