基于SSM实现图书管理系统

Posted 编程指南针

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于SSM实现图书管理系统相关的知识,希望对你有一定的参考价值。

项目编号: BS-XX-029

本项目基于SSM框架开发实现,前端采用Layui实现开发,系统交互性好,功能完整,页面简洁大方,开发工具为IDEA或ECLIPSE,数据库采用mysql

系统分两 种角色:

管理员角色:可以管理读者,图书,借阅记录等

读者角色:可以查阅并借阅图 书,归还图书等 操作

具体功能演示如下:

管理员用户登陆:

管理员操作主界面:

图书管理

图书查询

添加图书

最新图书

图书借阅记录

读者管理

图书下架列表

读者添加

逾期查询

读者角色进入系统:

查询图书

最新图书

借阅管理

以上是系统的部分功能展示,系统功能完整,运行无误,适合做毕业设计使用。

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>();
        
        //设置当前页数
        pageBean.setCurrPage(currentPage);
        
        //设置每页显示的数据
        int pageSize = Message.PAGE_SIZE;
        pageBean.setPageSize(pageSize);
        
        //设置总页数
        int totalCount = msAdminMapper.selectCount();
        pageBean.setTotalCount(totalCount);
        
        //设置总页数
        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);
        
        //封装每页显示的数据
        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>();
        
        //设置当前页数
        pageBean.setCurrPage(currentPage);
        
        //设置每页显示的数据
        int pageSize = Message.PAGE_SIZE;
        pageBean.setPageSize(pageSize);
        
        //设置总页数
        int totalCount = msBookMapper.selectCount();
        pageBean.setTotalCount(totalCount);
        
        //设置总页数
        double tc = totalCount;
        Double num = Math.ceil(tc/pageSize);
        pageBean.setTotalPage(num.intValue());
        
        map.put("start", (currentPage-1)*pageSize);
        map.put("size", pageBean.getPageSize());
        
        //封装每页显示的数据
//        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>();
        
        //设置当前页数
        pageBean.setCurrPage(currentPage);
        
        //设置每页显示的数据
        int pageSize = Message.PAGE_SIZE;
        pageBean.setPageSize(pageSize);
        
        //设置总页数
        int totalCount = msBookMapper.selectCount();
        pageBean.setTotalCount(totalCount);
        
        //设置总页数
        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);
        
        //封装每页显示的数据
        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>();
		
        //设置当前页数
        pageBean.setCurrPage(currentPage);
        
        //设置每页显示的数据
        int pageSize = Message.PAGE_SIZE;
        pageBean.setPageSize(pageSize);
        
        //设置总页数
        int totalCount = msBookMapper.selectCount();
        pageBean.setTotalCount(totalCount);
		
        //设置总页数
        double tc = totalCount;
        Double num = Math.ceil(tc/pageSize);
        pageBean.setTotalPage(num.intValue());
        
        map.put("start", (currentPage-1)*pageSize);
        map.put("size", pageBean.getPageSize());
        
        //封装每页显示的数据
//        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>();
		
        //设置当前页数
        pageBean.setCurrPage(currentPage);
        
        //设置每页显示的数据
        int pageSize = Message.PAGE_SIZE;
        pageBean.setPageSize(pageSize);
        
        //设置总页数
        int totalCount = msBookMapper.selectCount();
        pageBean.setTotalCount(totalCount);
		
        //设置总页数
        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);
        
        //封装每页显示的数据
        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);
	




以上是关于基于SSM实现图书管理系统的主要内容,如果未能解决你的问题,请参考以下文章

基于SSM框架图书馆预约占座系统的设计与实现(附源码论文)

基于SSM框架图书馆预约占座系统的设计与实现(附源码论文)

基于SSM实现的图书馆管理系统

计算机毕业设计之java+SSM基于推荐算法的图书购物网站

基于SSM框架的图书管理系统的设计与实现程序.rar(项目源码+论文+答辩记录)

基于SSM实现图书馆座位预约系统