todo 模块依赖的版本可能有变化,等项目稳定回来确认一下

VirtualBox

VirtualBox相对VMware来说是轻量级的虚拟软件, 最关键的是VirtualBox是开源免费的。

使用之前要开启电脑的CPU虚拟化,自行百度

视频里讲的版本是VirtualBox6.0.12,vagrant_2.2.5,
但在创建linux虚拟机的时候会报kernel panic - not syncing fatal exception,把版本升到最新版本这个问题就没有了。

VirtualBox6.1.26下载地址

之前在VirtualBox创建linux虚拟机需要先下载镜像,然后创建,麻烦了些。

使用Vagrant可以快速的从官方镜像仓库创建虚拟机。

Vagrant 官方镜像仓库
Vagrant2.2.18 下载

# 初始化centos7环境
# 在dos目录下会创建vagrant.file文件
# c盘空间不够的话,也可以自定义目录
vagrant init centos/7# 下载centos7镜像的过程可能及其漫长,可以先自己下载镜像,地址在vagrant up的启动日志有,然后添加
# 但是我装了三次, init等大概十分钟是可以的
vagrant box add centos/7 D:\developsoft\CentOS-7-x86_64-Vagrant-1905_01.VirtualBox.box# 启动虚拟环境,下载镜像并启动
# 这个命令和在VirtualBox上启动虚拟机是一个道理
vagrant up# 连接虚拟机
vagrant ssh# 查询登录用户,root默认密码是vagrant
whoami# 退出
exit;

在VirtualBox重启虚拟机是不会载入新配置的,需要vagrant reload

打通宿主机与虚拟机之间的网络通信

# 在dos目录下vagrant.file文件添加静态ip
# 然后vagrant reload,测试是否与宿主机互通
# 宿主机 ipconfig 本地链接IPV6地址
# ip地址段在宿主机的VirtualBox Host-Only Network网卡
config.vm.network "private_network", ip: "192.168.56.10"# 开放root登录权限(可以使用xshell等工具操作服务器)
vi /etc/ssh/sshd_config
# 更新或添加
PasswordAuthentication yes
service sshd restart# 解决中文乱码
# 一般的配置文件不会用中文,但难免配置一些需要中文的文件,例如es的分词文件# 查看当前系统内已有的中文字符集
locale -a|grep zh_CN
# 安装中文包,并重装gcc
yum -y install kde-l10n-Chinese telnet
yum -y reinstall glibc-common
# 从中文语言包内添加对应字符集
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
# locale -a查询系统内内容所有已有字符集,系统内至少有一种中文字符集的话,则一般不会出现中文完全无法显示的情况
# 将当前bash显示字符集切换到UTF-8,可修改/etc/locale.conf,source后永久生效
LANG="zh_CN.UTF-8"

安装docker

docker安装mysql

