文章目錄
- 碼云倉庫
- 安裝git
- 創建倉庫
- 微服務模塊
- 創建服務
- 提交碼云
- 創建資料庫
- gulimall_oms
- gulimall_pms
- gulimall_sms
- gulimall_ums
- gulimall_wms
- 后臺管理系統
- renren-fast
- renren-fast-vue
- 安裝vscode
- 代碼生成器
- renren-generator
- product、gulimall_pms
- 測驗
- coupon、gulimall-sms
- member、gulimall_ums
- ware、gulimall_wms
- order、gulimall_oms
- SpringCloud Alibaba簡介
- 搭配環境
- Nacos
碼云倉庫
安裝git
1、配置用戶名:git config --global user.name "username" ,(名字,隨意寫)
2、配置郵箱:git config --global user.email "xxx@qq.com",注冊賬號時使用 的郵箱
3、配置ssh免密登錄:ssh-keygen -t rsa -C "xxxx@qq.com"
4、三次回車后生成了密鑰,也可以查看密鑰:cat ~/.ssh/id_rsa.pub
5、瀏覽器登錄碼云后,個人頭像上點設定、然后點ssh公鑰、隨便填個標題,然后賦值
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6MWhGXSKdRxr1mGPZysDrcwABMTrxc8Va2IWZyIMMRHH9Qn/wy3PN2I9144UUqg65W0CDE/thxbOdn78MygFFsIG4j0wdT9sdjmSfzQikLHFsJ02yr58V6J2zwXcW9AhIlaGr+XIlGKDUy5mXb4OF+6UMXM6HKF7rY9FYh9wL6bun9f1jV4Ydlxftb/xtV8oQXXNJbI6OoqkogPKBYcNdWzMbjJdmbq2bSQugGaPVnHEqAD74Qgkw1G7SIDTXnY55gBlFPVzjLWUu74OWFCx4pFHH6LRZOCLlMaJ9haTwT2DB/sFzOG/Js+cEExx/arJ2rvvdmTMwlv/T+6xhrMS3 xxxx@qq.com
6、測驗:ssh -T git@gitee.com
7、測驗成功:Hi unique_perfect! You’ve successfully authenticated, but GITEE.COM does not provide shell access.


創建倉庫

微服務模塊

創建服務
在IDEA中New Project from version control Git 復制剛才專案的地址,如https://gitee.com/liujianyuaa/gulimall.git

我們把他設定成總模塊,以后所有的微服務專案都放到這里

創建以下模塊
- 商品服務product
- 存盤服務ware
- 訂單服務order
- 優惠券服務coupon
- 用戶服務member
- 每個模塊匯入web和openFeign
各個服務共同點
1、web服務、openfegin服務
2、每個服務的包名,com.liu.gulimall-xxxx(product/ware/oder/coupon/member)
3、模塊名:gulimall-xxxx(product/ware/oder/coupon/member)
4、都選擇spring專案
比如第一個gulimall-product


依次創建完畢
在maven視窗重繪,并點擊+號,找到剛才的pom.xml添加進來,發現多了個root,這樣比如運行root的clean命令,其他專案也一起clean了,

修改總專案的.gitignore,把小專案里的垃圾檔案在提交的時候忽略掉 ,比如

總專案的.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.cmd
**/.mvn
**/target
.idea
**/.gitignore
**/README.md
把檔案全部納入版本控制

要把代碼提交到碼云,下載插件

提交碼云
提交檔案

- 這里選擇commit和push,不然只是在本地倉庫

- 登陸碼云賬號

- 提交成功,右下角

- 查看碼云

- 并且沒有提交其他垃圾檔案,隨便點開一個

創建資料庫
每個服務建立不同的資料庫,分別建立了下面資料庫,字符集選utf8mb4,他能兼容utf8且能解決一些亂碼的問題,
-
gulimall_oms :訂單管理系統
-
gulimall_pms :商品管理系統
-
gulimall_sms :優惠券管理系統
-
gulimall_ums :用戶管理系統
-
gulimall_wms:存盤管理系統
所有的資料庫資料再復雜也不建立外鍵,因為在電商系統里,資料量大, 做外鍵關聯很耗性能,

