基于SSM實現(xiàn)圖書管理系統(tǒng)
項目編號: BS-XX-029
本項目基于SSM框架開發(fā)實現(xiàn),前端采用Layui實現(xiàn)開發(fā),系統(tǒng)交互性好,功能完整,頁面簡潔大方,開發(fā)工具為IDEA或ECLIPSE,數(shù)據(jù)庫采用MYSQL。
系統(tǒng)分兩 種角色:
管理員角色:可以管理讀者,圖書,借閱記錄等
讀者角色:可以查閱并借閱圖 書,歸還圖書等 操作
具體功能演示如下:
管理員用戶登陸:

管理員操作主界面:

圖書管理

圖書查詢

添加圖書

最新圖書

圖書借閱記錄

讀者管理

圖書下架列表

讀者添加

逾期查詢

讀者角色進入系統(tǒng):

查詢圖書

最新圖書

借閱管理

以上是系統(tǒng)的部分功能展示,系統(tǒng)功能完整,運行無誤,適合做畢業(yè)設計使用。
package cn.test.bookms.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import cn.test.bookms.entity.MsAdmin;
import cn.test.bookms.entity.PageBean;
import cn.test.bookms.mapper.MsAdminMapper;
import cn.test.bookms.service.MsAdminService;
import cn.test.bookms.util.Message;
@Service("msAdminService")
public class MsAdminServiceImpl implements MsAdminService{
?? ?Logger logger = Logger.getLogger(MsAdminServiceImpl.class);?? ?@Autowired
?? ?private MsAdminMapper msAdminMapper;
?? ??? ?public MsAdmin selectByPrimaryKey(Integer id) {
?? ??? ?return msAdminMapper.selectByPrimaryKey(id);
?? ?}?? ?public MsAdmin selectAdmin(Map<String,String> map) {
?? ??? ?return msAdminMapper.selectAdmin(map);
?? ?}?? ?public int updatePwd(String newPwd, String adminNumber) {
?? ??? ?logger.info("***MsAdminServiceImpl類的updatePwd方法***");
?? ??? ?return msAdminMapper.updatePwd(newPwd, adminNumber);
?? ?}?? ?public PageBean<MsAdmin> selectReaderByPage(String adminNumber, String adminName, Integer identity, int currentPage) {
?? ??? ?HashMap<String,Object> map = new HashMap<String,Object>();
??????? PageBean<MsAdmin> pageBean = new PageBean<MsAdmin>();
?? ??? ?
??????? //設置當前頁數(shù)
??????? pageBean.setCurrPage(currentPage);
?????? ?
??????? //設置每頁顯示的數(shù)據(jù)
??????? int pageSize = Message.PAGE_SIZE;
??????? pageBean.setPageSize(pageSize);
?????? ?
??????? //設置總頁數(shù)
??????? int totalCount = msAdminMapper.selectCount();
??????? pageBean.setTotalCount(totalCount);
?? ??? ?
??????? //設置總頁數(shù)
??????? double tc = totalCount;
??????? Double num = Math.ceil(tc/pageSize);
??????? pageBean.setTotalPage(num.intValue());
?????? ?
??????? map.put("start", (currentPage-1)*pageSize);
??????? map.put("size", pageBean.getPageSize());
??????? map.put("adminNumber", adminNumber);
??????? map.put("adminName", adminName);
??????? map.put("identity", identity);
?????? ?
??????? //封裝每頁顯示的數(shù)據(jù)
??????? List<MsAdmin> adminList = msAdminMapper.selectByPage(map);
??????? pageBean.setLists(adminList);
?????? ?
?? ??? ?return pageBean;
?? ?}?? ?public int insertAdmin(MsAdmin admin) {
?? ??? ?logger.info("***MsAdminServiceImpl類的insertAdmin方法***");
?? ??? ?return msAdminMapper.insert(admin);
?? ?}?? ?@Override
?? ?public int deleteAdmin(int adminId) {
?? ??? ?logger.info("***MsAdminServiceImpl類的deleteAdmin方法***");
?? ??? ?return msAdminMapper.deleteByPrimaryKey(adminId);
?? ?}}
package cn.test.bookms.service.impl;
import java.util.HashMap;
import java.util.List;import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import cn.test.bookms.entity.MsBook;
import cn.test.bookms.entity.PageBean;
import cn.test.bookms.mapper.MsBookMapper;
import cn.test.bookms.service.MsBookService;
import cn.test.bookms.util.Message;@Service("msBookService")
public class MsBookServiceImpl implements MsBookService {
?? ?Logger logger = Logger.getLogger(MsBookServiceImpl.class);?? ?@Autowired
?? ?private MsBookMapper msBookMapper;
?? ?
?? ?
?? ?public void insertBook(MsBook book) {
?? ??? ?msBookMapper.insert(book);
?? ?}?? ?/**
?? ? * 分頁顯示借閱信息
?? ? */
?? ?public PageBean<MsBook> selectByAdminId(int adminId, int currentPage) {
?? ??? ?HashMap<String,Object> map = new HashMap<String,Object>();
??????? PageBean<MsBook> pageBean = new PageBean<MsBook>();
?? ??? ?
??????? //設置當前頁數(shù)
??????? pageBean.setCurrPage(currentPage);
?????? ?
??????? //設置每頁顯示的數(shù)據(jù)
??????? int pageSize = Message.PAGE_SIZE;
??????? pageBean.setPageSize(pageSize);
?????? ?
??????? //設置總頁數(shù)
??????? int totalCount = msBookMapper.selectCount();
??????? pageBean.setTotalCount(totalCount);
?? ??? ?
??????? //設置總頁數(shù)
??????? double tc = totalCount;
??????? Double num = Math.ceil(tc/pageSize);
??????? pageBean.setTotalPage(num.intValue());
?????? ?
??????? map.put("start", (currentPage-1)*pageSize);
??????? map.put("size", pageBean.getPageSize());
?????? ?
??????? //封裝每頁顯示的數(shù)據(jù)
//??????? List<MsBook> bookList = msBookMapper.selectByPage(map);
??????? List<MsBook> bookList = msBookMapper.selectByAdminId(adminId);
??????? pageBean.setLists(bookList);
?????? ?
?? ??? ?return pageBean;
?? ?}
?? ?
?? ?/**
?? ? * 分頁顯示書籍
?? ? */
?? ?public PageBean<MsBook> selectByPage(String title,String author,int currentPage) {
?? ??? ?HashMap<String,Object> map = new HashMap<String,Object>();
??????? PageBean<MsBook> pageBean = new PageBean<MsBook>();
?? ??? ?
??????? //設置當前頁數(shù)
??????? pageBean.setCurrPage(currentPage);
?????? ?
??????? //設置每頁顯示的數(shù)據(jù)
??????? int pageSize = Message.PAGE_SIZE;
??????? pageBean.setPageSize(pageSize);
?????? ?
??????? //設置總頁數(shù)
??????? int totalCount = msBookMapper.selectCount();
??????? pageBean.setTotalCount(totalCount);
?? ??? ?
??????? //設置總頁數(shù)
??????? double tc = totalCount;
??????? Double num = Math.ceil(tc/pageSize);
??????? pageBean.setTotalPage(num.intValue());
?????? ?
??????? map.put("start", (currentPage-1)*pageSize);
??????? map.put("size", pageBean.getPageSize());
??????? map.put("author", author);
??????? map.put("title", title);
?????? ?
??????? //封裝每頁顯示的數(shù)據(jù)
??????? List<MsBook> bookList = msBookMapper.selectByPage(map);
??????? pageBean.setLists(bookList);
?????? ?
?? ??? ?return pageBean;
?? ?}
?? ?public int selectCount() {
?? ??? ?return msBookMapper.selectCount();
?? ?}
?? ?public MsBook selectByID(int id) {
?? ??? ?return msBookMapper.selectByPrimaryKey(id);
?? ?}
?? ?
?? ?public int updateByPrimaryKeySelective(MsBook record) {
?? ??? ?return msBookMapper.updateByPrimaryKeySelective(record);
?? ?}
?? ?public int deleteByPrimaryKey(Integer id) {
?? ??? ?return msBookMapper.deleteByPrimaryKey(id);
?? ?}
?? ?public List<MsBook> selectNewBook() {
?? ??? ?return msBookMapper.selectNewBook();
?? ?}
?? ?public List<MsBook> selectBookDel() {
?? ??? ?return msBookMapper.selectBookDel();
?? ?}
?? ?public int updateBackBook(int id) {
?? ??? ?return msBookMapper.updateBackBook(id);
?? ?}
?? ?public int deleteBookReal(int id) {
?? ??? ?return msBookMapper.deleteBookReal(id);
?? ?}
?? ?public int updateBookRemainder(Integer id, String borrowOrReturn) {
?? ??? ?logger.info("***MsBookServiceImpl類的updateBorrowBook方法***");
?? ??? ?if (borrowOrReturn == "borrow") {?? ?// 借 -1
?? ??? ??? ?return msBookMapper.updateBookRemainderSub(id);
?? ??? ?}
?? ??? ?if (borrowOrReturn == "return") {?? ?// 還 +1
?? ??? ??? ?return msBookMapper.updateBookRemainderAdd(id);
?? ??? ?}
?? ??? ?return 0;
?? ?}?? ?public int updateBookSum(Integer id) {
?? ??? ?logger.info("***MsBookServiceImpl類的updateBookSum方法***");
?? ??? ?return msBookMapper.updateBookSum(id);
?? ?}
}
package cn.test.bookms.service.impl;
import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.test.bookms.entity.MsBook;
import cn.test.bookms.entity.PageBean;
import cn.test.bookms.mapper.MsBookMapper;
import cn.test.bookms.service.MsBookService;
import cn.test.bookms.util.Message;
@Service("msBookService")
public class MsBookServiceImpl implements MsBookService {
Logger logger = Logger.getLogger(MsBookServiceImpl.class);
@Autowired
private MsBookMapper msBookMapper;
public void insertBook(MsBook book) {
msBookMapper.insert(book);
}
/**
* 分頁顯示借閱信息
*/
public PageBean<MsBook> selectByAdminId(int adminId, int currentPage) {
HashMap<String,Object> map = new HashMap<String,Object>();
? ? ? ?PageBean<MsBook> pageBean = new PageBean<MsBook>();
? ? ? ?//設置當前頁數(shù)
? ? ? ?pageBean.setCurrPage(currentPage);
? ? ? ?
? ? ? ?//設置每頁顯示的數(shù)據(jù)
? ? ? ?int pageSize = Message.PAGE_SIZE;
? ? ? ?pageBean.setPageSize(pageSize);
? ? ? ?
? ? ? ?//設置總頁數(shù)
? ? ? ?int totalCount = msBookMapper.selectCount();
? ? ? ?pageBean.setTotalCount(totalCount);
? ? ? ?//設置總頁數(shù)
? ? ? ?double tc = totalCount;
? ? ? ?Double num = Math.ceil(tc/pageSize);
? ? ? ?pageBean.setTotalPage(num.intValue());
? ? ? ?
? ? ? ?map.put("start", (currentPage-1)*pageSize);
? ? ? ?map.put("size", pageBean.getPageSize());
? ? ? ?
? ? ? ?//封裝每頁顯示的數(shù)據(jù)
// ? ? ? ?List<MsBook> bookList = msBookMapper.selectByPage(map);
? ? ? ?List<MsBook> bookList = msBookMapper.selectByAdminId(adminId);
? ? ? ?pageBean.setLists(bookList);
? ? ? ?
return pageBean;
}
/**
* 分頁顯示書籍
*/
public PageBean<MsBook> selectByPage(String title,String author,int currentPage) {
HashMap<String,Object> map = new HashMap<String,Object>();
? ? ? ?PageBean<MsBook> pageBean = new PageBean<MsBook>();
? ? ? ?//設置當前頁數(shù)
? ? ? ?pageBean.setCurrPage(currentPage);
? ? ? ?
? ? ? ?//設置每頁顯示的數(shù)據(jù)
? ? ? ?int pageSize = Message.PAGE_SIZE;
? ? ? ?pageBean.setPageSize(pageSize);
? ? ? ?
? ? ? ?//設置總頁數(shù)
? ? ? ?int totalCount = msBookMapper.selectCount();
? ? ? ?pageBean.setTotalCount(totalCount);
? ? ? ?//設置總頁數(shù)
? ? ? ?double tc = totalCount;
? ? ? ?Double num = Math.ceil(tc/pageSize);
? ? ? ?pageBean.setTotalPage(num.intValue());
? ? ? ?
? ? ? ?map.put("start", (currentPage-1)*pageSize);
? ? ? ?map.put("size", pageBean.getPageSize());
? ? ? ?map.put("author", author);
? ? ? ?map.put("title", title);
? ? ? ?
? ? ? ?//封裝每頁顯示的數(shù)據(jù)
? ? ? ?List<MsBook> bookList = msBookMapper.selectByPage(map);
? ? ? ?pageBean.setLists(bookList);
? ? ? ?
return pageBean;
}
public int selectCount() {
return msBookMapper.selectCount();
}
public MsBook selectByID(int id) {
return msBookMapper.selectByPrimaryKey(id);
}
public int updateByPrimaryKeySelective(MsBook record) {
return msBookMapper.updateByPrimaryKeySelective(record);
}
public int deleteByPrimaryKey(Integer id) {
return msBookMapper.deleteByPrimaryKey(id);
}
public List<MsBook> selectNewBook() {
return msBookMapper.selectNewBook();
}
public List<MsBook> selectBookDel() {
return msBookMapper.selectBookDel();
}
public int updateBackBook(int id) {
return msBookMapper.updateBackBook(id);
}
public int deleteBookReal(int id) {
return msBookMapper.deleteBookReal(id);
}
public int updateBookRemainder(Integer id, String borrowOrReturn) {
logger.info("***MsBookServiceImpl類的updateBorrowBook方法***");
if (borrowOrReturn == "borrow") { // 借 -1
return msBookMapper.updateBookRemainderSub(id);
}
if (borrowOrReturn == "return") { // 還 +1
return msBookMapper.updateBookRemainderAdd(id);
}
return 0;
}
public int updateBookSum(Integer id) {
logger.info("***MsBookServiceImpl類的updateBookSum方法***");
return msBookMapper.updateBookSum(id);
}
}