docker pull mysql:5.7# -d 后台方式运行
docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7# mysqld: Can‘t read dir of ‘/etc/mysql/conf.d/‘ (Errcode: 2 - No such file or directory
# 如果发生上面这个错误,是因为我们本地没有 conf.d 这个文件
# 运行一个容器,从容器中cp出来即可
docker run -d -e MYSQL_ROOT_PASSWORD=root mysql:5.7
docker cp 容器id:/etc/mysql/ /mydata/mysql/conf# 添加mysql配置文件
vi /mydata/mysql/conf/my.cnf
[client]
default-character-set=utf8 [mysql]
default-character-set=utf8 [mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve

docker安装redis

# -p 递归创建
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf# 连接redis客户端
docker exec -it redis redis-cli# 向/mydata/redis/conf/redis.conf添加AOF持久化策略
# aof是记录写操作
appendonly yes

环境配置

maven配置

mven目录下conf -> settings.xml

# 配置阿里云仓库
<mirror><id>nexus-aliyun</id><mirrorOf>central</mirrorOf><name>Nexus aliyun</name>        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror># 配置 jdk1.8 编译项目
<profiles><profile><id>jdk-1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties></profile>
</profiles>

idea配置

打开idea,配置maven,路径 settings -> maven
idea安装lombok(简化pojo的操作)和mybatisx(mybatis plus提供的从mapper的方法快速定位到xml文件)插件

vscode配置

插件

# 自动开闭HTML/XML标签
Auto Close Tag v 0.5.12# 自动完成另一侧标签的同步修改
Auto Rename Tag v0.1.8 # 简体中文包
Chinese (Simplified) (简体中文) Language Pack for Visual Studio Code # 语法纠错
ESLint v2.1.25 # 让 html 标签上写 class 智能提示当前项目所支持的样式
HTML CSS Support v1.10.2    # html 快速自动补全
HTML Snippets v0.2.1 # ES6 语 法 智 能 提 示 以 及 快 速 输 入 ,
# 除 js 外 还 支 持.ts,.jsx,.tsx,.html,.vue,
# 省去了配置其支持各种包含 js 代码文件的时间
JavaScript (ES6) code snippets v1.8.0 # 以内嵌服务器方式打开
Live Server v5.6.1 # 在浏览器打开页面
open in browser v2.0.0 # 语法高亮、智能感知、Emmet 等 包含格式化功能,
# Alt+Shift+F (格式化全文),
# Ctrl+K Ctrl+F(格式化选中代码,两个 Ctrl
Vetur v0.34.1# vue2语法提示
Vue 2 Snippets

谷歌浏览器配置

开发通常(别抬杠)用的浏览器都是谷歌

# vue开发f12会多出一个vue调试工具
# 下载应该是个压缩包,解压之后,,点谷歌的开发者工具-扩展程序-加载已解压的扩展程序
# 版本是4.1.4
vue-devtools

git 配置

git bash here 界面

# 配置作者信息
# 配置用户名
git config --global user.name "username"
# 配置邮箱
git config --global user.email "username@email.com"

配置ssh免密登录

# 生成密钥
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"# 查看生成的密钥
cat ~/.ssh/id_rsa.pub
# 将生成的密钥粘贴到码云 -> 设置 -> SSH公钥
# 测试成功后就可以不用密码提交代码了# 测试
ssh -T git@gitee.com

创建项目

git仓库用的是国内的码云,git hub是国外的,诸多不便。由于简单,不赘述了。

创建好仓库后,拉取,手动创建模块

使用idea自带的Spring Initializr创建,选取的依赖为Spring Web和OpenFeign

  1. gulistore-coupon – 优惠卷服务
  2. gulistore-product – 商品服务
  3. gulistore-member – 会员服务
  4. gulistore-order – 订单服务
  5. gulistore-ware – 仓储服务

各模块pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.5</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.atguigu.gulistore</groupId><artifactId>gulistore-ware</artifactId><version>0.0.1-SNAPSHOT</version><name>gulistore-ware</name><description>谷粒商城仓储服务</description><properties><java.version>1.8</java.version><spring-cloud.version>2020.0.4</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

父类pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.atguigu.gulistore</groupId><artifactId>gulistore</artifactId><version>0.0.1-SNAPSHOT</version><name>gulistore</name><description>谷粒商城聚合服务</description><packaging>pom</packaging><modules><module>gulistore-coupon</module><module>gulistore-member</module><module>gulistore-order</module><module>gulistore-product</module><module>gulistore-ware</module></modules></project>

编写.gitignore

忽略一些文件,不提交到码云仓库

target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar# 忽略任意路径下的mvnw文件
**/mvnw
**/mvnw.cmd
**/.mvn
**/target/
.idea

数据库初始化

  1. 所有表之间,关系再复杂,不建立外键。
    在电商系统里,数据量超大,做外键关联是非常耗费性能的操作。
    假设每张表都有几十万几百万的数据,每插入、删除一条数据,数据库都要对外键进行检查,保证数据的一致性和完整性。
  2. 依据微服务划分,每一个微服务都操作自己的数据库。
drop table if exists oms_order;drop table if exists oms_order_item;drop table if exists oms_order_operate_history;drop table if exists oms_order_return_apply;drop table if exists oms_order_return_reason;drop table if exists oms_order_setting;drop table if exists oms_payment_info;drop table if exists oms_refund_info;drop table if exists pms_attr;drop table if exists pms_attr_attrgroup_relation;drop table if exists pms_attr_group;drop table if exists pms_brand;drop table if exists pms_category;drop table if exists pms_comment_replay;drop table if exists pms_product_attr_value;drop table if exists pms_sku_images;drop table if exists pms_sku_info;drop table if exists pms_sku_sale_attr_value;drop table if exists pms_spu_comment;drop table if exists pms_spu_images;drop table if exists pms_spu_info;drop table if exists pms_spu_info_desc;drop table if exists sms_category_bounds;drop table if exists sms_coupon;drop table if exists sms_coupon_history;drop table if exists sms_coupon_spu_category_relation;drop table if exists sms_coupon_spu_relation;drop table if exists sms_home_adv;drop table if exists sms_home_subject;drop table if exists sms_home_subject_spu;drop table if exists sms_member_price;drop table if exists sms_seckill_promotion;drop table if exists sms_seckill_session;drop table if exists sms_seckill_sku_notice;drop table if exists sms_seckill_sku_relation;drop table if exists sms_sku_bounds;drop table if exists sms_sku_full_reduction;drop table if exists sms_sku_ladder;drop table if exists sms_spu_bounds;drop table if exists ums_growth_change_history;drop table if exists ums_integration_change_history;drop table if exists ums_member;drop table if exists ums_member_collect_spu;drop table if exists ums_member_collect_subject;drop table if exists ums_member_level;drop table if exists ums_member_login_log;drop table if exists ums_member_receive_address;drop table if exists ums_member_statistics_info;drop table if exists wms_purchase;drop table if exists wms_purchase_detail;drop table if exists wms_ware_info;drop table if exists wms_ware_order_task;drop table if exists wms_ware_order_task_detail;drop table if exists wms_ware_sku;

oms 订单系统

/*==============================================================*/
/* Table: oms_order  订单系统                                   */
/*==============================================================*/
create table oms_order
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',order_sn             char(32) comment '订单号',coupon_id            bigint comment '使用的优惠券',create_time          datetime comment 'create_time',member_username      varchar(200) comment '用户名',total_amount         decimal(18,4) comment '订单总额',pay_amount           decimal(18,4) comment '应付总额',freight_amount       decimal(18,4) comment '运费金额',promotion_amount     decimal(18,4) comment '促销优化金额(促销价、满减、阶梯价)',integration_amount   decimal(18,4) comment '积分抵扣金额',coupon_amount        decimal(18,4) comment '优惠券抵扣金额',discount_amount      decimal(18,4) comment '后台调整订单使用的折扣金额',pay_type             tinyint comment '支付方式【1->支付宝;2->微信;3->银联; 4->货到付款;】',source_type          tinyint comment '订单来源[0->PC订单;1->app订单]',status               tinyint comment '订单状态【0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单】',delivery_company     varchar(64) comment '物流公司(配送方式)',delivery_sn          varchar(64) comment '物流单号',auto_confirm_day     int comment '自动确认时间(天)',integration          int comment '可以获得的积分',growth               int comment '可以获得的成长值',bill_type            tinyint comment '发票类型[0->不开发票;1->电子发票;2->纸质发票]',bill_header          varchar(255) comment '发票抬头',bill_content         varchar(255) comment '发票内容',bill_receiver_phone  varchar(32) comment '收票人电话',bill_receiver_email  varchar(64) comment '收票人邮箱',receiver_name        varchar(100) comment '收货人姓名',receiver_phone       varchar(32) comment '收货人电话',receiver_post_code   varchar(32) comment '收货人邮编',receiver_province    varchar(32) comment '省份/直辖市',receiver_city        varchar(32) comment '城市',receiver_region      varchar(32) comment '区',receiver_detail_address varchar(200) comment '详细地址',note                 varchar(500) comment '订单备注',confirm_status       tinyint comment '确认收货状态[0->未确认;1->已确认]',delete_status        tinyint comment '删除状态【0->未删除;1->已删除】',use_integration      int comment '下单时使用的积分',payment_time         datetime comment '支付时间',delivery_time        datetime comment '发货时间',receive_time         datetime comment '确认收货时间',comment_time         datetime comment '评价时间',modify_time          datetime comment '修改时间',primary key (id)
);alter table oms_order comment '订单';/*==============================================================*/
/* Table: oms_order_item                                        */
/*==============================================================*/
create table oms_order_item
(id                   bigint not null auto_increment comment 'id',order_id             bigint comment 'order_id',order_sn             char(32) comment 'order_sn',spu_id               bigint comment 'spu_id',spu_name             varchar(255) comment 'spu_name',spu_pic              varchar(500) comment 'spu_pic',spu_brand            varchar(200) comment '品牌',category_id          bigint comment '商品分类id',sku_id               bigint comment '商品sku编号',sku_name             varchar(255) comment '商品sku名字',sku_pic              varchar(500) comment '商品sku图片',sku_price            decimal(18,4) comment '商品sku价格',sku_quantity         int comment '商品购买的数量',sku_attrs_vals       varchar(500) comment '商品销售属性组合(JSON)',promotion_amount     decimal(18,4) comment '商品促销分解金额',coupon_amount        decimal(18,4) comment '优惠券优惠分解金额',integration_amount   decimal(18,4) comment '积分优惠分解金额',real_amount          decimal(18,4) comment '该商品经过优惠后的分解金额',gift_integration     int comment '赠送积分',gift_growth          int comment '赠送成长值',primary key (id)
);alter table oms_order_item comment '订单项信息';/*==============================================================*/
/* Table: oms_order_operate_history                             */
/*==============================================================*/
create table oms_order_operate_history
(id                   bigint not null auto_increment comment 'id',order_id             bigint comment '订单id',operate_man          varchar(100) comment '操作人[用户;系统;后台管理员]',create_time          datetime comment '操作时间',order_status         tinyint comment '订单状态【0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单】',note                 varchar(500) comment '备注',primary key (id)
);alter table oms_order_operate_history comment '订单操作历史记录';/*==============================================================*/
/* Table: oms_order_return_apply                                */
/*==============================================================*/
create table oms_order_return_apply
(id                   bigint not null auto_increment comment 'id',order_id             bigint comment 'order_id',sku_id               bigint comment '退货商品id',order_sn             char(32) comment '订单编号',create_time          datetime comment '申请时间',member_username      varchar(64) comment '会员用户名',return_amount        decimal(18,4) comment '退款金额',return_name          varchar(100) comment '退货人姓名',return_phone         varchar(20) comment '退货人电话',status               tinyint(1) comment '申请状态[0->待处理;1->退货中;2->已完成;3->已拒绝]',handle_time          datetime comment '处理时间',sku_img              varchar(500) comment '商品图片',sku_name             varchar(200) comment '商品名称',sku_brand            varchar(200) comment '商品品牌',sku_attrs_vals       varchar(500) comment '商品销售属性(JSON)',sku_count            int comment '退货数量',sku_price            decimal(18,4) comment '商品单价',sku_real_price       decimal(18,4) comment '商品实际支付单价',reason               varchar(200) comment '原因',description述         varchar(500) comment '描述',desc_pics            varchar(2000) comment '凭证图片,以逗号隔开',handle_note          varchar(500) comment '处理备注',handle_man           varchar(200) comment '处理人员',receive_man          varchar(100) comment '收货人',receive_time         datetime comment '收货时间',receive_note         varchar(500) comment '收货备注',receive_phone        varchar(20) comment '收货电话',company_address      varchar(500) comment '公司收货地址',primary key (id)
);alter table oms_order_return_apply comment '订单退货申请';/*==============================================================*/
/* Table: oms_order_return_reason                               */
/*==============================================================*/
create table oms_order_return_reason
(id                   bigint not null auto_increment comment 'id',name                 varchar(200) comment '退货原因名',sort                 int comment '排序',status               tinyint(1) comment '启用状态',create_time          datetime comment 'create_time',primary key (id)
);alter table oms_order_return_reason comment '退货原因';/*==============================================================*/
/* Table: oms_order_setting                                     */
/*==============================================================*/
create table oms_order_setting
(id                   bigint not null auto_increment comment 'id',flash_order_overtime int comment '秒杀订单超时关闭时间(分)',normal_order_overtime int comment '正常订单超时时间(分)',confirm_overtime     int comment '发货后自动确认收货时间(天)',finish_overtime      int comment '自动完成交易时间,不能申请退货(天)',comment_overtime     int comment '订单完成后自动好评时间(天)',member_level         tinyint(2) comment '会员等级【0-不限会员等级,全部通用;其他-对应的其他会员等级】',primary key (id)
);alter table oms_order_setting comment '订单配置信息';/*==============================================================*/
/* Table: oms_payment_info                                      */
/*==============================================================*/
create table oms_payment_info
(id                   bigint not null auto_increment comment 'id',order_sn             char(32) comment '订单号(对外业务号)',order_id             bigint comment '订单id',alipay_trade_no      varchar(50) comment '支付宝交易流水号',total_amount         decimal(18,4) comment '支付总金额',subject              varchar(200) comment '交易内容',payment_status       varchar(20) comment '支付状态',create_time          datetime comment '创建时间',confirm_time         datetime comment '确认时间',callback_content     varchar(4000) comment '回调内容',callback_time        datetime comment '回调时间',primary key (id)
);alter table oms_payment_info comment '支付信息表';/*==============================================================*/
/* Table: oms_refund_info                                       */
/*==============================================================*/
create table oms_refund_info
(id                   bigint not null auto_increment comment 'id',order_return_id      bigint comment '退款的订单',refund               decimal(18,4) comment '退款金额',refund_sn            varchar(64) comment '退款交易流水号',refund_status        tinyint(1) comment '退款状态',refund_channel       tinyint comment '退款渠道[1-支付宝,2-微信,3-银联,4-汇款]',refund_content       varchar(5000),primary key (id)
);alter table oms_refund_info comment '退款信息';

