• (原创)springboot,vue网上购物商城定制版v3.0


    (全新)基于springboot,vue网上商城定制版v3.0

    本人原创作品,用户前台、系统管理员后台项目完整,无任何bug。

    每行代码都是本人自己写,我在代码上面都写有详细注释,不懂任何问题都可以咨询

    开发工具:IDEA

    服务器:Tomcat9.0, jdk1.8

    项目构建:maven

    数据库:mysql5.7

    系统分前后台,采用前后端分离

    前端技术:vue (vue cli,vue-router,vuex全家桶),elementUI等框架实现

    服务端技术:springboot,mybatis-plus

    定制版v3.0功能说明:项目全新技术开发与设计,前后端分离

    功能说明:

    前台截图:

    后台截图:

    package com.ping.controller;


    import com.ping.dto.ProductDto;
    import com.ping.dto.ProductEvaluationDto;
    import com.ping.dto.query.ProductEvaluationQueryDto;
    import com.ping.dto.query.ProductQueryDto;
    import com.ping.pojo.*;
    import com.ping.service.IProductCategoryService;
    import com.ping.service.IProductEvaluationService;
    import com.ping.service.IProductService;
    import io.swagger.annotations.ApiOperation;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.*;
    import java.util.List;

    /**
     *


     *  前端控制器
     *


     *
     * @author IT教程资源(vx:3092994143)
     * @since 2022-07-03
     */
    @RestController
    @RequestMapping("/product")
    public class ProductController {

        @Autowired
        private IProductService iProductService;

        @Autowired
        private IProductCategoryService iProductCategoryService;

        @Autowired
        private IProductEvaluationService iProductEvaluationService;


        @ApiOperation("分页查询商品信息")
        @PostMapping("/getProductPage")
        public RespPageBean getProductPage(@RequestBody ProductQueryDto queryDto){
            return iProductService.getProductPage(queryDto);
        }

        /**
         * @Author IT教程资源(vx:3092994143) 2022/7/9 14:09
         * @Description 商品分类信息
         */
        @ApiOperation(value = "商品分类列表")
        @GetMapping("/getProductCategory")
        public List getProductCategory(){
            return iProductCategoryService.getProductCategory();
        }

        /**
         * @Author IT教程资源(vx:3092994143) 2022/7/23 15:04
         * @Description 商品详情
         */
        @ApiOperation(value = "商品详情")
        @GetMapping("/getProductInfo")
        public ProductDto getProductInfo(Integer id){
            //根据id查询商品信息
            Product product = iProductService.getById(id);
            ProductDto productDto=new ProductDto();
            BeanUtils.copyProperties(product,productDto);
            //根据商品分类id查询商品所属分类信息
            ProductCategory productCategory = iProductCategoryService.getById(product.getProductCategoryId());
            productDto.setProductCategory(productCategory);
            //商品评价信息
            ProductEvaluationQueryDto productEvaluationQueryDto=new ProductEvaluationQueryDto();
            productEvaluationQueryDto.setProductId(id);
            List productEvaluationDtos=iProductEvaluationService.queryProductEvaluationById(productEvaluationQueryDto);
            productDto.setProductEvaluationDtos(productEvaluationDtos);
            return productDto;
        }
    }
     

    1. package com.ping.controller;
    2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
    3. import com.ping.dto.ShoppingCartDto;
    4. import com.ping.pojo.Product;
    5. import com.ping.pojo.RespBean;
    6. import com.ping.pojo.ShoppingCart;
    7. import com.ping.pojo.User;
    8. import com.ping.service.IProductService;
    9. import com.ping.service.IShoppingCartService;
    10. import com.ping.utils.UserUtils;
    11. import io.swagger.annotations.ApiOperation;
    12. import org.springframework.beans.factory.annotation.Autowired;
    13. import org.springframework.web.bind.annotation.*;
    14. import java.util.Arrays;
    15. import java.util.List;
    16. /**
    17. * @Author IT教程资源(vx : 3092994143) 2022/7/23 21:03
    18. * @Description 购物车
    19. */
    20. @RestController
    21. @RequestMapping("/shoppingCart")
    22. public class ShoppingCartController {
    23. @Autowired
    24. private IShoppingCartService iShoppingCartService;
    25. @Autowired
    26. private IProductService iProductService;
    27. /**
    28. * @Author IT教程资源(vx : 3092994143) 2022/7/23 21:04
    29. * @Description 添加购物车
    30. */
    31. @ApiOperation("添加购物车")
    32. @PostMapping("/addShoppingCart")
    33. public RespBean addShoppingCart(@RequestBody ShoppingCart shoppingCart) {
    34. User currentUser = UserUtils.getCurrentUser();
    35. shoppingCart.setUserId(currentUser.getId());
    36. //查询当前用户购物车信息
    37. QueryWrapper shoppingCartQueryWrapper = new QueryWrapper<>();
    38. shoppingCartQueryWrapper.eq("user_id", currentUser.getId());
    39. List shoppingCarts = iShoppingCartService.list(shoppingCartQueryWrapper);
    40. //如果之前有存在该商品,累加并更新,否则新增
    41. ShoppingCart oldShoppingCart = null;
    42. for (ShoppingCart cart : shoppingCarts) {
    43. //如果存在,取出该购物车信息
    44. if (cart.getProductId().equals(shoppingCart.getProductId())) {
    45. oldShoppingCart = cart;
    46. }
    47. }
    48. boolean result;
    49. //存在该购物车商品,进行更新
    50. if (oldShoppingCart != null) {
    51. //修改数量
    52. oldShoppingCart.setPayAmount(oldShoppingCart.getPayAmount() + shoppingCart.getPayAmount());
    53. result = iShoppingCartService.updateById(oldShoppingCart);
    54. } else {
    55. //新增购物车记录
    56. result = iShoppingCartService.save(shoppingCart);
    57. }
    58. if (result) {
    59. return RespBean.success("添加购物车成功!");
    60. } else {
    61. return RespBean.error("添加购物车失败!");
    62. }
    63. }
    64. /**
    65. * @Author IT教程资源(vx:3092994143) 2022/7/23 23:09
    66. * @Description 查询购物车信息
    67. */
    68. @ApiOperation(value = "购物车信息列表")
    69. @GetMapping("/getShoppingCartInfo")
    70. public List getShoppingCartInfo(){
    71. User currentUser = UserUtils.getCurrentUser();
    72. return iShoppingCartService.getShoppingCartInfo(currentUser);
    73. }
    74. /**
    75. * @Author IT教程资源(vx:3092994143) 2022/7/24 11:45
    76. * @Description 删除购物车
    77. */
    78. @ApiOperation("删除购物车")
    79. @DeleteMapping("/deleteShoppingCart/{id}")
    80. public RespBean deleteShoppingCart(@PathVariable Integer id){
    81. if(iShoppingCartService.removeById(id)){
    82. return RespBean.success("删除成功!");
    83. }
    84. return RespBean.error("删除失败!");
    85. }
    86. /**
    87. * @Author IT教程资源(vx:3092994143) 2022/7/24 12:30
    88. * @Description 批量删除购物车
    89. */
    90. @ApiOperation("批量删除购物车")
    91. @DeleteMapping("/deleteBatchShoppingCart")
    92. public RespBean deleteBatchShoppingCart(Integer[] ids){
    93. if(iShoppingCartService.removeByIds(Arrays.asList(ids))){
    94. return RespBean.success("删除成功!");
    95. }
    96. return RespBean.error("删除失败!");
    97. }
    98. /**
    99. * @Author IT教程资源(vx:3092994143) 2022/7/24 12:48
    100. * @Description 修改购物车商品数量
    101. */
    102. @ApiOperation("修改购物车商品数量")
    103. @PutMapping("/updateShoppingCart")
    104. public RespBean updateShoppingCart(@RequestBody ShoppingCart shoppingCart){
    105. //校验库存是否足够
    106. Product product = iProductService.getById(shoppingCart.getProductId());
    107. if((product.getStock()-product.getVolume())
    108. return RespBean.error("库存不足!");
    109. }
    110. if(iShoppingCartService.updateById(shoppingCart)){
    111. return RespBean.success(shoppingCart);
    112. }
    113. return RespBean.error("更新失败!");
    114. }
    115. }

  • 相关阅读:
    使用命令行cli脚手架创建uniapp项目(微信小程序、H5、APP)
    LeetCode知识点总结 - 437
    前端周刊第三十八期
    《调试九法》阅读笔记
    删除集合中的指定元素A.discard(B)A.remove(B)
    21.3 CSS 背景属性
    mysql性能分析
    文化融合与社交网络:Facebook的角色
    Windows11 安装 chocolatey 包管理器
    Redis布隆过滤器和布谷鸟过滤器
  • 原文地址:https://blog.csdn.net/weixin_42899150/article/details/126115981