您好,登錄后才能下訂單哦!
這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)怎么用Java實(shí)現(xiàn)網(wǎng)上電商項(xiàng)目,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
本系統(tǒng)功能包括: 一款基于Springboot+Vue的電商項(xiàng)目,前后端分離項(xiàng)目,前臺(tái)后臺(tái)都有,前臺(tái)商品展示購(gòu)買,購(gòu)物車分類,訂 單查詢等等,后臺(tái)商品管理,訂單管理,信息維護(hù),用戶管理等等。
環(huán)境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。
項(xiàng)目技術(shù): Springboot + Maven + Mybatis + Vue + Redis^K, B/S 模式+ Maven等等,附帶支付寶沙箱環(huán)境以及支付環(huán)節(jié)代碼。
/** * @author Qiu * @description 商品相關(guān)業(yè)務(wù) */ @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("商品數(shù)量查詢成功",count); }else{ return CommonResult.error("商品數(shù)量查詢失敗"); } } @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("商品品牌名稱查詢失敗"); } } }
/** * @author Qiu * @description 商品規(guī)格、商品與商品規(guī)格的關(guān)聯(lián) */ @RestController @CrossOrigin public class SpecsController { final SpecsService specsService; final ProductSpecsService productSpecsService; public SpecsController(SpecsService specsService,ProductSpecsService productSpecsService) { this.specsService = specsService; this.productSpecsService = productSpecsService; } /*根據(jù)id查詢規(guī)格*/ @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("查詢失敗"); } } /*查詢所有規(guī)格信息*/ @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("數(shù)據(jù)不存在"); } @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("刪除失敗"); } } /*商品 與 規(guī)格 的關(guān)聯(lián)表*/ /*查詢所有商品規(guī)格對(duì)應(yīng)信息*/ @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("數(shù)據(jù)不存在"); } @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("數(shù)據(jù)不存在"); } @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實(shí)現(xiàn)網(wǎng)上電商項(xiàng)目了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。