Giter Site home page Giter Site logo

gz-yami / mall4cloud Goto Github PK

View Code? Open in Web Editor NEW
5.8K 241.0 1.5K 22.76 MB

⭐️⭐️⭐️微服务商城系统 springcloud微服务商城 小程序商城

Home Page: https://www.mall4j.com

License: GNU Affero General Public License v3.0

Java 31.73% JavaScript 35.37% Dockerfile 0.01% HTML 0.09% Vue 28.43% SCSS 4.19% CSS 0.19%
springcloud springboot3 java vue3 mall

mall4cloud's Introduction

输入图片说明

一个基于Spring Cloud、Nacos、Seata、Mysql、Redis、RocketMQ、canal、ElasticSearch、minio的微服务B2B2C电商商城系统,采用主流的互联网技术架构、全新的UI设计、支持集群部署、服务注册和发现以及拥有完整的订单流程等,代码完全开源,没有任何二次封装,是一个非常适合二次开发的电商平台系统。

Spring以及VUE官方宣布,SpringBoot2与Vue2已在2023年底停止维护。新项目建议使用SpringBoot3+Vue3的组合,本商城已完成升级!!!

前言

本商城致力于为中大型企业打造一个功能完整、易于维护的微服务B2B2C电商商城系统,采用主流微服务技术实现。后台管理系统包含平台管理,店铺管理、商品管理、订单管理、规格管理、权限管理、资源管理等模块。

文档

这代码有没有文档呀? 当然有啦,你已经下载了,在doc这个文件夹上,实在不知道,我就给链接出来咯:

gitee:https://gitee.com/gz-yami/mall4cloud/tree/master/doc

开发环境搭建视频(推荐先看下文档再看视频):https://www.bilibili.com/video/BV1TK411C7aV

有声音了。如果视频对你有用,记得点赞投币噢。

本项目是一个极度遵守阿里巴巴代码规约的项目,以下是代码规约扫描结果

阿里代码规约扫描结果

具体目录结构和代码规范,可以查看 https://gitee.com/gz-yami/mall4cloud/tree/master/doc/%E4%BB%A3%E7%A0%81%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84

授权

除开源版本外,本商城还提供商业版本的商城,欲知详情,请访问官网。

商城官网:https://www.mall4j.com

商城使用 AGPLv3 开源,请遵守 AGPLv3 的相关条款,或者联系作者获取商业授权(https://www.mall4j.com)

项目链接

JAVA后台:https://gitee.com/gz-yami/mall4cloud

平台端:https://gitee.com/gz-yami/mall4cloud-platform

商家端:https://gitee.com/gz-yami/mall4cloud-multishop

uni-app:https://gitee.com/gz-yami/mall4cloud-uniapp

演示地址

商业版演示地址:

pc端:https://cloud-pc.mall4j.com

H5端:https://h5.mall4j.com/cloud

商业版小程序演示

输入图片说明

目录结构规范

我们也有自己的目录结构

img

  • VO(View Object):显示层对象,通常是 Web 向模板渲染引擎层传输的对象。
  • DTO(Data Transfer Object):数据传输对象,前端像后台进行传输的对象,类似于param。
  • BO(Business Object):业务对象,内部业务对象,只在内部传递,不对外进行传递。
  • Model:模型层,此对象与数据库表结构一一对应,通过 Mapper 层向上传输数据源对象。
  • Controller:主要是对外部访问控制进行转发,各类基本参数校验,或者不复用的业务简单处理等。为了简单起见,一些与事务无关的代码也在这里编写。
  • FeignClient:由于微服务之间存在互相调用,这里是内部请求的接口。
  • Controller:主要是对内部访问控制进行转发,各类基本参数校验,或者不复用的业务简单处理等。为了简单起见,一些与事务无关的代码也在这里编写。
  • Service 层:相对具体的业务逻辑服务层。
  • Manager 层:通用业务处理层,它有如下特征:
    • 1) 对第三方平台封装的层,预处理返回结果及转化异常信息,适配上层接口。
    • 2) 对 Service 层通用能力的下沉,如缓存方案、中间件通用处理。
    • 3) 与 DAO 层交互,对多个 DAO 的组合复用。
  • Mapper持久层:数据访问层,与底层 MySQL进行数据交互。
  • Listener:监听 RocketMQ 进行处理,有时候会监听easyexcel相关数据。

关于FeignClient,由于微服务之间存在互相调用,Feign 是http协议,理论上是为了解耦,而实际上提供方接口进行修改,调用方却没有进行修改的时候,会造成异常,所以我们抽取出来。还有就是对内暴露的接口,是很多地方都公用的,所以我们还将接口抽取了出了一个模块,方便引用。可以看到mall4cloud-api这个模块下是所有对内feign接口的信息。

目录结构

mall4cloud
├─mall4cloud-api -- 内网接口
│  ├─mall4cloud-api-auth  -- 授权对内接口
│  ├─mall4cloud-api-biz  -- biz对内接口
│  ├─mall4cloud-api-leaf  -- 美团分布式id生成接口
│  ├─mall4cloud-api-multishop  -- 店铺对内接口
│  ├─mall4cloud-api-order  -- 订单对内接口
│  ├─mall4cloud-api-platform  -- 平台对内接口
│  ├─mall4cloud-api-product  -- 商品对内接口
│  ├─mall4cloud-api-rbac  -- 用户角色权限对内接口
│  ├─mall4cloud-api-search  -- 搜索对内接口
│  └─mall4cloud-api-user  -- 用户对内接口
├─mall4cloud-auth  -- 授权校验模块
├─mall4cloud-biz  -- mall4cloud 业务代码。如图片上传/短信等
├─mall4cloud-common -- 一些公共的方法
│  ├─mall4cloud-common-cache  -- 缓存相关公共代码
│  ├─mall4cloud-common-core  -- 公共模块核心(公共中的公共代码)
│  ├─mall4cloud-common-database  -- 数据库连接相关公共代码
│  ├─mall4cloud-common-order  -- 订单相关公共代码
│  ├─mall4cloud-common-product  -- 商品相关公共代码
│  ├─mall4cloud-common-rocketmq  -- rocketmq相关公共代码
│  └─mall4cloud-common-security  -- 安全相关公共代码
├─mall4cloud-gateway  -- 网关
├─mall4cloud-leaf  -- 基于美团leaf的生成id服务
├─mall4cloud-multishop  -- 商家端
├─mall4cloud-order  -- 订单服务
├─mall4cloud-payment  -- 支付服务
├─mall4cloud-platform  -- 平台端
├─mall4cloud-product  -- 商品服务
├─mall4cloud-rbac  -- 用户角色权限模块
├─mall4cloud-search  -- 搜索模块
└─mall4cloud-user  -- 用户服务

技术选型

技术框架

系统架构图

架构图

商城部署后 API 地址

服务 地址
mall4cloud-gatway 网关服务 http://127.0.0.1:8000
mall4cloud-auth 授权校验服务 http://127.0.0.1:9101
mall4cloud-biz 业务代码服务(如图片上传/短信等) http://127.0.0.1:9000
mall4cloud-leaf 基于美团leaf的生成id服务 http://127.0.0.1:9100
mall4cloud-multishop 商家服务 http://127.0.0.1:9103
mall4cloud-order 订单服务 http://127.0.0.1:9106
mall4cloud-payment 支付服务 http://127.0.0.1:9113
mall4cloud-product 商品服务 http://127.0.0.1:9114
mall4cloud-rbac 用户角色服务 http://127.0.0.1:9102
mall4cloud-search 搜索服务 http://127.0.0.1:9108
mall4cloud-user 用户服务 http://127.0.0.1:9105

部署教程

部署教程请参考该文件夹下的/基本开发文档/mall4cloud开发环境搭建.md以及/开发环境搭建目录下的中间件安装。

代码运行相关截图

1.后台截图

  • 平台端

  • 商家端

    image-20210705151729559

    image-20210705151847270

2.小程序截图

小程序-1625472143277

3.uni-app截图

uniapp-1625469707350

提交反馈

  • Mall4j官网 https://www.mall4j.com
  • mall4cloud开源技术QQ群:561496886
  • 如需购买商业版源码,请联系商务微信

输入图片说明

springboot版本商城请点击

https://gitee.com/gz-yami/mall4j

