Book
package com.sjsq.po;
import java.io.Serializable;
import java.util.Date;
/**
* @author shuijianshiqing
* @date 2020/5/19 22:40
*/
public class Book implements Serializable {
private static final long serialVersionUID = 1L;
private Integer bookid;
private String bookname;
private Double price;
private String author;
private String publish;
private Integer categoryid;
private String booklink;
private Date deadline;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPublish() {
return publish;
}
public void setPublish(String publish) {
this.publish = publish;
}
public Integer getCategoryid() {
return categoryid;
}
public void setCategoryid(Integer categoryid) {
this.categoryid = categoryid;
}
public String getBooklink() {
return booklink;
}
public void setBooklink(String booklink) {
this.booklink = booklink;
}
public Date getDeadline() {
return deadline;
}
public void setDeadline(Date deadline) {
this.deadline = deadline;
}
@Override
public String toString() {
return "Book{" +
"bookid=" + bookid +
", bookname='" + bookname + '\'' +
", price=" + price +
", author='" + author + '\'' +
", publish='" + publish + '\'' +
", categoryid=" + categoryid +
", booklink='" + booklink + '\'' +
", deadline=" + deadline +
'}';
}
}
User
package com.sjsq.po;
import java.io.Serializable;
/**
* @author shuijianshiqing
* @date 2020/5/19 22:19
* 用户的实体类
*/
public class User implements Serializable {
// 增加序列号,作用是反序列化的时候不会报错,切能进行IO的持久化
public static final long serialVersionUID = 1L;
private Integer userid;
private String username;
private String password;
private String email;
private String phone;
private Integer isadmin;
public static long getSerialVersionUID() {
return serialVersionUID;
}
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getIsadmin() {
return isadmin;
}
public void setIsadmin(Integer isadmin) {
this.isadmin = isadmin;
}
@Override
public String toString() {
return "User{" +
"userid=" + userid +
", username='" + username + '\'' +
", password='" + password + '\'' +
", email='" + email + '\'' +
", phone='" + phone + '\'' +
", isadmin=" + isadmin +
'}';
}
}
Record
package com.sjsq.po;
import java.util.Date;
/**
* @author shuijianshiqing
* @date 2021/5/22 22:05
* 借阅记录实体类
*/
public class Record {
private Integer borrowid;
private Integer userid;
private Integer bookid;
private String bookname;
private String booklink;
private Date borrowtime;
public Integer getBorrowid() {
return borrowid;
}
public void setBorrowid(Integer borrowid) {
this.borrowid = borrowid;
}
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public String getBooklink() {
return booklink;
}
public void setBooklink(String booklink) {
this.booklink = booklink;
}
public Date getBorrowtime() {
return borrowtime;
}
public void setBorrowtime(Date borrowtime) {
this.borrowtime = borrowtime;
}
@Override
public String toString() {
return "Record{" +
"borrowid=" + borrowid +
", userid=" + userid +
", bookid=" + bookid +
", bookname='" + bookname + '\'' +
", booklink='" + booklink + '\'' +
", borrowtime=" + borrowtime +
'}';
}
}
Comment
package com.sjsq.po;
import java.sql.Time;
import java.util.Date;
/**
* @author shuijianshiqing
* @date 2021/5/22 17:18
*
* 留言表
*/
public class Comment {
private Integer commentid;
private Integer userid;
private String username;
private Integer bookid;
private String bookname;
private String comment;
private Date time;
public Integer getCommentid() {
return commentid;
}
public void setCommentid(Integer commentid) {
this.commentid = commentid;
}
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
@Override
public String toString() {
return "Comment{" +
"commentid=" + commentid +
", userid=" + userid +
", username='" + username + '\'' +
", bookid=" + bookid +
", bookname='" + bookname + '\'' +
", comment='" + comment + '\'' +
", time=" + time +
'}';
}
}
BookShelf
package com.sjsq.po;
import java.util.Date;
/**
* @author shuijianshiqing
* @date 2021/5/22 12:21
* 书架类
*/
public class BookShelf {
private Integer id;
private Integer userid;
private Integer bookid;
private String bookname;
private String booklink;
private Date adddate;
private Date removedate;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserid() {
return userid;
}
public void setUserid(Integer userid) {
this.userid = userid;
}
public Integer getBookid() {
return bookid;
}
public void setBookid(Integer bookid) {
this.bookid = bookid;
}
public String getBookname() {
return bookname;
}
public void setBookname(String bookname) {
this.bookname = bookname;
}
public String getBooklink() {
return booklink;
}
public void setBooklink(String booklink) {
this.booklink = booklink;
}
public Date getAdddate() {
return adddate;
}
public void setAdddate(Date adddate) {
this.adddate = adddate;
}
public Date getRemovedate() {
return removedate;
}
public void setRemovedate(Date removedate) {
this.removedate = removedate;
}
@Override
public String toString() {
return "BookShelf{" +
"id=" + id +
", userid=" + userid +
", bookid=" + bookid +
", bookname='" + bookname + '\'' +
", booklink='" + booklink + '\'' +
", adddate=" + adddate +
", removedate=" + removedate +
'}';
}
}
BookDao
package com.sjsq.dao;
import com.sjsq.po.Book;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2020/5/20 23:13
* 图书信息接口
*/
public interface BookDao {
/**
* 查询图书信息
* @param sql
* @param arr
* @return
*/
public List<Book> select(String sql, Object[] arr);
/**
* 根据图书编号进行查询
* @param bookid
* @return
*/
public Book getBook(Integer bookid);
/**
* 图书新增
* @param book
* @return
*/
public boolean addBook(Book book);
/**
* 图书修改
* @param book
* @return
*/
public boolean updateBook(Book book);
/**
* 删除图书
* @param bookid
* @return
*/
public boolean deleteBook(Integer bookid);
}
BookShelfDao
package com.sjsq.dao;
import com.sjsq.po.BookShelf;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 12:23
*/
public interface BookShelfDao {
/**
* 按照用户名检索书架
* @param userid
* @return
*/
public List<BookShelf> selectBookShelf(Integer userid);
/**
* 加入书架
* @param bookShelf
* @return
*/
public boolean addBookShelf(BookShelf bookShelf);
/**
* 移出书架
* @param userid
* @param bookid
* @return
*/
public boolean removeBookShelf(Integer userid,Integer bookid);
}
CommentDao
package com.sjsq.dao;
import com.sjsq.po.Comment;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 17:21
*/
public interface CommentDao {
/**
* 添加留言
* @param comment
* @return
*/
public boolean addComment(Comment comment);
/**
* 展示留言
* @param bookid
* @return
*/
public List<Comment> selectComment(Integer bookid);
}
RecordDao
package com.sjsq.dao;
import com.sjsq.po.Record;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 22:07
*/
public interface RecordDao {
/**
* 查询所有借阅信息
* @return
*/
public List<Record> selectRecords();
/**
* 查询借阅信息
* @return
*/
public List<Record> selectRecord(Integer userid);
/**
* 新增借阅记录
* @param record
* @return
*/
public boolean addRecord(Record record);
/**
* 删除借阅记录
* @param borrowid
* @return
*/
public boolean deleteRecord(Integer borrowid);
}
UserDao
package com.sjsq.dao;
import com.sjsq.po.User;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2020/5/20 22:10
* 创建一个接口用于声明用户登录注册的方法
*/
public interface UserDao {
/**
* 用户登录
* @param user
* @return
*/
public User login(User user);
/**
* 用户注册
* @param user
* @return
*/
public boolean register(User user);
/**
* 查询用户信息
* @param sql
* @param arr
* @return
*/
public List<User> selectUser(String sql, Object arr[]);
/**
* 根据用户编号进行查询
* @param userid
* @return
*/
public User getUser(Integer userid);
/**
* 新增用户
* @param user
* @return
*/
public boolean addUser(User user);
/**
* 修改用户
* @param user
* @return
*/
public boolean updateUser(User user);
/**
* 删除用户
* @param userid
* @return
*/
public boolean deleteUser(Integer userid);
}
BookService
package com.sjsq.service;
import com.sjsq.po.Book;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2020/5/20 23:37
* Book的Service层
*/
public interface BookService {
/**
* 查询图书信息
* @param bookname
* @return
*/
public List<Book> select(String bookname);
/**
* 根据图书编号进行查询
* @param id
* @return
*/
public Book getBook(Integer id);
/**
* 图书新增
* @param book
* @return
*/
public boolean addBook(Book book);
/**
* 图书修改
* @param book
* @return
*/
public boolean updateBook(Book book);
/**
* 删除图书
* @param bookid
* @return
*/
public boolean deleteBook(Integer bookid);
}
BookShelfService
package com.sjsq.service;
import com.sjsq.po.BookShelf;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 12:36
*/
public interface BookShelfService {
/**
* 按照用户名检索书架
* @param userid
* @return
*/
public List<BookShelf> selectBookShelf(Integer userid);
/**
* 加入书架
* @param bookShelf
* @return
*/
public boolean addBookShelf(BookShelf bookShelf);
/**
* 移出书架
* @param userid
* @param bookid
* @return
*/
public boolean removeBookShelf(Integer userid,Integer bookid);
}
CommentService
package com.sjsq.service;
import com.sjsq.po.Comment;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 17:21
*/
public interface CommentService {
/**
* 添加留言
* @param comment
* @return
*/
public boolean addComment(Comment comment);
/**
* 展示留言
* @param bookid
* @return
*/
public List<Comment> selectComment(Integer bookid);
}
RecordService
package com.sjsq.service;
import com.sjsq.po.Record;
import java.util.List;
/**
* @author shuijianshiqing
* @date 2021/5/22 22:17
*/
public interface RecordService {
/**
* 查询所有借阅信息
* @return
*/
public List<Record> selectRecords();
/**
* 查询借阅信息
* @return
*/
public List<Record> selectRecord(Integer userid);
/**
* 新增借阅记录
* @param record
* @return
*/
public boolean addRecord(Record record);
/**
* 删除借阅记录
* @param borrowid
* @return
*/
public boolean deleteRecord(Integer borrowid);
}
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登录</title>
<style type="text/css">
h1{
text-align: center;
}
h4{
text-align: center;color: red;
}
body{
background-color: antiquewhite;
}
a{
text-decoration: none;font-size: 20px;color: black;
}
a:hover{
text-decoration: underline;font-size: 24px;color: red;
}
</style>
</head>
<body>
<form action="login-do-info.jsp" method="post">
<h1>用户登录</h1>
<hr/>
<table align="center">
<tr>
<td>账号:</td>
<td><input type="text" name="username" id="username" placeholder="请输入您的账号" autofocus="autofocus"></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="password" id="password" placeholder="请输入您的密码"></td>
<td><a href="search-password.jsp">找回密码</a></td>
</tr>
<tr>
<td colspan="1">
</td>
<td>
<input type="submit" value="登录"/>
<input type="reset" value="重置"/>
<a href="register.jsp" target="_blank">注册</a>
</td>
</tr>
</table>
</form>
</body>
</html>