diff --git a/README.md b/README.md
index 461d81c..3251531 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
## 项目介绍
-`mall-swarm`是一套微服务商城系统,采用了 Spring Cloud Greenwich、Spring Boot 2、MyBatis、Docker、Elasticsearch等核心技术,同时提供了基于Vue的管理后台方便快速搭建系统。`mall-swarm`在电商业务的基础集成了注册中心、配置中心、监控中心、网关等系统功能。 文档齐全,附带全套Spring Cloud教程。
+`mall-swarm`是一套微服务商城系统,采用了 Spring Cloud Hoxton & Alibaba、Spring Boot 2.3、Oauth2、MyBatis、Docker、Elasticsearch等核心技术,同时提供了基于Vue的管理后台方便快速搭建系统。`mall-swarm`在电商业务的基础集成了注册中心、配置中心、监控中心、网关等系统功能。 文档齐全,附带全套Spring Cloud教程。
## 系统架构图
@@ -22,15 +22,14 @@
mall
├── mall-common -- 工具类及通用代码模块
├── mall-mbg -- MyBatisGenerator生成的数据库操作代码模块
-├── mall-security -- 封装SpringSecurity+JWT的安全认证的模块
-├── mall-registry -- 基于Eureka的微服务注册中心
-├── mall-config -- 基于Spring Cloud Config的微服务配置中心
+├── mall-auth -- 基于Spring Security Oauth2的统一的认证中心
├── mall-gateway -- 基于Spring Cloud Gateway的微服务API网关服务
├── mall-monitor -- 基于Spring Boot Admin的微服务监控中心
├── mall-admin -- 后台管理系统服务
├── mall-search -- 基于Elasticsearch的商品搜索系统服务
├── mall-portal -- 移动端商城系统服务
-└── mall-demo -- 微服务远程调用测试服务
+├── mall-demo -- 微服务远程调用测试服务
+└── config -- 配置中心存储的配置
```
## 项目文档
@@ -47,29 +46,30 @@ mall
### 后端技术
-| 技术 | 说明 | 官网 |
-| ---------------- | -------------------- | ---------------------------------------------------- |
-| Spring Cloud | 微服务框架 | https://spring.io/projects/spring-cloud |
-| Spring Boot | 容器+MVC框架 | https://spring.io/projects/spring-boot |
-| Spring Security | 认证和授权框架 | https://spring.io/projects/spring-security |
-| MyBatis | ORM框架 | http://www.mybatis.org/mybatis-3/zh/index.html |
-| MyBatisGenerator | 数据层代码生成 | http://www.mybatis.org/generator/index.html |
-| PageHelper | MyBatis物理分页插件 | http://git.oschina.net/free/Mybatis_PageHelper |
-| Swagger-UI | 文档生产工具 | https://github.com/swagger-api/swagger-ui |
-| Elasticsearch | 搜索引擎 | https://github.com/elastic/elasticsearch |
-| RabbitMq | 消息队列 | https://www.rabbitmq.com/ |
-| Redis | 分布式缓存 | https://redis.io/ |
-| MongoDb | NoSql数据库 | https://www.mongodb.com/ |
-| Docker | 应用容器引擎 | https://www.docker.com/ |
-| Druid | 数据库连接池 | https://github.com/alibaba/druid |
-| OSS | 对象存储 | https://github.com/aliyun/aliyun-oss-java-sdk |
-| MinIO | 对象存储 | https://github.com/minio/minio |
-| JWT | JWT登录支持 | https://github.com/jwtk/jjwt |
-| LogStash | 日志收集 | https://github.com/logstash/logstash-logback-encoder |
-| Lombok | 简化对象封装工具 | https://github.com/rzwitserloot/lombok |
-| Seata | 全局事务管理框架 | https://github.com/seata/seata |
-| Portainer | 可视化Docker容器管理 | https://github.com/portainer/portainer |
-| Jenkins | 自动化部署工具 | https://github.com/jenkinsci/jenkins |
+| 技术 | 说明 | 官网 |
+| ---------------------- | -------------------- | ---------------------------------------------------- |
+| Spring Cloud | 微服务框架 | https://spring.io/projects/spring-cloud |
+| Spring Cloud Alibaba | 微服务框架 | https://github.com/alibaba/spring-cloud-alibaba |
+| Spring Boot | 容器+MVC框架 | https://spring.io/projects/spring-boot |
+| Spring Security Oauth2 | 认证和授权框架 | https://spring.io/projects/spring-security-oauth |
+| MyBatis | ORM框架 | http://www.mybatis.org/mybatis-3/zh/index.html |
+| MyBatisGenerator | 数据层代码生成 | http://www.mybatis.org/generator/index.html |
+| PageHelper | MyBatis物理分页插件 | http://git.oschina.net/free/Mybatis_PageHelper |
+| Knife4j | 文档生产工具 | https://github.com/xiaoymin/swagger-bootstrap-ui |
+| Elasticsearch | 搜索引擎 | https://github.com/elastic/elasticsearch |
+| RabbitMq | 消息队列 | https://www.rabbitmq.com/ |
+| Redis | 分布式缓存 | https://redis.io/ |
+| MongoDb | NoSql数据库 | https://www.mongodb.com/ |
+| Docker | 应用容器引擎 | https://www.docker.com/ |
+| Druid | 数据库连接池 | https://github.com/alibaba/druid |
+| OSS | 对象存储 | https://github.com/aliyun/aliyun-oss-java-sdk |
+| MinIO | 对象存储 | https://github.com/minio/minio |
+| JWT | JWT登录支持 | https://github.com/jwtk/jjwt |
+| LogStash | 日志收集 | https://github.com/logstash/logstash-logback-encoder |
+| Lombok | 简化对象封装工具 | https://github.com/rzwitserloot/lombok |
+| Seata | 全局事务管理框架 | https://github.com/seata/seata |
+| Portainer | 可视化Docker容器管理 | https://github.com/portainer/portainer |
+| Jenkins | 自动化部署工具 | https://github.com/jenkinsci/jenkins |
### 前端技术
@@ -87,15 +87,17 @@ mall
### 开发环境
-工具 | 版本号 | 下载
-----|----|----
-JDK | 1.8 | https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
-Mysql | 5.7 | https://www.mysql.com/
-Redis | 3.2 | https://redis.io/download
-Elasticsearch | 6.2.2 | https://www.elastic.co/downloads
-MongoDb | 3.2 | https://www.mongodb.com/download-center
-RabbitMq | 3.7.14 | http://www.rabbitmq.com/download.html
-nginx | 1.10 | http://nginx.org/en/download.html
+| 工具 | 版本号 | 下载 |
+| ------------- | ------ | ------------------------------------------------------------ |
+| JDK | 1.8 | https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html |
+| Mysql | 5.7 | https://www.mysql.com/ |
+| Redis | 5.0 | https://redis.io/download |
+| Elasticsearch | 7.6.2 | https://www.elastic.co/cn/downloads/elasticsearch |
+| Kibana | 7.6.2 | https://www.elastic.co/cn/downloads/kibana |
+| Logstash | 7.6.2 | https://www.elastic.co/cn/downloads/logstash |
+| MongoDb | 4.2.5 | https://www.mongodb.com/download-center |
+| RabbitMq | 3.7.14 | http://www.rabbitmq.com/download.html |
+| nginx | 1.10 | http://nginx.org/en/download.html |
### 搭建步骤
@@ -106,8 +108,6 @@ nginx | 1.10 | http://nginx.org/en/download.html
- `ELK`日志收集系统的搭建请参考:[SpringBoot应用整合ELK实现日志收集](http://www.macrozheng.com/#/technology/mall_tiny_elk);
- 使用MinIO存储文件请参考:[前后端分离项目,如何优雅实现文件存储](http://www.macrozheng.com/#/technology/minio_use);
- 读写分离解决方案请参考:[你还在代码里做读写分离么,试试这个中间件吧](http://www.macrozheng.com/#/reference/gaea);
-- 如果想使用`Consul`作为注册及配置中心的话请参考:[Spring Cloud Consul:服务治理与配置中心](http://www.macrozheng.com/#/cloud/consul);
-- 如果想使用`Nacos`作为注册及配置中心的话请参考:[Spring Cloud Alibaba:Nacos 作为注册中心和配置中心使用](http://www.macrozheng.com/#/cloud/nacos);
- `分布式事务`解决方案请参考:[使用Seata彻底解决Spring Cloud中的分布式事务问题!](http://www.macrozheng.com/#/cloud/seata)。
> Docker环境部署
@@ -120,21 +120,31 @@ nginx | 1.10 | http://nginx.org/en/download.html
## 运行效果展示
-- 注册中心控制台信息:
+- 查看注册中心注册服务信息,访问地址:http://192.168.3.101:8848/nacos/
-
+
-- 监控中心应用信息:
+- 监控中心应用信息,访问地址:http://192.168.3.101:8101
-
+
-
+
-- 可视化容器管理:
+
-
+- API文档信息,访问地址:http://192.168.3.101:8201
-
+
+
+- 日志收集系统信息,访问地址:http://192.168.3.101:5601
+
+
+
+- 可视化容器管理,访问地址:http://192.168.3.101:9000
+
+
+
+
## 公众号
diff --git a/mall-config/src/main/resources/config/admin/admin-dev.yml b/config/admin/mall-admin-dev.yaml
similarity index 69%
rename from mall-config/src/main/resources/config/admin/admin-dev.yml
rename to config/admin/mall-admin-dev.yaml
index 3395943..8762958 100644
--- a/mall-config/src/main/resources/config/admin/admin-dev.yml
+++ b/config/admin/mall-admin-dev.yaml
@@ -15,7 +15,15 @@ spring:
url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: root
+ redis:
+ host: localhost # Redis服务器地址
+ database: 0 # Redis数据库索引(默认为0)
+ port: 6379 # Redis服务器连接端口
+ password: # Redis服务器连接密码(默认为空)
+ timeout: 3000ms # 连接超时时间(毫秒)
logging:
level:
- root: info #日志配置DEBUG,INFO,WARN,ERROR
- com.macro.mall: debug
\ No newline at end of file
+ root: info
+ com.macro.mall: debug
+logstash:
+ host: localhost
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/admin/admin-prod.yml b/config/admin/mall-admin-prod.yaml
similarity index 72%
rename from mall-config/src/main/resources/config/admin/admin-prod.yml
rename to config/admin/mall-admin-prod.yaml
index a0002db..52e3f79 100644
--- a/mall-config/src/main/resources/config/admin/admin-prod.yml
+++ b/config/admin/mall-admin-prod.yaml
@@ -15,5 +15,16 @@ spring:
url: jdbc:mysql://db:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: reader
password: 123456
+ redis:
+ host: redis # Redis服务器地址
+ database: 0 # Redis数据库索引(默认为0)
+ port: 6379 # Redis服务器连接端口
+ password: #不设置密码
logging:
- path: /var/logs #配置日志生成路径
\ No newline at end of file
+ file:
+ path: /var/logs
+ level:
+ root: info
+ com.macro.mall: info
+logstash:
+ host: logstash
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/demo/demo-dev.yml b/config/demo/mall-demo-dev.yaml
similarity index 66%
rename from mall-config/src/main/resources/config/demo/demo-dev.yml
rename to config/demo/mall-demo-dev.yaml
index 6f0240f..53e977f 100644
--- a/mall-config/src/main/resources/config/demo/demo-dev.yml
+++ b/config/demo/mall-demo-dev.yaml
@@ -5,6 +5,7 @@ spring:
password: root
logging:
level:
- root: info #日志配置DEBUG,INFO,WARN,ERROR
+ root: info
com.macro.mall: debug
- com.macro.mall.demo.service.FeignAdminService: debug
\ No newline at end of file
+logstash:
+ host: localhost
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/demo/demo-prod.yml b/config/demo/mall-demo-prod.yaml
similarity index 63%
rename from mall-config/src/main/resources/config/demo/demo-prod.yml
rename to config/demo/mall-demo-prod.yaml
index 4e49a5f..1f6e91d 100644
--- a/mall-config/src/main/resources/config/demo/demo-prod.yml
+++ b/config/demo/mall-demo-prod.yaml
@@ -4,4 +4,10 @@ spring:
username: reader
password: 123456
logging:
- path: /var/logs #配置日志生成路径
\ No newline at end of file
+ file:
+ path: /var/logs
+ level:
+ root: info
+ com.macro.mall: info
+logstash:
+ host: logstash
\ No newline at end of file
diff --git a/config/gateway/mall-gateway-dev.yaml b/config/gateway/mall-gateway-dev.yaml
new file mode 100644
index 0000000..38661e4
--- /dev/null
+++ b/config/gateway/mall-gateway-dev.yaml
@@ -0,0 +1,18 @@
+spring:
+ redis:
+ host: localhost # Redis服务器地址
+ database: 0 # Redis数据库索引(默认为0)
+ port: 6379 # Redis服务器连接端口
+ password: # Redis服务器连接密码(默认为空)
+ timeout: 3000ms # 连接超时时间(毫秒)
+ security:
+ oauth2:
+ resourceserver:
+ jwt:
+ jwk-set-uri: 'http://localhost:8201/mall-auth/rsa/publicKey'
+logging:
+ level:
+ root: info
+ com.macro.mall: debug
+logstash:
+ host: localhost
\ No newline at end of file
diff --git a/config/gateway/mall-gateway-prod.yaml b/config/gateway/mall-gateway-prod.yaml
new file mode 100644
index 0000000..0a5f108
--- /dev/null
+++ b/config/gateway/mall-gateway-prod.yaml
@@ -0,0 +1,19 @@
+spring:
+ redis:
+ host: redis # Redis服务器地址
+ database: 0 # Redis数据库索引(默认为0)
+ port: 6379 # Redis服务器连接端口
+ password: #不设置密码
+ security:
+ oauth2:
+ resourceserver:
+ jwt:
+ jwk-set-uri: 'http://mall-gateway:8201/mall-auth/rsa/publicKey'
+logging:
+ file:
+ path: /var/logs
+ level:
+ root: info
+ com.macro.mall: info
+logstash:
+ host: logstash
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/portal/portal-dev.yml b/config/portal/mall-portal-dev.yaml
similarity index 75%
rename from mall-config/src/main/resources/config/portal/portal-dev.yml
rename to config/portal/mall-portal-dev.yaml
index 75c292b..6b8d6df 100644
--- a/mall-config/src/main/resources/config/portal/portal-dev.yml
+++ b/config/portal/mall-portal-dev.yaml
@@ -19,10 +19,10 @@ spring:
virtual-host: /mall
username: mall
password: mall
- publisher-confirms: true #如果对异步消息需要回调必须设置为true
# 日志配置
logging:
level:
- org.springframework.data.mongodb.core: debug
- com.macro.mall.mapper: debug
- com.macro.mall.portal.dao: debug
\ No newline at end of file
+ root: info
+ com.macro.mall: debug
+logstash:
+ host: localhost
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/portal/portal-prod.yml b/config/portal/mall-portal-prod.yaml
similarity index 84%
rename from mall-config/src/main/resources/config/portal/portal-prod.yml
rename to config/portal/mall-portal-prod.yaml
index accb7f9..2a898d9 100644
--- a/mall-config/src/main/resources/config/portal/portal-prod.yml
+++ b/config/portal/mall-portal-prod.yaml
@@ -20,4 +20,12 @@ spring:
username: mall
password: mall
publisher-confirms: true #如果对异步消息需要回调必须设置为true
+logging:
+ file:
+ path: /var/logs
+ level:
+ root: info
+ com.macro.mall: info
+logstash:
+ host: logstash
diff --git a/mall-config/src/main/resources/config/search/search-dev.yml b/config/search/mall-search-dev.yaml
similarity index 59%
rename from mall-config/src/main/resources/config/search/search-dev.yml
rename to config/search/mall-search-dev.yaml
index 38ee08e..1507e16 100644
--- a/mall-config/src/main/resources/config/search/search-dev.yml
+++ b/config/search/mall-search-dev.yaml
@@ -3,14 +3,12 @@ spring:
url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root
password: root
- data:
- elasticsearch:
- cluster-nodes: 127.0.0.1:9300
- cluster-name: elasticsearch
elasticsearch:
rest:
uris: http://localhost:9200
logging:
level:
- root: info #日志配置DEBUG,INFO,WARN,ERROR
- com.macro.mall: debug
\ No newline at end of file
+ root: info
+ com.macro.mall: debug
+logstash:
+ host: localhost
\ No newline at end of file
diff --git a/mall-config/src/main/resources/config/search/search-prod.yml b/config/search/mall-search-prod.yaml
similarity index 58%
rename from mall-config/src/main/resources/config/search/search-prod.yml
rename to config/search/mall-search-prod.yaml
index 3496b41..b7c1d48 100644
--- a/mall-config/src/main/resources/config/search/search-prod.yml
+++ b/config/search/mall-search-prod.yaml
@@ -3,16 +3,18 @@ spring:
url: jdbc:mysql://db:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: reader
password: 123456
- data:
- elasticsearch:
- cluster-nodes: es:9300
- cluster-name: elasticsearch
elasticsearch:
rest:
uris: http://es:9200
-logging:
- path: /var/logs #配置日志生成路径
management:
health:
elasticsearch:
- response-timeout: 1000ms #加大健康检查超时时间
\ No newline at end of file
+ response-timeout: 1000ms #加大健康检查超时时间
+logging:
+ file:
+ path: /var/logs
+ level:
+ root: info
+ com.macro.mall: info
+logstash:
+ host: logstash
\ No newline at end of file
diff --git a/document/docker/docker-compose-app.yml b/document/docker/docker-compose-app.yml
index 42c9381..6eaf166 100644
--- a/document/docker/docker-compose-app.yml
+++ b/document/docker/docker-compose-app.yml
@@ -5,23 +5,78 @@ services:
container_name: mall-admin
ports:
- 8080:8080
+ volumes:
+ - /mydata/app/mall-admin/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
external_links:
- mysql:db #可以用db这个域名访问mysql服务
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
mall-search:
image: mall/mall-search:1.0-SNAPSHOT
container_name: mall-search
ports:
- 8081:8081
+ volumes:
+ - /mydata/app/mall-search/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
external_links:
- elasticsearch:es #可以用es这个域名访问elasticsearch服务
- mysql:db #可以用db这个域名访问mysql服务
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
mall-portal:
image: mall/mall-portal:1.0-SNAPSHOT
container_name: mall-portal
ports:
- 8085:8085
+ volumes:
+ - /mydata/app/mall-portal/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
external_links:
- redis:redis #可以用redis这个域名访问redis服务
- mongo:mongo #可以用mongo这个域名访问mongo服务
- mysql:db #可以用db这个域名访问mysql服务
- - rabbitmq:rabbit #可以用rabbit这个域名访问rabbitmq服务
\ No newline at end of file
+ - rabbitmq:rabbit #可以用rabbit这个域名访问rabbitmq服务
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
+ mall-auth:
+ image: mall/mall-auth:1.0-SNAPSHOT
+ container_name: mall-auth
+ ports:
+ - 8401:8401
+ volumes:
+ - /mydata/app/mall-auth/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
+ external_links:
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
+ mall-gateway:
+ image: mall/mall-gateway:1.0-SNAPSHOT
+ container_name: mall-gateway
+ ports:
+ - 8201:8201
+ volumes:
+ - /mydata/app/mall-gateway/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
+ external_links:
+ - redis:redis #可以用redis这个域名访问redis服务
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
+ mall-monitor:
+ image: mall/mall-monitor:1.0-SNAPSHOT
+ container_name: mall-monitor
+ ports:
+ - 8101:8101
+ volumes:
+ - /mydata/app/mall-monitor/logs:/var/logs
+ - /etc/localtime:/etc/localtime
+ environment:
+ - 'TZ="Asia/Shanghai"'
+ external_links:
+ - nacos-registry:nacos-registry #可以用nacos-registry这个域名访问nacos服务
\ No newline at end of file
diff --git a/document/docker/docker-compose-env.yml b/document/docker/docker-compose-env.yml
index b4e1f82..c292a83 100644
--- a/document/docker/docker-compose-env.yml
+++ b/document/docker/docker-compose-env.yml
@@ -14,7 +14,7 @@ services:
- /mydata/mysql/data/conf:/etc/mysql/conf.d #配置文件挂载
- /mydata/mysql/log:/var/log/mysql #日志文件挂载
redis:
- image: redis:3.2
+ image: redis:5
container_name: redis
command: redis-server --appendonly yes
volumes:
@@ -40,8 +40,9 @@ services:
- 5672:5672
- 15672:15672
elasticsearch:
- image: elasticsearch:6.4.0
+ image: elasticsearch:7.6.2
container_name: elasticsearch
+ user: root
environment:
- "cluster.name=elasticsearch" #设置集群名称为elasticsearch
- "discovery.type=single-node" #以单一节点模式启动
@@ -52,8 +53,24 @@ services:
ports:
- 9200:9200
- 9300:9300
+ logstash:
+ image: logstash:7.6.2
+ container_name: logstash
+ environment:
+ - TZ=Asia/Shanghai
+ volumes:
+ - /mydata/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf #挂载logstash的配置文件
+ depends_on:
+ - elasticsearch #kibana在elasticsearch启动之后再启动
+ links:
+ - elasticsearch:es #可以用es这个域名访问elasticsearch服务
+ ports:
+ - 4560:4560
+ - 4561:4561
+ - 4562:4562
+ - 4563:4563
kibana:
- image: kibana:6.4.0
+ image: kibana:7.6.2
container_name: kibana
links:
- elasticsearch:es #可以用es这个域名访问elasticsearch服务
@@ -64,9 +81,16 @@ services:
ports:
- 5601:5601
mongo:
- image: mongo:3.2
+ image: mongo:4.2.5
container_name: mongo
volumes:
- /mydata/mongo/db:/data/db #数据文件挂载
ports:
- - 27017:27017
\ No newline at end of file
+ - 27017:27017
+ nacos-registry:
+ image: nacos/nacos-server:1.3.0
+ container_name: nacos-registry
+ environment:
+ - "MODE=standalone"
+ ports:
+ - 8848:8848
diff --git a/document/docker/docker-deploy.md b/document/docker/docker-deploy.md
deleted file mode 100644
index 8cd872f..0000000
--- a/document/docker/docker-deploy.md
+++ /dev/null
@@ -1,149 +0,0 @@
-# docker环境部署
-
-## docker环境安装
-### docker安装
-1. 安装yum-utils:
-yum install -y yum-utils \
-device-mapper-persistent-data \
-lvm2
-2. 为yum源添加docker仓库位置:
-yum-config-manager \
---add-repo \
-https://download.docker.com/linux/centos/docker-ce.repo
-3. 安装docker:
-yum install docker-ce
-4. 启动docker:
-systemctl start docker
-注:常见命令见document/reference文件夹中的docker.md
-5. 安装上传下载插件:
-yum -y install lrzsz
-### docker compose安装
-1. 下载地址:https://github.com/docker/compose/releases
-2. 安装地址:/usr/local/bin/docker-compose
-3. 设置为可执行:sudo chmod +x /usr/local/bin/docker-compose
-4. 测试是否安装成功:docker-compose --version
-
-## mysql安装
-### 下载镜像文件
-docker pull mysql:5.7
-### 创建实例并启动
-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
-> 参数说明
-- -p 3306:3306:将容器的3306端口映射到主机的3306端口
-- -v /mydata/mysql/conf:/etc/mysql:将配置文件夹挂在到主机
-- -v /mydata/mysql/log:/var/log/mysql:将日志文件夹挂载到主机
-- -v /mydata/mysql/data:/var/lib/mysql/:将配置文件夹挂载到主机
-- -e MYSQL_ROOT_PASSWORD=root:初始化root用户的密码
-### 通过容器的mysql命令行工具连接
-docker exec -it mysql mysql -uroot -proot
-### 设置远程访问
-grant all privileges on *.* to 'root' @'%' identified by 'root';
-flush privileges;
-### 进入容器文件系统
-docker exec -it mysql /bin/bash
-
-## redis安装
-### 下载镜像文件
-docker pull redis:3.2
-### 创建实例并启动
-docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data -d redis:3.2 redis-server --appendonly yes
-### 使用redis镜像执行redis-cli命令连接
-docker exec -it redis redis-cli
-
-## nginx安装
-### 下载镜像文件
-docker pull nginx:1.10
-### 创建实例并启动
-docker run -p 80:80 --name nginx \
--v /mydata/nginx/html:/usr/share/nginx/html \
--v /mydata/nginx/logs:/var/log/nginx \
--d nginx:1.10
-### 修改nginx配置
-1. 将容器内的配置文件拷贝到当前目录:docker container cp nginx:/etc/nginx .
-2. 修改文件名称:mv nginx conf
-3. 终止容器:docker stop nginx
-4. 执行命令删除原容器:docker rm $ContainerId
-5. 执行以下命令:
-docker run -p 80:80 --name nginx \
--v /mydata/nginx/html:/usr/share/nginx/html \
--v /mydata/nginx/logs:/var/log/nginx \
--v /mydata/nginx/conf:/etc/nginx \
--d nginx:1.10
-
-## rabbitmq安装
-### 下载镜像文件
-docker pull rabbitmq:management
-### 创建实例并启动
-docker run -d --name rabbitmq --publish 5671:5671 \
- --publish 5672:5672 --publish 4369:4369 --publish 25672:25672 --publish 15671:15671 --publish 15672:15672 \
-rabbitmq:management
-
-## elasticsearch安装
-### 下载镜像文件
-docker pull elasticsearch:6.4.0
-### 创建实例并运行
-docker run -p 9200:9200 -p 9300:9300 --name elasticsearch \
--v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
--v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
--d elasticsearch:6.4.0
-### 测试
-访问会返回版本信息:http://192.168.1.66:9200/
-### 安装目录位置
-/usr/share/elasticsearch
-### 安装head插件(可以不安装,仅用于测试)
-1. 进入docker内部bash:docker exec -it elasticsearch /bin/bash
-2. 安装插件,具体参考:https://github.com/mobz/elasticsearch-head
-3. 测试:http://192.168.1.66:9200/_plugin/head/
-### 安装中文分词器IKAnalyzer
-1. 进入docker内部bash:docker exec -it elasticsearch /bin/bash
-2. 安装中文分词插件,执行以下命令:elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.2/elasticsearch-analysis-ik-6.2.2.zip
-3. 测试:
- - 访问header插件:打开地址http://192.168.1.66:9200/_plugin/head/
- - 选择复合查询,输入地址:POST:http://192.168.1.66:9200/_analyze
- - 输入参数:JSON:{"analyzer":"ik","text":"我们是大数据开发人员"}
-
-## mongodb安装
-### 下载镜像文件
-docker pull mongo:3.2
-### 创建实例并运行
-docker run -p 27017:27017 --name mongo -v /mydata/mongo/db:/data/db -d mongo:3.2
-### 使用mongo命令进入容器
-docker exec -it mongo mongo
-
-## SpringBoot应用命令部署
-**docker容器间进行连接才能互相访问**
-### 部署mall-admin
-docker run -p 8080:8080 --name mall-admin \
---link mysql:db \
--v /etc/timezone:/etc/timezone \
--v /etc/localtime:/etc/localtime \
--v /mydata/app/admin/logs:/var/logs \
--d mall/mall-admin:1.0-SNAPSHOT
-### 部署mall-search
-docker run -p 8081:8081 --name mall-search \
---link elasticsearch:es \
---link mysql:db \
--v /etc/timezone:/etc/timezone \
--v /etc/localtime:/etc/localtime \
--v /mydata/app/search/logs:/var/logs \
--d mall/mall-search:1.0-SNAPSHOT
-### 部署mall-port
-docker run -p 8085:8085 --name mall-portal \
---link mysql:db \
---link redis:redis \
---link mongo:mongo \
--v /etc/timezone:/etc/timezone \
--v /etc/localtime:/etc/localtime \
--v /mydata/app/portal/logs:/var/logs \
--d mall/mall-portal:1.0-SNAPSHOT
-
-## SpringBoot应用自动化部署
-### 部署文件
-document/docker/docker-compose.yml
-### 部署命令
-docker-compose up -d
\ No newline at end of file
diff --git a/document/elk/logstash-springboot.conf b/document/elk/logstash-springboot.conf
deleted file mode 100644
index a71e919..0000000
--- a/document/elk/logstash-springboot.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-input {
- tcp {
- mode => "server"
- host => "0.0.0.0"
- port => 4560
- codec => json_lines
- }
-}
-output {
- elasticsearch {
- hosts => "es:9200"
- index => "springboot-logstash-%{+YYYY.MM.dd}"
- }
-}
\ No newline at end of file
diff --git a/document/elk/logstash.conf b/document/elk/logstash.conf
new file mode 100644
index 0000000..953d054
--- /dev/null
+++ b/document/elk/logstash.conf
@@ -0,0 +1,49 @@
+input {
+ tcp {
+ mode => "server"
+ host => "0.0.0.0"
+ port => 4560
+ codec => json_lines
+ type => "debug"
+ }
+ tcp {
+ mode => "server"
+ host => "0.0.0.0"
+ port => 4561
+ codec => json_lines
+ type => "error"
+ }
+ tcp {
+ mode => "server"
+ host => "0.0.0.0"
+ port => 4562
+ codec => json_lines
+ type => "business"
+ }
+ tcp {
+ mode => "server"
+ host => "0.0.0.0"
+ port => 4563
+ codec => json_lines
+ type => "record"
+ }
+}
+filter{
+ if [type] == "record" {
+ mutate {
+ remove_field => "port"
+ remove_field => "host"
+ remove_field => "@version"
+ }
+ json {
+ source => "message"
+ remove_field => ["message"]
+ }
+ }
+}
+output {
+ elasticsearch {
+ hosts => "es:9200"
+ index => "mall-%{type}-%{+YYYY.MM.dd}"
+ }
+}
\ No newline at end of file
diff --git a/document/resource/mall_swarm_linux_02.png b/document/resource/mall_swarm_linux_02.png
deleted file mode 100644
index 970955c..0000000
Binary files a/document/resource/mall_swarm_linux_02.png and /dev/null differ
diff --git a/document/resource/mall_swarm_linux_04.png b/document/resource/mall_swarm_linux_04.png
deleted file mode 100644
index 471974a..0000000
Binary files a/document/resource/mall_swarm_linux_04.png and /dev/null differ
diff --git a/document/resource/mall_swarm_linux_07.png b/document/resource/mall_swarm_linux_07.png
deleted file mode 100644
index 45bf959..0000000
Binary files a/document/resource/mall_swarm_linux_07.png and /dev/null differ
diff --git a/document/resource/mall_swarm_linux_08.png b/document/resource/mall_swarm_linux_08.png
deleted file mode 100644
index 6b7c8b1..0000000
Binary files a/document/resource/mall_swarm_linux_08.png and /dev/null differ
diff --git a/document/resource/mall_swarm_linux_09.png b/document/resource/mall_swarm_linux_09.png
deleted file mode 100644
index 14961fc..0000000
Binary files a/document/resource/mall_swarm_linux_09.png and /dev/null differ
diff --git a/document/resource/mall_swarm_run_01.png b/document/resource/mall_swarm_run_01.png
new file mode 100644
index 0000000..5254d49
Binary files /dev/null and b/document/resource/mall_swarm_run_01.png differ
diff --git a/document/resource/mall_swarm_run_02.png b/document/resource/mall_swarm_run_02.png
new file mode 100644
index 0000000..635d3e2
Binary files /dev/null and b/document/resource/mall_swarm_run_02.png differ
diff --git a/document/resource/mall_swarm_run_03.png b/document/resource/mall_swarm_run_03.png
new file mode 100644
index 0000000..74327bb
Binary files /dev/null and b/document/resource/mall_swarm_run_03.png differ
diff --git a/document/resource/mall_swarm_run_04.png b/document/resource/mall_swarm_run_04.png
new file mode 100644
index 0000000..e3de4b9
Binary files /dev/null and b/document/resource/mall_swarm_run_04.png differ
diff --git a/document/resource/mall_swarm_run_05.png b/document/resource/mall_swarm_run_05.png
new file mode 100644
index 0000000..1bbfe3e
Binary files /dev/null and b/document/resource/mall_swarm_run_05.png differ
diff --git a/document/resource/mall_swarm_run_06.png b/document/resource/mall_swarm_run_06.png
new file mode 100644
index 0000000..d5e4acc
Binary files /dev/null and b/document/resource/mall_swarm_run_06.png differ
diff --git a/document/resource/mall_swarm_run_07.png b/document/resource/mall_swarm_run_07.png
new file mode 100644
index 0000000..07143a7
Binary files /dev/null and b/document/resource/mall_swarm_run_07.png differ
diff --git a/document/resource/mall_swarm_run_08.png b/document/resource/mall_swarm_run_08.png
new file mode 100644
index 0000000..53721a3
Binary files /dev/null and b/document/resource/mall_swarm_run_08.png differ
diff --git a/document/resource/mall_swarm_run_09.png b/document/resource/mall_swarm_run_09.png
new file mode 100644
index 0000000..819234d
Binary files /dev/null and b/document/resource/mall_swarm_run_09.png differ
diff --git a/document/resource/mall_swarm_run_10.png b/document/resource/mall_swarm_run_10.png
new file mode 100644
index 0000000..64f5f98
Binary files /dev/null and b/document/resource/mall_swarm_run_10.png differ
diff --git a/document/resource/mall_swarm_run_11.png b/document/resource/mall_swarm_run_11.png
new file mode 100644
index 0000000..db31253
Binary files /dev/null and b/document/resource/mall_swarm_run_11.png differ
diff --git a/document/resource/rabbitmq_install_1.png b/document/resource/rabbitmq_install_1.png
deleted file mode 100644
index 73d4586..0000000
Binary files a/document/resource/rabbitmq_install_1.png and /dev/null differ
diff --git a/document/resource/rabbitmq_install_2.png b/document/resource/rabbitmq_install_2.png
deleted file mode 100644
index 89dee1b..0000000
Binary files a/document/resource/rabbitmq_install_2.png and /dev/null differ
diff --git a/document/resource/rabbitmq_install_3.png b/document/resource/rabbitmq_install_3.png
deleted file mode 100644
index d3fe850..0000000
Binary files a/document/resource/rabbitmq_install_3.png and /dev/null differ
diff --git a/document/resource/rabbitmq_install_4.png b/document/resource/rabbitmq_install_4.png
deleted file mode 100644
index 7426be6..0000000
Binary files a/document/resource/rabbitmq_install_4.png and /dev/null differ
diff --git a/mall-admin/pom.xml b/mall-admin/pom.xml
index 43902bf..5fb8c82 100644
--- a/mall-admin/pom.xml
+++ b/mall-admin/pom.xml
@@ -22,29 +22,37 @@
mall-mbg
- com.macro.mall
- mall-security
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
- org.springframework.cloud
- spring-cloud-starter-netflix-eureka-client
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
- org.springframework.cloud
- spring-cloud-starter-config
+ org.springframework.boot
+ spring-boot-starter-data-redis
com.aliyun.oss
aliyun-sdk-oss
-
- net.logstash.logback
- logstash-logback-encoder
-
io.minio
minio
+
+ jakarta.validation
+ jakarta.validation-api
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
+
diff --git a/mall-admin/src/main/java/com/macro/mall/MallAdminApplication.java b/mall-admin/src/main/java/com/macro/mall/MallAdminApplication.java
index 2f95822..8e1e27b 100644
--- a/mall-admin/src/main/java/com/macro/mall/MallAdminApplication.java
+++ b/mall-admin/src/main/java/com/macro/mall/MallAdminApplication.java
@@ -3,11 +3,13 @@ package com.macro.mall;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 应用启动入口
* Created by macro on 2018/4/26.
*/
+@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class MallAdminApplication {
diff --git a/mall-admin/src/main/java/com/macro/mall/bo/AdminUserDetails.java b/mall-admin/src/main/java/com/macro/mall/bo/AdminUserDetails.java
deleted file mode 100644
index a46ab68..0000000
--- a/mall-admin/src/main/java/com/macro/mall/bo/AdminUserDetails.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.macro.mall.bo;
-
-import com.macro.mall.model.UmsAdmin;
-import com.macro.mall.model.UmsResource;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * SpringSecurity需要的用户详情
- * Created by macro on 2018/4/26.
- */
-public class AdminUserDetails implements UserDetails {
- private UmsAdmin umsAdmin;
- private List resourceList;
- public AdminUserDetails(UmsAdmin umsAdmin,List resourceList) {
- this.umsAdmin = umsAdmin;
- this.resourceList = resourceList;
- }
-
- @Override
- public Collection extends GrantedAuthority> getAuthorities() {
- //返回当前用户的角色
- return resourceList.stream()
- .map(role ->new SimpleGrantedAuthority(role.getId()+":"+role.getName()))
- .collect(Collectors.toList());
- }
-
- @Override
- public String getPassword() {
- return umsAdmin.getPassword();
- }
-
- @Override
- public String getUsername() {
- return umsAdmin.getUsername();
- }
-
- @Override
- public boolean isAccountNonExpired() {
- return true;
- }
-
- @Override
- public boolean isAccountNonLocked() {
- return true;
- }
-
- @Override
- public boolean isCredentialsNonExpired() {
- return true;
- }
-
- @Override
- public boolean isEnabled() {
- return umsAdmin.getStatus().equals(1);
- }
-}
diff --git a/mall-admin/src/main/java/com/macro/mall/bo/WebLog.java b/mall-admin/src/main/java/com/macro/mall/bo/WebLog.java
deleted file mode 100644
index 98c51dd..0000000
--- a/mall-admin/src/main/java/com/macro/mall/bo/WebLog.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.macro.mall.bo;
-
-/**
- * Controller层的日志封装类
- * Created by macro on 2018/4/26.
- */
-public class WebLog {
- /**
- * 操作描述
- */
- private String description;
-
- /**
- * 操作用户
- */
- private String username;
-
- /**
- * 操作时间
- */
- private Long startTime;
-
- /**
- * 消耗时间
- */
- private Integer spendTime;
-
- /**
- * 根路径
- */
- private String basePath;
-
- /**
- * URI
- */
- private String uri;
-
- /**
- * URL
- */
- private String url;
-
- /**
- * 请求类型
- */
- private String method;
-
- /**
- * IP地址
- */
- private String ip;
-
- private Object parameter;
-
- private Object result;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public Long getStartTime() {
- return startTime;
- }
-
- public void setStartTime(Long startTime) {
- this.startTime = startTime;
- }
-
- public Integer getSpendTime() {
- return spendTime;
- }
-
- public void setSpendTime(Integer spendTime) {
- this.spendTime = spendTime;
- }
-
- public String getBasePath() {
- return basePath;
- }
-
- public void setBasePath(String basePath) {
- this.basePath = basePath;
- }
-
- public String getUri() {
- return uri;
- }
-
- public void setUri(String uri) {
- this.uri = uri;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getMethod() {
- return method;
- }
-
- public void setMethod(String method) {
- this.method = method;
- }
-
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public Object getParameter() {
- return parameter;
- }
-
- public void setParameter(Object parameter) {
- this.parameter = parameter;
- }
-
- public Object getResult() {
- return result;
- }
-
- public void setResult(Object result) {
- this.result = result;
- }
-}
diff --git a/mall-admin/src/main/java/com/macro/mall/component/ResourceRoleRulesHolder.java b/mall-admin/src/main/java/com/macro/mall/component/ResourceRoleRulesHolder.java
new file mode 100644
index 0000000..721094c
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/component/ResourceRoleRulesHolder.java
@@ -0,0 +1,23 @@
+package com.macro.mall.component;
+
+import com.macro.mall.service.UmsResourceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * 资源与角色访问对应关系操作组件
+ * Created by macro on 2020/7/17.
+ */
+@Component
+public class ResourceRoleRulesHolder {
+
+ @Autowired
+ private UmsResourceService resourceService;
+
+ @PostConstruct
+ public void initResourceRolesMap(){
+ resourceService.initResourceRolesMap();
+ }
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/config/GlobalCorsConfig.java b/mall-admin/src/main/java/com/macro/mall/config/GlobalCorsConfig.java
deleted file mode 100644
index f07d095..0000000
--- a/mall-admin/src/main/java/com/macro/mall/config/GlobalCorsConfig.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.macro.mall.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-/**
- * 全局跨域配置
- * 注意:前端从网关进行调用时不需要配置
- * Created by macro on 2019/7/27.
- */
-//@Configuration
-public class GlobalCorsConfig {
-
- /**
- * 允许跨域调用的过滤器
- */
- @Bean
- public CorsFilter corsFilter() {
- CorsConfiguration config = new CorsConfiguration();
- //允许所有域名进行跨域调用
- config.addAllowedOrigin("*");
- //允许跨越发送cookie
- config.setAllowCredentials(true);
- //放行全部原始头信息
- config.addAllowedHeader("*");
- //允许所有请求方法跨域调用
- config.addAllowedMethod("*");
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- source.registerCorsConfiguration("/**", config);
- return new CorsFilter(source);
- }
-}
diff --git a/mall-admin/src/main/java/com/macro/mall/config/MallSecurityConfig.java b/mall-admin/src/main/java/com/macro/mall/config/MallSecurityConfig.java
deleted file mode 100644
index 23b6f15..0000000
--- a/mall-admin/src/main/java/com/macro/mall/config/MallSecurityConfig.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.macro.mall.config;
-
-import com.macro.mall.model.UmsResource;
-import com.macro.mall.security.component.DynamicSecurityService;
-import com.macro.mall.security.config.SecurityConfig;
-import com.macro.mall.service.UmsAdminService;
-import com.macro.mall.service.UmsResourceService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.access.ConfigAttribute;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.core.userdetails.UserDetailsService;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * mall-security模块相关配置
- * Created by macro on 2019/11/9.
- */
-@Configuration
-@EnableWebSecurity
-@EnableGlobalMethodSecurity(prePostEnabled = true)
-public class MallSecurityConfig extends SecurityConfig {
-
- @Autowired
- private UmsAdminService adminService;
- @Autowired
- private UmsResourceService resourceService;
-
- @Bean
- public UserDetailsService userDetailsService() {
- //获取登录用户信息
- return username -> adminService.loadUserByUsername(username);
- }
-
- @Bean
- public DynamicSecurityService dynamicSecurityService() {
- return new DynamicSecurityService() {
- @Override
- public Map loadDataSource() {
- Map map = new ConcurrentHashMap<>();
- List resourceList = resourceService.listAll();
- for (UmsResource resource : resourceList) {
- map.put(resource.getUrl(), new org.springframework.security.access.SecurityConfig(resource.getId() + ":" + resource.getName()));
- }
- return map;
- }
- };
- }
-}
diff --git a/mall-admin/src/main/java/com/macro/mall/config/MyBatisConfig.java b/mall-admin/src/main/java/com/macro/mall/config/MyBatisConfig.java
index 4f0677a..1164256 100644
--- a/mall-admin/src/main/java/com/macro/mall/config/MyBatisConfig.java
+++ b/mall-admin/src/main/java/com/macro/mall/config/MyBatisConfig.java
@@ -5,7 +5,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
- * MyBatis配置类
+ * MyBatis相关配置
* Created by macro on 2019/4/8.
*/
@Configuration
diff --git a/mall-admin/src/main/java/com/macro/mall/config/OssConfig.java b/mall-admin/src/main/java/com/macro/mall/config/OssConfig.java
index d0112a9..9f7da2a 100644
--- a/mall-admin/src/main/java/com/macro/mall/config/OssConfig.java
+++ b/mall-admin/src/main/java/com/macro/mall/config/OssConfig.java
@@ -6,6 +6,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
+ * OSS对象存储相关配置
* Created by macro on 2018/5/17.
*/
@Configuration
diff --git a/mall-admin/src/main/java/com/macro/mall/config/RedisConfig.java b/mall-admin/src/main/java/com/macro/mall/config/RedisConfig.java
new file mode 100644
index 0000000..90bba12
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/config/RedisConfig.java
@@ -0,0 +1,19 @@
+package com.macro.mall.config;
+
+import com.macro.mall.common.config.BaseRedisConfig;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * Redis相关配置
+ * Created by macro on 2020/6/19.
+ */
+@Configuration
+public class RedisConfig extends BaseRedisConfig {
+
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/config/Swagger2Config.java b/mall-admin/src/main/java/com/macro/mall/config/Swagger2Config.java
deleted file mode 100644
index a3da046..0000000
--- a/mall-admin/src/main/java/com/macro/mall/config/Swagger2Config.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.macro.mall.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.ApiKey;
-import springfox.documentation.service.AuthorizationScope;
-import springfox.documentation.service.SecurityReference;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Swagger2API文档的配置
- * Created by macro on 2018/4/26.
- */
-@Configuration
-@EnableSwagger2
-public class Swagger2Config {
- @Bean
- public Docket createRestApi(){
- return new Docket(DocumentationType.SWAGGER_2)
- .apiInfo(apiInfo())
- .select()
- .apis(RequestHandlerSelectors.basePackage("com.macro.mall.controller"))
- .paths(PathSelectors.any())
- .build()
- .securitySchemes(securitySchemes())
- .securityContexts(securityContexts());
- }
-
- private ApiInfo apiInfo() {
- return new ApiInfoBuilder()
- .title("mall后台系统")
- .description("mall后台模块")
- .contact("macro")
- .version("1.0")
- .build();
- }
-
- private List securitySchemes() {
- //设置请求头信息
- List result = new ArrayList<>();
- ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
- result.add(apiKey);
- return result;
- }
-
- private List securityContexts() {
- //设置需要登录认证的路径
- List result = new ArrayList<>();
- result.add(getContextByPath("/brand/.*"));
- result.add(getContextByPath("/product/.*"));
- result.add(getContextByPath("/productCategory/.*"));
- return result;
- }
-
- private SecurityContext getContextByPath(String pathRegex){
- return SecurityContext.builder()
- .securityReferences(defaultAuth())
- .forPaths(PathSelectors.regex(pathRegex))
- .build();
- }
-
- private List defaultAuth() {
- List result = new ArrayList<>();
- AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
- AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
- authorizationScopes[0] = authorizationScope;
- result.add(new SecurityReference("Authorization", authorizationScopes));
- return result;
- }
-}
diff --git a/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java b/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java
new file mode 100644
index 0000000..37894e3
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/config/SwaggerConfig.java
@@ -0,0 +1,41 @@
+package com.macro.mall.config;
+
+import com.macro.mall.common.config.BaseSwaggerConfig;
+import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.ApiKey;
+import springfox.documentation.service.AuthorizationScope;
+import springfox.documentation.service.SecurityReference;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spi.service.contexts.SecurityContext;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Swagger API文档相关配置
+ * Created by macro on 2018/4/26.
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig extends BaseSwaggerConfig {
+
+ @Override
+ public SwaggerProperties swaggerProperties() {
+ return SwaggerProperties.builder()
+ .apiBasePackage("com.macro.mall.controller")
+ .title("mall后台系统")
+ .description("mall后台相关接口文档")
+ .contactName("macro")
+ .version("1.0")
+ .enableSecurity(true)
+ .build();
+ }
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java b/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
index 1958965..71e015b 100644
--- a/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
+++ b/mall-admin/src/main/java/com/macro/mall/controller/MinioController.java
@@ -1,9 +1,11 @@
package com.macro.mall.controller;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
import com.macro.mall.common.api.CommonResult;
+import com.macro.mall.dto.BucketPolicyConfigDto;
import com.macro.mall.dto.MinioUploadDto;
-import io.minio.MinioClient;
-import io.minio.policy.PolicyType;
+import io.minio.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@@ -20,6 +22,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
/**
+ * MinIO对象存储管理
* Created by macro on 2019/12/25.
*/
@Api(tags = "MinioController", description = "MinIO对象存储管理")
@@ -43,39 +46,68 @@ public class MinioController {
public CommonResult upload(@RequestParam("file") MultipartFile file) {
try {
//创建一个MinIO的Java客户端
- MinioClient minioClient = new MinioClient(ENDPOINT, ACCESS_KEY, SECRET_KEY);
- boolean isExist = minioClient.bucketExists(BUCKET_NAME);
+ MinioClient minioClient =MinioClient.builder()
+ .endpoint(ENDPOINT)
+ .credentials(ACCESS_KEY,SECRET_KEY)
+ .build();
+ boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(BUCKET_NAME).build());
if (isExist) {
LOGGER.info("存储桶已经存在!");
} else {
//创建存储桶并设置只读权限
- minioClient.makeBucket(BUCKET_NAME);
- minioClient.setBucketPolicy(BUCKET_NAME, "*.*", PolicyType.READ_ONLY);
+ minioClient.makeBucket(MakeBucketArgs.builder().bucket(BUCKET_NAME).build());
+ BucketPolicyConfigDto bucketPolicyConfigDto = createBucketPolicyConfigDto(BUCKET_NAME);
+ SetBucketPolicyArgs setBucketPolicyArgs = SetBucketPolicyArgs.builder()
+ .bucket(BUCKET_NAME)
+ .config(JSONUtil.toJsonStr(bucketPolicyConfigDto))
+ .build();
+ minioClient.setBucketPolicy(setBucketPolicyArgs);
}
String filename = file.getOriginalFilename();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
// 设置存储对象名称
String objectName = sdf.format(new Date()) + "/" + filename;
// 使用putObject上传一个文件到存储桶中
- minioClient.putObject(BUCKET_NAME, objectName, file.getInputStream(), file.getContentType());
+ PutObjectArgs putObjectArgs = PutObjectArgs.builder()
+ .bucket(BUCKET_NAME)
+ .object(objectName)
+ .contentType(file.getContentType())
+ .stream(file.getInputStream(), file.getSize(), ObjectWriteArgs.MIN_MULTIPART_SIZE).build();
+ minioClient.putObject(putObjectArgs);
LOGGER.info("文件上传成功!");
MinioUploadDto minioUploadDto = new MinioUploadDto();
minioUploadDto.setName(filename);
minioUploadDto.setUrl(ENDPOINT + "/" + BUCKET_NAME + "/" + objectName);
return CommonResult.success(minioUploadDto);
} catch (Exception e) {
+ e.printStackTrace();
LOGGER.info("上传发生错误: {}!", e.getMessage());
}
return CommonResult.failed();
}
+ private BucketPolicyConfigDto createBucketPolicyConfigDto(String bucketName) {
+ BucketPolicyConfigDto.Statement statement = BucketPolicyConfigDto.Statement.builder()
+ .Effect("Allow")
+ .Principal("*")
+ .Action("s3:GetObject")
+ .Resource("arn:aws:s3:::"+bucketName+"/*.**").build();
+ return BucketPolicyConfigDto.builder()
+ .Version("2012-10-17")
+ .Statement(CollUtil.toList(statement))
+ .build();
+ }
+
@ApiOperation("文件删除")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("objectName") String objectName) {
try {
- MinioClient minioClient = new MinioClient(ENDPOINT, ACCESS_KEY, SECRET_KEY);
- minioClient.removeObject(BUCKET_NAME, objectName);
+ MinioClient minioClient = MinioClient.builder()
+ .endpoint(ENDPOINT)
+ .credentials(ACCESS_KEY,SECRET_KEY)
+ .build();
+ minioClient.removeObject(RemoveObjectArgs.builder().bucket(BUCKET_NAME).object(objectName).build());
return CommonResult.success(null);
} catch (Exception e) {
e.printStackTrace();
diff --git a/mall-admin/src/main/java/com/macro/mall/controller/UmsAdminController.java b/mall-admin/src/main/java/com/macro/mall/controller/UmsAdminController.java
index ee36dc7..5237008 100644
--- a/mall-admin/src/main/java/com/macro/mall/controller/UmsAdminController.java
+++ b/mall-admin/src/main/java/com/macro/mall/controller/UmsAdminController.java
@@ -1,7 +1,9 @@
package com.macro.mall.controller;
+import cn.hutool.core.collection.CollUtil;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
+import com.macro.mall.common.domain.UserDto;
import com.macro.mall.dto.UmsAdminLoginParam;
import com.macro.mall.dto.UmsAdminParam;
import com.macro.mall.dto.UpdateAdminPasswordParam;
@@ -13,16 +15,14 @@ import com.macro.mall.service.UmsRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
-import javax.servlet.http.HttpServletRequest;
-import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* 后台用户管理
@@ -32,10 +32,6 @@ import java.util.Map;
@Api(tags = "UmsAdminController", description = "后台用户管理")
@RequestMapping("/admin")
public class UmsAdminController {
- @Value("${jwt.tokenHeader}")
- private String tokenHeader;
- @Value("${jwt.tokenHead}")
- private String tokenHead;
@Autowired
private UmsAdminService adminService;
@Autowired
@@ -56,45 +52,23 @@ public class UmsAdminController {
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public CommonResult login(@RequestBody UmsAdminLoginParam umsAdminLoginParam, BindingResult result) {
- String token = adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword());
- if (token == null) {
- return CommonResult.validateFailed("用户名或密码错误");
- }
- Map tokenMap = new HashMap<>();
- tokenMap.put("token", token);
- tokenMap.put("tokenHead", tokenHead);
- return CommonResult.success(tokenMap);
- }
-
- @ApiOperation(value = "刷新token")
- @RequestMapping(value = "/refreshToken", method = RequestMethod.GET)
- @ResponseBody
- public CommonResult refreshToken(HttpServletRequest request) {
- String token = request.getHeader(tokenHeader);
- String refreshToken = adminService.refreshToken(token);
- if (refreshToken == null) {
- return CommonResult.failed("token已经过期!");
- }
- Map tokenMap = new HashMap<>();
- tokenMap.put("token", refreshToken);
- tokenMap.put("tokenHead", tokenHead);
- return CommonResult.success(tokenMap);
+ return adminService.login(umsAdminLoginParam.getUsername(),umsAdminLoginParam.getPassword());
}
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
- public CommonResult getAdminInfo(Principal principal) {
- if(principal==null){
- return CommonResult.unauthorized(null);
- }
- String username = principal.getName();
- UmsAdmin umsAdmin = adminService.getAdminByUsername(username);
+ public CommonResult getAdminInfo() {
+ UmsAdmin umsAdmin = adminService.getCurrentAdmin();
Map data = new HashMap<>();
data.put("username", umsAdmin.getUsername());
- data.put("roles", new String[]{"TEST"});
data.put("menus", roleService.getMenuList(umsAdmin.getId()));
data.put("icon", umsAdmin.getIcon());
+ List roleList = adminService.getRoleList(umsAdmin.getId());
+ if(CollUtil.isNotEmpty(roleList)){
+ List roles = roleList.stream().map(UmsRole::getName).collect(Collectors.toList());
+ data.put("roles",roles);
+ }
return CommonResult.success(data);
}
@@ -215,4 +189,12 @@ public class UmsAdminController {
List permissionList = adminService.getPermissionList(adminId);
return CommonResult.success(permissionList);
}
+
+ @ApiOperation("根据用户名获取通用用户信息")
+ @RequestMapping(value = "/loadByUsername", method = RequestMethod.GET)
+ @ResponseBody
+ public UserDto loadUserByUsername(@RequestParam String username) {
+ UserDto userDTO = adminService.loadUserByUsername(username);
+ return userDTO;
+ }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/controller/UmsResourceController.java b/mall-admin/src/main/java/com/macro/mall/controller/UmsResourceController.java
index 09685e9..5261007 100644
--- a/mall-admin/src/main/java/com/macro/mall/controller/UmsResourceController.java
+++ b/mall-admin/src/main/java/com/macro/mall/controller/UmsResourceController.java
@@ -3,7 +3,6 @@ package com.macro.mall.controller;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.UmsResource;
-import com.macro.mall.security.component.DynamicSecurityMetadataSource;
import com.macro.mall.service.UmsResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -12,6 +11,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
+import java.util.Map;
/**
* 后台资源管理Controller
@@ -24,15 +24,12 @@ public class UmsResourceController {
@Autowired
private UmsResourceService resourceService;
- @Autowired
- private DynamicSecurityMetadataSource dynamicSecurityMetadataSource;
@ApiOperation("添加后台资源")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody UmsResource umsResource) {
int count = resourceService.create(umsResource);
- dynamicSecurityMetadataSource.clearDataSource();
if (count > 0) {
return CommonResult.success(count);
} else {
@@ -46,7 +43,6 @@ public class UmsResourceController {
public CommonResult update(@PathVariable Long id,
@RequestBody UmsResource umsResource) {
int count = resourceService.update(id, umsResource);
- dynamicSecurityMetadataSource.clearDataSource();
if (count > 0) {
return CommonResult.success(count);
} else {
@@ -67,7 +63,6 @@ public class UmsResourceController {
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = resourceService.delete(id);
- dynamicSecurityMetadataSource.clearDataSource();
if (count > 0) {
return CommonResult.success(count);
} else {
@@ -94,4 +89,12 @@ public class UmsResourceController {
List resourceList = resourceService.listAll();
return CommonResult.success(resourceList);
}
+
+ @ApiOperation("初始化资源角色关联数据")
+ @RequestMapping(value = "/initResourceRolesMap", method = RequestMethod.GET)
+ @ResponseBody
+ public CommonResult initResourceRolesMap() {
+ Map> resourceRolesMap = resourceService.initResourceRolesMap();
+ return CommonResult.success(resourceRolesMap);
+ }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/CmsPrefrenceAreaProductRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/CmsPrefrenceAreaProductRelationDao.java
index 6d2276f..9f8216f 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/CmsPrefrenceAreaProductRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/CmsPrefrenceAreaProductRelationDao.java
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 自定义优选和商品关系操作
+ * 自定义优选和商品关系操作Dao
* Created by macro on 2018/4/26.
*/
public interface CmsPrefrenceAreaProductRelationDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/CmsSubjectProductRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/CmsSubjectProductRelationDao.java
index df2d05b..749aee6 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/CmsSubjectProductRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/CmsSubjectProductRelationDao.java
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 自定义商品和专题关系操作
+ * 自定义商品和专题关系操作Dao
* Created by macro on 2018/4/26.
*/
public interface CmsSubjectProductRelationDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductAttributeCategoryDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductAttributeCategoryDao.java
index cf1e27e..b126010 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductAttributeCategoryDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductAttributeCategoryDao.java
@@ -10,7 +10,7 @@ import java.util.List;
*/
public interface PmsProductAttributeCategoryDao {
/**
- * 获取商品属性分类,包括属性
+ * 获取包含属性的商品属性分类
*/
List getListWithAttr();
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java
index 3697f08..9ac86da 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java
@@ -10,7 +10,7 @@ import java.util.List;
*/
public interface PmsProductCategoryDao {
/**
- * 获取商品分类包括子分类
+ * 获取商品分类及其子分类
*/
List listWithChildren();
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductDao.java
index 443adbc..982b482 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductDao.java
@@ -5,7 +5,7 @@ import org.apache.ibatis.annotations.Param;
/**
- * 商品自定义Dao
+ * 自定义商品管理Dao
* Created by macro on 2018/4/26.
*/
public interface PmsProductDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductLadderDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductLadderDao.java
index 48b909f..ef95cb8 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductLadderDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductLadderDao.java
@@ -10,5 +10,8 @@ import java.util.List;
* Created by macro on 2018/4/26.
*/
public interface PmsProductLadderDao {
+ /**
+ * 批量创建
+ */
int insertList(@Param("list") List productLadderList);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductVertifyRecordDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductVertifyRecordDao.java
index c17c172..71c6ce7 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductVertifyRecordDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductVertifyRecordDao.java
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 商品审核日志自定义Dao
+ * 自定义商品审核日志管理Dao
* Created by macro on 2018/4/27.
*/
public interface PmsProductVertifyRecordDao {
+ /**
+ * 批量创建
+ */
int insertList(@Param("list") List list);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsSkuStockDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsSkuStockDao.java
index 9ce1896..0568474 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/PmsSkuStockDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsSkuStockDao.java
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 自定义商品sku库存Dao
+ * 自定义商品SKU管理Dao
* Created by macro on 2018/4/26.
*/
public interface PmsSkuStockDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponDao.java b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponDao.java
index 3c57ad0..603c03d 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponDao.java
@@ -4,9 +4,12 @@ import com.macro.mall.dto.SmsCouponParam;
import org.apache.ibatis.annotations.Param;
/**
- * 优惠券管理自定义查询Dao
+ * 自定义优惠券管理Dao
* Created by macro on 2018/8/29.
*/
public interface SmsCouponDao {
+ /**
+ * 获取优惠券详情包括绑定关系
+ */
SmsCouponParam getItem(@Param("id") Long id);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductCategoryRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductCategoryRelationDao.java
index 78973ab..ae5054f 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductCategoryRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductCategoryRelationDao.java
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 优惠券和商品分类关系自定义Dao
+ * 自定义优惠券和商品分类关系管理Dao
* Created by macro on 2018/8/28.
*/
public interface SmsCouponProductCategoryRelationDao {
+ /**
+ * 批量创建
+ */
int insertList(@Param("list")List productCategoryRelationList);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductRelationDao.java
index f78531e..10d7e01 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/SmsCouponProductRelationDao.java
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 优惠券和产品关系自定义Dao
+ * 自定义优惠券和商品关系关系Dao
* Created by macro on 2018/8/28.
*/
public interface SmsCouponProductRelationDao {
+ /**
+ * 批量创建
+ */
int insertList(@Param("list")List productRelationList);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/SmsFlashPromotionProductRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/SmsFlashPromotionProductRelationDao.java
index d574bcc..2e4b02d 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/SmsFlashPromotionProductRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/SmsFlashPromotionProductRelationDao.java
@@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 限时购商品关联自定义Dao
+ * 自定义限时购商品关系管理Dao
* Created by macro on 2018/11/16.
*/
public interface SmsFlashPromotionProductRelationDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminPermissionRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminPermissionRelationDao.java
index b75bfe6..6493161 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminPermissionRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminPermissionRelationDao.java
@@ -6,9 +6,12 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 用户权限自定义Dao
+ * 自定义用户权限关系管理Dao
* Created by macro on 2018/10/8.
*/
public interface UmsAdminPermissionRelationDao {
+ /**
+ * 批量创建
+ */
int insertList(@Param("list") List list);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminRoleRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminRoleRelationDao.java
index eba581d..fe55396 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminRoleRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/UmsAdminRoleRelationDao.java
@@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 后台用户与角色管理自定义Dao
+ * 自定义后台用户与角色管理Dao
* Created by macro on 2018/10/8.
*/
public interface UmsAdminRoleRelationDao {
@@ -37,4 +37,9 @@ public interface UmsAdminRoleRelationDao {
* 获取用户所有可访问资源
*/
List getResourceList(@Param("adminId") Long adminId);
+
+ /**
+ * 获取资源相关用户ID列表
+ */
+ List getAdminIdList(@Param("resourceId") Long resourceId);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/UmsRoleDao.java b/mall-admin/src/main/java/com/macro/mall/dao/UmsRoleDao.java
index d38ee0b..04873d8 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/UmsRoleDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/UmsRoleDao.java
@@ -7,13 +7,20 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 后台用户角色自定义Dao
+ * 自定义后台角色管理Dao
* Created by macro on 2020/2/2.
*/
public interface UmsRoleDao {
+ /**
+ * 根据后台用户ID获取菜单
+ */
List getMenuList(@Param("adminId") Long adminId);
-
+ /**
+ * 根据角色ID获取菜单
+ */
List getMenuListByRoleId(@Param("roleId") Long roleId);
-
+ /**
+ * 根据角色ID获取资源
+ */
List getResourceListByRoleId(@Param("roleId") Long roleId);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dao/UmsRolePermissionRelationDao.java b/mall-admin/src/main/java/com/macro/mall/dao/UmsRolePermissionRelationDao.java
index a09882d..795d573 100644
--- a/mall-admin/src/main/java/com/macro/mall/dao/UmsRolePermissionRelationDao.java
+++ b/mall-admin/src/main/java/com/macro/mall/dao/UmsRolePermissionRelationDao.java
@@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
- * 后台用户角色管理自定义Dao
+ * 自定义角色权限关系管理Dao
* Created by macro on 2018/9/30.
*/
public interface UmsRolePermissionRelationDao {
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/BucketPolicyConfigDto.java b/mall-admin/src/main/java/com/macro/mall/dto/BucketPolicyConfigDto.java
new file mode 100644
index 0000000..c37f898
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/dto/BucketPolicyConfigDto.java
@@ -0,0 +1,31 @@
+package com.macro.mall.dto;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * Minio Bucket访问策略配置
+ * Created by macro on 2020/8/11.
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Builder
+public class BucketPolicyConfigDto {
+
+ private String Version;
+ private List Statement;
+
+ @Data
+ @EqualsAndHashCode(callSuper = false)
+ @Builder
+ public static class Statement {
+ private String Effect;
+ private String Principal;
+ private String Action;
+ private String Resource;
+
+ }
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/MinioUploadDto.java b/mall-admin/src/main/java/com/macro/mall/dto/MinioUploadDto.java
index 1ce3980..a2769c9 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/MinioUploadDto.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/MinioUploadDto.java
@@ -1,5 +1,6 @@
package com.macro.mall.dto;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -10,6 +11,8 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class MinioUploadDto {
+ @ApiModelProperty("文件访问URL")
private String url;
+ @ApiModelProperty("文件名称")
private String name;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OmsMoneyInfoParam.java b/mall-admin/src/main/java/com/macro/mall/dto/OmsMoneyInfoParam.java
index 8d4125f..71ba001 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OmsMoneyInfoParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OmsMoneyInfoParam.java
@@ -1,5 +1,6 @@
package com.macro.mall.dto;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -12,8 +13,12 @@ import java.math.BigDecimal;
@Getter
@Setter
public class OmsMoneyInfoParam {
+ @ApiModelProperty("订单ID")
private Long orderId;
+ @ApiModelProperty("运费金额")
private BigDecimal freightAmount;
+ @ApiModelProperty("管理员后台调整订单使用的折扣金额")
private BigDecimal discountAmount;
+ @ApiModelProperty("订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
private Integer status;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderDetail.java b/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderDetail.java
index 494fb0c..129c0f2 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderDetail.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderDetail.java
@@ -3,6 +3,7 @@ package com.macro.mall.dto;
import com.macro.mall.model.OmsOrder;
import com.macro.mall.model.OmsOrderItem;
import com.macro.mall.model.OmsOrderOperateHistory;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -15,8 +16,10 @@ import java.util.List;
public class OmsOrderDetail extends OmsOrder {
@Getter
@Setter
+ @ApiModelProperty("订单商品列表")
private List orderItemList;
@Getter
@Setter
+ @ApiModelProperty("订单操作记录列表")
private List historyList;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderReturnApplyResult.java b/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderReturnApplyResult.java
index 4d77fdd..8e43953 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderReturnApplyResult.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OmsOrderReturnApplyResult.java
@@ -2,6 +2,7 @@ package com.macro.mall.dto;
import com.macro.mall.model.OmsCompanyAddress;
import com.macro.mall.model.OmsOrderReturnApply;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -12,5 +13,6 @@ import lombok.Setter;
public class OmsOrderReturnApplyResult extends OmsOrderReturnApply {
@Getter
@Setter
+ @ApiModelProperty(value = "公司收货地址")
private OmsCompanyAddress companyAddress;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OmsReceiverInfoParam.java b/mall-admin/src/main/java/com/macro/mall/dto/OmsReceiverInfoParam.java
index 773f314..5bd0351 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OmsReceiverInfoParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OmsReceiverInfoParam.java
@@ -1,5 +1,6 @@
package com.macro.mall.dto;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -10,13 +11,22 @@ import lombok.Setter;
@Getter
@Setter
public class OmsReceiverInfoParam {
+ @ApiModelProperty(value = "订单ID")
private Long orderId;
+ @ApiModelProperty(value = "收货人姓名")
private String receiverName;
+ @ApiModelProperty(value = "收货人电话")
private String receiverPhone;
+ @ApiModelProperty(value = "收货人邮编")
private String receiverPostCode;
+ @ApiModelProperty(value = "详细地址")
private String receiverDetailAddress;
+ @ApiModelProperty(value = "省份/直辖市")
private String receiverProvince;
+ @ApiModelProperty(value = "城市")
private String receiverCity;
+ @ApiModelProperty(value = "区")
private String receiverRegion;
+ @ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
private Integer status;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackParam.java b/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackParam.java
index 202fd85..26134b8 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackParam.java
@@ -1,11 +1,15 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
/**
* oss上传成功后的回调参数
* Created by macro on 2018/5/17.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class OssCallbackParam {
@ApiModelProperty("请求的回调地址")
private String callbackUrl;
@@ -13,28 +17,4 @@ public class OssCallbackParam {
private String callbackBody;
@ApiModelProperty("回调时传入参数的格式,比如表单提交形式")
private String callbackBodyType;
-
- public String getCallbackUrl() {
- return callbackUrl;
- }
-
- public void setCallbackUrl(String callbackUrl) {
- this.callbackUrl = callbackUrl;
- }
-
- public String getCallbackBody() {
- return callbackBody;
- }
-
- public void setCallbackBody(String callbackBody) {
- this.callbackBody = callbackBody;
- }
-
- public String getCallbackBodyType() {
- return callbackBodyType;
- }
-
- public void setCallbackBodyType(String callbackBodyType) {
- this.callbackBodyType = callbackBodyType;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackResult.java b/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackResult.java
index 3213dd0..6cf67d4 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackResult.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OssCallbackResult.java
@@ -1,11 +1,15 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
/**
* oss上传文件的回调结果
* Created by macro on 2018/5/17.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class OssCallbackResult {
@ApiModelProperty("文件名称")
private String filename;
@@ -17,44 +21,4 @@ public class OssCallbackResult {
private String width;
@ApiModelProperty("图片文件的高")
private String height;
-
- public String getFilename() {
- return filename;
- }
-
- public void setFilename(String filename) {
- this.filename = filename;
- }
-
- public String getSize() {
- return size;
- }
-
- public void setSize(String size) {
- this.size = size;
- }
-
- public String getMimeType() {
- return mimeType;
- }
-
- public void setMimeType(String mimeType) {
- this.mimeType = mimeType;
- }
-
- public String getWidth() {
- return width;
- }
-
- public void setWidth(String width) {
- this.width = width;
- }
-
- public String getHeight() {
- return height;
- }
-
- public void setHeight(String height) {
- this.height = height;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/OssPolicyResult.java b/mall-admin/src/main/java/com/macro/mall/dto/OssPolicyResult.java
index c42dc02..c24f780 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/OssPolicyResult.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/OssPolicyResult.java
@@ -1,11 +1,15 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
/**
* 获取OSS上传文件授权返回结果
* Created by macro on 2018/5/17.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class OssPolicyResult {
@ApiModelProperty("访问身份验证中用到用户标识")
private String accessKeyId;
@@ -19,52 +23,4 @@ public class OssPolicyResult {
private String host;
@ApiModelProperty("上传成功后的回调设置")
private String callback;
-
- public String getAccessKeyId() {
- return accessKeyId;
- }
-
- public void setAccessKeyId(String accessKeyId) {
- this.accessKeyId = accessKeyId;
- }
-
- public String getPolicy() {
- return policy;
- }
-
- public void setPolicy(String policy) {
- this.policy = policy;
- }
-
- public String getSignature() {
- return signature;
- }
-
- public void setSignature(String signature) {
- this.signature = signature;
- }
-
- public String getDir() {
- return dir;
- }
-
- public void setDir(String dir) {
- this.dir = dir;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getCallback() {
- return callback;
- }
-
- public void setCallback(String callback) {
- this.callback = callback;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsBrandParam.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsBrandParam.java
index 7b3df4a..e903476 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsBrandParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsBrandParam.java
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
import com.macro.mall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
@@ -10,6 +12,8 @@ import javax.validation.constraints.NotEmpty;
* 品牌传递参数
* Created by macro on 2018/4/26.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class PmsBrandParam {
@ApiModelProperty(value = "品牌名称",required = true)
@NotEmpty(message = "名称不能为空")
@@ -32,68 +36,4 @@ public class PmsBrandParam {
private String bigPic;
@ApiModelProperty(value = "品牌故事")
private String brandStory;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getFirstLetter() {
- return firstLetter;
- }
-
- public void setFirstLetter(String firstLetter) {
- this.firstLetter = firstLetter;
- }
-
- public Integer getSort() {
- return sort;
- }
-
- public void setSort(Integer sort) {
- this.sort = sort;
- }
-
- public Integer getFactoryStatus() {
- return factoryStatus;
- }
-
- public void setFactoryStatus(Integer factoryStatus) {
- this.factoryStatus = factoryStatus;
- }
-
- public Integer getShowStatus() {
- return showStatus;
- }
-
- public void setShowStatus(Integer showStatus) {
- this.showStatus = showStatus;
- }
-
- public String getLogo() {
- return logo;
- }
-
- public void setLogo(String logo) {
- this.logo = logo;
- }
-
- public String getBigPic() {
- return bigPic;
- }
-
- public void setBigPic(String bigPic) {
- this.bigPic = bigPic;
- }
-
- public String getBrandStory() {
- return brandStory;
- }
-
- public void setBrandStory(String brandStory) {
- this.brandStory = brandStory;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeCategoryItem.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeCategoryItem.java
index 9109796..550596c 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeCategoryItem.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeCategoryItem.java
@@ -2,6 +2,10 @@ package com.macro.mall.dto;
import com.macro.mall.model.PmsProductAttribute;
import com.macro.mall.model.PmsProductAttributeCategory;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
import java.util.List;
@@ -10,13 +14,8 @@ import java.util.List;
* Created by macro on 2018/5/24.
*/
public class PmsProductAttributeCategoryItem extends PmsProductAttributeCategory {
+ @Getter
+ @Setter
+ @ApiModelProperty(value = "商品属性列表")
private List productAttributeList;
-
- public List getProductAttributeList() {
- return productAttributeList;
- }
-
- public void setProductAttributeList(List productAttributeList) {
- this.productAttributeList = productAttributeList;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeParam.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeParam.java
index 56279b2..28b6b8b 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductAttributeParam.java
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
import com.macro.mall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotEmpty;
@@ -9,6 +11,8 @@ import javax.validation.constraints.NotEmpty;
* 商品属性参数
* Created by macro on 2018/4/26.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class PmsProductAttributeParam {
@ApiModelProperty("属性分类ID")
@NotEmpty(message = "属性分类不能为空")
@@ -41,92 +45,4 @@ public class PmsProductAttributeParam {
@ApiModelProperty("属性的类型;0->规格;1->参数")
@FlagValidator({"0","1"})
private Integer type;
-
- public Long getProductAttributeCategoryId() {
- return productAttributeCategoryId;
- }
-
- public void setProductAttributeCategoryId(Long productAttributeCategoryId) {
- this.productAttributeCategoryId = productAttributeCategoryId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Integer getSelectType() {
- return selectType;
- }
-
- public void setSelectType(Integer selectType) {
- this.selectType = selectType;
- }
-
- public Integer getInputType() {
- return inputType;
- }
-
- public void setInputType(Integer inputType) {
- this.inputType = inputType;
- }
-
- public String getInputList() {
- return inputList;
- }
-
- public void setInputList(String inputList) {
- this.inputList = inputList;
- }
-
- public Integer getSort() {
- return sort;
- }
-
- public void setSort(Integer sort) {
- this.sort = sort;
- }
-
- public Integer getFilterType() {
- return filterType;
- }
-
- public void setFilterType(Integer filterType) {
- this.filterType = filterType;
- }
-
- public Integer getSearchType() {
- return searchType;
- }
-
- public void setSearchType(Integer searchType) {
- this.searchType = searchType;
- }
-
- public Integer getRelatedStatus() {
- return relatedStatus;
- }
-
- public void setRelatedStatus(Integer relatedStatus) {
- this.relatedStatus = relatedStatus;
- }
-
- public Integer getHandAddStatus() {
- return handAddStatus;
- }
-
- public void setHandAddStatus(Integer handAddStatus) {
- this.handAddStatus = handAddStatus;
- }
-
- public Integer getType() {
- return type;
- }
-
- public void setType(Integer type) {
- this.type = type;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryParam.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryParam.java
index 4b0ea74..b560b18 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryParam.java
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
import com.macro.mall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
@@ -11,6 +13,8 @@ import java.util.List;
* 添加更新产品分类的参数
* Created by macro on 2018/4/26.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class PmsProductCategoryParam {
@ApiModelProperty("父分类的编号")
private Long parentId;
@@ -36,84 +40,4 @@ public class PmsProductCategoryParam {
private String description;
@ApiModelProperty("产品相关筛选属性集合")
private List productAttributeIdList;
-
- public Long getParentId() {
- return parentId;
- }
-
- public void setParentId(Long parentId) {
- this.parentId = parentId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getProductUnit() {
- return productUnit;
- }
-
- public void setProductUnit(String productUnit) {
- this.productUnit = productUnit;
- }
-
- public Integer getNavStatus() {
- return navStatus;
- }
-
- public void setNavStatus(Integer navStatus) {
- this.navStatus = navStatus;
- }
-
- public Integer getShowStatus() {
- return showStatus;
- }
-
- public void setShowStatus(Integer showStatus) {
- this.showStatus = showStatus;
- }
-
- public Integer getSort() {
- return sort;
- }
-
- public void setSort(Integer sort) {
- this.sort = sort;
- }
-
- public String getIcon() {
- return icon;
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- public String getKeywords() {
- return keywords;
- }
-
- public void setKeywords(String keywords) {
- this.keywords = keywords;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List getProductAttributeIdList() {
- return productAttributeIdList;
- }
-
- public void setProductAttributeIdList(List productAttributeIdList) {
- this.productAttributeIdList = productAttributeIdList;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java
index 7d5a990..f69f4b4 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java
@@ -1,6 +1,9 @@
package com.macro.mall.dto;
import com.macro.mall.model.PmsProductCategory;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
import java.util.List;
@@ -8,13 +11,8 @@ import java.util.List;
* Created by macro on 2018/5/25.
*/
public class PmsProductCategoryWithChildrenItem extends PmsProductCategory {
+ @Getter
+ @Setter
+ @ApiModelProperty("子级分类")
private List children;
-
- public List getChildren() {
- return children;
- }
-
- public void setChildren(List children) {
- this.children = children;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductParam.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductParam.java
index 371cb7a..1f29d1e 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductParam.java
@@ -2,6 +2,8 @@ package com.macro.mall.dto;
import com.macro.mall.model.*;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import java.util.List;
@@ -9,6 +11,8 @@ import java.util.List;
* 创建和修改商品时使用的参数
* Created by macro on 2018/4/26.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class PmsProductParam extends PmsProduct{
@ApiModelProperty("商品阶梯价格设置")
private List productLadderList;
@@ -24,60 +28,4 @@ public class PmsProductParam extends PmsProduct{
private List subjectProductRelationList;
@ApiModelProperty("优选专区和商品的关系")
private List prefrenceAreaProductRelationList;
-
- public List getProductLadderList() {
- return productLadderList;
- }
-
- public void setProductLadderList(List productLadderList) {
- this.productLadderList = productLadderList;
- }
-
- public List getProductFullReductionList() {
- return productFullReductionList;
- }
-
- public void setProductFullReductionList(List productFullReductionList) {
- this.productFullReductionList = productFullReductionList;
- }
-
- public List getMemberPriceList() {
- return memberPriceList;
- }
-
- public void setMemberPriceList(List memberPriceList) {
- this.memberPriceList = memberPriceList;
- }
-
- public List getSkuStockList() {
- return skuStockList;
- }
-
- public void setSkuStockList(List skuStockList) {
- this.skuStockList = skuStockList;
- }
-
- public List getProductAttributeValueList() {
- return productAttributeValueList;
- }
-
- public void setProductAttributeValueList(List productAttributeValueList) {
- this.productAttributeValueList = productAttributeValueList;
- }
-
- public List getSubjectProductRelationList() {
- return subjectProductRelationList;
- }
-
- public void setSubjectProductRelationList(List subjectProductRelationList) {
- this.subjectProductRelationList = subjectProductRelationList;
- }
-
- public List getPrefrenceAreaProductRelationList() {
- return prefrenceAreaProductRelationList;
- }
-
- public void setPrefrenceAreaProductRelationList(List prefrenceAreaProductRelationList) {
- this.prefrenceAreaProductRelationList = prefrenceAreaProductRelationList;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductQueryParam.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductQueryParam.java
index d24907c..ccba855 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductQueryParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductQueryParam.java
@@ -1,11 +1,15 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
/**
* 产品查询参数
* Created by macro on 2018/4/27.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class PmsProductQueryParam {
@ApiModelProperty("上架状态")
private Integer publishStatus;
@@ -19,52 +23,4 @@ public class PmsProductQueryParam {
private Long productCategoryId;
@ApiModelProperty("商品品牌编号")
private Long brandId;
-
- public Integer getPublishStatus() {
- return publishStatus;
- }
-
- public void setPublishStatus(Integer publishStatus) {
- this.publishStatus = publishStatus;
- }
-
- public Integer getVerifyStatus() {
- return verifyStatus;
- }
-
- public void setVerifyStatus(Integer verifyStatus) {
- this.verifyStatus = verifyStatus;
- }
-
- public String getKeyword() {
- return keyword;
- }
-
- public void setKeyword(String keyword) {
- this.keyword = keyword;
- }
-
- public String getProductSn() {
- return productSn;
- }
-
- public void setProductSn(String productSn) {
- this.productSn = productSn;
- }
-
- public Long getProductCategoryId() {
- return productCategoryId;
- }
-
- public void setProductCategoryId(Long productCategoryId) {
- this.productCategoryId = productCategoryId;
- }
-
- public Long getBrandId() {
- return brandId;
- }
-
- public void setBrandId(Long brandId) {
- this.brandId = brandId;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductResult.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductResult.java
index 4db7f68..7ddeecc 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductResult.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductResult.java
@@ -1,18 +1,16 @@
package com.macro.mall.dto;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
/**
* 查询单个产品进行修改时返回的结果
* Created by macro on 2018/4/26.
*/
public class PmsProductResult extends PmsProductParam {
- //商品所选分类的父id
+ @Getter
+ @Setter
+ @ApiModelProperty("商品所选分类的父id")
private Long cateParentId;
-
- public Long getCateParentId() {
- return cateParentId;
- }
-
- public void setCateParentId(Long cateParentId) {
- this.cateParentId = cateParentId;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/ProductAttrInfo.java b/mall-admin/src/main/java/com/macro/mall/dto/ProductAttrInfo.java
index 6bed624..3d6218a 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/ProductAttrInfo.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/ProductAttrInfo.java
@@ -1,27 +1,19 @@
package com.macro.mall.dto;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
/**
* 商品分类对应属性信息
* Created by macro on 2018/5/23.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class ProductAttrInfo {
+ @ApiModelProperty("商品属性ID")
private Long attributeId;
+ @ApiModelProperty("商品属性分类ID")
private Long attributeCategoryId;
-
- public Long getAttributeId() {
- return attributeId;
- }
-
- public void setAttributeId(Long attributeId) {
- this.attributeId = attributeId;
- }
-
- public Long getAttributeCategoryId() {
- return attributeCategoryId;
- }
-
- public void setAttributeCategoryId(Long attributeCategoryId) {
- this.attributeCategoryId = attributeCategoryId;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/SmsCouponParam.java b/mall-admin/src/main/java/com/macro/mall/dto/SmsCouponParam.java
index 99643cb..bc974d9 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/SmsCouponParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/SmsCouponParam.java
@@ -3,6 +3,9 @@ package com.macro.mall.dto;
import com.macro.mall.model.SmsCoupon;
import com.macro.mall.model.SmsCouponProductCategoryRelation;
import com.macro.mall.model.SmsCouponProductRelation;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
import java.util.List;
@@ -11,24 +14,12 @@ import java.util.List;
* Created by macro on 2018/8/28.
*/
public class SmsCouponParam extends SmsCoupon {
- //优惠券绑定的商品
+ @Getter
+ @Setter
+ @ApiModelProperty("优惠券绑定的商品")
private List productRelationList;
- //优惠券绑定的商品分类
+ @Getter
+ @Setter
+ @ApiModelProperty("优惠券绑定的商品分类")
private List productCategoryRelationList;
-
- public List getProductRelationList() {
- return productRelationList;
- }
-
- public void setProductRelationList(List productRelationList) {
- this.productRelationList = productRelationList;
- }
-
- public List getProductCategoryRelationList() {
- return productCategoryRelationList;
- }
-
- public void setProductCategoryRelationList(List productCategoryRelationList) {
- this.productCategoryRelationList = productCategoryRelationList;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionProduct.java b/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionProduct.java
index a3e5877..d9b5e7f 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionProduct.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionProduct.java
@@ -2,6 +2,7 @@ package com.macro.mall.dto;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -12,5 +13,6 @@ import lombok.Setter;
public class SmsFlashPromotionProduct extends SmsFlashPromotionProductRelation{
@Getter
@Setter
+ @ApiModelProperty("关联商品")
private PmsProduct product;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionSessionDetail.java b/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionSessionDetail.java
index 4d35c6d..d441f6c 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionSessionDetail.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/SmsFlashPromotionSessionDetail.java
@@ -1,6 +1,7 @@
package com.macro.mall.dto;
import com.macro.mall.model.SmsFlashPromotionSession;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -11,5 +12,6 @@ import lombok.Setter;
public class SmsFlashPromotionSessionDetail extends SmsFlashPromotionSession {
@Setter
@Getter
+ @ApiModelProperty("商品数量")
private Long productCount;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/UmsAdminLoginParam.java b/mall-admin/src/main/java/com/macro/mall/dto/UmsAdminLoginParam.java
index dc0595b..988f8a6 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/UmsAdminLoginParam.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/UmsAdminLoginParam.java
@@ -1,6 +1,8 @@
package com.macro.mall.dto;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotEmpty;
@@ -8,6 +10,8 @@ import javax.validation.constraints.NotEmpty;
* 用户登录参数
* Created by macro on 2018/4/26.
*/
+@Data
+@EqualsAndHashCode(callSuper = false)
public class UmsAdminLoginParam {
@ApiModelProperty(value = "用户名", required = true)
@NotEmpty(message = "用户名不能为空")
@@ -15,20 +19,4 @@ public class UmsAdminLoginParam {
@ApiModelProperty(value = "密码", required = true)
@NotEmpty(message = "密码不能为空")
private String password;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/UmsMenuNode.java b/mall-admin/src/main/java/com/macro/mall/dto/UmsMenuNode.java
index 8dcb13c..ec36ada 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/UmsMenuNode.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/UmsMenuNode.java
@@ -1,6 +1,7 @@
package com.macro.mall.dto;
import com.macro.mall.model.UmsMenu;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -13,5 +14,6 @@ import java.util.List;
@Getter
@Setter
public class UmsMenuNode extends UmsMenu {
+ @ApiModelProperty(value = "子级菜单")
private List children;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/dto/UmsPermissionNode.java b/mall-admin/src/main/java/com/macro/mall/dto/UmsPermissionNode.java
index adb570d..d38fc65 100644
--- a/mall-admin/src/main/java/com/macro/mall/dto/UmsPermissionNode.java
+++ b/mall-admin/src/main/java/com/macro/mall/dto/UmsPermissionNode.java
@@ -1,6 +1,7 @@
package com.macro.mall.dto;
import com.macro.mall.model.UmsPermission;
+import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@@ -13,5 +14,6 @@ import java.util.List;
public class UmsPermissionNode extends UmsPermission {
@Getter
@Setter
+ @ApiModelProperty(value = "子级权限")
private List children;
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/AuthService.java b/mall-admin/src/main/java/com/macro/mall/service/AuthService.java
new file mode 100644
index 0000000..e25c505
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/service/AuthService.java
@@ -0,0 +1,20 @@
+package com.macro.mall.service;
+
+import com.macro.mall.common.api.CommonResult;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.Map;
+
+/**
+ * 认证服务远程调用
+ * Created by macro on 2020/7/19.
+ */
+@FeignClient("mall-auth")
+public interface AuthService {
+
+ @PostMapping(value = "/oauth/token")
+ CommonResult getAccessToken(@RequestParam Map parameters);
+
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeService.java b/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeService.java
index 76b6851..2f1b6b8 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeService.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/PmsProductAttributeService.java
@@ -14,8 +14,7 @@ import java.util.List;
public interface PmsProductAttributeService {
/**
* 根据分类分页获取商品属性
- *
- * @param cid 分类id
+ * @param cid 分类id
* @param type 0->属性;2->参数
*/
List getList(Long cid, Integer type, Integer pageSize, Integer pageNum);
@@ -36,14 +35,8 @@ public interface PmsProductAttributeService {
*/
PmsProductAttribute getItem(Long id);
- /**
- * 批量删除商品属性
- */
@Transactional
int delete(List ids);
- /**
- * 获取和分类相关的商品属性
- */
List getProductAttrInfo(Long productCategoryId);
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/UmsAdminCacheService.java b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminCacheService.java
new file mode 100644
index 0000000..030fd8c
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminCacheService.java
@@ -0,0 +1,27 @@
+package com.macro.mall.service;
+
+import com.macro.mall.model.UmsAdmin;
+import com.macro.mall.model.UmsResource;
+
+import java.util.List;
+
+/**
+ * 后台用户缓存操作类
+ * Created by macro on 2020/3/13.
+ */
+public interface UmsAdminCacheService {
+ /**
+ * 删除后台用户缓存
+ */
+ void delAdmin(Long adminId);
+
+ /**
+ * 获取缓存后台用户信息
+ */
+ UmsAdmin getAdmin(Long adminId);
+
+ /**
+ * 设置缓存后台用户信息
+ */
+ void setAdmin(UmsAdmin admin);
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
index fc241f6..cc42c38 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
@@ -1,12 +1,10 @@
package com.macro.mall.service;
+import com.macro.mall.common.api.CommonResult;
+import com.macro.mall.common.domain.UserDto;
import com.macro.mall.dto.UmsAdminParam;
import com.macro.mall.dto.UpdateAdminPasswordParam;
-import com.macro.mall.model.UmsAdmin;
-import com.macro.mall.model.UmsPermission;
-import com.macro.mall.model.UmsResource;
-import com.macro.mall.model.UmsRole;
-import org.springframework.security.core.userdetails.UserDetails;
+import com.macro.mall.model.*;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -30,15 +28,9 @@ public interface UmsAdminService {
* 登录功能
* @param username 用户名
* @param password 密码
- * @return 生成的JWT的token
+ * @return 调用认证中心返回结果
*/
- String login(String username,String password);
-
- /**
- * 刷新token的功能
- * @param oldToken 旧的token
- */
- String refreshToken(String oldToken);
+ CommonResult login(String username, String password);
/**
* 根据用户id获取用户
@@ -95,5 +87,10 @@ public interface UmsAdminService {
/**
* 获取用户信息
*/
- UserDetails loadUserByUsername(String username);
+ UserDto loadUserByUsername(String username);
+
+ /**
+ * 获取当前登录后台用户
+ */
+ UmsAdmin getCurrentAdmin();
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/UmsResourceService.java b/mall-admin/src/main/java/com/macro/mall/service/UmsResourceService.java
index 131c555..33a1dc4 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/UmsResourceService.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/UmsResourceService.java
@@ -3,6 +3,7 @@ package com.macro.mall.service;
import com.macro.mall.model.UmsResource;
import java.util.List;
+import java.util.Map;
/**
* 后台资源管理Service
@@ -38,4 +39,9 @@ public interface UmsResourceService {
* 查询全部资源
*/
List listAll();
+
+ /**
+ * 初始化资源角色规则
+ */
+ Map> initResourceRolesMap();
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminCacheServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminCacheServiceImpl.java
new file mode 100644
index 0000000..16b45ad
--- /dev/null
+++ b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminCacheServiceImpl.java
@@ -0,0 +1,45 @@
+package com.macro.mall.service.impl;
+
+import com.macro.mall.common.service.RedisService;
+import com.macro.mall.model.UmsAdmin;
+import com.macro.mall.service.UmsAdminCacheService;
+import com.macro.mall.service.UmsAdminService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+/**
+ * UmsAdminCacheService实现类
+ * Created by macro on 2020/3/13.
+ */
+@Service
+public class UmsAdminCacheServiceImpl implements UmsAdminCacheService {
+ @Autowired
+ private UmsAdminService adminService;
+ @Autowired
+ private RedisService redisService;
+ @Value("${redis.database}")
+ private String REDIS_DATABASE;
+ @Value("${redis.expire.common}")
+ private Long REDIS_EXPIRE;
+ @Value("${redis.key.admin}")
+ private String REDIS_KEY_ADMIN;
+
+ @Override
+ public void delAdmin(Long adminId) {
+ String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + adminId;
+ redisService.del(key);
+ }
+
+ @Override
+ public UmsAdmin getAdmin(Long adminId) {
+ String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + adminId;
+ return (UmsAdmin) redisService.get(key);
+ }
+
+ @Override
+ public void setAdmin(UmsAdmin admin) {
+ String key = REDIS_DATABASE + ":" + REDIS_KEY_ADMIN + ":" + admin.getId();
+ redisService.set(key, admin, REDIS_EXPIRE);
+ }
+}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
index 484a8f0..5f675f4 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
@@ -2,8 +2,14 @@ package com.macro.mall.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.digest.BCrypt;
+import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
-import com.macro.mall.bo.AdminUserDetails;
+import com.macro.mall.common.api.CommonResult;
+import com.macro.mall.common.api.ResultCode;
+import com.macro.mall.common.constant.AuthConstant;
+import com.macro.mall.common.domain.UserDto;
+import com.macro.mall.common.exception.Asserts;
import com.macro.mall.dao.UmsAdminPermissionRelationDao;
import com.macro.mall.dao.UmsAdminRoleRelationDao;
import com.macro.mall.dto.UmsAdminParam;
@@ -13,19 +19,13 @@ import com.macro.mall.mapper.UmsAdminMapper;
import com.macro.mall.mapper.UmsAdminPermissionRelationMapper;
import com.macro.mall.mapper.UmsAdminRoleRelationMapper;
import com.macro.mall.model.*;
-import com.macro.mall.security.util.JwtTokenUtil;
+import com.macro.mall.service.AuthService;
+import com.macro.mall.service.UmsAdminCacheService;
import com.macro.mall.service.UmsAdminService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@@ -33,9 +33,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -46,10 +44,6 @@ import java.util.stream.Collectors;
public class UmsAdminServiceImpl implements UmsAdminService {
private static final Logger LOGGER = LoggerFactory.getLogger(UmsAdminServiceImpl.class);
@Autowired
- private JwtTokenUtil jwtTokenUtil;
- @Autowired
- private PasswordEncoder passwordEncoder;
- @Autowired
private UmsAdminMapper adminMapper;
@Autowired
private UmsAdminRoleRelationMapper adminRoleRelationMapper;
@@ -61,6 +55,12 @@ public class UmsAdminServiceImpl implements UmsAdminService {
private UmsAdminPermissionRelationDao adminPermissionRelationDao;
@Autowired
private UmsAdminLoginLogMapper loginLogMapper;
+ @Autowired
+ private AuthService authService;
+ @Autowired
+ private UmsAdminCacheService adminCacheService;
+ @Autowired
+ private HttpServletRequest request;
@Override
public UmsAdmin getAdminByUsername(String username) {
@@ -87,30 +87,29 @@ public class UmsAdminServiceImpl implements UmsAdminService {
return null;
}
//将密码进行加密操作
- String encodePassword = passwordEncoder.encode(umsAdmin.getPassword());
+ String encodePassword = BCrypt.hashpw(umsAdmin.getPassword());
umsAdmin.setPassword(encodePassword);
adminMapper.insert(umsAdmin);
return umsAdmin;
}
@Override
- public String login(String username, String password) {
- String token = null;
- //密码需要客户端加密后传递
- try {
- UserDetails userDetails = loadUserByUsername(username);
- if(!passwordEncoder.matches(password,userDetails.getPassword())){
- throw new BadCredentialsException("密码不正确");
- }
- UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
- SecurityContextHolder.getContext().setAuthentication(authentication);
- token = jwtTokenUtil.generateToken(userDetails);
+ public CommonResult login(String username, String password) {
+ if(StrUtil.isEmpty(username)||StrUtil.isEmpty(password)){
+ Asserts.fail("用户名或密码不能为空!");
+ }
+ Map params = new HashMap<>();
+ params.put("client_id", AuthConstant.ADMIN_CLIENT_ID);
+ params.put("client_secret","123456");
+ params.put("grant_type","password");
+ params.put("username",username);
+ params.put("password",password);
+ CommonResult restResult = authService.getAccessToken(params);
+ if(ResultCode.SUCCESS.getCode()==restResult.getCode()&&restResult.getData()!=null){
// updateLoginTimeByUsername(username);
insertLoginLog(username);
- } catch (AuthenticationException e) {
- LOGGER.warn("登录异常:{}", e.getMessage());
}
- return token;
+ return restResult;
}
/**
@@ -119,6 +118,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
*/
private void insertLoginLog(String username) {
UmsAdmin admin = getAdminByUsername(username);
+ if(admin==null) return;
UmsAdminLoginLog loginLog = new UmsAdminLoginLog();
loginLog.setAdminId(admin.getId());
loginLog.setCreateTime(new Date());
@@ -139,11 +139,6 @@ public class UmsAdminServiceImpl implements UmsAdminService {
adminMapper.updateByExampleSelective(record, example);
}
- @Override
- public String refreshToken(String oldToken) {
- return jwtTokenUtil.refreshHeadToken(oldToken);
- }
-
@Override
public UmsAdmin getItem(Long id) {
return adminMapper.selectByPrimaryKey(id);
@@ -173,15 +168,19 @@ public class UmsAdminServiceImpl implements UmsAdminService {
if(StrUtil.isEmpty(admin.getPassword())){
admin.setPassword(null);
}else{
- admin.setPassword(passwordEncoder.encode(admin.getPassword()));
+ admin.setPassword(BCrypt.hashpw(admin.getPassword()));
}
}
- return adminMapper.updateByPrimaryKeySelective(admin);
+ int count = adminMapper.updateByPrimaryKeySelective(admin);
+ adminCacheService.delAdmin(id);
+ return count;
}
@Override
public int delete(Long id) {
- return adminMapper.deleteByPrimaryKey(id);
+ int count = adminMapper.deleteByPrimaryKey(id);
+ adminCacheService.delAdmin(id);
+ return count;
}
@Override
@@ -271,22 +270,46 @@ public class UmsAdminServiceImpl implements UmsAdminService {
return -2;
}
UmsAdmin umsAdmin = adminList.get(0);
- if(!passwordEncoder.matches(param.getOldPassword(),umsAdmin.getPassword())){
+ if(!BCrypt.checkpw(param.getOldPassword(),umsAdmin.getPassword())){
return -3;
}
- umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword()));
+ umsAdmin.setPassword(BCrypt.hashpw(param.getNewPassword()));
adminMapper.updateByPrimaryKey(umsAdmin);
+ adminCacheService.delAdmin(umsAdmin.getId());
return 1;
}
@Override
- public UserDetails loadUserByUsername(String username){
+ public UserDto loadUserByUsername(String username){
//获取用户信息
UmsAdmin admin = getAdminByUsername(username);
if (admin != null) {
- List resourceList = getResourceList(admin.getId());
- return new AdminUserDetails(admin,resourceList);
+ List roleList = getRoleList(admin.getId());
+ UserDto userDTO = new UserDto();
+ BeanUtils.copyProperties(admin,userDTO);
+ if(CollUtil.isNotEmpty(roleList)){
+ List roleStrList = roleList.stream().map(item -> item.getId() + "_" + item.getName()).collect(Collectors.toList());
+ userDTO.setRoles(roleStrList);
+ }
+ return userDTO;
+ }
+ return null;
+ }
+
+ @Override
+ public UmsAdmin getCurrentAdmin() {
+ String userStr = request.getHeader(AuthConstant.USER_TOKEN_HEADER);
+ if(StrUtil.isEmpty(userStr)){
+ Asserts.fail(ResultCode.UNAUTHORIZED);
+ }
+ UserDto userDto = JSONUtil.toBean(userStr, UserDto.class);
+ UmsAdmin admin = adminCacheService.getAdmin(userDto.getId());
+ if(admin!=null){
+ return admin;
+ }else{
+ admin = adminMapper.selectByPrimaryKey(userDto.getId());
+ adminCacheService.setAdmin(admin);
+ return admin;
}
- throw new UsernameNotFoundException("用户名或密码错误");
}
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsResourceServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsResourceServiceImpl.java
index 4d866c0..44f517f 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsResourceServiceImpl.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsResourceServiceImpl.java
@@ -2,15 +2,20 @@ package com.macro.mall.service.impl;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
+import com.macro.mall.common.constant.AuthConstant;
+import com.macro.mall.common.service.RedisService;
import com.macro.mall.mapper.UmsResourceMapper;
-import com.macro.mall.model.UmsResource;
-import com.macro.mall.model.UmsResourceExample;
+import com.macro.mall.mapper.UmsRoleMapper;
+import com.macro.mall.mapper.UmsRoleResourceRelationMapper;
+import com.macro.mall.model.*;
+import com.macro.mall.service.UmsAdminCacheService;
import com.macro.mall.service.UmsResourceService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* 后台资源管理Service实现类
@@ -20,16 +25,28 @@ import java.util.List;
public class UmsResourceServiceImpl implements UmsResourceService {
@Autowired
private UmsResourceMapper resourceMapper;
+ @Autowired
+ private UmsRoleMapper roleMapper;
+ @Autowired
+ private UmsRoleResourceRelationMapper roleResourceRelationMapper;
+ @Autowired
+ private RedisService redisService;
+ @Value("${spring.application.name}")
+ private String applicationName;
@Override
public int create(UmsResource umsResource) {
umsResource.setCreateTime(new Date());
- return resourceMapper.insert(umsResource);
+ int count = resourceMapper.insert(umsResource);
+ initResourceRolesMap();
+ return count;
}
@Override
public int update(Long id, UmsResource umsResource) {
umsResource.setId(id);
- return resourceMapper.updateByPrimaryKeySelective(umsResource);
+ int count = resourceMapper.updateByPrimaryKeySelective(umsResource);
+ initResourceRolesMap();
+ return count;
}
@Override
@@ -39,7 +56,9 @@ public class UmsResourceServiceImpl implements UmsResourceService {
@Override
public int delete(Long id) {
- return resourceMapper.deleteByPrimaryKey(id);
+ int count = resourceMapper.deleteByPrimaryKey(id);
+ initResourceRolesMap();
+ return count;
}
@Override
@@ -63,4 +82,21 @@ public class UmsResourceServiceImpl implements UmsResourceService {
public List listAll() {
return resourceMapper.selectByExample(new UmsResourceExample());
}
+
+ @Override
+ public Map> initResourceRolesMap() {
+ Map> resourceRoleMap = new TreeMap<>();
+ List resourceList = resourceMapper.selectByExample(new UmsResourceExample());
+ List roleList = roleMapper.selectByExample(new UmsRoleExample());
+ List relationList = roleResourceRelationMapper.selectByExample(new UmsRoleResourceRelationExample());
+ for (UmsResource resource : resourceList) {
+ Set roleIds = relationList.stream().filter(item -> item.getResourceId().equals(resource.getId())).map(UmsRoleResourceRelation::getRoleId).collect(Collectors.toSet());
+ List roleNames = roleList.stream().filter(item -> roleIds.contains(item.getId())).map(item -> item.getId() + "_" + item.getName()).collect(Collectors.toList());
+ resourceRoleMap.put("/"+applicationName+resource.getUrl(),roleNames);
+ }
+ redisService.del(AuthConstant.RESOURCE_ROLES_MAP_KEY);
+ redisService.hSetAll(AuthConstant.RESOURCE_ROLES_MAP_KEY, resourceRoleMap);
+ return resourceRoleMap;
+
+ }
}
diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java
index ddd9230..879099c 100644
--- a/mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java
+++ b/mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java
@@ -8,6 +8,8 @@ import com.macro.mall.mapper.UmsRoleMenuRelationMapper;
import com.macro.mall.mapper.UmsRolePermissionRelationMapper;
import com.macro.mall.mapper.UmsRoleResourceRelationMapper;
import com.macro.mall.model.*;
+import com.macro.mall.service.UmsAdminCacheService;
+import com.macro.mall.service.UmsResourceService;
import com.macro.mall.service.UmsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -35,6 +37,8 @@ public class UmsRoleServiceImpl implements UmsRoleService {
private UmsRolePermissionRelationDao rolePermissionRelationDao;
@Autowired
private UmsRoleDao roleDao;
+ @Autowired
+ private UmsResourceService resourceService;
@Override
public int create(UmsRole role) {
role.setCreateTime(new Date());
@@ -53,7 +57,9 @@ public class UmsRoleServiceImpl implements UmsRoleService {
public int delete(List ids) {
UmsRoleExample example = new UmsRoleExample();
example.createCriteria().andIdIn(ids);
- return roleMapper.deleteByExample(example);
+ int count = roleMapper.deleteByExample(example);
+ resourceService.initResourceRolesMap();
+ return count;
}
@Override
@@ -137,6 +143,7 @@ public class UmsRoleServiceImpl implements UmsRoleService {
relation.setResourceId(resourceId);
roleResourceRelationMapper.insert(relation);
}
+ resourceService.initResourceRolesMap();
return resourceIds.size();
}
}
diff --git a/mall-admin/src/main/resources/application.yml b/mall-admin/src/main/resources/application.yml
index 09139a7..93213fb 100644
--- a/mall-admin/src/main/resources/application.yml
+++ b/mall-admin/src/main/resources/application.yml
@@ -1,5 +1,5 @@
server:
- port: 8180
+ port: 8080
spring:
datasource:
url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
@@ -14,6 +14,12 @@ spring:
stat-view-servlet: #访问监控网页的登录用户名和密码
login-username: druid
login-password: druid
+ redis:
+ host: localhost # Redis服务器地址
+ database: 0 # Redis数据库索引(默认为0)
+ port: 6379 # Redis服务器连接端口
+ password: # Redis服务器连接密码(默认为空)
+ timeout: 3000ms # 连接超时时间(毫秒)
rabbitmq: #rabbitmq相关配置
host: localhost
port: 5672
@@ -35,30 +41,12 @@ management: #开启SpringBoot Admin的监控
endpoint:
health:
show-details: always
-jwt:
- tokenHeader: Authorization #JWT存储的请求头
- secret: mall-admin-secret #JWT加解密使用的密钥
- expiration: 604800 #JWT的超期限时间(60*60*24)
- tokenHead: Bearer #JWT负载中拿到开头
-secure:
- ignored:
- urls: #安全路径白名单
- - /swagger-ui.html
- - /swagger-resources/**
- - /swagger/**
- - /**/v2/api-docs
- - /**/*.js
- - /**/*.css
- - /**/*.png
- - /**/*.ico
- - /webjars/springfox-swagger-ui/**
- - /actuator/**
- - /druid/**
- - /admin/login
- - /admin/register
- - /admin/info
- - /admin/logout
- - /minio/upload
+redis:
+ database: mall
+ key:
+ admin: 'ums:admin'
+ expire:
+ common: 86400 # 24小时
aliyun:
oss:
endpoint: oss-cn-shenzhen.aliyuncs.com # oss对外服务的访问域名
@@ -75,4 +63,10 @@ minio:
endpoint: http://192.168.6.132:9090 #MinIO服务所在地址
bucketName: mall #存储桶名称
accessKey: minioadmin #访问的key
- secretKey: minioadmin #访问的秘钥
\ No newline at end of file
+ secretKey: minioadmin #访问的秘钥
+feign:
+ okhttp:
+ enabled: true
+ribbon:
+ ConnectTimeout: 3000 #服务请求连接超时时间(毫秒)
+ ReadTimeout: 3000 #服务请求处理超时时间(毫秒)
\ No newline at end of file
diff --git a/mall-admin/src/main/resources/bootstrap-dev.yml b/mall-admin/src/main/resources/bootstrap-dev.yml
index d35a60c..365fbba 100644
--- a/mall-admin/src/main/resources/bootstrap-dev.yml
+++ b/mall-admin/src/main/resources/bootstrap-dev.yml
@@ -1,13 +1,8 @@
spring:
cloud:
- config:
- profile: dev #启用环境名称
- label: master #分支名称
- name: admin #配置文件名称
+ nacos:
discovery:
- enabled: true
- service-id: mall-config
-eureka:
- client:
- service-url:
- defaultZone: http://localhost:8001/eureka/
\ No newline at end of file
+ server-addr: http://localhost:8848
+ config:
+ server-addr: http://localhost:8848
+ file-extension: yaml
\ No newline at end of file
diff --git a/mall-admin/src/main/resources/bootstrap-prod.yml b/mall-admin/src/main/resources/bootstrap-prod.yml
index 14e897e..fc71e7a 100644
--- a/mall-admin/src/main/resources/bootstrap-prod.yml
+++ b/mall-admin/src/main/resources/bootstrap-prod.yml
@@ -1,15 +1,8 @@
spring:
cloud:
- config:
- profile: prod #启用环境名称
- label: master #分支名称
- name: admin #配置文件名称
+ nacos:
discovery:
- enabled: true
- service-id: mall-config
-eureka:
- client:
- service-url:
- defaultZone: http://mall-registry:8001/eureka/
- instance:
- prefer-ip-address: true
\ No newline at end of file
+ server-addr: http://nacos-registry:8848
+ config:
+ server-addr: http://nacos-registry:8848
+ file-extension: yaml
\ No newline at end of file
diff --git a/mall-admin/src/main/resources/dao/UmsAdminRoleRelationDao.xml b/mall-admin/src/main/resources/dao/UmsAdminRoleRelationDao.xml
index 6b1ec7d..badc580 100644
--- a/mall-admin/src/main/resources/dao/UmsAdminRoleRelationDao.xml
+++ b/mall-admin/src/main/resources/dao/UmsAdminRoleRelationDao.xml
@@ -71,4 +71,12 @@
GROUP BY
ur.id
+
\ No newline at end of file
diff --git a/mall-admin/src/main/resources/logback-spring.xml b/mall-admin/src/main/resources/logback-spring.xml
deleted file mode 100644
index a86c84c..0000000
--- a/mall-admin/src/main/resources/logback-spring.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
- ${APP_NAME}
-
-
-
- ${LOG_FILE_PATH}/${APP_NAME}-%d{yyyy-MM-dd}.log
- 30
-
-
- ${FILE_LOG_PATTERN}
-
-
-
-
- localhost:4560
-
-
-
-
-
-
-
-
-
diff --git a/mall-config/pom.xml b/mall-auth/pom.xml
similarity index 54%
rename from mall-config/pom.xml
rename to mall-auth/pom.xml
index b8db18b..cacc678 100644
--- a/mall-config/pom.xml
+++ b/mall-auth/pom.xml
@@ -1,13 +1,16 @@
-
+
4.0.0
com.macro.mall
- mall-config
+ mall-auth
1.0-SNAPSHOT
- mall-config
- mall-config project for mall
+ jar
+
+ mall-auth
+ mall-auth project for mall
com.macro.mall
@@ -17,12 +20,46 @@
- org.springframework.cloud
- spring-cloud-config-server
+ com.macro.mall
+ mall-common
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+ org.springframework.boot
+ spring-boot-starter-security
org.springframework.cloud
- spring-cloud-starter-netflix-eureka-client
+ spring-cloud-starter-oauth2
+
+
+ com.nimbusds
+ nimbus-jose-jwt
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-okhttp
@@ -62,4 +99,4 @@
-
+
\ No newline at end of file
diff --git a/mall-config/src/main/java/com/macro/mall/MallConfigApplication.java b/mall-auth/src/main/java/com/macro/mall/auth/MallAuthApplication.java
similarity index 50%
rename from mall-config/src/main/java/com/macro/mall/MallConfigApplication.java
rename to mall-auth/src/main/java/com/macro/mall/auth/MallAuthApplication.java
index 2c6c13d..8c6cda8 100644
--- a/mall-config/src/main/java/com/macro/mall/MallConfigApplication.java
+++ b/mall-auth/src/main/java/com/macro/mall/auth/MallAuthApplication.java
@@ -1,17 +1,17 @@
-package com.macro.mall;
+package com.macro.mall.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.config.server.EnableConfigServer;
+import org.springframework.cloud.openfeign.EnableFeignClients;
-@EnableConfigServer
+@EnableFeignClients
@EnableDiscoveryClient
-@SpringBootApplication
-public class MallConfigApplication {
+@SpringBootApplication(scanBasePackages = "com.macro.mall")
+public class MallAuthApplication {
public static void main(String[] args) {
- SpringApplication.run(MallConfigApplication.class, args);
+ SpringApplication.run(MallAuthApplication.class, args);
}
}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/component/JwtTokenEnhancer.java b/mall-auth/src/main/java/com/macro/mall/auth/component/JwtTokenEnhancer.java
new file mode 100644
index 0000000..c6b9e80
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/component/JwtTokenEnhancer.java
@@ -0,0 +1,29 @@
+package com.macro.mall.auth.component;
+
+import com.macro.mall.auth.domain.SecurityUser;
+import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.token.TokenEnhancer;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * JWT内容增强器
+ * Created by macro on 2020/6/19.
+ */
+@Component
+public class JwtTokenEnhancer implements TokenEnhancer {
+ @Override
+ public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
+ SecurityUser securityUser = (SecurityUser) authentication.getPrincipal();
+ Map info = new HashMap<>();
+ //把用户ID设置到JWT中
+ info.put("id", securityUser.getId());
+ info.put("client_id",securityUser.getClientId());
+ ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(info);
+ return accessToken;
+ }
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/config/Oauth2ServerConfig.java b/mall-auth/src/main/java/com/macro/mall/auth/config/Oauth2ServerConfig.java
new file mode 100644
index 0000000..ae90217
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/config/Oauth2ServerConfig.java
@@ -0,0 +1,89 @@
+package com.macro.mall.auth.config;
+
+import com.macro.mall.auth.component.JwtTokenEnhancer;
+import com.macro.mall.auth.service.impl.UserServiceImpl;
+import lombok.AllArgsConstructor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.TokenEnhancer;
+import org.springframework.security.oauth2.provider.token.TokenEnhancerChain;
+import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+import org.springframework.security.rsa.crypto.KeyStoreKeyFactory;
+
+import java.security.KeyPair;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 认证服务器配置
+ * Created by macro on 2020/6/19.
+ */
+@AllArgsConstructor
+@Configuration
+@EnableAuthorizationServer
+public class Oauth2ServerConfig extends AuthorizationServerConfigurerAdapter {
+
+ private final PasswordEncoder passwordEncoder;
+ private final UserServiceImpl userDetailsService;
+ private final AuthenticationManager authenticationManager;
+ private final JwtTokenEnhancer jwtTokenEnhancer;
+
+ @Override
+ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
+ clients.inMemory()
+ .withClient("admin-app")
+ .secret(passwordEncoder.encode("123456"))
+ .scopes("all")
+ .authorizedGrantTypes("password", "refresh_token")
+ .accessTokenValiditySeconds(3600)
+ .refreshTokenValiditySeconds(86400)
+ .and()
+ .withClient("portal-app")
+ .secret(passwordEncoder.encode("123456"))
+ .scopes("all")
+ .authorizedGrantTypes("password", "refresh_token")
+ .accessTokenValiditySeconds(3600)
+ .refreshTokenValiditySeconds(86400);
+ }
+
+ @Override
+ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
+ TokenEnhancerChain enhancerChain = new TokenEnhancerChain();
+ List delegates = new ArrayList<>();
+ delegates.add(jwtTokenEnhancer);
+ delegates.add(accessTokenConverter());
+ enhancerChain.setTokenEnhancers(delegates); //配置JWT的内容增强器
+ endpoints.authenticationManager(authenticationManager)
+ .userDetailsService(userDetailsService) //配置加载用户信息的服务
+ .accessTokenConverter(accessTokenConverter())
+ .tokenEnhancer(enhancerChain);
+ }
+
+ @Override
+ public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
+ security.allowFormAuthenticationForClients();
+ }
+
+ @Bean
+ public JwtAccessTokenConverter accessTokenConverter() {
+ JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
+ jwtAccessTokenConverter.setKeyPair(keyPair());
+ return jwtAccessTokenConverter;
+ }
+
+ @Bean
+ public KeyPair keyPair() {
+ //从classpath下的证书中获取秘钥对
+ KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "123456".toCharArray());
+ return keyStoreKeyFactory.getKeyPair("jwt", "123456".toCharArray());
+ }
+
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java b/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java
new file mode 100644
index 0000000..4de6626
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/config/SwaggerConfig.java
@@ -0,0 +1,27 @@
+package com.macro.mall.auth.config;
+
+import com.macro.mall.common.config.BaseSwaggerConfig;
+import com.macro.mall.common.domain.SwaggerProperties;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**
+ * Swagger API文档相关配置
+ * Created by macro on 2018/4/26.
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig extends BaseSwaggerConfig {
+
+ @Override
+ public SwaggerProperties swaggerProperties() {
+ return SwaggerProperties.builder()
+ .apiBasePackage("com.macro.mall.auth.controller")
+ .title("mall认证中心")
+ .description("mall认证中心相关接口文档")
+ .contactName("macro")
+ .version("1.0")
+ .enableSecurity(true)
+ .build();
+ }
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java b/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java
new file mode 100644
index 0000000..537f831
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/config/WebSecurityConfig.java
@@ -0,0 +1,41 @@
+package com.macro.mall.auth.config;
+
+import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+/**
+ * SpringSecurity配置
+ * Created by macro on 2020/6/19.
+ */
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.authorizeRequests()
+ .requestMatchers(EndpointRequest.toAnyEndpoint()).permitAll()
+ .antMatchers("/rsa/publicKey").permitAll()
+ .antMatchers("/v2/api-docs").permitAll()
+ .anyRequest().authenticated();
+ }
+
+ @Bean
+ @Override
+ public AuthenticationManager authenticationManagerBean() throws Exception {
+ return super.authenticationManagerBean();
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/constant/MessageConstant.java b/mall-auth/src/main/java/com/macro/mall/auth/constant/MessageConstant.java
new file mode 100644
index 0000000..a2f9738
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/constant/MessageConstant.java
@@ -0,0 +1,23 @@
+package com.macro.mall.auth.constant;
+
+/**
+ * 消息常量
+ * Created by macro on 2020/6/19.
+ */
+public class MessageConstant {
+
+ public static final String LOGIN_SUCCESS = "登录成功!";
+
+ public static final String USERNAME_PASSWORD_ERROR = "用户名或密码错误!";
+
+ public static final String CREDENTIALS_EXPIRED = "该账户的登录凭证已过期,请重新登录!";
+
+ public static final String ACCOUNT_DISABLED = "该账户已被禁用,请联系管理员!";
+
+ public static final String ACCOUNT_LOCKED = "该账号已被锁定,请联系管理员!";
+
+ public static final String ACCOUNT_EXPIRED = "该账号已过期,请联系管理员!";
+
+ public static final String PERMISSION_DENIED = "没有访问权限,请联系管理员!";
+
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/controller/AuthController.java b/mall-auth/src/main/java/com/macro/mall/auth/controller/AuthController.java
new file mode 100644
index 0000000..3aa8865
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/controller/AuthController.java
@@ -0,0 +1,55 @@
+package com.macro.mall.auth.controller;
+
+import com.macro.mall.auth.domain.Oauth2TokenDto;
+import com.macro.mall.common.api.CommonResult;
+import com.macro.mall.common.constant.AuthConstant;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
+import org.springframework.web.HttpRequestMethodNotSupportedException;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.security.Principal;
+import java.util.Map;
+
+/**
+ * 自定义Oauth2获取令牌接口
+ * Created by macro on 2020/7/17.
+ */
+@RestController
+@Api(tags = "AuthController", description = "认证中心登录认证")
+@RequestMapping("/oauth")
+public class AuthController {
+
+ @Autowired
+ private TokenEndpoint tokenEndpoint;
+
+ @ApiOperation("Oauth2获取token")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "grant_type", value = "授权模式", required = true),
+ @ApiImplicitParam(name = "client_id", value = "Oauth2客户端ID", required = true),
+ @ApiImplicitParam(name = "client_secret", value = "Oauth2客户端秘钥", required = true),
+ @ApiImplicitParam(name = "refresh_token", value = "刷新token"),
+ @ApiImplicitParam(name = "username", value = "登录用户名"),
+ @ApiImplicitParam(name = "password", value = "登录密码")
+ })
+ @RequestMapping(value = "/token", method = RequestMethod.POST)
+ public CommonResult postAccessToken(@ApiIgnore Principal principal, @ApiIgnore @RequestParam Map parameters) throws HttpRequestMethodNotSupportedException {
+ OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
+ Oauth2TokenDto oauth2TokenDto = Oauth2TokenDto.builder()
+ .token(oAuth2AccessToken.getValue())
+ .refreshToken(oAuth2AccessToken.getRefreshToken().getValue())
+ .expiresIn(oAuth2AccessToken.getExpiresIn())
+ .tokenHead(AuthConstant.JWT_TOKEN_PREFIX).build();
+
+ return CommonResult.success(oauth2TokenDto);
+ }
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java b/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java
new file mode 100644
index 0000000..c21c1a2
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/controller/KeyPairController.java
@@ -0,0 +1,30 @@
+package com.macro.mall.auth.controller;
+
+import com.nimbusds.jose.jwk.JWKSet;
+import com.nimbusds.jose.jwk.RSAKey;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.security.KeyPair;
+import java.security.interfaces.RSAPublicKey;
+import java.util.Map;
+
+/**
+ * 获取RSA公钥接口
+ * Created by macro on 2020/6/19.
+ */
+@RestController
+public class KeyPairController {
+
+ @Autowired
+ private KeyPair keyPair;
+
+ @GetMapping("/rsa/publicKey")
+ public Map getKey() {
+ RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
+ RSAKey key = new RSAKey.Builder(publicKey).build();
+ return new JWKSet(key).toJSONObject();
+ }
+
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/domain/Oauth2TokenDto.java b/mall-auth/src/main/java/com/macro/mall/auth/domain/Oauth2TokenDto.java
new file mode 100644
index 0000000..8464b15
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/domain/Oauth2TokenDto.java
@@ -0,0 +1,24 @@
+package com.macro.mall.auth.domain;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * Oauth2获取Token返回信息封装
+ * Created by macro on 2020/7/17.
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Builder
+public class Oauth2TokenDto {
+ @ApiModelProperty("访问令牌")
+ private String token;
+ @ApiModelProperty("刷令牌")
+ private String refreshToken;
+ @ApiModelProperty("访问令牌头前缀")
+ private String tokenHead;
+ @ApiModelProperty("有效时间(秒)")
+ private int expiresIn;
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/domain/SecurityUser.java b/mall-auth/src/main/java/com/macro/mall/auth/domain/SecurityUser.java
new file mode 100644
index 0000000..c07017e
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/domain/SecurityUser.java
@@ -0,0 +1,95 @@
+package com.macro.mall.auth.domain;
+
+import com.macro.mall.common.domain.UserDto;
+import lombok.Data;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * 登录用户信息
+ * Created by macro on 2020/6/19.
+ */
+@Data
+public class SecurityUser implements UserDetails {
+
+ /**
+ * ID
+ */
+ private Long id;
+ /**
+ * 用户名
+ */
+ private String username;
+ /**
+ * 用户密码
+ */
+ private String password;
+ /**
+ * 用户状态
+ */
+ private Boolean enabled;
+ /**
+ * 登录客户端ID
+ */
+ private String clientId;
+ /**
+ * 权限数据
+ */
+ private Collection authorities;
+
+ public SecurityUser() {
+
+ }
+
+ public SecurityUser(UserDto userDto) {
+ this.setId(userDto.getId());
+ this.setUsername(userDto.getUsername());
+ this.setPassword(userDto.getPassword());
+ this.setEnabled(userDto.getStatus() == 1);
+ this.setClientId(userDto.getClientId());
+ if (userDto.getRoles() != null) {
+ authorities = new ArrayList<>();
+ userDto.getRoles().forEach(item -> authorities.add(new SimpleGrantedAuthority(item)));
+ }
+ }
+
+ @Override
+ public Collection extends GrantedAuthority> getAuthorities() {
+ return this.authorities;
+ }
+
+ @Override
+ public String getPassword() {
+ return this.password;
+ }
+
+ @Override
+ public String getUsername() {
+ return this.username;
+ }
+
+ @Override
+ public boolean isAccountNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isAccountNonLocked() {
+ return true;
+ }
+
+ @Override
+ public boolean isCredentialsNonExpired() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/exception/Oauth2ExceptionHandler.java b/mall-auth/src/main/java/com/macro/mall/auth/exception/Oauth2ExceptionHandler.java
new file mode 100644
index 0000000..f237a4d
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/exception/Oauth2ExceptionHandler.java
@@ -0,0 +1,20 @@
+package com.macro.mall.auth.exception;
+
+import com.macro.mall.common.api.CommonResult;
+import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 全局处理Oauth2抛出的异常
+ * Created by macro on 2020/7/17.
+ */
+@ControllerAdvice
+public class Oauth2ExceptionHandler {
+ @ResponseBody
+ @ExceptionHandler(value = OAuth2Exception.class)
+ public CommonResult handleOauth2(OAuth2Exception e) {
+ return CommonResult.failed(e.getMessage());
+ }
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/service/UmsAdminService.java b/mall-auth/src/main/java/com/macro/mall/auth/service/UmsAdminService.java
new file mode 100644
index 0000000..e386fb7
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/service/UmsAdminService.java
@@ -0,0 +1,16 @@
+package com.macro.mall.auth.service;
+
+import com.macro.mall.common.domain.UserDto;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Created by macro on 2019/10/18.
+ */
+@FeignClient("mall-admin")
+public interface UmsAdminService {
+
+ @GetMapping("/admin/loadByUsername")
+ UserDto loadUserByUsername(@RequestParam String username);
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/service/UmsMemberService.java b/mall-auth/src/main/java/com/macro/mall/auth/service/UmsMemberService.java
new file mode 100644
index 0000000..25fb689
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/service/UmsMemberService.java
@@ -0,0 +1,15 @@
+package com.macro.mall.auth.service;
+
+import com.macro.mall.common.domain.UserDto;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Created by macro on 2020/7/16.
+ */
+@FeignClient("mall-portal")
+public interface UmsMemberService {
+ @GetMapping("/sso/loadByUsername")
+ UserDto loadUserByUsername(@RequestParam String username);
+}
diff --git a/mall-auth/src/main/java/com/macro/mall/auth/service/impl/UserServiceImpl.java b/mall-auth/src/main/java/com/macro/mall/auth/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..4563988
--- /dev/null
+++ b/mall-auth/src/main/java/com/macro/mall/auth/service/impl/UserServiceImpl.java
@@ -0,0 +1,61 @@
+package com.macro.mall.auth.service.impl;
+
+import com.macro.mall.auth.domain.SecurityUser;
+import com.macro.mall.auth.constant.MessageConstant;
+import com.macro.mall.auth.service.UmsAdminService;
+import com.macro.mall.auth.service.UmsMemberService;
+import com.macro.mall.common.constant.AuthConstant;
+import com.macro.mall.common.domain.UserDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.AccountExpiredException;
+import org.springframework.security.authentication.CredentialsExpiredException;
+import org.springframework.security.authentication.DisabledException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 用户管理业务类
+ * Created by macro on 2020/6/19.
+ */
+@Service
+public class UserServiceImpl implements UserDetailsService {
+
+ @Autowired
+ private UmsAdminService adminService;
+ @Autowired
+ private UmsMemberService memberService;
+ @Autowired
+ private HttpServletRequest request;
+
+ @Override
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+ String clientId = request.getParameter("client_id");
+ UserDto userDto;
+ if(AuthConstant.ADMIN_CLIENT_ID.equals(clientId)){
+ userDto = adminService.loadUserByUsername(username);
+ }else{
+ userDto = memberService.loadUserByUsername(username);
+ }
+ if (userDto==null) {
+ throw new UsernameNotFoundException(MessageConstant.USERNAME_PASSWORD_ERROR);
+ }
+ userDto.setClientId(clientId);
+ SecurityUser securityUser = new SecurityUser(userDto);
+ if (!securityUser.isEnabled()) {
+ throw new DisabledException(MessageConstant.ACCOUNT_DISABLED);
+ } else if (!securityUser.isAccountNonLocked()) {
+ throw new LockedException(MessageConstant.ACCOUNT_LOCKED);
+ } else if (!securityUser.isAccountNonExpired()) {
+ throw new AccountExpiredException(MessageConstant.ACCOUNT_EXPIRED);
+ } else if (!securityUser.isCredentialsNonExpired()) {
+ throw new CredentialsExpiredException(MessageConstant.CREDENTIALS_EXPIRED);
+ }
+ return securityUser;
+ }
+
+}
diff --git a/mall-auth/src/main/resources/application.yml b/mall-auth/src/main/resources/application.yml
new file mode 100644
index 0000000..b66c00d
--- /dev/null
+++ b/mall-auth/src/main/resources/application.yml
@@ -0,0 +1,13 @@
+server:
+ port: 8401
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+feign:
+ okhttp:
+ enabled: true
+ribbon:
+ ConnectTimeout: 3000 #服务请求连接超时时间(毫秒)
+ ReadTimeout: 3000 #服务请求处理超时时间(毫秒)
diff --git a/mall-auth/src/main/resources/bootstrap-dev.yml b/mall-auth/src/main/resources/bootstrap-dev.yml
new file mode 100644
index 0000000..d9d496a
--- /dev/null
+++ b/mall-auth/src/main/resources/bootstrap-dev.yml
@@ -0,0 +1,11 @@
+spring:
+ cloud:
+ nacos:
+ discovery:
+ server-addr: http://localhost:8848
+ config:
+ server-addr: http://localhost:8848
+ file-extension: yaml
+logging:
+ level:
+ root: debug
\ No newline at end of file
diff --git a/mall-auth/src/main/resources/bootstrap-prod.yml b/mall-auth/src/main/resources/bootstrap-prod.yml
new file mode 100644
index 0000000..15564b9
--- /dev/null
+++ b/mall-auth/src/main/resources/bootstrap-prod.yml
@@ -0,0 +1,11 @@
+spring:
+ cloud:
+ nacos:
+ discovery:
+ server-addr: http://nacos-registry:8848
+ config:
+ server-addr: http://nacos-registry:8848
+ file-extension: yaml
+logging:
+ level:
+ root: info
\ No newline at end of file
diff --git a/mall-auth/src/main/resources/bootstrap.yml b/mall-auth/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..75e96d9
--- /dev/null
+++ b/mall-auth/src/main/resources/bootstrap.yml
@@ -0,0 +1,5 @@
+spring:
+ profiles:
+ active: dev
+ application:
+ name: mall-auth
\ No newline at end of file
diff --git a/mall-auth/src/main/resources/jwt.jks b/mall-auth/src/main/resources/jwt.jks
new file mode 100644
index 0000000..af359ea
Binary files /dev/null and b/mall-auth/src/main/resources/jwt.jks differ
diff --git a/mall-common/pom.xml b/mall-common/pom.xml
index 4ffe1c4..ee34b46 100644
--- a/mall-common/pom.xml
+++ b/mall-common/pom.xml
@@ -20,35 +20,27 @@
com.github.pagehelper
- pagehelper-spring-boot-starter
+ pagehelper
org.springframework.boot
spring-boot-starter-web
- com.alibaba
- druid-spring-boot-starter
-
-
- io.springfox
- springfox-swagger2
-
-
- io.springfox
- springfox-swagger-ui
+ org.springframework.boot
+ spring-boot-starter-data-redis
org.springframework.data
spring-data-commons
- cn.hutool
- hutool-all
+ com.github.xiaoymin
+ knife4j-micro-spring-boot-starter
- org.projectlombok
- lombok
+ net.logstash.logback
+ logstash-logback-encoder
diff --git a/mall-common/src/main/java/com/macro/mall/common/annotation/CacheException.java b/mall-common/src/main/java/com/macro/mall/common/annotation/CacheException.java
new file mode 100644
index 0000000..fc37d5c
--- /dev/null
+++ b/mall-common/src/main/java/com/macro/mall/common/annotation/CacheException.java
@@ -0,0 +1,12 @@
+package com.macro.mall.common.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 自定义注解,有该注解的缓存方法会抛出异常
+ */
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CacheException {
+}
diff --git a/mall-common/src/main/java/com/macro/mall/common/config/BaseRedisConfig.java b/mall-common/src/main/java/com/macro/mall/common/config/BaseRedisConfig.java
new file mode 100644
index 0000000..27a137d
--- /dev/null
+++ b/mall-common/src/main/java/com/macro/mall/common/config/BaseRedisConfig.java
@@ -0,0 +1,69 @@
+package com.macro.mall.common.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+import com.macro.mall.common.service.RedisService;
+import com.macro.mall.common.service.impl.RedisServiceImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import java.time.Duration;
+
+/**
+ * Redis基础配置
+ * Created by macro on 2020/6/19.
+ */
+public class BaseRedisConfig {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisSerializer