基于springboot的书店图书销售管理系统拥有三个角色
图书书店销售管理系统是一种用于管理图书书店日常运营的软件系统。该系统包括库存管理、销售记录、顾客信息、采购管理和报表生成等功能模块。通过库存管理,书店可以追踪图书库存量,预测销售趋势并自动补货。销售记录模块记录每笔交易的详细信息,包括销售日期、商品清单和支付方式等。顾客信息模块存储客户基本信息及购买历史,帮助书店更好地了解顾客需求并进行精准营销。采购管理模块可根据销售情况自动生成采购订单,并跟踪供应商信息。报表生成模块提供销售统计、库存盘点和财务报表等功能,帮助书店管理者进行数据分析和业务决策。这样的系统能够提高图书书店的运营效率,优化库存管理,并提供更好的顾客体验。
后端框架:springboot
前端技术:jsp、css、JavaScript、JQuery
Spring Boot是由Pivotal团队提供的基于Spring的框架,该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。Spring Boot集成了绝大部分目前流行的开发框架,就像Maven集成了所有的JAR包一样,Spring Boot集成了几乎所有的框架,使得开发者能快速搭建Spring项目。
MySQL是一款Relational Database Management System,直译过来的意思就是关系型数据库管理系统,MySQL有着它独特的特点,这些特点使他成为目前最流行的RDBMS之一,MySQL想比与其他数据库如ORACLE、DB2等,它属于一款体积小、速度快的数据库,重点是它符合本次毕业设计的真实租赁环境,拥有成本低,开发源码这些特点,这也是选择它的主要原因。
server.port=8080
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.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=true
mapper.mappers=tk.mybatis.mapper.common.Mapper
mapper.not-empty=false
mapper.identity=MYSQL
logging.level.org.zdd.bookstore.model.dao=debug
pagehelper.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=.jsp
spring.mail.host=smtp.qq.com
[email protected]
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 = 50MB
[email protected]
book.category=6
#default.book.category=2
image.url.prefix = upload/images
my.ip = 10.50.1.45
#角色id
super.role-id = 1
ordinary.role-id = 2
business.role-id = 3
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 {
@Autowired
private IUserService userService;
@Autowired
private IMailService mailService;
@Autowired
private 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 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")
@ResponseBody
public 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(), "---用户激活---",
"亲爱的" + user.getUsername() +
",请您点击此链接前往激活");
} 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")
@ResponseBody
public 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}")
@ResponseBody
public 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);
}
}
基于springboot的书店图书销售管理系统的设计与实现 (含源码+sql+视频导入教程)