基于javaweb的SSM+Maven图书租赁管理系统(java+ssm+jsp+bootstrap+echarts+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

270023052402

280023052402

300023052402

310023052402

320023052402

330023052402

基于javaweb的SSM+Maven图书租赁管理系统(java+ssm+jsp+bootstrap+echarts+mysql)

图书租赁管理系统

项目介绍

图书租赁管理系统,该系统分为管理员与普通读者两种角色; 管理员主要功能包括: 图书管理:添加、修改、删除; 图书分类管理:添加、修改、删除; 借阅信息:还书; 预定信息:确认借书; 归还信息; 统计管理:借书/归还、营业额、销量; 普通读者主要功能包括:预定图书、待拿图书、借阅中、归还信息等;

客户端的充值,使用的支付宝沙箱测试化境

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 8.0版本; 7.lombok插件安装:本项目需要安装lombok插件,否则运行会有异常;

技术栈

  1. 后端:Spring SpringMVC MyBatis 2. 前端:JSP+bootstrap+jQuery+echarts

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;

  2. 运行项目,输入localhost:8080/bm/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

@Service
@Slf4j
public class ReserveBorrowBooksService {

@Autowired
private ReserveBorrowBookMapper reserveBookMapper;

@Autowired
private BorrowBookMapper borrowBookMapper;

@Autowired
private BookMapper bookMapper;

@Autowired
private BMSystemProperties bmProperties;

@Autowired
private ReaderMapper readerMapper;

public Page<ReserveBorrowBooks> reserveBookByPage(Integer page, Integer size,
ReserveBorrowBooks reserveBorrowBook) {
boolean search = false;
if(!StringUtils.isEmpty(reserveBorrowBook.getBName()) ||
!StringUtils.isEmpty(reserveBorrowBook.getNumber()) ||
!StringUtils.isEmpty(reserveBorrowBook.getRName()) ) {
search = true;
}
List<ReserveBorrowBooks> reserveBorrowBooks = reserveBookMapper.queryReserveBorrowBooks(reserveBorrowBook);
if(CollectionUtils.isEmpty(reserveBorrowBooks)){
if(search){ //未搜索到符合条件的预借书记录
throw new LyException(ExceptionEnum.SEARCH_RESERVE_BOOK_NOT_FOUND);
}else{ //记录为空
throw new LyException(ExceptionEnum.RESERVE_BOOK_NOT_FOUND);
}
}
return new Page<ReserveBorrowBooks>(new PageInfo(reserveBorrowBooks));
}

//保存多个 借书记录 (借书)
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
public void saveReserves(List<Integer> resIds) {
for (Integer resId : resIds) {
//根据在 reserveBorrowBooks 表中查询数据
ReserveBorrowBooks reserveBorrowBooks = reserveBookMapper.selectByPrimaryKey(resId);
if(reserveBorrowBooks == null){ //预借书记录未找到!
throw new LyException(ExceptionEnum.RESERVE_NOT_FOUND);
}
//账户至少有 多少钱才能预定图书
Reader reader = readerMapper.selectByPrimaryKey(reserveBorrowBooks.getRId());
if(reader.getBalance()/100.0 < bmProperties.getBorrowBooksAccountLest()){
//抱歉,{r_name}用户,账户余额少于{balanceLess}元不能借书,请先充值!
ExceptionEnum em = ExceptionEnum.APPOINT_ACCOUNT_BALANCE_LESS;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    if (!CollectionUtils.isEmpty(readerMapper.select(new Reader(accountName)))) {    //账户名已存在
throw new LyException(ExceptionEnum.READER_ACCOUNT_NAME_EXIST);
}
}

//用户注册
public void saveReader(Reader reader) {
//根据用户的账户名获取邮箱的验证码
String verifyCode = jedis.get(reader.getAccount());
if (StringUtils.isBlank(verifyCode)) { //验证码已失效,或邮箱地址错误!
throw new LyException(ExceptionEnum.VERIFY_EXPIRY_OR_EMAIL_ERROR);
}
if (!reader.getVerifyCode().equals(verifyCode)) { //邮箱验证码不匹配
throw new LyException(ExceptionEnum.VERIFY_CODE_NOT_MATCHING);
}
reader.builderReader();
readerMapper.insert(reader);
}

//发送邮箱验证码
public void verifyMailCode(String account, String email) {
//获取4位数的验证码
String verifyCode = new Random().nextInt(9999) + "";
//将验证码根据 account存入
jedis.set(account, verifyCode);
//设置验证码有效期
jedis.expire(account, bmProperties.getEmailVerifyCodeMinute()*60);
//发送邮箱验证码
Integer validMinute = bmProperties.getEmailVerifyCodeMinute();
String emailMsg = bmProperties.getMailReaderRegisterContentModel();
emailMsg = emailMsg.replace("{emailVerifyCode}", verifyCode).replace("{emailVerifyCodeMinute}", validMinute + "");
try {
mailUtils.sendRegisterVerifyCode(email, emailMsg);
} catch (MessagingException e) {
e.printStackTrace(); //发送邮箱验证码失败
throw new LyException(ExceptionEnum.SEND_REGISTER_VERIFY_CODE_FAIL);
}
}

public void addBalance(Double money,HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html;charset=UTF-8");
//获得初始化的AlipayClient
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
//设置请求参数
AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
AlipayTradePagePayModel model = new AlipayTradePagePayModel();
//商户订单号,商户网站订单系统中唯一订单号,必填
String orderNo = NumberUtils.getOrderNo();
model.setOutTradeNo(orderNo);
//订单名称,必填
model.setSubject("图书借阅系统充值");
//支付金额
model.setTotalAmount(money+"");
//超时关闭该订单时间
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 * 设置Cookie的值 不设置生效时间默认浏览器关闭即失效,也不编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue) {
setCookie(request, response, cookieName, cookieValue, -1,"/");
}

/**
* 设置Cookie的值 在指定时间内生效,但不编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage) {
setCookie(request, response, cookieName, cookieValue, cookieMaxage, false);
}

/**
* 设置Cookie的值 不设置生效时间,但编码
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, boolean isEncode) {
setCookie(request, response, cookieName, cookieValue, -1, isEncode);
}

/**
* 设置Cookie的值 在指定时间内生效, 编码参数
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode,"/");
}

/**
* 设置Cookie的值 在指定时间内生效, 编码参数(指定编码)
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString,"/");
}

/**
* 删除Cookie带cookie域名
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,String path) {
doSetCookie(request, response, cookieName, "", -1, false,path);
}

/**
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
            params.put(name, valueStr);
}
return params;
}

public Double refreshMoney(HttpServletRequest request) {
Reader reader = (Reader) request.getSession().getAttribute(bmProperties.getReaderSessionName());
Reader reader1 = readerMapper.selectByPrimaryKey(reader.getRId());
if(reader.getBalance() != reader1.getBalance()){
request.getSession().setAttribute(bmProperties.getReaderSessionName(),reader1);
}
return reader1.getBalance()/100.0;
}
}
package com.bookManagerment.service;



@Service
@Slf4j
public class ReserveBorrowBooksService {

@Autowired
private ReserveBorrowBookMapper reserveBookMapper;

@Autowired
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* 设置Cookie的值 在指定时间内生效, 编码参数
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, isEncode,"/");
}

/**
* 设置Cookie的值 在指定时间内生效, 编码参数(指定编码)
*/
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, String encodeString) {
doSetCookie(request, response, cookieName, cookieValue, cookieMaxage, encodeString,"/");
}

/**
* 删除Cookie带cookie域名
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String cookieName,String path) {
doSetCookie(request, response, cookieName, "", -1, false,path);
}

/**
* 设置Cookie的值,并使其在指定时间内生效
*
* @param cookieMaxage
* cookie生效的最大秒数
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response, String cookieName, String cookieValue, int cookieMaxage, boolean isEncode,String path) {
try {
if (cookieValue == null) {
cookieValue = "";
} else if (isEncode) {
cookieValue = URLEncoder.encode(cookieValue, "utf-8");
}
Cookie cookie = new Cookie(cookieName, cookieValue);
if (cookieMaxage > 0)
cookie.setMaxAge(cookieMaxage);
if (null != request)// 设置域名的cookie
cookie.setDomain(getDomainName(request));
cookie.setPath(path);


项目链接:
https://javayms.github.io?id=371422272105200bh
https://javayms.pages.dev?id=371422272105200bh