pms 商品系统

/*==============================================================*/
/* Table: pms_attr   商品系统                                   */
/*==============================================================*/
create table pms_attr
(attr_id              bigint not null auto_increment comment '属性id',attr_name            char(30) comment '属性名',search_type          tinyint comment '是否需要检索[0-不需要,1-需要]',icon                 varchar(255) comment '属性图标',value_select         char(255) comment '可选值列表[用逗号分隔]',attr_type            tinyint comment '属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性]',enable               bigint comment '启用状态[0 - 禁用,1 - 启用]',catelog_id           bigint comment '所属分类',show_desc            tinyint comment '快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整',primary key (attr_id)
);alter table pms_attr comment '商品属性';/*==============================================================*/
/* Table: pms_attr_attrgroup_relation                           */
/*==============================================================*/
create table pms_attr_attrgroup_relation
(id                   bigint not null auto_increment comment 'id',attr_id              bigint comment '属性id',attr_group_id        bigint comment '属性分组id',attr_sort            int comment '属性组内排序',primary key (id)
);alter table pms_attr_attrgroup_relation comment '属性&属性分组关联';/*==============================================================*/
/* Table: pms_attr_group                                        */
/*==============================================================*/
create table pms_attr_group
(attr_group_id        bigint not null auto_increment comment '分组id',attr_group_name      char(20) comment '组名',sort                 int comment '排序',descript             varchar(255) comment '描述',icon                 varchar(255) comment '组图标',catelog_id           bigint comment '所属分类id',primary key (attr_group_id)
);alter table pms_attr_group comment '属性分组';/*==============================================================*/
/* Table: pms_brand                                             */
/*==============================================================*/
create table pms_brand
(brand_id             bigint not null auto_increment comment '品牌id',name                 char(50) comment '品牌名',logo                 varchar(2000) comment '品牌logo地址',descript             longtext comment '介绍',show_status          tinyint comment '显示状态[0-不显示;1-显示]',first_letter         char(1) comment '检索首字母',sort                 int comment '排序',primary key (brand_id)
);alter table pms_brand comment '品牌';/*==============================================================*/
/* Table: pms_category                                          */
/*==============================================================*/
create table pms_category
(cat_id               bigint not null auto_increment comment '分类id',name                 char(50) comment '分类名称',parent_cid           bigint comment '父分类id',cat_level            int comment '层级',show_status          tinyint comment '是否显示[0-不显示,1显示]',sort                 int comment '排序',icon                 char(255) comment '图标地址',product_unit         char(50) comment '计量单位',product_count        int comment '商品数量',primary key (cat_id)
);alter table pms_category comment '商品三级分类';/*==============================================================*/
/* Table: pms_comment_replay                                    */
/*==============================================================*/
create table pms_comment_replay
(id                   bigint not null auto_increment comment 'id',comment_id           bigint comment '评论id',reply_id             bigint comment '回复id',primary key (id)
);alter table pms_comment_replay comment '商品评价回复关系';/*==============================================================*/
/* Table: pms_product_attr_value                                */
/*==============================================================*/
create table pms_product_attr_value
(id                   bigint not null auto_increment comment 'id',spu_id               bigint comment '商品id',attr_id              bigint comment '属性id',attr_name            varchar(200) comment '属性名',attr_value           varchar(200) comment '属性值',attr_sort            int comment '顺序',quick_show           tinyint comment '快速展示【是否展示在介绍上;0-否 1-是】',primary key (id)
);alter table pms_product_attr_value comment 'spu属性值';/*==============================================================*/
/* Table: pms_sku_images                                        */
/*==============================================================*/
create table pms_sku_images
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',img_url              varchar(255) comment '图片地址',img_sort             int comment '排序',default_img          int comment '默认图[0 - 不是默认图,1 - 是默认图]',primary key (id)
);alter table pms_sku_images comment 'sku图片';/*==============================================================*/
/* Table: pms_sku_info                                          */
/*==============================================================*/
create table pms_sku_info
(sku_id               bigint not null auto_increment comment 'skuId',spu_id               bigint comment 'spuId',sku_name             varchar(255) comment 'sku名称',sku_desc             varchar(2000) comment 'sku介绍描述',catalog_id           bigint comment '所属分类id',brand_id             bigint comment '品牌id',sku_default_img      varchar(255) comment '默认图片',sku_title            varchar(255) comment '标题',sku_subtitle         varchar(2000) comment '副标题',price                decimal(18,4) comment '价格',sale_count           bigint comment '销量',primary key (sku_id)
);alter table pms_sku_info comment 'sku信息';/*==============================================================*/
/* Table: pms_sku_sale_attr_value                               */
/*==============================================================*/
create table pms_sku_sale_attr_value
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',attr_id              bigint comment 'attr_id',attr_name            varchar(200) comment '销售属性名',attr_value           varchar(200) comment '销售属性值',attr_sort            int comment '顺序',primary key (id)
);alter table pms_sku_sale_attr_value comment 'sku销售属性&值';/*==============================================================*/
/* Table: pms_spu_comment                                       */
/*==============================================================*/
create table pms_spu_comment
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',spu_id               bigint comment 'spu_id',spu_name             varchar(255) comment '商品名字',member_nick_name     varchar(255) comment '会员昵称',star                 tinyint(1) comment '星级',member_ip            varchar(64) comment '会员ip',create_time          datetime comment '创建时间',show_status          tinyint(1) comment '显示状态[0-不显示,1-显示]',spu_attributes       varchar(255) comment '购买时属性组合',likes_count          int comment '点赞数',reply_count          int comment '回复数',resources            varchar(1000) comment '评论图片/视频[json数据;[{type:文件类型,url:资源路径}]]',content              text comment '内容',member_icon          varchar(255) comment '用户头像',comment_type         tinyint comment '评论类型[0 - 对商品的直接评论,1 - 对评论的回复]',primary key (id)
);alter table pms_spu_comment comment '商品评价';/*==============================================================*/
/* Table: pms_spu_images                                        */
/*==============================================================*/
create table pms_spu_images
(id                   bigint not null auto_increment comment 'id',spu_id               bigint comment 'spu_id',img_name             varchar(200) comment '图片名',img_url              varchar(255) comment '图片地址',img_sort             int comment '顺序',default_img          tinyint comment '是否默认图',primary key (id)
);alter table pms_spu_images comment 'spu图片';/*==============================================================*/
/* Table: pms_spu_info                                          */
/*==============================================================*/
create table pms_spu_info
(id                   bigint not null auto_increment comment '商品id',spu_name             varchar(200) comment '商品名称',spu_description      varchar(1000) comment '商品描述',catalog_id           bigint comment '所属分类id',brand_id             bigint comment '品牌id',weight               decimal(18,4),publish_status       tinyint comment '上架状态[0 - 下架,1 - 上架]',create_time          datetime,update_time          datetime,primary key (id)
);alter table pms_spu_info comment 'spu信息';/*==============================================================*/
/* Table: pms_spu_info_desc                                     */
/*==============================================================*/
create table pms_spu_info_desc
(spu_id               bigint not null comment '商品id',decript              longtext comment '商品介绍',primary key (spu_id)
);alter table pms_spu_info_desc comment 'spu信息介绍';

sms 营销系统

/*==============================================================*/
/* Table: sms_category_bounds    营销系统                       */
/*==============================================================*/
create table sms_category_bounds
(id                   bigint not null auto_increment comment 'id',category_id          bigint,grow_bounds          decimal(18,4) comment '成长积分',buy_bounds           decimal(18,4) comment '购物积分',work                 tinyint(1) comment '优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]',primary key (id)
);alter table sms_category_bounds comment '商品分类积分设置';/*==============================================================*/
/* Table: sms_coupon                                            */
/*==============================================================*/
create table sms_coupon
(id                   bigint not null auto_increment comment 'id',coupon_type          tinyint(1) comment '优惠卷类型[0->全场赠券;1->会员赠券;2->购物赠券;3->注册赠券]',coupon_img           varchar(2000) comment '优惠券图片',coupon_name          varchar(100) comment '优惠卷名字',num                  int comment '数量',amount               decimal(18,4) comment '金额',per_limit            int comment '每人限领张数',min_point            decimal(18,4) comment '使用门槛',start_time           datetime comment '开始时间',end_time             datetime comment '结束时间',use_type             tinyint(1) comment '使用类型[0->全场通用;1->指定分类;2->指定商品]',note                 varchar(200) comment '备注',publish_count        int(11) comment '发行数量',use_count            int(11) comment '已使用数量',receive_count        int(11) comment '领取数量',enable_start_time    datetime comment '可以领取的开始日期',enable_end_time      datetime comment '可以领取的结束日期',code                 varchar(64) comment '优惠码',member_level         tinyint(1) comment '可以领取的会员等级[0->不限等级,其他-对应等级]',publish              tinyint(1) comment '发布状态[0-未发布,1-已发布]',primary key (id)
);alter table sms_coupon comment '优惠券信息';/*==============================================================*/
/* Table: sms_coupon_history                                    */
/*==============================================================*/
create table sms_coupon_history
(id                   bigint not null auto_increment comment 'id',coupon_id            bigint comment '优惠券id',member_id            bigint comment '会员id',member_nick_name     varchar(64) comment '会员名字',get_type             tinyint(1) comment '获取方式[0->后台赠送;1->主动领取]',create_time          datetime comment '创建时间',use_type             tinyint(1) comment '使用状态[0->未使用;1->已使用;2->已过期]',use_time             datetime comment '使用时间',order_id             bigint comment '订单id',order_sn             bigint comment '订单号',primary key (id)
);alter table sms_coupon_history comment '优惠券领取历史记录';/*==============================================================*/
/* Table: sms_coupon_spu_category_relation                      */
/*==============================================================*/
create table sms_coupon_spu_category_relation
(id                   bigint not null auto_increment comment 'id',coupon_id            bigint comment '优惠券id',category_id          bigint comment '产品分类id',category_name        varchar(64) comment '产品分类名称',primary key (id)
);alter table sms_coupon_spu_category_relation comment '优惠券分类关联';/*==============================================================*/
/* Table: sms_coupon_spu_relation                               */
/*==============================================================*/
create table sms_coupon_spu_relation
(id                   bigint not null auto_increment comment 'id',coupon_id            bigint comment '优惠券id',spu_id               bigint comment 'spu_id',spu_name             varchar(255) comment 'spu_name',primary key (id)
);alter table sms_coupon_spu_relation comment '优惠券与产品关联';/*==============================================================*/
/* Table: sms_home_adv                                          */
/*==============================================================*/
create table sms_home_adv
(id                   bigint not null auto_increment comment 'id',name                 varchar(100) comment '名字',pic                  varchar(500) comment '图片地址',start_time           datetime comment '开始时间',end_time             datetime comment '结束时间',status               tinyint(1) comment '状态',click_count          int comment '点击数',url                  varchar(500) comment '广告详情连接地址',note                 varchar(500) comment '备注',sort                 int comment '排序',publisher_id         bigint comment '发布者',auth_id              bigint comment '审核者',primary key (id)
);alter table sms_home_adv comment '首页轮播广告';/*==============================================================*/
/* Table: sms_home_subject                                      */
/*==============================================================*/
create table sms_home_subject
(id                   bigint not null auto_increment comment 'id',name                 varchar(200) comment '专题名字',title                varchar(255) comment '专题标题',sub_title            varchar(255) comment '专题副标题',status               tinyint(1) comment '显示状态',url                  varchar(500) comment '详情连接',sort                 int comment '排序',img                  varchar(500) comment '专题图片地址',primary key (id)
);alter table sms_home_subject comment '首页专题表【jd首页下面很多专题,每个专题链接新的页面,展示专题商品信息】';/*==============================================================*/
/* Table: sms_home_subject_spu                                  */
/*==============================================================*/
create table sms_home_subject_spu
(id                   bigint not null auto_increment comment 'id',name                 varchar(200) comment '专题名字',subject_id           bigint comment '专题id',spu_id               bigint comment 'spu_id',sort                 int comment '排序',primary key (id)
);alter table sms_home_subject_spu comment '专题商品';/*==============================================================*/
/* Table: sms_member_price                                      */
/*==============================================================*/
create table sms_member_price
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',member_level_id      bigint comment '会员等级id',member_level_name    varchar(100) comment '会员等级名',member_price         decimal(18,4) comment '会员对应价格',add_other            tinyint(1) comment '可否叠加其他优惠[0-不可叠加优惠,1-可叠加]',primary key (id)
);alter table sms_member_price comment '商品会员价格';/*==============================================================*/
/* Table: sms_seckill_promotion                                 */
/*==============================================================*/
create table sms_seckill_promotion
(id                   bigint not null auto_increment comment 'id',title                varchar(255) comment '活动标题',start_time           datetime comment '开始日期',end_time             datetime comment '结束日期',status               tinyint comment '上下线状态',create_time          datetime comment '创建时间',user_id              bigint comment '创建人',primary key (id)
);alter table sms_seckill_promotion comment '秒杀活动';/*==============================================================*/
/* Table: sms_seckill_session                                   */
/*==============================================================*/
create table sms_seckill_session
(id                   bigint not null auto_increment comment 'id',name                 varchar(200) comment '场次名称',start_time           datetime comment '每日开始时间',end_time             datetime comment '每日结束时间',status               tinyint(1) comment '启用状态',create_time          datetime comment '创建时间',primary key (id)
);alter table sms_seckill_session comment '秒杀活动场次';/*==============================================================*/
/* Table: sms_seckill_sku_notice                                */
/*==============================================================*/
create table sms_seckill_sku_notice
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',sku_id               bigint comment 'sku_id',session_id           bigint comment '活动场次id',subcribe_time        datetime comment '订阅时间',send_time            datetime comment '发送时间',notice_type          tinyint(1) comment '通知方式[0-短信,1-邮件]',primary key (id)
);alter table sms_seckill_sku_notice comment '秒杀商品通知订阅';/*==============================================================*/
/* Table: sms_seckill_sku_relation                              */
/*==============================================================*/
create table sms_seckill_sku_relation
(id                   bigint not null auto_increment comment 'id',promotion_id         bigint comment '活动id',promotion_session_id bigint comment '活动场次id',sku_id               bigint comment '商品id',seckill_price        decimal comment '秒杀价格',seckill_count        decimal comment '秒杀总量',seckill_limit        decimal comment '每人限购数量',seckill_sort         int comment '排序',primary key (id)
);alter table sms_seckill_sku_relation comment '秒杀活动商品关联';/*==============================================================*/
/* Table: sms_sku_bounds                                        */
/*==============================================================*/
create table sms_sku_bounds
(id                   bigint not null auto_increment comment 'id',sku_id               bigint,grow_bounds          decimal(18,4) comment '成长积分',buy_bounds           decimal(18,4) comment '购物积分',work                 tinyint(1) comment '优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]',primary key (id)
);alter table sms_sku_bounds comment '商品sku积分设置';/*==============================================================*/
/* Table: sms_sku_full_reduction                                */
/*==============================================================*/
create table sms_sku_full_reduction
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'spu_id',full_price           decimal(18,4) comment '满多少',reduce_price         decimal(18,4) comment '减多少',add_other            tinyint(1) comment '是否参与其他优惠',primary key (id)
);alter table sms_sku_full_reduction comment '商品满减信息';/*==============================================================*/
/* Table: sms_sku_ladder                                        */
/*==============================================================*/
create table sms_sku_ladder
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'spu_id',full_count           int comment '满几件',discount             decimal(4,2) comment '打几折',price                decimal(18,4) comment '折后价',add_other            tinyint(1) comment '是否叠加其他优惠[0-不可叠加,1-可叠加]',primary key (id)
);alter table sms_sku_ladder comment '商品阶梯价格';/*==============================================================*/
/* Table: sms_spu_bounds                                        */
/*==============================================================*/
create table sms_spu_bounds
(id                   bigint not null auto_increment comment 'id',spu_id               bigint,grow_bounds          decimal(18,4) comment '成长积分',buy_bounds           decimal(18,4) comment '购物积分',work                 tinyint(1) comment '优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]',primary key (id)
);alter table sms_spu_bounds comment '商品spu积分设置';

ums 用户系统

/*==============================================================*/
/* Table: ums_growth_change_history  用户系统                   */
/*==============================================================*/
create table ums_growth_change_history
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',create_time          datetime comment 'create_time',change_count         int comment '改变的值(正负计数)',note                 varchar(0) comment '备注',source_type          tinyint comment '积分来源[0-购物,1-管理员修改]',primary key (id)
);alter table ums_growth_change_history comment '成长值变化历史记录';/*==============================================================*/
/* Table: ums_integration_change_history                        */
/*==============================================================*/
create table ums_integration_change_history
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',create_time          datetime comment 'create_time',change_count         int comment '变化的值',note                 varchar(255) comment '备注',source_tyoe          tinyint comment '来源[0->购物;1->管理员修改;2->活动]',primary key (id)
);alter table ums_integration_change_history comment '积分变化历史记录';/*==============================================================*/
/* Table: ums_member                                            */
/*==============================================================*/
create table ums_member
(id                   bigint not null auto_increment comment 'id',level_id             bigint comment '会员等级id',username             char(64) comment '用户名',password             varchar(64) comment '密码',nickname             varchar(64) comment '昵称',mobile               varchar(20) comment '手机号码',email                varchar(64) comment '邮箱',header               varchar(500) comment '头像',gender               tinyint comment '性别',birth                date comment '生日',city                 varchar(500) comment '所在城市',job                  varchar(255) comment '职业',sign                 varchar(255) comment '个性签名',source_type          tinyint comment '用户来源',integration          int comment '积分',growth               int comment '成长值',status               tinyint comment '启用状态',create_time          datetime comment '注册时间',primary key (id)
);alter table ums_member comment '会员';/*==============================================================*/
/* Table: ums_member_collect_spu                                */
/*==============================================================*/
create table ums_member_collect_spu
(id                   bigint not null comment 'id',member_id            bigint comment '会员id',spu_id               bigint comment 'spu_id',spu_name             varchar(500) comment 'spu_name',spu_img              varchar(500) comment 'spu_img',create_time          datetime comment 'create_time',primary key (id)
);alter table ums_member_collect_spu comment '会员收藏的商品';/*==============================================================*/
/* Table: ums_member_collect_subject                            */
/*==============================================================*/
create table ums_member_collect_subject
(id                   bigint not null auto_increment comment 'id',subject_id           bigint comment 'subject_id',subject_name         varchar(255) comment 'subject_name',subject_img          varchar(500) comment 'subject_img',subject_urll         varchar(500) comment '活动url',primary key (id)
);alter table ums_member_collect_subject comment '会员收藏的专题活动';/*==============================================================*/
/* Table: ums_member_level                                      */
/*==============================================================*/
create table ums_member_level
(id                   bigint not null auto_increment comment 'id',name                 varchar(100) comment '等级名称',growth_point         int comment '等级需要的成长值',default_status       tinyint comment '是否为默认等级[0->不是;1->是]',free_freight_point   decimal(18,4) comment '免运费标准',comment_growth_point int comment '每次评价获取的成长值',priviledge_free_freight tinyint comment '是否有免邮特权',priviledge_member_price tinyint comment '是否有会员价格特权',priviledge_birthday  tinyint comment '是否有生日特权',note                 varchar(255) comment '备注',primary key (id)
);alter table ums_member_level comment '会员等级';/*==============================================================*/
/* Table: ums_member_login_log                                  */
/*==============================================================*/
create table ums_member_login_log
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',create_time          datetime comment '创建时间',ip                   varchar(64) comment 'ip',city                 varchar(64) comment 'city',login_type           tinyint(1) comment '登录类型[1-web,2-app]',primary key (id)
);alter table ums_member_login_log comment '会员登录记录';/*==============================================================*/
/* Table: ums_member_receive_address                            */
/*==============================================================*/
create table ums_member_receive_address
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment 'member_id',name                 varchar(255) comment '收货人姓名',phone                varchar(64) comment '电话',post_code            varchar(64) comment '邮政编码',province             varchar(100) comment '省份/直辖市',city                 varchar(100) comment '城市',region               varchar(100) comment '区',detail_address       varchar(255) comment '详细地址(街道)',areacode             varchar(15) comment '省市区代码',default_status       tinyint(1) comment '是否默认',primary key (id)
);alter table ums_member_receive_address comment '会员收货地址';/*==============================================================*/
/* Table: ums_member_statistics_info                            */
/*==============================================================*/
create table ums_member_statistics_info
(id                   bigint not null auto_increment comment 'id',member_id            bigint comment '会员id',consume_amount       decimal(18,4) comment '累计消费金额',coupon_amount        decimal(18,4) comment '累计优惠金额',order_count          int comment '订单数量',coupon_count         int comment '优惠券数量',comment_count        int comment '评价数',return_order_count   int comment '退货数量',login_count          int comment '登录次数',attend_count         int comment '关注数量',fans_count           int comment '粉丝数量',collect_product_count int comment '收藏的商品数量',collect_subject_count int comment '收藏的专题活动数量',collect_comment_count int comment '收藏的评论数量',invite_friend_count  int comment '邀请的朋友数量',primary key (id)
);alter table ums_member_statistics_info comment '会员统计信息';

wms 库存系统

/*==============================================================*/
/* Table: wms_purchase            库存系统                      */
/*==============================================================*/
create table wms_purchase
(id                   bigint not null auto_increment,assignee_id          bigint,assignee_name        varchar(255),phone                char(13),priority             int(4),status               int(4),ware_id              bigint,amount               decimal(18,4),create_time          datetime,update_time          datetime,primary key (id)
);alter table wms_purchase comment '采购信息';/*==============================================================*/
/* Table: wms_purchase_detail                                   */
/*==============================================================*/
create table wms_purchase_detail
(id                   bigint not null auto_increment,purchase_id          bigint comment '采购单id',sku_id               bigint comment '采购商品id',sku_num              int comment '采购数量',sku_price            decimal(18,4) comment '采购金额',ware_id              bigint comment '仓库id',status               int comment '状态[0新建,1已分配,2正在采购,3已完成,4采购失败]',primary key (id)
);/*==============================================================*/
/* Table: wms_ware_info                                         */
/*==============================================================*/
create table wms_ware_info
(id                   bigint not null auto_increment comment 'id',name                 varchar(255) comment '仓库名',address              varchar(255) comment '仓库地址',areacode             varchar(20) comment '区域编码',primary key (id)
);alter table wms_ware_info comment '仓库信息';/*==============================================================*/
/* Table: wms_ware_order_task                                   */
/*==============================================================*/
create table wms_ware_order_task
(id                   bigint not null auto_increment comment 'id',order_id             bigint comment 'order_id',order_sn             varchar(255) comment 'order_sn',consignee            varchar(100) comment '收货人',consignee_tel        char(15) comment '收货人电话',delivery_address     varchar(500) comment '配送地址',order_comment        varchar(200) comment '订单备注',payment_way          tinyint(1) comment '付款方式【 1:在线付款 2:货到付款】',task_status          tinyint(2) comment '任务状态',order_body           varchar(255) comment '订单描述',tracking_no          char(30) comment '物流单号',create_time          datetime comment 'create_time',ware_id              bigint comment '仓库id',task_comment         varchar(500) comment '工作单备注',primary key (id)
);alter table wms_ware_order_task comment '库存工作单';/*==============================================================*/
/* Table: wms_ware_order_task_detail                            */
/*==============================================================*/
create table wms_ware_order_task_detail
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',sku_name             varchar(255) comment 'sku_name',sku_num              int comment '购买个数',task_id              bigint comment '工作单id',primary key (id)
);alter table wms_ware_order_task_detail comment '库存工作单';/*==============================================================*/
/* Table: wms_ware_sku                                          */
/*==============================================================*/
create table wms_ware_sku
(id                   bigint not null auto_increment comment 'id',sku_id               bigint comment 'sku_id',ware_id              bigint comment '仓库id',stock                int comment '库存数',sku_name             varchar(200) comment 'sku_name',stock_locked         int comment '锁定库存',primary key (id)
);alter table wms_ware_sku comment '商品库存';

