赞
踩
基于javaweb+mysql的springboot前后端分离网上商城项目设计和实现(java+ssm+springboot+vue+redis)
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot前后端分离网上商城项目设计和实现(java+ssm+springboot+vue+redis)
主要实现技术:Java、springmvc、springboot、mybatis、mysql、tomcat、shiro权限框架、vue、jquery、node.js 、redis数据库、邮箱相关等技术。
主要功能实现:
用户登录、注册、商城浏览、购买、订单、购物车、退货、用户、个人中心、修改密码、角色等管理
前端主页面:商品关键字搜索和分类搜索功能以及首页轮播图配置展示
首页个人中心主要功能:密码修改、订单、购物车、商品详情模块、可以购买、加入购物车
购买时需要填写用户手机号和收获地址等信息、注册时默认生成支付宝模拟账号密码:
后台管理员主要对商品数据进行管理、分类管理、订单管理以及用户管理扥。
商品列表数据管理、后台添加商品信息、商品基础数据的维护管理、商品订单详情管理:根据关键字查询以及查看每一个订单的详情信息
首页轮播图配置展示、用户角色和权限管理控制:
前后端源码结构:
数据库图:
private CommonResult update(ProductSpecs productSpecs) { if(productSpecsService.updateById(productSpecs)){ return CommonResult.success("更新成功",productSpecs); }else{ return CommonResult.error("更新失败"); } } @RequestMapping(value = "/productSpecs/delete") private CommonResult delete(ProductSpecs productSpecs) { if(productSpecsService.deleteById(productSpecs)){ return CommonResult.success("删除成功",productSpecs); }else{ return CommonResult.error("删除失败"); } } } /** * @email qiudb.top@aliyun.com * @description 用户授权等相关业务 */ @RestController @CrossOrigin public class RoleController { final RoleService roleService; public RoleController(RoleService roleService) { this.roleService = roleService; } /*根据id查询用户*/ @RequestMapping(value = "/role/findById") private CommonResult findById(Integer roleId) { Role role = roleService.selectById(roleId); if(role!=null){ return CommonResult.success("查询成功",role); }else{ return CommonResult.error("查询失败"); }
/*同意买家退货*/ @RequestMapping(value = "/returnGoods/dealRefund") private CommonResult dealRefund(Integer returnId,String operatorNumber,String operatorName) { if(returnId!=null){ ReturnGoods returnGoods = returnGoodsService.selectById(returnId); returnGoods.setReturnState("退款完成"); returnGoods.setDealTime(new Date()); returnGoods.setOperatorNumber(operatorNumber); returnGoods.setOperatorName(operatorName); String orderNo = returnGoods.getOrderNo(); Integer orderId = orderService.selectIdByKey(orderNo); Order order = new Order(); order.setOrderId(orderId); order.setReturnState(true); order.setOrderState("已退款"); Logistics logistics = logisticsService.selectOrderNo(orderNo); if(logistics!=null){ logisticsService.deleteById(logistics.getLogisticId()); } if(orderService.updateById(order)){ if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退款数据不存在"); } /*拒绝买家退款申请*/ @RequestMapping(value = "/returnGoods/rejectRefund") private CommonResult rejectRefund(Integer returnId,String operatorNumber,String operatorName) { if(returnId!=null){ ReturnGoods returnGoods = returnGoodsService.selectById(returnId); returnGoods.setReturnState("拒绝退款"); returnGoods.setDealTime(new Date()); returnGoods.setOperatorNumber(operatorNumber); returnGoods.setOperatorName(operatorName);
/** * @email qiudb.top@aliyun.com * @description 订单相关业务 */ @RestController @CrossOrigin public class OrderController { final OrderService orderService; final ProductService productService; final LogisticsService logisticsService; final RedisTemplate<String,String> redisTemplate; public OrderController(RedisTemplate<String,String> redisTemplate,OrderService orderService,LogisticsService logisticsService,ProductService productService) { this.orderService = orderService; this.productService = productService; this.logisticsService = logisticsService; this.redisTemplate = redisTemplate; } @RequestMapping(value = "/order/findById") private CommonResult findOrderById(Integer orderId) { Order order= orderService.selectById(orderId); if(orderId!=null){ return CommonResult.success("订单信息查询成功",order); }else{ return CommonResult.error("订单信息查询失败"); } } @RequestMapping(value = "/order/findOrderInfo") private CommonResult findOrderInfo(String userAccount) { List<Map<String, Object>> orderMap = orderService.selectAllOrder(userAccount); if(orderMap!=null){ return CommonResult.success("订单信息查询成功",orderMap);
Logistics logistics = logisticsService.selectOrderNo(orderNo); if(logistics!=null){ logisticsService.deleteById(logistics.getLogisticId()); } if(orderService.updateById(order)){ if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退货数据不存在"); } /*买家快递寄回*/ @RequestMapping(value = "/returnGoods/sendBack") private CommonResult sendBack(Integer returnId) { if(returnId!=null){ ReturnGoods returnGoods = new ReturnGoods(); returnGoods.setReturnId(returnId); returnGoods.setReturnState("待收货"); returnGoods.setDealTime(new Date()); if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退货数据不完整"); } /*商家收到寄回的商品*/ @RequestMapping(value = "/returnGoods/receipt") private CommonResult receipt(Integer returnId) { if(returnId!=null){ ReturnGoods returnGoods = new ReturnGoods(); returnGoods.setReturnId(returnId); returnGoods.setReturnState("退货完成"); returnGoods.setDealTime(new Date()); if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods);
return CommonResult.error("商品退款数据不存在"); } /*同意买家退货*/ @RequestMapping(value = "/returnGoods/dealWithReturn") private CommonResult dealWithReturn(Integer returnId,String operatorNumber,String operatorName) { if(returnId!=null){ ReturnGoods returnGoods = returnGoodsService.selectById(returnId); returnGoods.setReturnState("允许退货"); returnGoods.setDealTime(new Date()); returnGoods.setOperatorNumber(operatorNumber); returnGoods.setOperatorName(operatorName); String orderNo = returnGoods.getOrderNo(); Integer orderId = orderService.selectIdByKey(orderNo); Order order = new Order(); order.setOrderId(orderId); order.setReturnState(true); order.setOrderState("已退货"); Logistics logistics = logisticsService.selectOrderNo(orderNo); if(logistics!=null){ logisticsService.deleteById(logistics.getLogisticId()); } if(orderService.updateById(order)){ if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退货数据不存在"); } /*买家快递寄回*/ @RequestMapping(value = "/returnGoods/sendBack") private CommonResult sendBack(Integer returnId) { if(returnId!=null){ ReturnGoods returnGoods = new ReturnGoods();
if(productSpecs!=null){ return CommonResult.success("查询成功",productSpecs); }else{ return CommonResult.error("查询失败"); } } @RequestMapping(value = "/productSpecs/findAllByProId") private CommonResult findAllByProId(Integer productId) { List<String> specsName = productSpecsService.selectAllByProId(productId); if(specsName!=null){ return CommonResult.success("查询成功",specsName); }else{ return CommonResult.error("查询失败"); } } @RequestMapping(value = "/productSpecs/add") private CommonResult add(ProductSpecs productSpecs) { if(productSpecs!=null){ if(productSpecsService.insertData(productSpecs)){ return CommonResult.success("添加成功",productSpecs); }else{ return CommonResult.error("添加失败"); } } return CommonResult.error("数据不存在"); } @RequestMapping(value = "/productSpecs/addBatch") private CommonResult addBatch(Integer productId,Integer[] specsIds) { System.out.println(productId); System.out.println(Arrays.toString(specsIds)); if(specsIds!=null){ ProductSpecs productSpecs; List<ProductSpecs> productSpecsList = new ArrayList<>(); for (Integer specsId : specsIds) { productSpecs = new ProductSpecs(); productSpecs.setProductId(productId); productSpecs.setSpecsId(specsId); productSpecsList.add(productSpecs); } for (ProductSpecs specs : productSpecsList) { System.out.println(specs); }
return CommonResult.error("数据不存在"); } @RequestMapping(value = "/productSpecs/addBatch") private CommonResult addBatch(Integer productId,Integer[] specsIds) { System.out.println(productId); System.out.println(Arrays.toString(specsIds)); if(specsIds!=null){ ProductSpecs productSpecs; List<ProductSpecs> productSpecsList = new ArrayList<>(); for (Integer specsId : specsIds) { productSpecs = new ProductSpecs(); productSpecs.setProductId(productId); productSpecs.setSpecsId(specsId); productSpecsList.add(productSpecs); } for (ProductSpecs specs : productSpecsList) { System.out.println(specs); } if(productSpecsService.insertBatch(productSpecsList)){ return CommonResult.success("添加成功",productSpecsList); }else{ return CommonResult.error("添加失败"); } } return CommonResult.error("数据不存在"); } @RequestMapping(value = "/productSpecs/update") private CommonResult update(ProductSpecs productSpecs) { if(productSpecsService.updateById(productSpecs)){ return CommonResult.success("更新成功",productSpecs); }else{ return CommonResult.error("更新失败"); } } @RequestMapping(value = "/productSpecs/delete") private CommonResult delete(ProductSpecs productSpecs) { if(productSpecsService.deleteById(productSpecs)){ return CommonResult.success("删除成功",productSpecs); }else{ return CommonResult.error("删除失败"); } } }
} } @RequestMapping(value = "/product/delete") private CommonResult delete(Integer productId) { if(productService.deleteById(productId)){ return CommonResult.success("商品删除成功","productId:" + productId); }else{ return CommonResult.error("商品删除失败"); } } /*商品类别*/ @RequestMapping(value = "/productType/add") private CommonResult addType(ProductType productType) { if(productTypeService.insertData(productType)){ return CommonResult.success("商品分类添加成功",productType); }else{ return CommonResult.error("商品分类添加失败"); } } @RequestMapping(value = "/productType/update") private CommonResult updateType(ProductType productType) { if(productTypeService.updateById(productType)){ return CommonResult.success("商品分类修改成功",productType); }else{ return CommonResult.error("商品分类修改失败"); } } @RequestMapping(value = "/productType/deleteById") private CommonResult deleteTypeById(Integer typeId) { if(productTypeService.deleteById(typeId)){ return CommonResult.success("商品分类删除成功","typeId: "+typeId); }else{ return CommonResult.error("商品分类删除失败"); } } @RequestMapping(value = "/productType/deleteByName") private CommonResult deleteTypeByName(String typeName) { if(productTypeService.deleteByName(typeName)){ return CommonResult.success("商品分类删除成功","typeName: "+typeName); }else{ return CommonResult.error("商品分类删除失败"); } }
private CommonResult findAllByType() { List<Map<String, Object>> maps = productService.selectAllByType(); if(maps!=null){ return CommonResult.success("商品分类信息查询成功",maps); }else{ return CommonResult.error("商品分类信息查询失败"); } } @RequestMapping(value = "/product/add") private CommonResult add(Product product) { System.out.println(product); if(productService.insertData(product)){ return CommonResult.success("添加商品成功",product); }else{ return CommonResult.error("添加商品失败"); } } @RequestMapping(value = "/product/update") private CommonResult update(Product product) { if(product.getIsNew()!=null && product.getIsNew()){ product.setSaleTime(new Date()); } if(productService.updateById(product)){ return CommonResult.success("修改商品成功",product); }else{ return CommonResult.error("修改商品失败"); } } @RequestMapping(value = "/product/delete") private CommonResult delete(Integer productId) { if(productService.deleteById(productId)){ return CommonResult.success("商品删除成功","productId:" + productId); }else{ return CommonResult.error("商品删除失败"); } } /*商品类别*/ @RequestMapping(value = "/productType/add") private CommonResult addType(ProductType productType) { if(productTypeService.insertData(productType)){ return CommonResult.success("商品分类添加成功",productType); }else{ return CommonResult.error("商品分类添加失败"); } } @RequestMapping(value = "/productType/update") private CommonResult updateType(ProductType productType) { if(productTypeService.updateById(productType)){
}else{ return CommonResult.error("商品分类名称查询失败"); } } /*商品品牌*/ @RequestMapping(value = "/productBrand/add") private CommonResult addBrand(ProductBrand productBrand) { if(productBrandService.insertData(productBrand)){ return CommonResult.success("商品品牌添加成功",productBrand); }else{ return CommonResult.error("商品品牌添加失败"); } } @RequestMapping(value = "/productBrand/update") private CommonResult updateBrand(ProductBrand productBrand) { if(productBrandService.updateById(productBrand)){ return CommonResult.success("商品品牌修改成功",productBrand); }else{ return CommonResult.error("商品品牌修改失败"); } } @RequestMapping(value = "/productBrand/deleteById") private CommonResult deleteBrandById(Integer brandId) { if(productBrandService.deleteById(brandId)){ return CommonResult.success("商品品牌删除成功","brandId: "+brandId); }else{ return CommonResult.error("商品品牌删除失败"); } } @RequestMapping(value = "/productBrand/deleteByName") private CommonResult deleteBrandByName(String brandName) { if(productBrandService.deleteByName(brandName)){ return CommonResult.success("商品品牌删除成功","brandName: "+brandName); }else{ return CommonResult.error("商品品牌删除失败"); } } @RequestMapping(value = "/productBrand/findAll")
private CommonResult updateShoppingCart(ShoppingCart shoppingCart) { if(shoppingCartService.updateById(shoppingCart)){ return CommonResult.success("购物车修改成功",shoppingCart); }else{ return CommonResult.error("购物车修改失败"); } } @RequestMapping(value = "/shoppingCart/deleteById") private CommonResult deleteShoppingCart(Integer cartId) { if(shoppingCartService.deleteById(cartId)){ return CommonResult.success("购物车删除成功","cartId: "+cartId); }else{ return CommonResult.error("购物车删除失败"); } } @RequestMapping(value = "/shoppingCart/deleteByUser") private CommonResult deleteByUser(String accountNumber) { if(shoppingCartService.deleteByUser(accountNumber)){ return CommonResult.success("购物车删除成功","accountNumber: "+accountNumber); }else{ return CommonResult.error("购物车删除失败"); } } @RequestMapping(value = "/shoppingCart/findAll") private CommonResult findAllShoppingCart(String accountNumber) { List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(accountNumber); if(shoppingInfo!=null){ return CommonResult.success("购物车查询成功",shoppingInfo); }else{ return CommonResult.error("购物车查询失败"); } } @RequestMapping(value = "/shoppingCart/findById") private CommonResult findById(Integer cartId) { ShoppingCart shoppingCart = shoppingCartService.selectById(cartId); if(shoppingCart!=null){
} } return CommonResult.error("商品退货数据不存在"); } /*买家快递寄回*/ @RequestMapping(value = "/returnGoods/sendBack") private CommonResult sendBack(Integer returnId) { if(returnId!=null){ ReturnGoods returnGoods = new ReturnGoods(); returnGoods.setReturnId(returnId); returnGoods.setReturnState("待收货"); returnGoods.setDealTime(new Date()); if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退货数据不完整"); } /*商家收到寄回的商品*/ @RequestMapping(value = "/returnGoods/receipt") private CommonResult receipt(Integer returnId) { if(returnId!=null){ ReturnGoods returnGoods = new ReturnGoods(); returnGoods.setReturnId(returnId); returnGoods.setReturnState("退货完成"); returnGoods.setDealTime(new Date()); if(returnGoodsService.updateById(returnGoods)){ return CommonResult.success("更新成功",returnGoods); }else{ return CommonResult.error("更新失败"); } } return CommonResult.error("商品退货数据不完整"); } @RequestMapping(value = "/returnGoods/deleteReturn") private CommonResult deleteReturn(Integer returnId) { if(returnId!=null){ if(returnGoodsService.deleteById(returnId)){ return CommonResult.success("删除成功",returnId); }else{ return CommonResult.error("删除失败"); } } return CommonResult.error("商品退货数据不存在"); }
/*商品品牌*/ @RequestMapping(value = "/productBrand/add") private CommonResult addBrand(ProductBrand productBrand) { if(productBrandService.insertData(productBrand)){ return CommonResult.success("商品品牌添加成功",productBrand); }else{ return CommonResult.error("商品品牌添加失败"); } } @RequestMapping(value = "/productBrand/update") private CommonResult updateBrand(ProductBrand productBrand) { if(productBrandService.updateById(productBrand)){ return CommonResult.success("商品品牌修改成功",productBrand); }else{ return CommonResult.error("商品品牌修改失败"); } } @RequestMapping(value = "/productBrand/deleteById") private CommonResult deleteBrandById(Integer brandId) { if(productBrandService.deleteById(brandId)){ return CommonResult.success("商品品牌删除成功","brandId: "+brandId); }else{ return CommonResult.error("商品品牌删除失败"); } } @RequestMapping(value = "/productBrand/deleteByName") private CommonResult deleteBrandByName(String brandName) { if(productBrandService.deleteByName(brandName)){ return CommonResult.success("商品品牌删除成功","brandName: "+brandName); }else{ return CommonResult.error("商品品牌删除失败"); } } @RequestMapping(value = "/productBrand/findAll") private CommonResult findAllBrand() { List<ProductBrand> productBrands = productBrandService.selectAll(); if(productBrands!=null){ return CommonResult.success("商品品牌查询成功",productBrands); }else{
return CommonResult.error("验证码发送失败,请稍后重试~"); } } } /** * @email qiudb.top@aliyun.com * @description 商品规格、商品与商品规格的关联 */ @RestController @CrossOrigin public class SpecsController { final SpecsService specsService; final ProductSpecsService productSpecsService; public SpecsController(SpecsService specsService,ProductSpecsService productSpecsService) { this.specsService = specsService; this.productSpecsService = productSpecsService; } /*根据id查询规格*/ @RequestMapping(value = "/specs/findById") private CommonResult findById(Integer specsId) { Specs specs = specsService.selectById(specsId); if(specs!=null){ return CommonResult.success("查询成功",specs); }else{ return CommonResult.error("查询失败"); } }
/** * @email qiudb.top@aliyun.com * @description 发送邮件、产生验证码图片、发送短信等工具类操作 */ @RestController @CrossOrigin public class UtilController { private final RedisTemplate<String, String> redisTemplate; private final AliYunSmsService aliYunSmsService; private final IMailService mailService; private final Logger logger = LoggerFactory.getLogger(this.getClass()); public UtilController(RedisTemplate<String, String> redisTemplate, IMailService mailService, AliYunSmsService aliYunSmsService) { this.mailService = mailService; this.aliYunSmsService = aliYunSmsService; this.redisTemplate = redisTemplate; } /** * 发送一个简单的文本邮件 * * @param sendTo 收件人 */ @RequestMapping(value = "/util/send") public String sendmail(String sendTo) { mailService.sendSimpleMail(sendTo, "主题:你好普通邮件", "内容:第一封邮件"); return "发送成功!"; } /** * 发送一个邮箱随机验证码 * * @param sendTo 收件人 */ @RequestMapping(value = "/allow/sendHtmlCode") public CommonResult sendHtmlCode(String sendTo) { // long startTime = System.currentTimeMillis(); //获取开始时间 try {
@RequestMapping(value = "/user/findIdByKey") private CommonResult findIdByKey(String key) { Integer id = userService.selectIdByKey(key); if(id!=null){ if(id!=0){ return CommonResult.success("查询成功","id: "+id); }else{ return CommonResult.error("未查询到"); } }else{ return CommonResult.error("查询失败"); } } //删除用户 @RequestMapping(value = "/user/delete") private CommonResult delete(Integer userId) { if(userService.deleteById(userId)){ return CommonResult.success("删除成功",userId); }else{ return CommonResult.error("删除失败"); } } @RequestMapping(value = "/user/author") private CommonResult author(Integer userId,@RequestParam List<Integer> roleId) { System.out.println(userId); System.out.println(roleId); if(userId!=null && roleId!=null && roleId.size()!=0){ if(userRoleService.deleteById(userId)){ UserRole userRole = new UserRole(); userRole.setUserId(userId); for (Integer id : roleId) { userRole.setRoleId(id); userRoleService.insertData(userRole); } } return CommonResult.success("授权成功"); }else{ return CommonResult.error("角色授权数据不完整!"); } } /*查询所有VIP用户*/ @RequestMapping(value = "/vip/findAllVip")
/** * @email qiudb.top@aliyun.com * @description 商品评价 业务类 */ @RestController @CrossOrigin public class ProductReviewController { final ProductReviewService ProductReviewService; final OrderService orderService; public ProductReviewController(ProductReviewService ProductReviewService,OrderService orderService){ this.ProductReviewService = ProductReviewService; this.orderService = orderService; } /*商品类别*/ @RequestMapping(value = "/productReview/add") private CommonResult addProductReview(ProductReview productReview) { if(ProductReviewService.insertData(productReview)){ Integer orderId = orderService.selectIdByKey(productReview.getOrderNo()); Order order = new Order(); order.setOrderId(orderId); order.setOrderState("已评价"); orderService.updateById(order); return CommonResult.success("商品评论添加成功",productReview); }else{ return CommonResult.error("商品评论添加失败"); } } @RequestMapping(value = "/productReview/update") private CommonResult updateProductReview(ProductReview productReview) { if(ProductReviewService.updateById(productReview)){ return CommonResult.success("商品评论修改成功",productReview); }else{ return CommonResult.error("商品评论修改失败"); } } @RequestMapping(value = "/productReview/deleteById") private CommonResult deleteProductReview(Integer reviewId) { if(ProductReviewService.deleteById(reviewId)){ return CommonResult.success("商品评论删除成功","reviewId: "+reviewId); }else{ return CommonResult.error("商品评论删除失败"); } } @RequestMapping(value = "/productReview/findAll") private CommonResult findAllProductReview(String productNo) {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。