Git Product home page Git Product logo

2227324689 / gpmall Goto Github PK

View Code? Open in Web Editor NEW
4.8K 4.8K 1.9K 55.59 MB

【咕泡学院实战项目】-基于SpringBoot+Dubbo构建的电商平台-微服务架构、商城、电商、微服务、高并发、kafka、Elasticsearch

Home Page: http://vip.istio.tech/

License: Apache License 2.0

Java 44.59% JavaScript 32.87% HTML 0.09% Vue 17.93% PLpgSQL 4.34% SCSS 0.18%
canal dubbo elasticsearch elk java kafka nacos sentinel springboot springcloud-alibaba zookeeper

gpmall's Introduction

1566284996878

license issues constract us origin blog author Gpmall hits community

咕泡商城- 微服务架构实战

咕泡商城是咕泡学院 Java架构课程中,帮助学员对于技术更好落地的一个实战项目,项目基于springboot2.1.6.RELEASE+Dubbo2.7.3 来构建微服务。

业务模块划分,尽量贴合互联网公司的架构体系。所以,除了业务本身的复杂度不是很高之外,整体的架构基本和实际架构相差无几。

但实际上,真实的生产级的项目由于用户量以及业务的复杂度,会变得非常复杂。 所以我们会让更多的人参与进来,从需求、设计、解决方案等方面出发来对项目进行迭代,从而培养出一定的

实际解决方案的经验和能力。

应用架构图

1565533924343

项目演示地址

项目用到的技术

项目采用前后端分离开发,前端需要独立部署。目前核心的技术栈采用的是SpringBoot2.1.5.RELEASE+Dubbo2.7.2,

前端使用的技术

  • nodejs
  • axios
  • es6
  • vue
  • sass
  • Element UI
  • webpack
  • vue router
  • mockjs

后端使用的技术

后端的主要架构是基于springboot+dubbo+mybatis.

  • SpringBoot2.1.6
  • Mybatis
  • Dubbo2.7.2
  • Zookeeper
  • Mysql
  • Redis
  • Elasticsearch
  • Kafka
  • druid
  • Docker
  • mybatis generator
  • Sentinel

项目模块说明

db_script 本项目的数据库脚本 使用mysql 暂时未做分表处理,不过有考虑到分表的情况
gpmall-cashier 收银台,负责支付相关的交互逻辑 web项目 8083端口
gpmall-commons 公共的组件 jar 公共组件,很多地方都有引用,改动的时候要注意
gpmall-front 咕泡商城的前端项目 前端项目 使用vue、node、es等前端技术开发
gpmall-parent 父控文件,用来统一管理所有jar包 父控文件 用来统一管理所有项目的jar包的版本
gpmall-shopping 商品/购物车/首页渲染等交互 web项目 8081端口
gpmall-user 提供用户相关的交互,如登录、注册、个人中心等 web项目 8082端口
market-service 促销活动的Dubbo服务【暂时未联调完成,可以不启动】 dubbo服务 20884端口
pay-service 提供支付处理能力 dubbo服务 20883端口
shopping-service,提供购物车、推荐商品、商品等服务 dubbo服务 20881端口
user-service ,提供用户相关服务 dubbo服务 20880端口
order-service ,提供订单服务 dubbo服务 20882端口
comment-service , 商品评论服务 dubbo服务 20885端口
PRD 存放prd需求文档,有想参与设计的同学,可以提供prd需求
wiki 帮助文档,需要每一位同学贡献自己的一份力量

项目搭建方式

  1. 创建gpmall数据库,并把db_scrpit目录下的sql脚本导入。

  2. 按照下面顺序分别启动相关服务

    • gpmall-parent , 这个是整个项目的父控文件,需要执行install安装到本地,如果自己搭建了nexus,可以deploy到nexus上

    • gpmall-commons , 这个是整个项目的公共依赖,执行install安装到本地,如果自己搭建了nexus,可以deploy到nexus上

      注: 下列微服务,用到了mysql、redis、kafka等,需要提前安装好相关中间件,并且所有的服务配置的是host地址,建议用hostswitch工具统一维护

    • user-service , 用户服务,把user-service-api模块,install到本地仓库,因为其他模块有依赖。然后启动服务。

    • order-service , 订单服务, 把order-service-api模块,install到本地,给其他模块依赖

    • shopping-service , 商品服务, 把shopping-service-api模块,install到本地,给其他模块依赖

    • marking-service , 营销服务,暂时未开发功能。

    • pay-service , 支付服务,代码已经写完并调试通过(但是用的是老的接口版本,如果是新的版本,需要改接口),还需要提供appid这些,不过这个项目不启动,并不影响前面的页面的功能

    • comment-service , 评论服务,用于展示商品评论信息

      下面的服务为BFF,做服务聚合,分别依赖上面的微服务模块

    • gpmall-shopping

    • gpmall-user

    • gpmall-cashier

  3. 前端工程 gpmall-front, 这个项目采用vue开发。

    1. 安装node环境
    2. 安装python2.7
    3. 在gpmall-front中执行npm install
    4. 再执行npm run dev运行, 如果后端的服务都正常启动,此时gpmall-front会把请求转发到服务端获取相关数据进行渲染。