創建所有的資料庫

創建表
gulimall_oms
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;
/*==============================================================*/
/* 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 '退款資訊';
gulimall_pms
商品管理系統
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_category_brand_relation;
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;
/*==============================================================*/
/* 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_category_brand_relation */
/*==============================================================*/
create table pms_category_brand_relation
(
id bigint not null auto_increment,
brand_id bigint comment '品牌id',
catelog_id bigint comment '分類id',
brand_name varchar(255),
catelog_name varchar(255),
primary key (id)
);
alter table pms_category_brand_relation 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資訊介紹';
gulimall_sms
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_full_reduction;
drop table if exists sms_sku_ladder;
drop table if exists sms_spu_bounds;
/*==============================================================*/
/* 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_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積分設定';
gulimall_ums
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;
/*==============================================================*/
/* 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 '會員統計資訊';
gulimall_wms
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`xid` varchar(100) NOT NULL,
`context` varchar(128) NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime NOT NULL,
`log_modified` datetime NOT NULL,
`ext` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `wms_purchase`;
CREATE TABLE `wms_purchase` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`assignee_id` bigint(20) DEFAULT NULL,
`assignee_name` varchar(255) DEFAULT NULL,
`phone` char(13) DEFAULT NULL,
`priority` int(4) DEFAULT NULL,
`status` int(4) DEFAULT NULL,
`ware_id` bigint(20) DEFAULT NULL,
`amount` decimal(18,4) DEFAULT NULL,
`create_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='采購資訊';
DROP TABLE IF EXISTS `wms_purchase_detail`;
CREATE TABLE `wms_purchase_detail` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`purchase_id` bigint(20) DEFAULT NULL COMMENT '采購單id',
`sku_id` bigint(20) DEFAULT NULL COMMENT '采購商品id',
`sku_num` int(11) DEFAULT NULL COMMENT '采購數量',
`sku_price` decimal(18,4) DEFAULT NULL COMMENT '采購金額',
`ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
`status` int(11) DEFAULT NULL COMMENT '狀態[0新建,1已分配,2正在采購,3已完成,4采購失敗]',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `wms_ware_info`;
CREATE TABLE `wms_ware_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) DEFAULT NULL COMMENT '倉庫名',
`address` varchar(255) DEFAULT NULL COMMENT '倉庫地址',
`areacode` varchar(20) DEFAULT NULL COMMENT '區域編碼',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='倉庫資訊';
DROP TABLE IF EXISTS `wms_ware_order_task`;
CREATE TABLE `wms_ware_order_task` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`order_id` bigint(20) DEFAULT NULL COMMENT 'order_id',
`order_sn` varchar(255) DEFAULT NULL COMMENT 'order_sn',
`consignee` varchar(100) DEFAULT NULL COMMENT '識訓人',
`consignee_tel` char(15) DEFAULT NULL COMMENT '識訓人電話',
`delivery_address` varchar(500) DEFAULT NULL COMMENT '配送地址',
`order_comment` varchar(200) DEFAULT NULL COMMENT '訂單備注',
`payment_way` tinyint(1) DEFAULT NULL COMMENT '付款方式【 1:在線付款 2:貨到付款】',
`task_status` tinyint(2) DEFAULT NULL COMMENT '任務狀態',
`order_body` varchar(255) DEFAULT NULL COMMENT '訂單描述',
`tracking_no` char(30) DEFAULT NULL COMMENT '物流單號',
`create_time` datetime DEFAULT NULL COMMENT 'create_time',
`ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
`task_comment` varchar(500) DEFAULT NULL COMMENT '作業單備注',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='庫存作業單';
DROP TABLE IF EXISTS `wms_ware_order_task_detail`;
CREATE TABLE `wms_ware_order_task_detail` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`sku_id` bigint(20) DEFAULT NULL COMMENT 'sku_id',
`sku_name` varchar(255) DEFAULT NULL COMMENT 'sku_name',
`sku_num` int(11) DEFAULT NULL COMMENT '購買個數',
`task_id` bigint(20) DEFAULT NULL COMMENT '作業單id',
`ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
`lock_status` int(1) DEFAULT NULL COMMENT '1-已鎖定 2-已解鎖 3-扣減',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='庫存作業單';
DROP TABLE IF EXISTS `wms_ware_sku`;
CREATE TABLE `wms_ware_sku` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`sku_id` bigint(20) DEFAULT NULL COMMENT 'sku_id',
`ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
`stock` int(11) DEFAULT NULL COMMENT '庫存數',
`sku_name` varchar(200) DEFAULT NULL COMMENT 'sku_name',
`stock_locked` int(11) DEFAULT '0' COMMENT '鎖定庫存',
PRIMARY KEY (`id`),
KEY `sku_id` (`sku_id`) USING BTREE,
KEY `ware_id` (`ware_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品庫存';
后臺管理系統
- 在碼云上搜索人人開源,我們使用renren-fast,renren-fast-vue專案,

git clone https://gitee.com/renrenio/renren-fast.git
git clone https://gitee.com/renrenio/renren-fast-vue.git
我們把renren-fast移動到我們的專案檔案夾(刪掉.git檔案),而renren-fast-vue是用VSCode打開的(后面再弄)
renren-fast
在idea(root)專案里的pom.xml添加一個
<modules>
<module>gulimall-coupon</module>
<module>gulimall-member</module>
<module>gulimall-order</module>
<module>gulimall-product</module>
<module>gulimall-ware</module>
<module>renren-fast</module>
</modules>
然后打開renren-fast/db/mysql.sql,復制全部,在sqlyog中創建庫gulimall_admin,粘貼db中的mysql.sql的內容執行
資料庫和表創建完成之后修改renren-fast的配置
修改專案里renren-fast中的application.yml,發現是默認是dev,修改application-dev.yml中的數庫庫連接
url: jdbc:mysql://localhost:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: root
啟動測驗:執行java下的RenrenApplication,訪問:http://localhost:8080/renren-fast/ 得到:{“msg”:“invalid token”,“code”:401}就代表無誤
renren-fast-vue
安裝vscode
- 安裝以下插件
Auto Close Tag
Auto Rename Tag
Chinese
ESlint
HTML CSS Support
HTML Snippets
JavaScript (ES6) code snippets
Live Server
open in brower
Vetur
- 用VSCode打開renren-fast-vue
安裝node
C:\WINDOWS\system32>node -v # 查看版本
v14.18.0
然后
npm config set registry http://registry.npm.taobao.org/ # 設定node倉庫,提高下載速度
【注意】
-
首先https://www.npmjs.com/package/node-sass找到我們的node-sass和node的版本對應關系
-
修改專案 package.json
“node-sass”: “^4.14.1”, 【 node14對應的sass版本是4.14 】,清理快取(可直接洗掉 node_modules 目錄)然后
npm rebuild node-sass、npm uninstall node-sass -
在VScode的終端進入專案中輸入 npm install,會報錯,然后進行如下操作:
報錯:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chromedriver@2.27.2 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chromedriver@2.27.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! E:\installation_program\nodeRepository\npm_cache\_logs\2021-02-09T07_38_47_075Z-debug.log
解決報錯:
npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
-
再npm install、npm run dev
-
瀏覽器輸入localhost:8001 就可以看到內容了,登錄賬號admin 密碼admin
代碼生成器
renren-generator
還是采用人人開源
git clone https://gitee.com/renrenio/renren-generator.git
同樣把里面的.git檔案洗掉,然后移動到我們IDEA專案目錄中,同樣配置好pom.xml(root)
<modules>
<module>gulimall-coupon</module>
<module>gulimall-member</module>
<module>gulimall-order</module>
<module>gulimall-product</module>
<module>gulimall-ware</module>
<module>renren-fast</module>
<module>renren-generator</module>
</modules>
修改renren-generator的application.yml
product、gulimall_pms
以資料庫gulimall_pms和product模塊為例
url: jdbc:mysql://localhost:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
修改generator.properties
mainPath=com.liu # 主目錄
package=com.liu.gulimall # 包名
moduleName=product # 模塊名
author=liujianyu # 作者
email=liujianyu@qq.com # email
tablePrefix=pms_ # 我們的pms資料庫中的表的前綴都有pms,
# 如果寫了表前綴,每一張表對于的javaBean就不會添加前綴了
運行RenrenApplication,如果啟動不成功,修改application中是port為80,訪問http://localhost:80
然后點擊全部,點擊生成代碼,下載了壓縮包
解壓壓縮包,把main放到gulimall-product的同級目錄下,他會自動替換,sql先不管
由于我們現在的一些utils,shiro等等的類都沒有還有一些包依賴也沒有,所以采用一個gulimall-common來管理
-
在專案上右擊(在專案上右擊很重要)new modules— maven—然后在name上輸入gulimall-common,
-

-
在pom.xml中也自動添加了
<module>gulimall-common</module> -
在common專案的pom.xml(我們把每一個微服務公共的依賴、bean、工具類等)中添加,發現product中缺少的依賴匯入到common中
<!-- mybatisPLUS-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<!--簡化物體類,用@Data代替getset方法-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<!-- httpcomponent包https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.13</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version> 這里版本好和renren-fast的版本號一致
</dependency>

然后在product專案中的pom.xml中加入下面內容,匯入common
<dependency>
<groupId>com.liu.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
匯入相關類
-
renren-fast----utils包下的Query和PageUtils、R、Constant復制到common專案的java.com.liu.common.utils下
-
復制renren-fast中的xss包粘貼到common的java.com.liu.common目錄下,
-
還復制了exception檔案夾,對應的位置關系自己觀察一下就行
-
注釋掉product專案下類中匯入的//import org.apache.shiro.authz.annotation.RequiresPermissions;他是shiro的東西
-
把@RequiresPermissions這些注解掉,因為是shiro的,我們用security
-
由于我們很多的controller都有@RequiresPermissions這個注解,而且我們之后也不需要,所以我們修改代碼生成器,在生成的時候就不加上這個
找到renren-generator\src\main\resources\template\下的Controller.java.vm
-
刪掉import org.apache.shiro.authz.annotation.RequiresPermissions;
-
注釋renren-generator\src\main\resources\template\Controller.java.vm中所有的@RequiresPermissions,
-
再重啟renren-generator,然后下載,只需要把main中的controller匯入即可
-
總之什么報錯就去renren-fast里面找,
測驗
1、測驗與整合商品服務里的mybatisplus
- 在common的pom.xml中匯入
<!-- 資料庫驅動 https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version> 這里版本要和資料的版本最好相同,sqlyog可以直接看,但是呢mysql版本是適配的,版本也可以不同
</dependency>
<!--tomcat里一般都帶-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope> # Tomcat自帶,所以provided,表示不會打包帶上
</dependency>
- 刪掉common里xss/xssfiler和XssHttpServletRequestWrapper,我們用sercurity可以直接解決掉
- 在product專案的resources目錄下新建application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
# MapperScan
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml # sql映射檔案位置
global-config:
db-config:
id-type: auto # 主鍵自增
- 然后在主啟動類上加上注解@MapperScan()
@MapperScan("com.liu.gulimall.product.dao") // 告訴mybatis—plus我們的mapper介面都在哪 copy-reference,復制路徑
@SpringBootApplication
public class gulimallProductApplication {
public static void main(String[] args) {
SpringApplication.run(gulimallProductApplication.class, args);
}
}
- 然后去測驗,先通過下面方法給資料庫添加內容
@SpringBootTest
class gulimallProductApplicationTests {
@Autowired
BrandService brandService;
@Test
void contextLoads() {
// 品牌
BrandEntity brandEntity = new BrandEntity();
brandEntity.setDescript("hello");
brandEntity.setName("華為");
// 保存到資料庫
brandService.save(brandEntity);
System.out.println("保存成功");
// 查詢
List<BrandEntity> list = brandService.list(new QueryWrapper<BrandEntity>().eq("brand_id", 1L));
list.forEach((item)->{
System.out.println(item );
});
}
}
coupon、gulimall-sms
renren-generator配置:
1、資料源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
#MySQL配置
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
2、代碼源配置
# 主目錄
mainPath=com.liu
# 包名
package=com.liu.gulimall
moduleName=coupon
# 作者
author=liujianyu
# Email
email=380404812@qq.com
# 表前綴(類名不會包含表前綴)
tablePrefix=sms_
3、啟動下載,將main放到專案對應檔案中
coupon專案配置:
4、在coupon專案中匯入common依賴
<dependency>
<groupId>com.liu.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
5、創建application.yml
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
# MapperScan
# sql映射檔案位置
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
6、在啟動類上添加:@MapperScan("com.liu.gulimall.coupon.dao")
7、測驗
啟動服務,測驗介面即可http://localhost:8080/coupon/coupon/list
member、gulimall_ums
ware、gulimall_wms
【報錯】:private Longblob rollbackInfo 修改為:private Byte rollbackInfo;
order、gulimall_oms
SpringCloud Alibaba簡介
官網:https://spring.io/projects/spring-cloud-alibaba

搭配環境
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
在common的pom.xml中加入
# 下面是依賴管理,相當于以后再dependencies里引spring cloud alibaba就不用寫版本號, 全用dependencyManagement進行管理
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Nacos
關于Nacos:https://my.oschina.net/cicadasmile/blog/3171529
-
一個更易于構建云原生應用的動態服務發現、配置管理和服務管理平臺,
-
作為我們的注冊中心和配置中心,
先了解一下 Spring Cloud 應用如何接入 Nacos Discovery,
1、首先,修改 common中的pom.xml 檔案,引入 Nacos Discovery Starter,不用版本號
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
2、在應用的common中的application.yml 組態檔中配置 Nacos Server 地址和微服務名稱(為了讓nacos知道注冊的是哪個服務)
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
application:
name: gulimall-coupon # 微服務名稱
# MapperScan
# sql映射檔案位置
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
server:
port: 7000
3、我們要配置nacos服務器的地址,也就是注冊中心地址,但是我們還沒有nacos服務器,所以我們需要啟動nacos server創建nacos服務
器(軟體官方可以下載,或者:https://github.com/alibaba/nacos/releases)
bin目錄下啟動命令windows:startup.cmd -m standalone

4、使用 @EnableDiscoveryClient 注解開啟服務注冊與發現功能
@SpringBootApplication
@MapperScan("com.liu.gulimall.coupon.dao")
@EnableDiscoveryClient
public class GulimallCouponApplication {
public static void main(String[] args) {
SpringApplication.run(GulimallCouponApplication.class, args);
}
}
5 訪問http://127.0.0.1:8848/nacos/ 賬號密碼都是:nacos
出現如下頁面,則表示訪問成功

按照以上步驟注冊member
1、在應用的common中的application.yml 組態檔中配置 Nacos Server 地址和微服務名稱
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
application:
name: gulimall-member
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
global-config:
db-config:
id-type: auto
server:
port: 8000
2、使用 @EnableDiscoveryClient注解開啟服務注冊與發現功能
@SpringBootApplication
@MapperScan("com.liu.gulimall.member.dao")
@EnableDiscoveryClient
public class GulimallMemberApplication {
public static void main(String[] args) {
SpringApplication.run(GulimallMemberApplication.class, args);
}
}
3、啟動nacos-service服務和微服務即可
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/379540.html
標籤:java