快速开发-后台管理系统

如果从头到尾搭建一个后台管理系统,写前端和后端,这是一个非常耗时,且繁重的工作,所以我们希望可以有一个搭建好的脚手架工程,我们稍加改造,就能成为我们的后台管理系统。

人人开源介绍

renren-fast – 后台管理系统后端
renren-fast-vue – 后台管理系统前端
renren-generator – 代码生成器
renren-security – 类似于模板引擎的单体项目

启动后台管理系统

  1. git clone renren-fast 和 renren-fast-vue,删除其中的git目录
  2. 将renren-fast项目粘贴到gulistore中,使其成为一个子项目,
  3. 修改数据库地址,账密
  4. 将项目文件夹下的db的mysql文件,创建gulistore_admin数据库,并运行sql
  5. 修改maven的groupId和其他子项目一样,否则有可能maven报错
  6. 启动项目,访问http://localhost:8080/renren-fast/,报401即成功

启动前端管理系统

使用vscode打开renren-fast-vue

下载Node.js

Node.js是一个基于Chorme V8引擎的javaScript运行环境,npm是随同nodejs一起安装的包管理工具,

javaScript – npm
java – maven

怎么下载自行百度,很简单

node -v# dos窗口,设置npm下载地址为国内
npm config set registry http://registry.npm.taobao.org/# vscode terminal
# 安装前端项目所需要的包
npm install# 不先运行这个命令会报错
npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/# 把package.json"node-sass": "4.13.1",改为4.14.1# 运行
npm run dev

此时,后台管理系统前后端搭建完成

快速开发-逆向工程

  1. clone renren-generator,使其成为项目的一个子模块

  2. 修改数据库路径、账密、生成代码模块的数据库,修改generator.properties,内容见下

  3. 生成之后删除resources下的src文件,里面都是vue的代码,暂时用不到,剩下的main文件全部覆盖到项目里

  4. 修改resources -> template -> Controller.java.vm,删除@RequiresPermissions(“moduleName:{moduleName}:moduleName:{pathName}:list”),
    这是shiro的注解,我们权限控制用的是springSecurity

  5. 启动项目,访问web,选中全部表,点生成代码

  6. 将生成的main包粘贴到该微服务下

需要修改的generator.properties

mainPath=com.atguigu
#\u5305\u540D
package=com.atguigu.gulistore
moduleName=product
#\u4F5C\u8005
author=lx
#Email
email=qazokmzjl@gmail.com
#\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00)
# 表前缀(类名不会包含表前缀)
tablePrefix=pms

创建common公共模块

使用maven直接创建,不需要spring,
该模块存放每一个微服务公共的依赖,bean,工具类等

在上一步创建好逆向工程后,发现好多报错,需要导入依赖、工具包等

pom

spring boot、spring cloud 、 spring cloud alibaba 版本选择

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>gulistore</artifactId><groupId>com.atguigu.gulistore</groupId><version>0.0.1-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>gulistore-common</artifactId><description>每一个微服务公共的依赖,bean,工具类等</description><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><dependencies><!--        mybatis-plus--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.3.1</version></dependency><!--        lombok--><!-- lombok的版本很奇怪,在做检索服务的时候突然项目就不能运行了,最终问题就是lombok的版本原因,common的版本是1.18.8,springboot自动依赖的是1.18.20,将common这里的版本去掉就好了究其原因应该是依赖传递的优先级出了问题,可是之前为什么没有问题呢?--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.8</version></dependency><!--        发送http请求--><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.4.12</version></dependency><dependency><groupId>commons-lang</groupId><artifactId>commons-lang</artifactId><version>2.6</version></dependency><!--    mysql驱动--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.17</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency><!--        服务发现/注册中心--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<!--            nacos中ribbon会造成loadbalanc包失效,进而项目启动不成功--><exclusions><exclusion><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-ribbon</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-loadbalancer</artifactId><version>3.0.3</version></dependency><!--    配置中心来做配置管理--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId><version>3.0.4</version></dependency></dependencies><!--    不导入包,只是在引入springcloudalibaba的时候,版本固定了--><dependencyManagement><dependencies><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId>
<!--                这是谷粒商城视频的版本-->
<!--                <version>2.1.0.RELEASE</version>--><version>2021.1</version>
<!--                <version>2.2.1.RELEASE</version>--><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement></project>