项目开发进度

前台项目整体的规划有

  • 首页渲染,轮播、自定义展示板块
  • 商品查询、商品展示、商品详情
  • 个人中心、用户注册、个人信息修改、收获地址维护
  • 购物车、订单查询、下单、支付
  • 促销活动

1565235690613

后台规划

效果图

项目架构图

1565861422268

如何贡献

非常欢迎您对Gpmall的开发作出贡献! 你可以选择以下方式向Gpmall贡献:

<<<<<<< HEAD

=======

个人微信公众号

跟着Mic学架构

88aab362053f002aeff65bb3c957591fafb1c788

作者的个人博客

https://istio.tech

gpmall's People

Contributors

2227324689 avatar 937345232 avatar bladeandmaster88 avatar dependabot[bot] avatar eleven-lo avatar fuyl1988 avatar gu-aoran avatar hepengshuai avatar jerry-sk avatar jiangnan7400 avatar joeltangerine avatar junlongzhangz avatar kaiguoyuanshuai avatar lanwp530 avatar liuchenghong6079 avatar lizhaowh avatar lkmxsxd avatar oahnus avatar pingpong-tech avatar qiangziwwq avatar ramln1989 avatar shuanglingmao avatar silent-night-no-trace avatar tufeng1992 avatar wwpy avatar xiaosos avatar zhangzhenguo2 avatar zszj888 avatar zzzxdm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpmall's Issues

事务咋都没解决啊

为啥在service 还try,try你就try吧,你catch还不throw,你是要闹哪样啊,咋想的,坑死我了

发起拼单的可能

比如双11凑单发起,基于家和上班的地点经纬度算法 发起拼单 省快递费? 其实类似美团外卖的拼单 不过需要计算库存.和打折优惠券之后的 没人付多少钱

发现验证码验证服务KaptchaServiceImpl有可能60s生成相同的,导致验证失败

如果60s内,大量用户校验验证码时,如生成了两个相同的Code,存入Redis,验证时会失败。
以下是测试代码
public class UserProviderApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context=SpringApplication.run(UserProviderApplication.class,args);
KaptchaServiceImpl kaptchaService= (KaptchaServiceImpl) context.getBean("kaptchaServiceImpl");
Map<String,Object> map=new HashMap<String,Object>();
KaptchaCodeRequest request=new KaptchaCodeRequest();
for(int i=0;i<2000;i++){
KaptchaCodeResponse response=kaptchaService.getKaptchaCode(new KaptchaCodeRequest());
if(map.get(response.getImageCode())==null){
map.put(response.getImageCode(),response);
}else{
System.out.println("60s内有重复的token生成 redis里有两份一样的code,response = " + response);
request.setUuid(response.getUuid());
request.setCode(response.getCode());
KaptchaCodeResponse validateResponse=kaptchaService.validateKaptchaCode(request);
System.out.println("validateResponse = " + validateResponse);
}
}
}
结果总有一两笔是重复的:
60s内有重复的token生成 redis里有两份一样的code,response = KaptchaCodeResponse(imageCode=dktv, uuid=5e884bee-136c-4621-b58c-17f1485c28a3)
2019-10-16 16:47:16.654 INFO 908 --- [ main] c.p.user.services.KaptchaServiceImpl : 请求的redisKey=kaptcha_uuid5e884bee-136c-4621-b58c-17f1485c28a3,请求的code=000000,从redis获得的code=dktv
validateResponse = KaptchaCodeResponse(imageCode=null, uuid=null)
60s内有重复的token生成 redis里有两份一样的code,response = KaptchaCodeResponse(imageCode=961m, uuid=495d00e6-a8b7-4148-9375-4940f6bed166)
2019-10-16 16:47:30.025 INFO 908 --- [ main] c.p.user.services.KaptchaServiceImpl : 请求的redisKey=kaptcha_uuid495d00e6-a8b7-4148-9375-4940f6bed166,请求的code=000000,从redis获得的code=961m
validateResponse = KaptchaCodeResponse(imageCode=null, uuid=null)

Security Vulnerability - Action Required: XXE vulnerability in the newest version of the gpmall

I think the your project may be vulnerable to Improper Restriction of XML External Entity Reference. It shares similarities to a recent CVE disclosure CVE-2021-3878 in the stanfordnlp/CoreNLP. The vulnerable methods are as follows:

  1. com.gpmall.pay.biz.payment.channel.wechatpay.WeChatBuildRequest.doXMLParse(String xml) in the file pay-service/pay-provider/src/main/java/com/gpmall/pay/biz/payment/channel/wechatpay/WeChatBuildRequest.java.

