基于javaweb+mysql的springboot大学生校园帮管理系统(java+springboot+ssm+layui+html+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot大学生校园帮管理系统(java+springboot+ssm+layui+html+mysql)
一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
return "goods/userGoodEdit";
@RequestMapping(value = "/goods/userGoodEdit/updateImage", method = RequestMethod.POST)
public String updateImage(
HttpSession session,
@RequestParam(value = "goodId", required = false) Integer goodId,
@RequestParam(value = "mainFile", required = false) MultipartFile mainFile,
@RequestParam(value = "file", required = false) MultipartFile[] file)
throws IOException {
User user = (User) session.getAttribute("user");
FileCheck fileCheck = new FileCheck();
imageService.deleteImage(goodId);
RandomString randomString = new RandomString();
Integer goodId = reviewService.getGoodIdByReviewId(reviewId);
return "redirect:/goods/goodInfo?goodId=" + goodId;
return "redirect:/user/userProfile";
@RequestMapping(value = "/userEdit", method = RequestMethod.GET)
public String getUserEdit(ModelMap model,
@RequestParam(value = "userId", required = false) Integer userId,
HttpSession session) {
User sessionUser = (User) session.getAttribute("user");
if (sessionUser == null) {
return "redirect:/";
User user = userService.getUserById(userId);
List<Order> sellGoods = orderService.getOrderBySellerId(user.getId());
List<Review> reviews = reviewService.gerReviewByToUserId(user.getId());
System.out.println("sellerInfo.size:" + orders.size());
return "user/sellerInfo";
@RequestMapping(value = "/user/order/delete/{orderId}", method = RequestMethod.GET)
public ResponseEntity deleteOrderById(@PathVariable Integer orderId) {
Boolean success;
success = orderService.deleteOrderById(orderId) > 0;
return ResponseEntity.ok(success);
@RequestMapping(value = "/user/sellerOrder/delete/{orderId}&{goodId}", method = RequestMethod.GET)
public ResponseEntity deleteSellerOrderById(@PathVariable Integer orderId,
@PathVariable Integer goodId) {
Boolean success;
Good good = goodService.getGoodById(goodId);
List<FirstType> firstTypes = typeService.getAllFirstType();
List<Good> goods = goodService.getAllGoods(0, 5);
List<Image> goodImages = imageService.getImageByGoodId(goodId);
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("goodImages", goodImages);
model.addAttribute("firstTypes", firstTypes);
return "goods/userGoodEdit";
@RequestMapping(value = "/goods/userGoodEdit", method = RequestMethod.POST)
public String postGoodEdit(ModelMap model, HttpSession session,
@Valid Good good) {
success = goodService.updateGoodStatusId(0, goodId) > 0;
return ResponseEntity.ok(success);
@RequestMapping(value = "/admin/goods/allGoods", method = RequestMethod.GET)
public ResponseEntity adminGetAllGoods() {
List<Good> goodList = goodService.getAllGoodList();
for (Good good : goodList) {
good.setGoodUser(userService.getUserById(good.getUserId()));
good.setGoodSecondType(typeService.getSecondTypeById(good
.getSecondTypeId()));
return ResponseEntity.ok(goodList);
订单管理控制层:
model.addAttribute("replies", replies);
model.addAttribute("sellGoods", sellGoods);
return "user/userProfile";
@RequestMapping(value = "/review", method = RequestMethod.GET)
public String getReviewInfo(@RequestParam(required = false) Integer goodId,
@RequestParam(required = false) Integer reviewId) {
System.out.println("reviewId" + reviewId);
if (reviewId != null) {
System.out.println("reviewId" + reviewId);
if (reviewService.updateReviewStatus(1, reviewId) == 1) {
return "redirect:/goods/goodInfo?goodId=" + goodId;
return "redirect:/user/userProfile";
@Valid Good good) {
List<FirstType> firstTypes = typeService.getAllFirstType();
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/";
List<Good> goods = goodService.getAllGoods(0, 5);
if (!(goodService.updateGood(good) > 0)) {
System.out.println("修改物品失败!");
List<Image> goodImages = imageService.getImageByGoodId(good.getId());
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("goodImages", goodImages);
User user = (User) session.getAttribute("user");
if (user == null) {
return "redirect:/";
List<Good> goods = goodService.getAllGoods(0, 5);
if (!(goodService.updateGood(good) > 0)) {
System.out.println("修改物品失败!");
List<Image> goodImages = imageService.getImageByGoodId(good.getId());
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("goodImages", goodImages);
model.addAttribute("firstTypes", firstTypes);
return "goods/userGoodEdit";
@RequestMapping(value = "/goods/userGoodEdit/updateImage", method = RequestMethod.POST)
ModelMap model,
@RequestParam(required = false, defaultValue = "") String searchText,
@RequestParam(required = false) Integer secondTypeId,
@RequestParam(required = false, defaultValue = "0") int offset,
@RequestParam(required = false, defaultValue = "40") int limit) {
List<Good> goods = goodService.getGoodsBySearchAndType(searchText,
secondTypeId, offset, limit);
double goodsNum = goodService.getGoodsBySearchAndTypeCount(searchText,
secondTypeId);
List<FirstType> firstTypes = typeService.getAllFirstType();
String oldPass = DigestUtils
.md5DigestAsHex((password.getOldPassword() + user.getCode())
.getBytes());
if (oldPass.equals(user.getPassword())) {
RandomString randomString = new RandomString();
String code = (randomString.getRandomString(5));
String md5Pass = DigestUtils.md5DigestAsHex((password
.getNewPassword() + code).getBytes());
Boolean success = userService.updatePassword(md5Pass, code,
password.getUserId());
if (success) {
return ResponseEntity.ok(true);
public String getReviewInfo(@RequestParam(required = false) Integer goodId,
@RequestParam(required = false) Integer reviewId) {
System.out.println("reviewId" + reviewId);
if (reviewId != null) {
System.out.println("reviewId" + reviewId);
if (reviewService.updateReviewStatus(1, reviewId) == 1) {
return "redirect:/goods/goodInfo?goodId=" + goodId;
return "redirect:/user/userProfile";
@RequestMapping(value = "/reply", method = RequestMethod.GET)
public String getReplyInfo(
@RequestParam(required = false) Integer reviewId,
this.imageService = imageService;
this.collectService = collectService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String getHomeGoods(
ModelMap model,
@RequestParam(required = false, defaultValue = "") String searchText,
@RequestParam(required = false) Integer secondTypeId,
@RequestParam(required = false, defaultValue = "0") int offset,
@RequestParam(required = false, defaultValue = "40") int limit) {
List<Good> goods = goodService.getGoodsBySearchAndType(searchText,
secondTypeId, offset, limit);
double goodsNum = goodService.getGoodsBySearchAndTypeCount(searchText,
@RequestParam(value = "mainFile", required = false) MultipartFile mainFile,
@RequestParam(value = "file", required = false) MultipartFile[] file)
throws IOException {
User user = (User) session.getAttribute("user");
FileCheck fileCheck = new FileCheck();
RandomString randomString = new RandomString();
String filePath = "/statics/image/goods/" + user.getId() + "/" + goodId;
String pathRoot = fileCheck.checkGoodFolderExist(filePath);
String name;
if (!mainFile.isEmpty()) {
String fileName = goodId + randomString.getRandomString(10);
String contentType = mainFile.getContentType();
String imageName = contentType
Boolean success = userService.updatePassword(md5Pass, code,
password.getUserId());
if (success) {
return ResponseEntity.ok(true);
} else {
return ResponseEntity.ok("密码修改失败!");
} else {
return ResponseEntity.ok("原密码输入不正确!");
商品管理控制层:
@Controller
public class GoodController {
model.addAttribute("goods", goods);
model.addAttribute("orders", orders);
model.addAttribute("reviews", reviews);
model.addAttribute("replies", replies);
model.addAttribute("sellGoods", sellGoods);
return "user/userProfile";
@RequestMapping(value = "/review", method = RequestMethod.GET)
public String getReviewInfo(@RequestParam(required = false) Integer goodId,
@RequestParam(required = false) Integer reviewId) {
System.out.println("reviewId" + reviewId);
if (reviewId != null) {
System.out.println("reviewId" + reviewId);
List<Good> goods = goodService.getAllGoods(0, 5);
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("firstTypes", firstTypes);
return "goods/publishGood";
@RequestMapping(value = "/goods/publishGood", method = RequestMethod.POST)
public String getGoodId(ModelMap model, HttpSession session,
@Valid Good good) {
List<FirstType> firstTypes = typeService.getAllFirstType();
User user = (User) session.getAttribute("user");
List<Good> goods = goodService.getAllGoods(0, 5);
good.setUserId(user.getId());
good.setPhotoUrl("/statics/image/goods/default/nophoto.png");
if (goodService.insertGood(good) != 1) {
String photoUrl = filePath + "/" + name;
goodService.updateGoodPhotoUrl(photoUrl, goodId);
for (MultipartFile mf : file) {
if (!mf.isEmpty()) {
// 生成uuid作为文件名称
String fileName = goodId + randomString.getRandomString(10);
// 获得文件类型(可以判断如果不是图片,禁止上传)
String contentType = mf.getContentType();
// 获得文件后缀名称
String imageName = contentType.substring(contentType
.indexOf("/") + 1);