工具包

exception、utils、xss,从renren-fast模块复制就ok了

gulistore-product微服务整合mybatis-plus

导入依赖

mysql驱动的选择主要看mysql的版本,我的是5.7.35,然而在maven的仓库里没有与之对应的版本

mysql官网指出,mysql5…版本使用8…就可以了

# 公共服务中已经有了
<!--        mybatis-plus-->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.3.1</version>
</dependency><!--    mysql驱动-->
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.17</version>
</dependency>

配置数据源

在resources目录下创建application.yml文件

spring:datasource:url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=falsedriver-class-name: com.mysql.jdbc.Driverusername: rootpassword: root# classpath* 依赖的依赖也扫描
mybatis-plus:mapper-locations: classpath:/mapper/**/*.xml#  主键自增# 在实体类中,每个主键都有@TableId,默认为None,可以设置为自增#  但是如果在每个实体类中都设置的话,如果有一天需要修改,将相当麻烦global-config:db-config:id-type: auto

配置mybatis-plus

# 在启动类添加@MapperScan,扫描dao
@MapperScan("com.atguigu.gulistore.product.dao")

测试

package com.lxit.gulimall.gulimall_product;import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lxit.gulimall.product.GulimallProductApplication;
import com.lxit.gulimall.product.entity.BrandEntity;
import com.lxit.gulimall.product.service.BrandService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;@SpringBootTest(classes = GulimallProductApplication.class)
class GulimallProductApplicationTests {@AutowiredBrandService brandService;@Testvoid contextLoads() {//        BrandEntity brandEntity = new BrandEntity();
//
//        brandEntity.setName("华为");
//        brandService.save(brandEntity);List<BrandEntity> brandEntityList = brandService.list(new QueryWrapper<BrandEntity>().eq("brand_id", 1L));brandEntityList.forEach((item) ->{System.out.println(item);});}}

其他的模块,依次生成就可以了,到此,一个最简单的架子搭起来了

尚硅谷学习视频B站链接:
https://www.bilibili.com/video/BV1np4y1C7Yf?p=3

部分知识点参考自:https://blog.csdn.net/df981011512/article/details/78989532

todo谷粒商城二本地虚拟机环境搭建及项目初始化相关推荐

  1. 谷粒商城-分布式基础篇-环境搭建

    1.写在前面 既个人博客系统和Java虚拟机学习后,深感技术点过于零散,于是照着尚硅谷教程写了谷粒商城这个项目.谷粒商城是一个完整的大型分布式架构电商平台,这个项目将我目前学到的知识点,以及还未学到的 ...

  2. Vue+koa2开发一款全栈小程序(服务端环境搭建和项目初始化)

    1.微信公众平台小程序关联腾讯云 腾讯云的开发环境是给免费的一个后台,但是只能够用于开发,如果用于生产是需要花钱的,我们先用开发环境吧 1.用小程序开发邮箱账号登录微信公众平台 2.[设置]→[开发者 ...

  3. Win10 Vue 环境搭建以及项目初始化

    文章目录 1. Node 下载和安装 1.1 安装验证 1.2 添加 `NODE_PATH` 环境变量 2. 使用 cnpm 的两种方式 2.1 下载安装 cnpm 2.2 通过改变地址来使用淘宝镜像 ...

  4. F5 WMware虚拟机环境搭建-BIG-IP Virtual Edition 11.3.0

    F5 WMware虚拟机环境搭建- BIG-IP Virtual Edition 11.3.0 一. 准备工作: -1.宿主PC,需支持硬件虚拟化.建议使用securable软件查看是否支持. -2. ...

  5. java服务器要二次编译,ecology项目二次开发环境搭建

    ecology项目二次开发环境搭建 Submitted By Weaver 文档版本控制 文档简要信息: 文档主题(Title) ecology项目二次开发环境搭建 作者(Author) 审批者 (T ...

  6. 分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群

    其实这是一篇来自:http://www.open-open.com/lib/view/open1435468300700.html 个人认为很适合新手参考的文章,感谢原创作者的努力. 分布式存储 Ce ...

  7. 微信开发——本地测试环境搭建

    版权声明:欢迎转载,请注明沉默王二原创. https://blog.csdn.net/qing_gee/article/details/52858939 微信开发的本地测试环境搭建起来颇为繁琐(对微信 ...

  8. Revit二次开发环境搭建(Revit 2019+Visual Studio 2017)

    Revit二次开发环境搭建(Revit 2019+Visual Studio 2017) 安装 Revit 2019 Visual Studio 2017 Revit SDK 2019 配置Addin ...

  9. Nacos 简介与 本地调试环境搭建

    目录 1.简介 2.Nacos架构 3.本地调试环境搭建 3.1 源码下载 3.3 单机启动 Nacos 3.4 集群方式启动:基于文件方式 4.Nacos源码模块介绍 5. 约定说明 1.简介 Na ...

最新文章

  1. Oracle后台进程
  2. 每日 30 秒 ⏱ 无障碍世界
  3. NYOJ 回文字符串
  4. python怎么读取txt文件并统计其字数-python计算文件的行数和读取某一行内容的实现方法...
  5. Microsoft加入量子计算的竞争
  6. BugKuCTF WEB 点击一百万次
  7. Directx11学习笔记【二】 将HelloWin封装成类
  8. 项目的包结构 mybatis三剑客
  9. linux下打开、关闭tomcat,实时查看tomcat运行日志
  10. sp.net MVCJQuery 应用(表单验证)
  11. select模型的原理、优点、缺点
  12. 第三方监测平台在道路安全管理中的应用
  13. CF AIM Tech Round 4 (Div. 1) A. Sorting by Subsequences
  14. LeetCode使用简介(leetcode中国-力扣)
  15. C++ 单词查询程序
  16. Spark 高级数据分析(第2版)
  17. vue酒店房间管理系统
  18. GitHub 上值得收藏的 100 个精选前端项目!
  19. KVM虚拟化之(1):CPU技术
  20. JAVA毕设项目公立医院绩效考核系统(Vue+Mybatis+Maven+Mysql+sprnig+SpringMVC)

热门文章

  1. 详解DNS 查询原理
  2. Events(事件)
  3. Ubuntu 20.04 系统最快安装WRF软件手册
  4. 谈论 ModSecurity 和新的 Coraza WAF
  5. Python 实现随机生成双色球号码
  6. Windows 10 安装 ADB (Android Debug Bridge,Android 调试桥)
  7. RemoteSensing投稿流程
  8. web前端——h标签
  9. 我们有理由相信,中国将进入一个全面的刷脸支付新时代
  10. python下载整个网站_python – Selenium下载整个HTML