The source vulnerability information is as follows:

Vulnerability Detail:
CVE Identifier: CVE-2021-3878
Description: corenlp is vulnerable to Improper Restriction of XML External Entity Reference
Reference:https://nvd.nist.gov/vuln/detail/CVE-2021-3878.
Patch: stanfordnlp/CoreNLP@e5bbe13.

Vulnerability Description:
This vulnerability occurs because of the Improper Restriction of XML External Entity Reference. Given that the XML schema files which is compromised by a hacker, the victim conducts regular process may result in an XML External Entity (XXE) Injection attack.

Recommended Actions:
The corresponding fixes are similar to CVE-2021-3878 to some extent. I have provided the following fixes by applying several patching statements, ensuring that the external entities and DTDs are not loaded when parsing and processing XML documents using the document builder. You can call the function safeDocumentBuilderFactory I defined below instead of directly calling DocumentBuilderFactory.newInstance() to create a DocumentBuilderFactory object to avoid XXE attacks.

  public static DocumentBuilderFactory safeDocumentBuilderFactory() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
      dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
      dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
      dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
      dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
      dbf.setFeature("http://apache.org/xml/features/dom/create-entity-ref-nodes", false);
      dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
    } catch (ParserConfigurationException e) {
      log.warn(e);
    }
    return dbf;
  }

Considering the potential riskes it may have, I am willing to cooperate with your to verify, address, and report the identified vulnerability promptly through responsible means. If you require any further information or assistance, please do not hesitate to reach out to me.
Thank you and looking forward to hearing from you soon.

项目架构

gpmall项目现在是微服务架构还是SOA架构

搜索

搜索部分是准备用es还是用什么其他技术实现?我看search-service里面还没有代码

分布式事务

请问下分布式事务,事务一直性采用的什么,怎么实现的

针对优惠券设计的一些建议

针对优惠券的设计补充一些建议

  • 优惠券的主表中增加针对优惠券条款,图片,除了优惠券总数外的最大领取数、已经领取数,使用分类限制、优惠券来源。另外,关于是否可用的字段来标识范围太局限,优惠券应该会涉及到上下架、删除、过期等状态。

  • 优惠券应该需要增加用户优惠券的设计纬度。以此针对来用户自己的优惠券使用情况及使用期限。

以上仅供参考

wxpay-sdk

com.github.wxpay wxpay-sdk 3.0.9

这个jar包下载不到,请问如何找到这个包

添加一个物流查询功能

支持登录的用户通过运单号实施查询物流信息,前期可以使用快递100的Api或直接访问快递100的查询运单接口

建议

项目中需要IP的地方能不能都换成localhost或者其他的。这样,我们clone运行的时候,只要启动相应组件,改下本地的host文件就可以了~

构建

项目不好构建,博主改成gradle项目吧

支付模块中的订单查询,退款,退款查询,异步通知功能如何设计

支付模块中,支付功能是单独封装了一个方法,并使用了策略模式。
但是,订单查询,退款,退款查询,异步通知功能如何设计?
--:是把几个功能一起封装到统一方法中,还是每个功能都封装一个方法,感觉每个都封装一个方法有点多余,不知大佬怎么思考?

token认证存在bug

user-service,user-provider项目中com.gpmall.user.utils.JwtTokenUtils#freeJwt,这个方法中:

//获得token的头部,载荷和签名,只对比头部和载荷
String[] headPayload = token.split("\\.");
 //获得jwt解密后头部
String header = decodedJWT.getHeader();
//获得jwt解密后载荷
String payload = decodedJWT.getPayload();
if (!header.equals(headPayload[0]) && !payload.equals(headPayload[1])) {
throw new ValidateException(SysRetCodeConstants.TOKEN_VALID_FAILED.getCode(), SysRetCodeConstants.TOKEN_VALID_FAILED.getMessage());
        }

其中header和payload都是解密之后的,而headPayload是解密之前的,这里是否存在逻辑错误,希望大家帮忙看看

服务启动的时候报错

java.lang.NoClassDefFoundError: org/apache/dubbo/config/spring/util/BeanRegistrar

at org.apache.dubbo.spring.boot.beans.factory.config.OverrideBeanDefinitionRegistryPostProcessor.postProcessBeanDefinitionRegistry(OverrideBeanDefinitionRegistryPostProcessor.java:36) ~[dubbo-spring-boot-autoconfigure-compatible-2.7.3.jar:2.7.3]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:70) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
at com.gpmall.user.bootstrap.UserProviderApplication.main(UserProviderApplication.java:14) [classes/:na]

Caused by: java.lang.ClassNotFoundException: org.apache.dubbo.config.spring.util.BeanRegistrar
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_291]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_291]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_291]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_291]
... 10 common frames omitted

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.