你的点赞鼓励,是我们前进的动力~

你的点赞鼓励,是我们前进的动力~

你的点赞鼓励,是我们前进的动力~

更多信息请查看官网 https://www.mall4j.com

mall4cloud's People

Contributors

7simin avatar brother-dragon avatar dh492786473 avatar frozenwatermelon avatar gz-yami avatar hcy6100 avatar hygge avatar jiexi128 avatar lijunwen559 avatar lzk50136 avatar opgithub avatar yangdashen avatar z1hui avatar zzldream 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

mall4cloud's Issues

启动AuthApplication时出现错误

SpringBoot报错:
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

Lack of Backend Validation for Uploaded Image Size and Type

Lack proper validation for uploaded image files in the backend.
While there is validation in the frontend component "img-box.vue," it is crucial to perform server-side validation as well. This vulnerability allows attackers to upload files of any type and size, potentially leading to XSS attacks or resource exhaustion, which can result in DDoS attacks.

It is recommended to implement server-side validation for uploaded image files, in ServerResponseEntity<OssVO> com.mall4j.cloud.biz.controller.OssController.uploadFile(@RequestParam(value="file") MultipartFile file) throws IOException. This includes checking the file size and verifying that the file type is allowed (e.g., image/jpeg, image/png). By implementing these validations in the backend, you can prevent the upload of malicious files, mitigate the risk of XSS attacks, and prevent resource consumption that could lead to DDoS attacks.

image

中间件没有搭建起来

环境:
windows11 22H2 i512600kf 32g ddr4 3600
Docker 20.10.22
Docker Compose v2.15.1

按照教程全局替换ip为我的win11宿主机ip后运行docker-compose up --build ,没有加 -d 是想看看容器日志输出

启动后会卡死,容器看不了日志,容器关闭不了也删除不了


很想学习一下这套架构,有能成功搭建起来的兄弟可以给个联系方式,请求付费协助!

RocketMQLog:WARN No appenders could be found for logger

请问启动项目的时候,报了这个错误怎么解决呀,我项目中使用了logback作为日志输出
RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.InternalThreadLocalMap).
RocketMQLog:WARN Please initialize the logger system properly.

新版nacos容器无法正常启动

环境

  1. CentOS7.6
  2. 使用最新docker-compose.yaml,部署运行了nacos容器

现象

  1. 通过http://192.168.1.46:8848/nacos无法进入Nacos管理界面
  2. 其他docker容器如MySQLRocketMQ等都正常启动。
  3. 使用docker ps -a | grep nacos 命令查看nacos状态,发现nacos一直处于重启状态。命令结果如下
[root@slave1 ~]# docker ps -a | grep nacos
90fb3b7bc783   nacos/nacos-server:v2.2.0-slim             "bin/docker-startup.…"   2 hours ago   Restarting (1) Less than a second ago                                                                                                                       mall4cloud-nacos
  1. 使用vim /root/docker/nacos/logs/nacos.log查看日志发现,在nacos中存在以下错误Unknown column 'encrypted_data_key' in 'field list'.具体错误片段如下
2023-03-02 17:32:43,237 INFO

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2023-03-02 17:32:43,257 ERROR Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/home/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-config-2.2.0.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
PreparedStatementCallback; bad SQL grammar [SELECT id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,type,encrypted_data_key FROM config_info WHERE id > ? ORDER BY id ASC LIMIT 0,1000]; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'encrypted_data_key' in 'field list'

原因

为保证用户敏感配置数据的安全,Nacos 提供了配置加密的新特性。降低了用户使用的风险,也不需要再对配置进行单独的加密处理。新版本的默认创建表的sql中已经添加该字段。

**而docker-compose.yml执行时在导入MySQLmall4cloud_nacos数据库与表结构并没有该字段。**导致nacos容器无法正常启动。

解决

数据库表 config_info、config_info_beta、his_config_info中需要新增字段 encrypted_data_key ,用来存储每一个配置项加密使用的秘钥。在mall4cloud_nacos数据库下执行以下语句

ALTER TABLE config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';
ALTER TABLE config_info_beta ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';
ALTER TABLE his_config_info ADD COLUMN `encrypted_data_key` text NOT NULL COMMENT '秘钥';

