一、项目简述
功能:
主页显示商品; 所有二手书商品展示,可进行商品搜索; 点击商品进入商品详情页,具有立即购买和加入购物车功能,可增减购买商品数量亦可手动输入,热销商品展示。 立即购买进入确认订单页面,可选择已经添加的地址,亦可新增地址。 可选择购买哪些商品,可删除不需要的商品。 点击结算进入确认订单页面,确认后提交订单。后台管理:(修改密码等),商品管理(商品批量添加、上下架等),订单管理。
二、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
+ 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 = "修改失败!";
.getCollectByUserId(user.getId());
for (Collect collect : collects) {
collect.setGood(goodService.getGoodById(collect.getGoodId()));
}
List<Good> goods = goodService.getGoodByUserId(user.getId());
List<Order> orders = orderService.getOrderByCustomerId(user.getId());
List<Review> reviews = reviewService.gerReviewByToUserId(user.getId());
List<Reply> replies = reviewService.gerReplyByToUserId(user.getId());
List<Order> sellGoods = orderService.getOrderBySellerId(user.getId());
model.addAttribute("collects", collects);
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,
@Autowired
public GoodController(GoodService goodService, TypeService typeService,
ReviewService reviewService, UserService userService,
ImageService imageService, CollectService collectService) {
this.goodService = goodService;
this.typeService = typeService;
this.reviewService = reviewService;
this.userService = userService;
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,
secondTypeId);
List<FirstType> firstTypes = typeService.getAllFirstType();
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) {
System.out.println("插入物品失败!");
}
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("firstTypes", firstTypes);
return "goods/publishGood";
}
@RequestMapping(value = "/goods/publishGood/uploadImage", method = RequestMethod.POST)
public String uploadImage(
HttpSession session,
@RequestParam(value = "goodId", required = false) Integer goodId,
@RequestMapping(value = "/user/orderInfo", method = RequestMethod.GET)
public String getOrderInfo(ModelMap model,
@RequestParam(value = "orderId", required = false) Integer orderId,
HttpSession session) {
User sessionUser = (User) session.getAttribute("user");
if (sessionUser == null) {
return "redirect:/";
}
Order orderInfo = orderService.getOrderById(orderId);
List<Order> orders = orderService.getOtherOrderByCustomerId(
sessionUser.getId(), orderId);
model.addAttribute("orderInfo", orderInfo);
model.addAttribute("orders", orders);
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) {
System.out.println("插入物品失败!");
}
model.addAttribute("goods", goods);
model.addAttribute("good", good);
model.addAttribute("firstTypes", firstTypes);
return "goods/publishGood";
}
@RequestMapping(value = "/goods/publishGood/uploadImage", method = RequestMethod.POST)
public String uploadImage(
HttpSession session,
@RequestParam(value = "goodId", required = false) Integer goodId,
}
}
return ResponseEntity.ok(success);
}
@RequestMapping(value = "/user/order/allOrder", method = RequestMethod.GET)
public ResponseEntity getAllOrders() {
List<Order> orderList = orderService.getOrderList();
return ResponseEntity.ok(orderList);
}
}
用户管理控制层:
@Controller
@RequestMapping(value = "user")
public class UserController {
private final GoodService goodService;
private final OrderService orderService;
private final ReviewService reviewService;
public class GoodController {
private final GoodService goodService;
private final TypeService typeService;
private final ReviewService reviewService;
private final UserService userService;
private final ImageService imageService;
private final CollectService collectService;
private static String message = "";
@Autowired
public GoodController(GoodService goodService, TypeService typeService,
ReviewService reviewService, UserService userService,
ImageService imageService, CollectService collectService) {
this.goodService = goodService;
this.typeService = typeService;
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)
public String updateImage(
HttpSession session,
@RequestParam(value = "goodId", required = false) Integer goodId,
@RequestParam(value = "mainFile", required = false) MultipartFile mainFile,
@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())
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)
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();
雾川泽野: 博主,做毕设选的这个题目找你指点一下可以吗,有偿