广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Java 实战练习之网上电商项目的实现
  • 369
分享到

Java 实战练习之网上电商项目的实现

2024-04-02 19:04:59 369人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

一、项目简述 本系统功能包括: 一款基于SpringBoot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,

一、项目简述

本系统功能包括: 一款基于SpringBoot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,信息维护,用户管理等等。

二、项目运行

环境配置: jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (WEBstORM也 行)+ Eclispe (IntelliJ idea,Eclispe,MyEclispe,Sts都支 持)。

项目技术: springboot + Maven + mybatis + Vue + Redis^K, B/S 模式+ Maven等等,附带支付宝沙箱环境以及支付环节代码。

商品相关业务代码:



 
@RestController
@CrossOrigin
public class ProductController {
    final ProductTypeService productTypeService;
    final ProductBrandService productBrandService;
    final ProductService productService;
    public ProductController(ProductService productService, ProductTypeService productTypeService,ProductBrandService productBrandService) {
        this.productTypeService = productTypeService;
        this.productBrandService = productBrandService;
        this.productService = productService;
    }
 
    
    @RequestMapping(value = "/product/findById")
    private CommonResult findById(Integer productId) {
        Product product = productService.selectById(productId);
        if(product!=null){
            return CommonResult.success("商品查询成功",product);
        }else{
            return CommonResult.error("商品查询失败");
        }
    }
    @RequestMapping(value = "/product/findByKey")
    private CommonResult findByKey(String productNo) {
        Product product = productService.selectByKey(productNo);
        if(product!=null){
            return CommonResult.success("商品查询成功",product);
        }else{
            return CommonResult.error("商品查询失败");
        }
    }
    @RequestMapping(value = "/product/findIdByKey")
    private CommonResult findIdByKey(String productNo) {
        Integer productId = productService.selectIdByKey(productNo);
        if(productId!=null){
            return CommonResult.success("商品id查询成功",productId);
        }else{
            return CommonResult.error("商品id查询失败");
        }
    }
    @RequestMapping(value = "/product/findCount")
    private CommonResult findCount() {
        Integer count = productService.selectCount();
        if(count!=null){
            return CommonResult.success("商品数量查询成功",count);
        }else{
            return CommonResult.error("商品数量查询失败");
        }
    }
    @RequestMapping(value = "/product/existsKey")
    private CommonResult existsKey(String productNo) {
        Boolean isExist = productService.existsWithPrimaryKey(productNo);
        if(isExist!=null){
            return CommonResult.success("商品是否存在查询成功",isExist);
        }else{
            return CommonResult.error("商品是否存在查询失败");
        }
    }
    @RequestMapping(value = "/product/existsType")
    private CommonResult existsType(String productType) {
        Boolean isExist = productService.existsProductType(productType);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    @RequestMapping(value = "/product/existsBrand")
    private CommonResult existsBrand(String productBrand) {
        Boolean isExist = productService.existsProductBrand(productBrand);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    @RequestMapping(value = "/product/findAll")
    private CommonResult findAll() {
        List<Product> products = productService.selectAll();
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllSale")
    private CommonResult findAllSale() {
        List<Product> products = productService.selectAllSale();
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllLikeName")
    private CommonResult findAllLikeName(String keyWord) {
        List<Product> products = productService.selectAllLikeName(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllLikeType")
    private CommonResult findAllLikeType(String keyWord) {
        List<Product> products = productService.selectAllLikeType(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllLikeBrand")
    private CommonResult findAllLikeBrand(String keyWord) {
        List<Product> products = productService.selectAllLikeBrand(keyWord);
        if(products!=null){
            return CommonResult.success("全部商品信息查询成功",products);
        }else{
            return CommonResult.error("全部商品信息查询失败");
        }
    }
    @RequestMapping(value = "/product/findAllByType")
    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)){
            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("商品分类删除失败");
        }
    }
 
    @RequestMapping(value = "/productType/existsTypeName")
    private CommonResult existsTypeName(Integer typeId,String typeName) {
        Boolean isExist = productTypeService.existsWithTypeName(typeId,typeName);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
 
    @RequestMapping(value = "/productType/findAll")
    private CommonResult findAllType() {
        List<ProductType> productTypes = productTypeService.selectAll();
        if(productTypes!=null){
            return CommonResult.success("商品分类查询成功",productTypes);
        }else{
            return CommonResult.error("商品分类查询失败");
        }
    }
 
    @RequestMapping(value = "/productType/findAllName")
    private CommonResult findAllTypeName() {
        List<String> names = productTypeService.selectAllName();
        if(names!=null){
            return CommonResult.success("商品分类名称查询成功",names);
        }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 findAllBrand() {
        List<ProductBrand> productBrands = productBrandService.selectAll();
        if(productBrands!=null){
            return CommonResult.success("商品品牌查询成功",productBrands);
        }else{
            return CommonResult.error("商品品牌查询失败");
        }
    }
 
    @RequestMapping(value = "/productBrand/existsBrandName")
    private CommonResult existsBrandName(Integer brandId,String brandName) {
        Boolean isExist = productBrandService.existsWithBrandName(brandId,brandName);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
 
    @RequestMapping(value = "/productBrand/findAllName")
    private CommonResult findAllBrandName() {
        List<String> names = productBrandService.selectAllName();
        if(names!=null){
            return CommonResult.success("商品品牌名称查询成功",names);
        }else{
            return CommonResult.error("商品品牌名称查询失败");
        }
    }
}

商品规格、商品与商品规格的关联代码:



 
@RestController
@CrossOrigin
public class SpecsController {
    final SpeCSService specsService;
    final ProductSpecsService productSpecsService;
    public SpecsController(SpecsService specsService,ProductSpecsService productSpecsService) {
        this.specsService = specsService;
        this.productSpecsService = productSpecsService;
    }
    
    @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("查询失败");
        }
    }
 
    
    @RequestMapping(value = "/specs/findAll")
    private CommonResult findAllSpecs() {
        List<Specs> specs = specsService.selectAll();
        if(specs!=null){
            return CommonResult.success("查询成功",specs);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    
    @RequestMapping(value = "/specs/existsSpecsName")
    private CommonResult existsSpecsName(Integer specsId, String specsName, String productType) {
        Boolean isExist = specsService.existsWithSpecsName(specsId,specsName,productType);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
 
    @RequestMapping(value = "/specs/findAllByType")
    private CommonResult findAllSpecsByType(String productType) {
        List<Specs> specs = specsService.selectAllByType(productType);
        if(specs!=null){
            return CommonResult.success("查询成功",specs);
        }else{
            return CommonResult.error("查询失败");
        }
    }
 
    @RequestMapping(value = "/specs/add")
    private CommonResult addSpecs(Specs specs) {
        if(specs!=null){
            if(specsService.insertData(specs)){
                return CommonResult.success("添加成功",specs);
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("数据不存在");
    }
 
    @RequestMapping(value = "/specs/update")
    private CommonResult updateSpecs(Specs specs) {
        if(specsService.updateById(specs)){
            return CommonResult.success("更新成功",specs);
        }else{
            return CommonResult.error("更新失败");
        }
    }
 
    @RequestMapping(value = "/specs/delete")
    private CommonResult deleteSpecs(Integer specsId) {
        if(specsService.deleteById(specsId)){
            return CommonResult.success("删除成功",specsId);
        }else{
            return CommonResult.error("删除失败");
        }
    }
 
 
 
    
 
    
    @RequestMapping(value = "/productSpecs/findAll")
    private CommonResult findAll() {
        List<ProductSpecs> productSpecs = productSpecsService.selectAll();
        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);
            }
            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("删除失败");
        }
    }
}

到此这篇关于Java 实战练习之网上电商项目的实现的文章就介绍到这了,更多相关Java 网上电商内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: Java 实战练习之网上电商项目的实现

本文链接: https://www.lsjlt.com/news/157196.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Java 实战练习之网上电商项目的实现
    一、项目简述 本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,...
    99+
    2022-11-12
  • Django项目之Web端电商网站的实战
    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/88810060 目录 一丶模板文件继承...
    99+
    2023-01-31
    商网 实战 项目
  • Java 实战项目锤炼之网上花店商城的实现流程
    一、项目简述 功能: 一套完整的网上花店商场系统,系统支持前台会员的注册 登陆系统留言,花朵的品种选择,详情浏览,加入购物 车,购买花朵等;后台支持管理员的花朵种类添加,花朵 详情的...
    99+
    2022-11-12
  • Java 实战项目锤炼之网上商城系统的实现流程
    一、项目简述(+需求文档+PPT) 功能: 主页显示热销商品;所有商品展示,可进行商品搜索;点 击商品进入商品详情页,显示库存,具有立即购买和加入 购物车功能,可增减购买商品数量亦可...
    99+
    2022-11-12
  • 怎么用Java实现网上电商项目
    这期内容当中小编将会给大家带来有关怎么用Java实现网上电商项目,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。一、项目简述本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,...
    99+
    2023-06-25
  • Java 实战项目锤炼之仿天猫网上商城的实现流程
    一、项目简述 功能: 前台: * 用户模块 * 分类模块 * 商品模块 * 购物车模块 * 订单模块 后台: * 管理员模块 * 分类管理模块 * 商品管理模块 * 订单模块 二、项...
    99+
    2022-11-12
  • Java实战项目练习之球馆在线预约系统的实现
    功能具体如下:前台用户:登录\注册、查看场馆、预约场馆、投诉、个人中心、关于我们、网站公告等。后台管理员:场馆列表、场地列表、场地安排、订单管理、教练管理、器材管理、收银员管理、会员...
    99+
    2022-11-12
  • Java 实战练手项目之酒店管理系统的实现流程
    一、项目简述 功能包括(管理员和用户角色): 酒店预订,酒店管理,员工管理,入住原理,订单管理, 楼层管理,退房管理,营业额报表等等。 二、项目运行 环境配置: Jdk1.8 + T...
    99+
    2022-11-12
  • Java 实战项目锤炼之在线蛋糕商城系统的实现
    一、项目简述 功能: 主页显示热销商品;所有蛋糕商品展示,可进行商品搜 索;点击商品进入商品详情页,具有立即购买和加入购物 车功能,可增减购买商品数量亦可手动输入(同时验证库 存),...
    99+
    2022-11-12
  • Java实战练手项目之医院预约挂号系统的实现流程
    一、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Ecli...
    99+
    2022-11-12
  • Java 实战练手项目之校园超市管理系统的实现流程
    前端模板框架为Bootstrap,系统分为前台和后台。后台主要为管理员角色,功能有:商品类型管理、商品管理、订单管理、会员管理、管理员管理等。前台用户功能有:登录、注册、查看商品、加...
    99+
    2022-11-12
  • Java 实战项目锤炼之网上图书馆管理系统的实现流程
    一、项目简述 功能: 区分为管理员用户和普通用户,普通用户:用户登录,个 人信息修改,图书查询,用户借阅,用户归还,管理员用 户:图书馆里,归还管理,借阅信息查询,图书维护,分 类管...
    99+
    2022-11-12
  • Java毕业设计实战项目之宠物商城系统的实现流程
    一、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Ecli...
    99+
    2022-11-13
  • Java 实战项目锤炼之在线购书商城系统的实现流程
    一、项目简述 功能:一个基于JavaWeb的网上书店的设计与实现,归纳 出了几个模块,首先是登录注册模块,图书查找模块,购 物车模块,订单模块,个人中心模块,用户管理模块,图 书管理...
    99+
    2022-11-12
  • Java实战之小蜜蜂扩音器网上商城系统的实现
    目录一、项目简述二、项目运行三、效果图四、核心代码用户管理控制层订单管理控制层品类控制层产品控制层一、项目简述 用户功能模块: 用户注册: 用户登录:商品模块:订单模块;后台管理系统...
    99+
    2022-11-13
  • Python PyQt5实战项目之网速监控器的实现
    目录简介psutil模块使用主界面网速线程全部代码成果展示简介 看到了一个能够轻松实现获取系统运行的进程和系统利用率(包括CPU、内存、磁盘、网络等)信息的模块–psutil模块。这...
    99+
    2022-11-12
  • Java实战网上电子书城的实现流程
    项目描述: spring mvc +jsp实现的简单书城项目,可以在支付宝沙箱内实现支付 运行环境: jdk8+tomcat9+mysql+IntelliJ IDEA 项目技术: s...
    99+
    2022-11-12
  • Java 实战项目锤炼之在线美食网站系统的实现流程
    一、项目简述 功能:用户的注册登录,美食浏览,美食文化,收藏百 科,趣味问答,食谱等等功能等等。 二、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + ...
    99+
    2022-11-12
  • Java 实战项目之诚途旅游系统的实现流程
    采用ssm架构实现的旅游网站系统 包括网站展示和后台管理功能,网站主要是页面浏览以及评论、制定旅游方案、智能推荐功能 后台就是维护网站展示的内容,添加旅游景点、管理用户、查看用户的搜...
    99+
    2022-11-12
  • Java实战项目之校园跑腿管理系统的实现
    前端使用的是vue+elementui,这款系统只适合学习巩固SpringBoot+VUE,后面还要在这上面加校园公告、校园零食等功能,后期代码我也会持续更新上去。系统分为管理员和学...
    99+
    2022-11-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作