Canal优化

有没有考虑把canal做成两端,一端是docker部署的canal-service 监听数据库,然后再起到canal-client项目去连接canal-service,用线程池监听数据发送到Mq里面去,这样会不会好一点

Docker Compose、容器内时区不对

docker compose 构建出来的seata容器时区不对,再网上尝试很多方式,尝试在compose的environment加入TZ=Asia/Shanghai环境变量。但是又需要容器安装了tzdata,求解决方式

Netty连接-启动时报错

NettyPool create channel to transactionRole:TMROLE,address:113.111.176.34:8091,msg:< RegisterTMRequest{applicationId='mall4cloud-biz', transactionServiceGroup='default_tx_group'} >

找不到哪里修改配置文件 修改ip及其端口,无法正常运行 ,麻烦大佬帮忙看一下。感谢了!

849d997b3933525f02ce95871ac5f30

no available service found in cluster 'default', please make sure registry config correct and keep your seata server running

按照项目中的docker-compose.yaml,配置了中间件,seata正常启动没有报错,但是开启product项目,显示如下错误

2023-02-08 10:31:43.215 ERROR 69014 --- [eoutChecker_1_1] i.s.c.r.netty.NettyClientChannelManager  : no available service found in cluster 'default', please make sure registry config correct and keep your seata server running
mall4cloud-seata:
    image: seataio/seata-server:1.4.2
    container_name: mall4cloud-seata
    restart: always
    depends_on:
      - mall4cloud-mysql
      - mall4cloud-nacos
    ports:
      - 8091:8091
    environment:
      - SEATA_IP=127.0.0.1
      - SEATA_CONFIG_NAME=file:/root/seata-config/registry
    volumes:
      - ./seata:/root/seata-config

docker中查看挂载的文件是正确的

registry {
  type = "nacos"
  nacos {
    application = "seata-server"
    serverAddr = "127.0.0.1:8848"
    group = "SEATA_GROUP"
    namespace = "4b70485d-72dd-44df-a76a-7a3f578a3001"
    cluster = "default"
    username = "nacos"
    password = "nacos"
  }
}
config {
  type = "nacos"
  nacos {
    serverAddr = "127.0.0.1:8848"
    namespace = "4b70485d-72dd-44df-a76a-7a3f578a3001"
    group = "SEATA_GROUP"
    username = "nacos"
    password = "nacos"
  }
}

application-dev.yml中配置为

seata:
  config:
    type: nacos
    nacos:
      namespace: 4b70485d-72dd-44df-a76a-7a3f578a3001
      server-addr: ${spring.cloud.nacos.discovery.server-addr}
      password: ${spring.cloud.nacos.discovery.password}
      username: ${spring.cloud.nacos.discovery.username}
  registry:
    type: nacos
    nacos:
      server-addr: ${spring.cloud.nacos.discovery.server-addr}
      username: ${spring.cloud.nacos.discovery.username}
      password: ${spring.cloud.nacos.discovery.password}
      namespace: ${seata.config.nacos.namespace}

Incorrect Access Control vulnerability

Project home page

https://github.com/gz-yami/mall4cloud

This project is an open source project & supports commercial use

4k+ star on Github

All management interfaces (API) on the platform side and the merchant side have Incorrect Access Control vulnerability

Ordinary users can perform operations such as adding, deleting, and modifying background management data beyond their authority.

Proofs

Platform side

vul code link:

@RequestMapping("/admin/index_img")

All interfaces under this module have not verified user permissions

After logging in as an ordinary user, test the management interface, and find that the carousel information can be added, deleted, and modified without authorization.

Carousel management module

Verification screenshot

Picture1

query operation

Picture2

Hot search management module

vul code link:
https://github.com/gz-yami/mall4cloud/blob/master/mall4cloud-product/src/main/java/com/mall4j/cloud/product/controller/admin/SpuController.java

There is no verification of user permissions:

Picture3

Test verification screenshot

Ordinary users can add hot searches

Picture5

Ordinary users delete hot searches
Picture6

Merchant side

same as above

There is no user rights check.
Picture7

Verification screenshot

Picture8

Discovered by : lazyhac# # #gmail.com

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.