👉文末查看项目功能视频演示+获取源码+sql脚本+视频导入教程视频
1 、功能描述
基于springboot的书店图书销售管理系统拥有三个角色
- 管理员:用户管理、角色管理、权限管理、店铺管理等
- 商家:图书管理、上架图书、访问量统计、销售总额统计、订单管理等
- 用户:登录注册、查看图书、购物车、下单、历史订单、结算订单
1.1 背景描述
图书书店销售管理系统是一种用于管理图书书店日常运营的软件系统。该系统包括库存管理、销售记录、顾客信息、采购管理和报表生成等功能模块。通过库存管理,书店可以追踪图书库存量,预测销售趋势并自动补货。销售记录模块记录每笔交易的详细信息,包括销售日期、商品清单和支付方式等。顾客信息模块存储客户基本信息及购买历史,帮助书店更好地了解顾客需求并进行精准营销。采购管理模块可根据销售情况自动生成采购订单,并跟踪供应商信息。报表生成模块提供销售统计、库存盘点和财务报表等功能,帮助书店管理者进行数据分析和业务决策。这样的系统能够提高图书书店的运营效率,优化库存管理,并提供更好的顾客体验。
2、项目技术
后端框架:springboot
前端技术:jsp、css、JavaScript、JQuery
2.1 springboot
Spring Boot是由Pivotal团队提供的基于Spring的框架,该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。Spring Boot集成了绝大部分目前流行的开发框架,就像Maven集成了所有的JAR包一样,Spring Boot集成了几乎所有的框架,使得开发者能快速搭建Spring项目。
2.2 mysql
MySQL是一款Relational Database Management System,直译过来的意思就是关系型数据库管理系统,MySQL有着它独特的特点,这些特点使他成为目前最流行的RDBMS之一,MySQL想比与其他数据库如ORACLE、DB2等,它属于一款体积小、速度快的数据库,重点是它符合本次毕业设计的真实租赁环境,拥有成本低,开发源码这些特点,这也是选择它的主要原因。
3、开发环境
- JAVA版本:JDK1.8
- IDE类型:IDEA、Eclipse都可运行
- tomcat版本:不需要
- 数据库类型:MySql(5.x和8.x版本都可)
- maven版本:无限制
- 硬件环境:Windows 或者 Mac OS
4、功能截图+视频演示+文档目录
4.1 登录注册
4.2 用户模块
4.3 商家模块
4.4 管理员模块
5 、核心代码实现
5.1 配置代码
server.port=8080
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8server.tomcat.uri-encoding=UTF-8spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/bookstore?serverTimezone=UTC&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
spring.datasource.username = root
spring.datasource.password = root#mybatis.config-location=classpath:mybatis/mybatis-config.xml
mybatis.type-aliases-package=org.zdd.bookstore.model.entity
mybatis.mapper-locations=classpath:mybatis/mapper/**/*.xml
#mybatis.configuration.map-underscore-to-camel-case=truemapper.mappers=tk.mybatis.mapper.common.Mapper
mapper.not-empty=false
mapper.identity=MYSQLlogging.level.org.zdd.bookstore.model.dao=debugpagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql#spring.cache.cache-names=userCache,orderMapperCustomCache#jsp
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jspspring.mail.host=smtp.qq.com
spring.mail.username=414882567@qq.com
spring.mail.password=xxx
spring.mail.default-encoding=UTF-8
##spring.mail.port=465
##spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
##spring.mail.properties.mail.debug=true
server.servlet.session.timeout=30m
spring.servlet.multipart.max-file-size = 10MB
spring.servlet.multipart.max-request-size = 50MBmail.fromMail.addr=414882567@qq.combook.category=6
#default.book.category=2image.url.prefix = upload/imagesmy.ip = 10.50.1.45#角色id
super.role-id = 1
ordinary.role-id = 2
business.role-id = 3
5.2 用户登录注册的核心代码
package org.zdd.bookstore.web.controller;import org.zdd.bookstore.common.pojo.BSResult;
import org.zdd.bookstore.common.utils.BSResultUtil;
import org.zdd.bookstore.model.entity.Store;
import org.zdd.bookstore.model.entity.User;
import org.zdd.bookstore.model.service.IMailService;
import org.zdd.bookstore.model.service.IStoreService;
import org.zdd.bookstore.model.service.IUserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.SavedRequest;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;@Controller
@RequestMapping("/user")
public class UserController {@Autowiredprivate IUserService userService;@Autowiredprivate IMailService mailService;@Autowiredprivate IStoreService storeService;@Value("${mail.fromMail.addr}")private String from;@Value("${my.ip}")private String ip;private final String USERNAME_PASSWORD_NOT_MATCH = "用户名或密码错误";private final String USERNAME_CANNOT_NULL = "用户名不能为空";@RequestMapping("/login")public String login(@RequestParam(value = "username", required = false) String username,@RequestParam(value = "password", required = false) String password,HttpServletRequest request, Model model) {if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {return "login";}//未认证的用户Subject userSubject = SecurityUtils.getSubject();if (!userSubject.isAuthenticated()) {UsernamePasswordToken token = new UsernamePasswordToken(username, password);token.setRememberMe(false);//禁止记住我功能try {//登录成功userSubject.login(token);User loginUser = (User) userSubject.getPrincipal();request.getSession().setAttribute("loginUser", loginUser);Store store = storeService.findStoreByUserId(loginUser.getUserId());request.getSession().setAttribute("loginStore", store);SavedRequest savedRequest = WebUtils.getSavedRequest(request);String url = "/";if (savedRequest != null) {url = savedRequest.getRequestUrl();if(url.contains(request.getContextPath())){url = url.replace(request.getContextPath(),"");}}if(StringUtils.isEmpty(url) || url.equals("/favicon.ico")){url = "/";}return "redirect:" + url;} catch (UnknownAccountException | IncorrectCredentialsException uae) {model.addAttribute("loginMsg", USERNAME_PASSWORD_NOT_MATCH);return "login";} catch (LockedAccountException lae) {model.addAttribute("loginMsg", "账户已被冻结!");return "login";} catch (AuthenticationException ae) {model.addAttribute("loginMsg", "登录失败!");return "login";}} else {//用户已经登录return "redirect:/index";}}@RequestMapping("/info")public String personInfo(){return "user_info";}/* @RequestMapping("/login1")public String login1(@RequestParam(value = "username", required = false) String username,@RequestParam(value = "password", required = false) String password,Model model, HttpServletRequest request) {if (StringUtils.isEmpty(username)) {model.addAttribute("loginMsg", USERNAME_CANNOT_NULL);return "login";}if (StringUtils.isEmpty(password)) {model.addAttribute("loginMsg", "密码不能为空");return "login";}BSResult<User> bsResult = userService.login(username, password);//登录校验失败if (bsResult.getData() == null) {model.addAttribute("loginMsg", bsResult.getMessage());return "login";}//登录校验成功,重定向到首页User user = bsResult.getData();//置密码为空user.setPassword("");request.getSession().setAttribute("user", user);return "redirect:/";}*///shiro框架帮我们注销@RequestMapping("/logout")@CacheEvict(cacheNames="authorizationCache",allEntries = true)public String logout() {SecurityUtils.getSubject().logout();return "redirect:/page/login";}/*** 注册 检验用户名是否存在** @param username* @return*/@RequestMapping("/checkUserExist")@ResponseBodypublic BSResult checkUserExist(String username) {if (StringUtils.isEmpty(username)) {return BSResultUtil.build(200, USERNAME_CANNOT_NULL, false);}return userService.checkUserExistByUsername(username);}/*** 注册,发激活邮箱** @param user* @return*/@RequestMapping("/register")public String register(User user, Model model) {BSResult isExist = checkUserExist(user.getUsername());//尽管前台页面已经用ajax判断用户名是否存在,// 为了防止用户不是点击前台按钮提交表单造成的错误,后台也需要判断if ((Boolean) isExist.getData()) {BSResult bsResult = userService.saveUser(user);//获得未激活的用户User userNotActive = (User) bsResult.getData();try {mailService.sendHtmlMail(user.getEmail(), "<dd书城>---用户激活---","<html><body><a href='http://"+ip+"/user/active?activeCode=" + userNotActive.getCode() + "'>亲爱的" + user.getUsername() +",请您点击此链接前往激活</a></body></html>");} catch (Exception e) {e.printStackTrace();model.addAttribute("registerError", "发送邮件异常!请检查您输入的邮箱地址是否正确。");return "fail";}model.addAttribute("username", user.getUsername());return "register_success";} else {//用户名已经存在,不能注册model.addAttribute("registerError", isExist.getMessage());return "register";}}@RequestMapping("/active")public String activeUser(String activeCode, Model model) {BSResult bsResult = userService.activeUser(activeCode);if (!StringUtils.isEmpty(bsResult.getData())) {model.addAttribute("username", bsResult.getData());return "active_success";} else {model.addAttribute("failMessage", bsResult.getMessage());return "fail";}}@RequestMapping("/update")@ResponseBodypublic BSResult updateUser(User user, HttpSession session){User loginUser = (User) session.getAttribute("loginUser");loginUser.setNickname(user.getNickname());loginUser.setLocation(user.getLocation());loginUser.setDetailAddress(user.getDetailAddress());loginUser.setGender(user.getGender());loginUser.setUpdated(new Date());loginUser.setPhone(user.getPhone());loginUser.setIdentity(user.getIdentity());loginUser.setPhone(user.getPhone());BSResult bsResult = userService.updateUser(loginUser);session.setAttribute("loginUser", loginUser);return bsResult;}@RequestMapping("/password/{userId}")@ResponseBodypublic BSResult changePassword(@PathVariable("userId") int userId,String oldPassword,String newPassword){if(StringUtils.isEmpty(oldPassword) || StringUtils.isEmpty(newPassword)){return BSResultUtil.build(400, "密码不能为空");}return userService.compareAndChange(userId,oldPassword,newPassword);}}
6 、功能视频演示
基于springboot的书店图书销售管理系统的设计与实现 (含源码+sql+视频导入教程)