👉文末查看项目功能视频演示+获取源码+sql脚本+视频导入教程视频
1 、功能描述
基于springboot的二手书交易管理系统10拥有三种角色
管理员:用户/卖家管理、分类管理、二手图书管理、求购管理、订单管理、公告管理、系统管理等
用户:登录注册、购物车、充值、评论、收藏、发布求购信息等
卖家:发布二手图书。、订单管理等
2、项目技术
后端框架:springboot、Mybatis
前端技术:Bootstrap、html、css、JavaScript、JQuery、VUE
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版本:Tomcat 7-10版本均可
- 数据库类型:MySql(5.5-5.7、8.x版本都可)
- maven版本:无限制
- 硬件环境:Windows
4、功能截图+视频演示+文档目录
4.1 登录
4.2 前端模块
4.3 用户模块
4.4 卖家模块
4.5 管理员模块
4.6 文档目录
5 、核心代码实现
5.1 配置代码
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
port: 8080
servlet:
context-path: /springbootoc81w
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springbootoc81w?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8
username: root
password: root
servlet:
multipart:
max-file-size: 300MB
max-request-size: 300MB
resources:
static-locations: classpath:static/,file:static/
mybatis-plus:
mapper-locations: classpath*:mapper/*.xml
typeAliasesPackage: com.entity
global-config:
id-type: 1
field-strategy: 1
db-column-underline: true
refresh-mapper: true
logic-delete-value: -1
logic-not-delete-value: 0
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
5.2 修改用户代码
@RequestMapping(value = "/userEdit", method = RequestMethod.POST)
public String postUserEdit(ModelMap model, @Valid User user,
HttpSession session,
@RequestParam(value = "photo", required = false) MultipartFile photo)
throws IOException {
String status;
Boolean insertSuccess;
User sessionUser = (User) session.getAttribute("user");
user.setId(sessionUser.getId());
InfoCheck infoCheck = new InfoCheck();
if (!infoCheck.isMobile(user.getMobile())) {
status = "请输入正确的手机号!";
} else if (!infoCheck.isEmail(user.getEmail())) {
status = "请输入正确的邮箱!";
} else if (userService.getUserByMobile(user.getMobile()).getId() != user
.getId()) {
System.out.println(userService.getUserByMobile(user.getMobile())
.getId() + " " + user.getId());
status = "此手机号码已使用!";
} else if (userService.getUserByEmail(user.getEmail()).getId() != user
.getId()) {
status = "此邮箱已使用!";
} else {
if (!photo.isEmpty()) {
RandomString randomString = new RandomString();
FileCheck fileCheck = new FileCheck();
String filePath = "/statics/image/photos/" + user.getId();
String pathRoot = fileCheck.checkGoodFolderExist1(filePath);
String fileName = user.getId()
+ randomString.getRandomString(10);
String contentType = photo.getContentType();
String imageName = contentType.substring(contentType
.indexOf("/") + 1);
String name = fileName + "." + imageName;
photo.transferTo(new File(pathRoot + name));
String photoUrl = filePath + "/" + name;
user.setPhotoUrl(photoUrl);
} else {
String photoUrl = userService.getUserById(user.getId())
.getPhotoUrl();
user.setPhotoUrl(photoUrl);
}
insertSuccess = userService.updateUser(user);
if (insertSuccess) {
session.removeAttribute("user");
session.setAttribute("user", user);
return "redirect:/user/userProfile";
} else {
status = "修改失败!";
model.addAttribute("user", user);
model.addAttribute("status", status);
return "user/userEdit";
}
}
System.out.println(user.getMobile());
System.out.println(status);
model.addAttribute("user", user);
model.addAttribute("status", status);
return "user/userEdit";
}