├── service-web
├── .env.development
├── .env.production
├── babel.config.js
├── public
│ ├── favicon.ico
│ └── index.html
├── src
│ ├── assets
│ │ ├── logo.png
│ │ ├── login
│ │ │ └── bg.jpg
│ │ └── mall
│ │ │ ├── drink.jpg
│ │ │ ├── flow.jpg
│ │ │ ├── phone.jpg
│ │ │ ├── sekill.png
│ │ │ ├── product.jpg
│ │ │ └── header-panel.jpg
│ ├── plugins
│ │ ├── router.js
│ │ └── element.js
│ ├── api
│ │ ├── login.js
│ │ └── workflow.js
│ ├── App.vue
│ ├── main.js
│ ├── utils
│ │ ├── token.js
│ │ └── request.js
│ ├── element-variables.scss
│ ├── styles
│ │ └── index.css
│ ├── router
│ │ └── index.js
│ └── views
│ │ └── workflow
│ │ ├── taskList.vue
│ │ └── index.vue
├── .gitignore
├── README.md
├── package.json
└── vue.config.js
├── service-component
├── service-auth
│ ├── src
│ │ ├── main
│ │ │ ├── resources
│ │ │ │ ├── bootstrap.properties
│ │ │ │ ├── application.yml
│ │ │ │ ├── redisson
│ │ │ │ │ ├── redisson-dev.yml
│ │ │ │ │ ├── redisson-prd.yml
│ │ │ │ │ └── redisson-stg.yml
│ │ │ │ ├── application-prd.yml
│ │ │ │ ├── application-stg.yml
│ │ │ │ ├── mapper
│ │ │ │ │ ├── UserRoleRelationMapper.xml
│ │ │ │ │ ├── RoleResourceRelationMapper.xml
│ │ │ │ │ ├── RoleMapper.xml
│ │ │ │ │ ├── ResourceMapper.xml
│ │ │ │ │ └── UserMapper.xml
│ │ │ │ └── application-dev.yml
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── auth
│ │ │ │ ├── mapper
│ │ │ │ ├── RoleMapper.java
│ │ │ │ ├── UserMapper.java
│ │ │ │ ├── ResourceMapper.java
│ │ │ │ ├── UserRoleRelationMapper.java
│ │ │ │ └── RoleResourceRelationMapper.java
│ │ │ │ ├── service
│ │ │ │ ├── IRoleService.java
│ │ │ │ ├── IUserService.java
│ │ │ │ ├── IResourceService.java
│ │ │ │ ├── IUserRoleRelationService.java
│ │ │ │ ├── IRoleResourceRelationService.java
│ │ │ │ └── impl
│ │ │ │ │ ├── RoleServiceImpl.java
│ │ │ │ │ ├── ResourceServiceImpl.java
│ │ │ │ │ ├── UserRoleRelationServiceImpl.java
│ │ │ │ │ ├── RoleResourceRelationServiceImpl.java
│ │ │ │ │ └── UserServiceImpl.java
│ │ │ │ ├── facade
│ │ │ │ ├── client
│ │ │ │ │ └── MessageServiceClient.java
│ │ │ │ ├── MessageFeignService.java
│ │ │ │ └── kafka
│ │ │ │ │ └── producer
│ │ │ │ │ ├── ShortMessageProducer.java
│ │ │ │ │ └── IntegralProducer.java
│ │ │ │ ├── entity
│ │ │ │ ├── UserRoleRelation.java
│ │ │ │ ├── Role.java
│ │ │ │ ├── RoleResourceRelation.java
│ │ │ │ ├── Resource.java
│ │ │ │ └── User.java
│ │ │ │ ├── AuthApplication.java
│ │ │ │ └── controller
│ │ │ │ ├── RoleController.java
│ │ │ │ ├── UserController.java
│ │ │ │ └── AuthController.java
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── cloud
│ │ │ └── auth
│ │ │ ├── controller
│ │ │ └── UserControllerTest.java
│ │ │ └── facade
│ │ │ └── kafka
│ │ │ └── producer
│ │ │ └── IntegralProducerTest.java
│ └── pom.xml
├── service-search
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── cloud
│ │ │ │ │ └── search
│ │ │ │ │ ├── config
│ │ │ │ │ └── ElasticSearchConfig.java
│ │ │ │ │ ├── repository
│ │ │ │ │ └── ProductRepository.java
│ │ │ │ │ ├── service
│ │ │ │ │ ├── ProductService.java
│ │ │ │ │ └── impl
│ │ │ │ │ │ └── ProductServiceImpl.java
│ │ │ │ │ ├── model
│ │ │ │ │ └── Product.java
│ │ │ │ │ └── SearchApplication.java
│ │ │ └── resources
│ │ │ │ ├── application.yml
│ │ │ │ └── redisson.yml
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── cloud
│ │ │ └── search
│ │ │ └── SearchApplicationTest.java
│ └── pom.xml
├── service-integral
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── cloud
│ │ │ │ │ └── integral
│ │ │ │ │ ├── service
│ │ │ │ │ ├── IIntegralRecordService.java
│ │ │ │ │ ├── IIntegralErrorRecordService.java
│ │ │ │ │ ├── IIntegralUserCountService.java
│ │ │ │ │ └── impl
│ │ │ │ │ │ ├── IntegralRecordServiceImpl.java
│ │ │ │ │ │ ├── IntegralErrorRecordServiceImpl.java
│ │ │ │ │ │ └── IntegralUserCountServiceImpl.java
│ │ │ │ │ ├── mapper
│ │ │ │ │ ├── IntegralUserCountMapper.java
│ │ │ │ │ ├── IntegralErrorRecordMapper.java
│ │ │ │ │ └── IntegralRecordMapper.java
│ │ │ │ │ ├── config
│ │ │ │ │ ├── IntegralRecordConfig.java
│ │ │ │ │ ├── IntegralDatabaseStrategy.java
│ │ │ │ │ └── IntegralTableStrategy.java
│ │ │ │ │ ├── IntegralApplication.java
│ │ │ │ │ ├── facade
│ │ │ │ │ └── kafka
│ │ │ │ │ │ ├── conveter
│ │ │ │ │ │ └── IntegralConverter.java
│ │ │ │ │ │ └── consumer
│ │ │ │ │ │ └── IntegralConsumer.java
│ │ │ │ │ └── entity
│ │ │ │ │ ├── IntegralErrorRecord.java
│ │ │ │ │ ├── IntegralUserCount.java
│ │ │ │ │ └── IntegralRecord.java
│ │ │ └── resources
│ │ │ │ ├── redisson.yml
│ │ │ │ ├── mapper
│ │ │ │ ├── IntegralErrorRecordMapper.xml
│ │ │ │ ├── IntegralUserCountMapper.xml
│ │ │ │ └── IntegralRecordMapper.xml
│ │ │ │ └── application.yml
│ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── cloud
│ │ │ └── integral
│ │ │ ├── mapper
│ │ │ └── IntegralRecordMapperTest.java
│ │ │ └── service
│ │ │ ├── IIntegralErrorRecordServiceTest.java
│ │ │ └── IIntegralRecordServiceTest.java
│ └── pom.xml
├── service-message
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── message
│ │ │ │ ├── controller
│ │ │ │ └── MessageController.java
│ │ │ │ └── MessageApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
├── service-pay
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── pay
│ │ │ │ └── PayApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
├── service-ware
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── ware
│ │ │ │ └── WareApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
├── service-product
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── mall
│ │ │ │ └── MallApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
├── service-order
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── order
│ │ │ │ └── OrderApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
├── service-seckill
│ ├── src
│ │ └── main
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── seckill
│ │ │ │ └── SeckillApplication.java
│ │ │ └── resources
│ │ │ └── application.yml
│ └── pom.xml
└── pom.xml
├── service-common
├── src
│ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── cloud
│ │ │ └── common
│ │ │ ├── tree
│ │ │ ├── Tree.java
│ │ │ ├── TreeUtil.java
│ │ │ └── DefaultTree.java
│ │ │ ├── base
│ │ │ ├── PageEntity.java
│ │ │ └── BaseEntity.java
│ │ │ ├── constant
│ │ │ ├── KafkaConstant.java
│ │ │ └── GlobalConstant.java
│ │ │ ├── exception
│ │ │ ├── BusinessException.java
│ │ │ ├── RedissonException.java
│ │ │ ├── ResponseResultValidateException.java
│ │ │ ├── AuthException.java
│ │ │ └── handler
│ │ │ │ └── GlobalExceptionHandler.java
│ │ │ ├── enums
│ │ │ ├── IntegralTypeEnum.java
│ │ │ ├── ResponseCodeEnum.java
│ │ │ ├── IntegralSourceEnum.java
│ │ │ └── MessageTemplateCodeEnum.java
│ │ │ ├── event
│ │ │ ├── ApplicationReadyEventListener.java
│ │ │ └── ApplicationFailedEventListener.java
│ │ │ ├── model
│ │ │ └── dto
│ │ │ │ ├── ShortMessageDTO.java
│ │ │ │ └── IntegralDTO.java
│ │ │ ├── utils
│ │ │ ├── ResponseResultValidateUtil.java
│ │ │ ├── PasswordUtil.java
│ │ │ └── CodeAutoGeneratorUtil.java
│ │ │ ├── config
│ │ │ ├── RedisConfig.java
│ │ │ └── SwaggerConfig.java
│ │ │ ├── auth
│ │ │ ├── TokenProvider.java
│ │ │ ├── UserInfo.java
│ │ │ └── WebContext.java
│ │ │ ├── response
│ │ │ └── ResponseResult.java
│ │ │ └── lock
│ │ │ └── RedisDistributedLock.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── cloud
│ │ └── common
│ │ ├── utils
│ │ └── PasswordUtilTest.java
│ │ └── tree
│ │ └── TreeUtilTest.java
└── pom.xml
├── service-gateway
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── cloud
│ │ │ │ └── gateway
│ │ │ │ ├── mapper
│ │ │ │ └── RequestLogMapper.java
│ │ │ │ ├── service
│ │ │ │ ├── IRequestLogService.java
│ │ │ │ └── impl
│ │ │ │ │ └── RequestLogServiceImpl.java
│ │ │ │ ├── config
│ │ │ │ └── AuthProperties.java
│ │ │ │ ├── GatewayApplication.java
│ │ │ │ ├── entity
│ │ │ │ └── RequestLog.java
│ │ │ │ ├── handler
│ │ │ │ └── GlobalGatewayExceptionHandler.java
│ │ │ │ └── filter
│ │ │ │ └── AuthFilter.java
│ │ └── resources
│ │ │ ├── application.yml
│ │ │ ├── redisson.yml
│ │ │ ├── application-prd.yml
│ │ │ ├── application-stg.yml
│ │ │ ├── application-dev.yml
│ │ │ └── mapper
│ │ │ └── RequestLogMapper.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── cloud
│ │ └── gateway
│ │ └── filter
│ │ └── AuthFilterTest.java
└── pom.xml
├── .gitignore
├── README.md
└── pom.xml
/service-web/.env.development:
--------------------------------------------------------------------------------
1 | NODE_ENV = 'development'
2 | VUE_APP_API = ''
3 |
4 |
--------------------------------------------------------------------------------
/service-web/.env.production:
--------------------------------------------------------------------------------
1 | NODE_ENV = 'production'
2 | VUE_APP_API = ''
3 |
4 |
--------------------------------------------------------------------------------
/service-web/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/service-web/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/public/favicon.ico
--------------------------------------------------------------------------------
/service-web/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/logo.png
--------------------------------------------------------------------------------
/service-web/src/plugins/router.js:
--------------------------------------------------------------------------------
1 | import router from '@/router'
2 |
3 | export default (app) => {
4 | app.use(router)
5 | }
6 |
--------------------------------------------------------------------------------
/service-web/src/assets/login/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/login/bg.jpg
--------------------------------------------------------------------------------
/service-web/src/assets/mall/drink.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/drink.jpg
--------------------------------------------------------------------------------
/service-web/src/assets/mall/flow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/flow.jpg
--------------------------------------------------------------------------------
/service-web/src/assets/mall/phone.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/phone.jpg
--------------------------------------------------------------------------------
/service-web/src/assets/mall/sekill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/sekill.png
--------------------------------------------------------------------------------
/service-web/src/assets/mall/product.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/product.jpg
--------------------------------------------------------------------------------
/service-web/src/assets/mall/header-panel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhuwj921/spring-cloud-framework/HEAD/service-web/src/assets/mall/header-panel.jpg
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | spring.cloud.nacos.config.server-addr=127.0.0.1:8848
2 |
3 | spring.application.name=service-auth
--------------------------------------------------------------------------------
/service-web/src/plugins/element.js:
--------------------------------------------------------------------------------
1 | import ElementPlus from 'element-plus'
2 | import '../element-variables.scss'
3 | import locale from 'element-plus/lib/locale/lang/zh-cn'
4 |
5 | export default (app) => {
6 | app.use(ElementPlus, { locale })
7 | }
8 |
--------------------------------------------------------------------------------
/service-web/src/api/login.js:
--------------------------------------------------------------------------------
1 | import request from '@/utils/request'
2 |
3 | const BASE_PREFIX = '/api/service-auth'
4 |
5 | //登录接口
6 | export function login(data) {
7 | return request({
8 | url: BASE_PREFIX + '/auth/token',
9 | method: 'post',
10 | data: data
11 | })
12 | }
--------------------------------------------------------------------------------
/service-web/src/api/workflow.js:
--------------------------------------------------------------------------------
1 | import request from '@/utils/request'
2 |
3 | const BASE_PREFIX = '/api/service-workflow'
4 |
5 | //任务列表接口
6 | export function page(data) {
7 | return request({
8 | url: BASE_PREFIX + '/task/page',
9 | method: 'post',
10 | data: data
11 | })
12 | }
--------------------------------------------------------------------------------
/service-web/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/service-web/src/main.js:
--------------------------------------------------------------------------------
1 | import {createApp} from 'vue'
2 | import App from './App.vue'
3 | import '@/styles/index.css'
4 | import installElementPlus from './plugins/element.js'
5 | import installVueRouter from './plugins/router.js'
6 |
7 |
8 | const app = createApp(App)
9 | installElementPlus(app)
10 | installVueRouter(app)
11 | app.mount('#app')
12 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/tree/Tree.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.tree;
2 |
3 | /**
4 | * @author zhuwj
5 | */
6 | public interface Tree {
7 | /**
8 | * 自身id
9 | * @return
10 | */
11 | Long getId();
12 |
13 | /**
14 | * 父级id
15 | * @return
16 | */
17 | Long getPid();
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/service-web/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/service-web/src/utils/token.js:
--------------------------------------------------------------------------------
1 | const TOKEN_NAME = "COULD-TOKEN"
2 |
3 | export function getToken() {
4 | return localStorage.getItem(TOKEN_NAME).toString()
5 | }
6 |
7 | export function setToken(value) {
8 | return localStorage.setItem(TOKEN_NAME, value)
9 | }
10 |
11 | export function removeToken() {
12 | return localStorage.removeItem(TOKEN_NAME)
13 | }
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/config/ElasticSearchConfig.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search.config;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 |
5 | /**
6 | * @author zhuwj
7 | * @date 2022/07/23 13:48
8 | * @description: ElasticSearch配置类
9 | **/
10 | @Configuration
11 | public class ElasticSearchConfig {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/mapper/RoleMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.mapper;
2 |
3 | import com.cloud.auth.entity.Role;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface RoleMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/mapper/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.mapper;
2 |
3 | import com.cloud.auth.entity.User;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface UserMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/IRoleService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service;
2 |
3 | import com.cloud.auth.entity.Role;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IRoleService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/IUserService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service;
2 |
3 | import com.cloud.auth.entity.User;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IUserService extends IService {
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/repository/ProductRepository.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search.repository;
2 |
3 | import com.cloud.search.model.Product;
4 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
5 |
6 | /**
7 | *
8 | * @author zhuwj
9 | */
10 | public interface ProductRepository extends ElasticsearchRepository {
11 | }
12 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8910
3 | spring:
4 | application:
5 | name: service-auth
6 | profiles:
7 | active: dev
8 | feign:
9 | client:
10 | config:
11 | default:
12 | connectTimeout: 5000
13 | readTimeout: 5000
14 | loggerLevel: basic
15 |
16 | mybatis-plus:
17 | mapper-locations: classpath:mapper/*Mapper.xml
18 |
--------------------------------------------------------------------------------
/service-web/src/element-variables.scss:
--------------------------------------------------------------------------------
1 | /*
2 | Write your variables here. All available variables can be
3 | found in element-plus/packages/theme-chalk/src/common/var.scss.
4 | For example, to overwrite the theme color:
5 | */
6 | $--color-primary: hotpink;
7 |
8 | /* icon font path, required */
9 | $--font-path: '~element-plus/lib/theme-chalk/fonts';
10 |
11 | @import "~element-plus/packages/theme-chalk/src/index";
12 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/mapper/ResourceMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.mapper;
2 |
3 | import com.cloud.auth.entity.Resource;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface ResourceMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/IResourceService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service;
2 |
3 | import com.cloud.auth.entity.Resource;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IResourceService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/mapper/RequestLogMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.mapper;
2 |
3 | import com.cloud.gateway.entity.RequestLog;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface RequestLogMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/service/IRequestLogService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.service;
2 |
3 | import com.cloud.gateway.entity.RequestLog;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IRequestLogService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-web/README.md:
--------------------------------------------------------------------------------
1 | # service-web
2 |
3 | ## Project setup
4 | ```
5 | yarn install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | yarn serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | yarn build
16 | ```
17 |
18 | ### Lints and fixes files
19 | ```
20 | yarn lint
21 | ```
22 |
23 | ### Customize configuration
24 | See [Configuration Reference](https://cli.vuejs.org/config/).
25 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/mapper/UserRoleRelationMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.mapper;
2 |
3 | import com.cloud.auth.entity.UserRoleRelation;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface UserRoleRelationMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/IUserRoleRelationService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service;
2 |
3 | import com.cloud.auth.entity.UserRoleRelation;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IUserRoleRelationService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/IIntegralRecordService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service;
2 |
3 | import com.cloud.integral.entity.IntegralRecord;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IIntegralRecordService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/mapper/RoleResourceRelationMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.mapper;
2 |
3 | import com.cloud.auth.entity.RoleResourceRelation;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface RoleResourceRelationMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/IRoleResourceRelationService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service;
2 |
3 | import com.cloud.auth.entity.RoleResourceRelation;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IRoleResourceRelationService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/mapper/IntegralUserCountMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.mapper;
2 |
3 | import com.cloud.integral.entity.IntegralUserCount;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-29
13 | */
14 | public interface IntegralUserCountMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/base/PageEntity.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.base;
2 |
3 | import lombok.Data;
4 | import org.springframework.data.domain.Sort;
5 |
6 | /**
7 | * Description: TODO
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-10-10
12 | */
13 | @Data
14 | public class PageEntity {
15 |
16 | private int page;
17 |
18 | private int size;
19 |
20 | private Sort sort;
21 |
22 | private T queryData;
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/mapper/IntegralErrorRecordMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.mapper;
2 |
3 | import com.cloud.integral.entity.IntegralErrorRecord;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * 积分错误信息表 Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-29
13 | */
14 | public interface IntegralErrorRecordMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/IIntegralErrorRecordService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service;
2 |
3 | import com.cloud.integral.entity.IntegralErrorRecord;
4 | import com.baomidou.mybatisplus.extension.service.IService;
5 |
6 | /**
7 | *
8 | * 积分错误信息表 服务类
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-29
13 | */
14 | public interface IIntegralErrorRecordService extends IService {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/service/ProductService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search.service;
2 |
3 | import com.cloud.search.model.Product;
4 |
5 | /**
6 | * @author zhuwj
7 | */
8 | public interface ProductService {
9 | /**
10 | * 保存
11 | * @param product
12 | */
13 | void save(Product product);
14 |
15 | /**
16 | * 查询
17 | * @param id
18 | * @return
19 | */
20 | Product findById(String id);
21 | }
22 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8990
3 | spring:
4 | application:
5 | name: service-search
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | redis:
10 | redisson:
11 | file: classpath:redisson.yml
12 | elasticsearch:
13 | rest:
14 | uris: 127.0.0.1:9200
15 | feign:
16 | client:
17 | config:
18 | default:
19 | connectTimeout: 5000
20 | readTimeout: 5000
21 | loggerLevel: basic
22 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/constant/KafkaConstant.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.constant;
2 |
3 | /**
4 | * @author zhuwj
5 | */
6 | public class KafkaConstant {
7 | /**
8 | * 积分topic
9 | */
10 | public static final String INTEGRAL_TOPIC = "integral_topic";
11 |
12 | /**
13 | * 短信topic
14 | */
15 | public static final String SHORT_MESSAGE_TOPIC = "short_message_topic";
16 |
17 | /**
18 | * 邮件topic
19 | */
20 | public static final String EMAIL_TOPIC = "email_topic";
21 | }
22 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/exception/BusinessException.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.exception;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: 业务异常
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-27
12 | */
13 |
14 | @Getter
15 | public class BusinessException extends RuntimeException {
16 |
17 |
18 | public BusinessException(CharSequence template, Object... params) {
19 | super(StrUtil.format(template, params));
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/exception/RedissonException.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.exception;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: Redisson异常
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-27
12 | */
13 |
14 | @Getter
15 | public class RedissonException extends RuntimeException {
16 |
17 |
18 | public RedissonException(CharSequence template, Object... params) {
19 | super(StrUtil.format(template, params));
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/model/Product.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search.model;
2 |
3 | import lombok.Data;
4 | import org.springframework.data.annotation.Id;
5 | import org.springframework.data.elasticsearch.annotations.Document;
6 |
7 | /**
8 | * @author zhuwj
9 | * @date 2022/07/23 23:04
10 | * @description: 产品信息
11 | **/
12 | @Document(indexName = "product")
13 | @Data
14 | public class Product {
15 |
16 | @Id
17 | private String id;
18 |
19 | private String productName;
20 |
21 | private String productType;
22 | }
23 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/mapper/IntegralRecordMapper.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.mapper;
2 |
3 | import com.cloud.integral.entity.IntegralRecord;
4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author zhuwj
12 | * @since 2022-05-15
13 | */
14 | public interface IntegralRecordMapper extends BaseMapper {
15 | /**
16 | * 动态建表
17 | *
18 | * @param tableName
19 | */
20 | void createTable(String tableName);
21 | }
22 |
--------------------------------------------------------------------------------
/service-common/src/test/java/com/cloud/common/utils/PasswordUtilTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.utils;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | /**
6 | * @author: zhuwj
7 | * @date: 2020/9/26 0:14
8 | * @description:
9 | */
10 | public class PasswordUtilTest {
11 |
12 | @Test
13 | public void test() {
14 | String oldPassword = PasswordUtil.generatePassword("sysadmin", "123456789");
15 | System.out.println(oldPassword);
16 | System.out.println(PasswordUtil.verifyPassword("sysadmin", "123456789",oldPassword));
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-web/src/styles/index.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 | outline: 0;
6 | -webkit-tap-highlight-color: transparent
7 | }
8 |
9 | html {
10 | min-width: 1190px;
11 | }
12 |
13 | body,
14 | html {
15 | height: 100%;
16 | background-color: #f4f4f4;
17 | color: #666;
18 | overflow-x: hidden;
19 | }
20 |
21 | a {
22 | text-decoration: none;
23 | cursor: pointer;
24 | }
25 | a:hover{
26 | color: #E4393C;
27 | text-decoration: underline;
28 | }
29 | img {
30 | border: 0;
31 | vertical-align: middle;
32 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # IDE Files #
2 | *.iml
3 | .idea
4 | .idea/
5 | .project
6 | .settings
7 | target
8 | .DS_Store
9 |
10 | # temp ignore
11 | *.cache
12 | *.diff
13 | *.patch
14 | *.tmp
15 |
16 | # Maven ignore
17 | .flattened-pom.xml
18 |
19 | # webpack
20 | .DS_Store
21 | node_modules
22 | /dist
23 |
24 |
25 | # local env files
26 | .env.local
27 | .env.*.local
28 |
29 | # Log files
30 | npm-debug.log*
31 | yarn-debug.log*
32 | yarn-error.log*
33 | pnpm-debug.log*
34 |
35 | # Editor directories and files
36 | .idea
37 | .vscode
38 | *.suo
39 | *.ntvs*
40 | *.njsproj
41 | *.sln
42 | *.sw?
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/enums/IntegralTypeEnum.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.enums;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: 积分类型
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-23
12 | */
13 |
14 | @AllArgsConstructor
15 | @Getter
16 | public enum IntegralTypeEnum {
17 | /**
18 | * 增加
19 | */
20 | GIVE(1, "增加"),
21 | /**
22 | * 消费
23 | */
24 | CONSUMER(2, "消费");
25 |
26 | private final Integer code;
27 |
28 | private final String label;
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8900
3 | spring:
4 | application:
5 | name: service-gateway
6 | redis:
7 | redisson:
8 | file: classpath:redisson.yml
9 | profiles:
10 | active: dev
11 |
12 | auth:
13 | ignore-url-patterns: /service-auth/auth/token,/service-auth/auth/refreshtoken,/service-auth/doc.html,/service-auth/swagger-ui.html,/service-auth/swagger-ui/*,/service-auth/swagger-resources/**,/service-auth/v2/api-docs,/service-auth/v3/api-docs,/service-auth/webjars/**
14 |
15 | mybatis-plus:
16 | mapper-locations: classpath:mapper/*Mapper.xml
17 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/enums/ResponseCodeEnum.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.enums;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: 响应code枚举
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-23
12 | */
13 |
14 | @AllArgsConstructor
15 | @Getter
16 | public enum ResponseCodeEnum {
17 | /**
18 | * 请求成功
19 | */
20 | OK("00000", "OK"),
21 | /**
22 | * 请求失败
23 | */
24 | ERROR("11111", "ERROR");
25 |
26 | private final String code;
27 |
28 | private final String msg;
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/impl/RoleServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service.impl;
2 |
3 | import com.cloud.auth.entity.Role;
4 | import com.cloud.auth.mapper.RoleMapper;
5 | import com.cloud.auth.service.IRoleService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class RoleServiceImpl extends ServiceImpl implements IRoleService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/config/IntegralRecordConfig.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.config;
2 |
3 | /**
4 | * @author zhuwj
5 | * @date 2022/05/23 20:40
6 | * @description: 积分表基础信息
7 | **/
8 | public interface IntegralRecordConfig {
9 | /**
10 | * 表名称前缀
11 | */
12 | String TABLE_PREFIX_NAME = "integral_record";
13 | /**
14 | * 表切片数量(0-255)
15 | */
16 | int TABLE_NODES = 256;
17 | /**
18 | * 数据库切片数量(0-3)
19 | */
20 | int DATABASE_NODES = 4;
21 | /**
22 | * 数据库前缀
23 | */
24 | String DATABASE_PREFIX_NAME = "ds";
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/exception/ResponseResultValidateException.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.exception;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import lombok.Getter;
5 |
6 | import static org.springframework.http.HttpStatus.UNAUTHORIZED;
7 |
8 | /**
9 | * Description: 结果校验异常
10 | *
11 | * @author zhuwj
12 | * @version V1.0
13 | * @date 2020-09-27
14 | */
15 |
16 | @Getter
17 | public class ResponseResultValidateException extends RuntimeException {
18 |
19 | public ResponseResultValidateException(CharSequence template, Object... params) {
20 | super(StrUtil.format(template, params));
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/impl/ResourceServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service.impl;
2 |
3 | import com.cloud.auth.entity.Resource;
4 | import com.cloud.auth.mapper.ResourceMapper;
5 | import com.cloud.auth.service.IResourceService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class ResourceServiceImpl extends ServiceImpl implements IResourceService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/exception/AuthException.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.exception;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import lombok.Getter;
5 |
6 | import static org.springframework.http.HttpStatus.UNAUTHORIZED;
7 |
8 | /**
9 | * Description: 授权异常
10 | *
11 | * @author zhuwj
12 | * @version V1.0
13 | * @date 2020-09-27
14 | */
15 |
16 | @Getter
17 | public class AuthException extends RuntimeException {
18 |
19 | private final Integer status = UNAUTHORIZED.value();
20 |
21 | public AuthException(CharSequence template, Object... params) {
22 | super(StrUtil.format(template, params));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/service/impl/RequestLogServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.service.impl;
2 |
3 | import com.cloud.gateway.entity.RequestLog;
4 | import com.cloud.gateway.mapper.RequestLogMapper;
5 | import com.cloud.gateway.service.IRequestLogService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class RequestLogServiceImpl extends ServiceImpl implements IRequestLogService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/IIntegralUserCountService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service;
2 |
3 | import com.cloud.common.model.dto.IntegralDTO;
4 | import com.cloud.integral.entity.IntegralUserCount;
5 | import com.baomidou.mybatisplus.extension.service.IService;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author zhuwj
13 | * @since 2022-05-29
14 | */
15 | public interface IIntegralUserCountService extends IService {
16 |
17 | /**
18 | * 积分统计和积分记录操作
19 | *
20 | * @param integral
21 | */
22 | void integralCountAndRecordChange(IntegralDTO integral);
23 | }
24 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/config/AuthProperties.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.config;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | import java.util.Set;
8 |
9 | /**
10 | * @title: security 配置
11 | * @description: 安全配置信息
12 | * @author: zhuwj
13 | * @create: 2020-09-21 14:37
14 | **/
15 | @Data
16 | @Configuration
17 | @ConfigurationProperties(prefix = "auth")
18 | public class AuthProperties {
19 |
20 | /**
21 | * 不需要鉴权的url
22 | */
23 | private Set ignoreUrlPatterns;
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/enums/IntegralSourceEnum.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.enums;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: 积分来源
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-23
12 | */
13 |
14 | @AllArgsConstructor
15 | @Getter
16 | public enum IntegralSourceEnum {
17 | /**
18 | * 请求成功
19 | */
20 | USER_REGISTER(1, "用户注册", 200),
21 | /**
22 | * 每日签到
23 | */
24 | EVERYDAY_SIGN(2, "每日签到", 10);
25 |
26 | private final Integer code;
27 |
28 | private final String label;
29 |
30 | private final Integer integralNum;
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/service-web/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/facade/client/MessageServiceClient.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.facade.client;
2 |
3 | import com.cloud.common.response.ResponseResult;
4 | import org.springframework.cloud.openfeign.FeignClient;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 |
7 | /**
8 | * Description: 消息服务 feign client
9 | *
10 | * @author zhuwj
11 | * @version V1.0
12 | * @date 2020-12-15
13 | */
14 |
15 | @FeignClient(name = "service-message")
16 | public interface MessageServiceClient {
17 |
18 | /**
19 | * 获取服务版本
20 | *
21 | * @return
22 | */
23 | @GetMapping("message/version")
24 | ResponseResult getVersion();
25 | }
26 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/impl/UserRoleRelationServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service.impl;
2 |
3 | import com.cloud.auth.entity.UserRoleRelation;
4 | import com.cloud.auth.mapper.UserRoleRelationMapper;
5 | import com.cloud.auth.service.IUserRoleRelationService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class UserRoleRelationServiceImpl extends ServiceImpl implements IUserRoleRelationService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/impl/IntegralRecordServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service.impl;
2 |
3 | import com.cloud.integral.entity.IntegralRecord;
4 | import com.cloud.integral.mapper.IntegralRecordMapper;
5 | import com.cloud.integral.service.IIntegralRecordService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class IntegralRecordServiceImpl extends ServiceImpl implements IIntegralRecordService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/event/ApplicationReadyEventListener.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.event;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.boot.context.event.ApplicationReadyEvent;
5 | import org.springframework.context.ApplicationListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | /**
9 | * Description: 启动成功事件
10 | *
11 | * @author zhuwj
12 | * @version V1.0
13 | * @date 2020-10-12
14 | */
15 | @Slf4j
16 | @Component
17 | public class ApplicationReadyEventListener implements ApplicationListener {
18 | @Override
19 | public void onApplicationEvent(ApplicationReadyEvent event) {
20 | log.info("system run success.");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/impl/RoleResourceRelationServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service.impl;
2 |
3 | import com.cloud.auth.entity.RoleResourceRelation;
4 | import com.cloud.auth.mapper.RoleResourceRelationMapper;
5 | import com.cloud.auth.service.IRoleResourceRelationService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-15
16 | */
17 | @Service
18 | public class RoleResourceRelationServiceImpl extends ServiceImpl implements IRoleResourceRelationService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/enums/MessageTemplateCodeEnum.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.enums;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 |
6 | /**
7 | * Description: 消息模板
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-09-23
12 | */
13 |
14 | @AllArgsConstructor
15 | @Getter
16 | public enum MessageTemplateCodeEnum {
17 | /**
18 | * 积分错误通知模板
19 | */
20 | INTEGRAL_ERROR_NOTIFY_TEMPLATE("integral_error_notify_template", "积分错误通知模板"),
21 | /**
22 | * 每日签到
23 | */
24 | SHORT_MESSAGE_AUTHENTICATION_CODE_TEMPLATE("short_message_authentication_code", "短信消息验证码模板");
25 |
26 | private final String code;
27 |
28 | private final String label;
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/event/ApplicationFailedEventListener.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.event;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.springframework.boot.context.event.ApplicationFailedEvent;
5 | import org.springframework.context.ApplicationListener;
6 | import org.springframework.stereotype.Component;
7 |
8 | /**
9 | * Description: 启动失败事件
10 | *
11 | * @author zhuwj
12 | * @version V1.0
13 | * @date 2020-10-12
14 | */
15 | @Slf4j
16 | @Component
17 | public class ApplicationFailedEventListener implements ApplicationListener {
18 | @Override
19 | public void onApplicationEvent(ApplicationFailedEvent event) {
20 | log.info("system run failed. ");
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.service.impl;
2 |
3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4 | import com.cloud.auth.entity.User;
5 | import com.cloud.auth.mapper.UserMapper;
6 | import com.cloud.auth.service.IUserService;
7 | import lombok.RequiredArgsConstructor;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.stereotype.Service;
10 |
11 | /**
12 | *
13 | * 服务实现类
14 | *
15 | *
16 | * @author zhuwj
17 | * @since 2022-05-15
18 | */
19 | @Slf4j
20 | @Service
21 | @RequiredArgsConstructor
22 | public class UserServiceImpl extends ServiceImpl implements IUserService {
23 |
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/impl/IntegralErrorRecordServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service.impl;
2 |
3 | import com.cloud.integral.entity.IntegralErrorRecord;
4 | import com.cloud.integral.mapper.IntegralErrorRecordMapper;
5 | import com.cloud.integral.service.IIntegralErrorRecordService;
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | *
11 | * 积分错误信息表 服务实现类
12 | *
13 | *
14 | * @author zhuwj
15 | * @since 2022-05-29
16 | */
17 | @Service
18 | public class IntegralErrorRecordServiceImpl extends ServiceImpl implements IIntegralErrorRecordService {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/model/dto/ShortMessageDTO.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.model.dto;
2 |
3 | import com.cloud.common.enums.MessageTemplateCodeEnum;
4 | import lombok.Builder;
5 | import lombok.Data;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @author zhuwj
11 | * @date 2022/05/28 22:49
12 | * @description: 短信消息DTO
13 | **/
14 | @Builder
15 | @Data
16 | public class ShortMessageDTO {
17 | /**
18 | * 电话号码
19 | */
20 | private String phoneNumber;
21 | /**
22 | * 模板编码
23 | */
24 | private MessageTemplateCodeEnum templateCode;
25 | /**
26 | * 消息参数
27 | */
28 | private List messageParams;
29 | /**
30 | * 消息编号
31 | */
32 | private String shortMessageNo;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/utils/ResponseResultValidateUtil.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.utils;
2 |
3 | import com.cloud.common.enums.ResponseCodeEnum;
4 | import com.cloud.common.exception.ResponseResultValidateException;
5 | import com.cloud.common.response.ResponseResult;
6 |
7 | /**
8 | * Description: 结果校验
9 | *
10 | * @author zhuwj
11 | * @version V1.0
12 | * @date 2020-12-15
13 | */
14 |
15 | public class ResponseResultValidateUtil {
16 |
17 | public static T validate(ResponseResult responseResult) {
18 | if (!ResponseCodeEnum.OK.getCode().equals(responseResult.getCode())) {
19 | throw new ResponseResultValidateException(responseResult.getMessage());
20 | }
21 | return responseResult.getData();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/facade/MessageFeignService.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.facade;
2 |
3 | import com.cloud.auth.facade.client.MessageServiceClient;
4 | import com.cloud.common.utils.ResponseResultValidateUtil;
5 | import lombok.RequiredArgsConstructor;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.stereotype.Service;
8 |
9 | /**
10 | * Description: 消息服务feign
11 | *
12 | * @author zhuwj
13 | * @version V1.0
14 | * @date 2020-12-15
15 | */
16 | @Slf4j
17 | @Service
18 | @RequiredArgsConstructor
19 | public class MessageFeignService {
20 |
21 | private final MessageServiceClient messageFeignClient;
22 |
23 | public String getVersion() {
24 | return ResponseResultValidateUtil.validate(messageFeignClient.getVersion());
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/service-web/src/router/index.js:
--------------------------------------------------------------------------------
1 | import {createRouter, createWebHashHistory} from 'vue-router'
2 |
3 | export const constantRoutes = [
4 | {
5 | path: '/',
6 | component: () => import('@/views/login')
7 | },
8 | {
9 | path: '/mall',
10 | component: () => import('@/views/mall')
11 | },
12 | {
13 | path: '/login',
14 | component: () => import('@/views/login')
15 | },
16 | {
17 | path: '/workflow',
18 | component: () => import('@/views/workflow')
19 | },
20 | {
21 | path: '/taskList',
22 | component: () => import('@/views/workflow/taskList')
23 | },
24 |
25 | ]
26 |
27 | const router = createRouter({
28 | history: createWebHashHistory(),
29 | routes: constantRoutes,
30 | })
31 |
32 | export default router
33 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/entity/UserRoleRelation.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 |
10 | /**
11 | *
12 | *
13 | *
14 | *
15 | * @author zhuwj
16 | * @since 2022-05-15
17 | */
18 | @Getter
19 | @Setter
20 | @TableName("auth_user_role_relation")
21 | @ApiModel(value = "UserRoleRelation对象", description = "用户与角色关系")
22 | public class UserRoleRelation extends BaseEntity {
23 |
24 | @TableField("role_id")
25 | private Long roleId;
26 |
27 | @TableField("user_id")
28 | private Long userId;
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/entity/Role.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 |
10 | /**
11 | *
12 | *
13 | *
14 | *
15 | * @author zhuwj
16 | * @since 2022-05-15
17 | */
18 | @Getter
19 | @Setter
20 | @TableName("auth_role")
21 | @ApiModel(value = "Role对象", description = "角色")
22 | public class Role extends BaseEntity {
23 |
24 | @TableField("role_key")
25 | private String roleKey;
26 |
27 | @TableField("role_name")
28 | private String roleName;
29 |
30 | @TableField("remark")
31 | private String remark;
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/entity/RoleResourceRelation.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 |
10 | /**
11 | *
12 | *
13 | *
14 | *
15 | * @author zhuwj
16 | * @since 2022-05-15
17 | */
18 | @Getter
19 | @Setter
20 | @TableName("auth_role_resource_relation")
21 | @ApiModel(value = "RoleResourceRelation对象", description = "角色与资源关系")
22 | public class RoleResourceRelation extends BaseEntity {
23 |
24 | @TableField("resource_id")
25 | private Long resourceId;
26 |
27 | @TableField("role_id")
28 | private Long roleId;
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/GatewayApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.context.config.annotation.RefreshScope;
8 | import org.springframework.context.annotation.ComponentScan;
9 | /**
10 | * @description: 网关应用启动
11 | * @author: zhuwj
12 | * @create: 2020-09-21 14:37
13 | **/
14 | @RefreshScope
15 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
16 | @MapperScan(GlobalConstant.MAPPER_SCAN)
17 | @SpringCloudApplication
18 | public class GatewayApplication {
19 | public static void main(String[] args) {
20 | SpringApplication.run(GatewayApplication.class, args);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/redisson.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/resources/redisson.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-component/service-search/src/main/resources/redisson.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/redisson/redisson-dev.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/redisson/redisson-prd.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/redisson/redisson-stg.yml:
--------------------------------------------------------------------------------
1 | singleServerConfig:
2 | #连接空闲超时,单位:毫秒
3 | idleConnectionTimeout: 10000
4 | #连接超时,单位:毫秒
5 | connectTimeout: 10000
6 | #命令等待超时,单位:毫秒
7 | timeout: 3000
8 | #命令失败重试次数
9 | retryAttempts: 3
10 | #命令重试发送时间间隔,单位:毫秒
11 | retryInterval: 1500
12 | #单个连接最大订阅数量
13 | subscriptionsPerConnection: 5
14 | #客户端名称
15 | clientName: service-gateway
16 | #地址
17 | address: "redis://127.0.0.1:6379"
18 | #数据库编号
19 | database: 0
20 | #密码
21 | password: cXLtoAfE85WkUi5R
22 | #发布和订阅连接的最小空闲连接数
23 | subscriptionConnectionMinimumIdleSize: 1
24 | #发布和订阅连接池大小
25 | subscriptionConnectionPoolSize: 50
26 | #最小空闲连接数
27 | connectionMinimumIdleSize: 32
28 | #连接池大小
29 | connectionPoolSize: 64
30 | #DNS监测时间间隔,单位:毫秒
31 | dnsMonitoringInterval: 5000
32 | threads: 0
33 | nettyThreads: 0
34 | codec: ! {}
35 | transportMode: "NIO"
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/entity/RequestLog.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import io.swagger.annotations.ApiModelProperty;
8 | import lombok.Getter;
9 | import lombok.Setter;
10 |
11 | /**
12 | *
13 | *
14 | *
15 | *
16 | * @author zhuwj
17 | * @since 2022-05-15
18 | */
19 | @Getter
20 | @Setter
21 | @TableName("gateway_request_log")
22 | @ApiModel(value = "RequestLog对象", description = "")
23 | public class RequestLog extends BaseEntity {
24 |
25 | @ApiModelProperty("请求url")
26 | @TableField("request_url")
27 | private String requestUrl;
28 |
29 | @ApiModelProperty("请求用户名称")
30 | @TableField("request_username")
31 | private String requestUsername;
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/service-component/service-message/src/main/java/com/cloud/message/controller/MessageController.java:
--------------------------------------------------------------------------------
1 | package com.cloud.message.controller;
2 |
3 | import com.cloud.common.response.ResponseResult;
4 | import lombok.RequiredArgsConstructor;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | /**
11 | * Description: 消息控制器
12 | *
13 | * @author zhuwj
14 | * @version V1.0
15 | * @date 2020-12-15
16 | */
17 | @Slf4j
18 | @RequestMapping("/message")
19 | @RestController
20 | @RequiredArgsConstructor
21 | public class MessageController {
22 |
23 | /**
24 | * 服务版本
25 | *
26 | * @return
27 | */
28 | @GetMapping("version")
29 | public ResponseResult getVersion() {
30 | return ResponseResult.ok("1.0.0");
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/application-prd.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
4 | username: root
5 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
6 | driver-class: com.mysql.cj.jdbc.Driver
7 | type: com.zaxxer.hikari.HikariDataSource
8 | hikari:
9 | minimum-idle: 5
10 | # 空闲连接存活最大时间,默认600000(10分钟)
11 | idle-timeout: 180000
12 | # 连接池最大连接数,默认是10
13 | maximum-pool-size: 10
14 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
15 | auto-commit: true
16 | # 连接池名称
17 | pool-name: MyHikariCP
18 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
19 | max-lifetime: 1800000
20 | # 数据库连接超时时间,默认30秒,即30000
21 | connection-timeout: 30000
22 | connection-test-query: SELECT 1
23 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/application-stg.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
4 | username: root
5 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
6 | driver-class: com.mysql.cj.jdbc.Driver
7 | type: com.zaxxer.hikari.HikariDataSource
8 | hikari:
9 | minimum-idle: 5
10 | # 空闲连接存活最大时间,默认600000(10分钟)
11 | idle-timeout: 180000
12 | # 连接池最大连接数,默认是10
13 | maximum-pool-size: 10
14 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
15 | auto-commit: true
16 | # 连接池名称
17 | pool-name: MyHikariCP
18 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
19 | max-lifetime: 1800000
20 | # 数据库连接超时时间,默认30秒,即30000
21 | connection-timeout: 30000
22 | connection-test-query: SELECT 1
23 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/application-prd.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
4 | username: root
5 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
6 | driver-class: com.mysql.cj.jdbc.Driver
7 | type: com.zaxxer.hikari.HikariDataSource
8 | hikari:
9 | minimum-idle: 5
10 | # 空闲连接存活最大时间,默认600000(10分钟)
11 | idle-timeout: 180000
12 | # 连接池最大连接数,默认是10
13 | maximum-pool-size: 10
14 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
15 | auto-commit: true
16 | # 连接池名称
17 | pool-name: MyHikariCP
18 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
19 | max-lifetime: 1800000
20 | # 数据库连接超时时间,默认30秒,即30000
21 | connection-timeout: 30000
22 | connection-test-query: SELECT 1
23 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/application-stg.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | datasource:
3 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
4 | username: root
5 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
6 | driver-class: com.mysql.cj.jdbc.Driver
7 | type: com.zaxxer.hikari.HikariDataSource
8 | hikari:
9 | minimum-idle: 5
10 | # 空闲连接存活最大时间,默认600000(10分钟)
11 | idle-timeout: 180000
12 | # 连接池最大连接数,默认是10
13 | maximum-pool-size: 10
14 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
15 | auto-commit: true
16 | # 连接池名称
17 | pool-name: MyHikariCP
18 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
19 | max-lifetime: 1800000
20 | # 数据库连接超时时间,默认30秒,即30000
21 | connection-timeout: 30000
22 | connection-test-query: SELECT 1
23 |
--------------------------------------------------------------------------------
/service-component/service-pay/src/main/java/com/cloud/pay/PayApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.pay;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class PayApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(PayApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/AuthApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class AuthApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(AuthApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-ware/src/main/java/com/cloud/ware/WareApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.ware;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class WareApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(WareApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/utils/PasswordUtil.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.utils;
2 |
3 | import cn.hutool.crypto.digest.BCrypt;
4 |
5 | /**
6 | * @author: zhuwj
7 | * @date: 2020/9/26 0:05
8 | * @description:
9 | */
10 | public class PasswordUtil {
11 |
12 | /**
13 | * 生成密码 根据用户名称和密码
14 | *
15 | * @param username
16 | * @param password
17 | * @return
18 | */
19 | public static String generatePassword(String username, String password) {
20 | String strongerSalt = BCrypt.gensalt(12);
21 | return BCrypt.hashpw(username + password, strongerSalt);
22 | }
23 |
24 | /**
25 | * 校验密码
26 | *
27 | * @param username
28 | * @param password
29 | * @param oldPassword
30 | * @return
31 | */
32 | public static boolean verifyPassword(String username, String password, String oldPassword) {
33 | return BCrypt.checkpw(username + password, oldPassword);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/service-component/service-product/src/main/java/com/cloud/mall/MallApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.mall;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class MallApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(MallApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-order/src/main/java/com/cloud/order/OrderApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.order;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class OrderApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(OrderApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-message/src/main/java/com/cloud/message/MessageApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.message;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | */
14 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
15 | @EnableTransactionManagement
16 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
17 | @MapperScan(GlobalConstant.MAPPER_SCAN)
18 | @SpringCloudApplication
19 | public class MessageApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(MessageApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/service-component/service-seckill/src/main/java/com/cloud/seckill/SeckillApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.seckill;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | * @description: 秒杀服务
14 | */
15 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
16 | @EnableTransactionManagement
17 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
18 | @MapperScan(GlobalConstant.MAPPER_SCAN)
19 | @SpringCloudApplication
20 | public class SeckillApplication {
21 | public static void main(String[] args) {
22 | SpringApplication.run(SeckillApplication.class, args);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | nacos:
4 | server-addr: 127.0.0.1:8848
5 | datasource:
6 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
7 | username: root
8 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
9 | driver-class: com.mysql.cj.jdbc.Driver
10 | type: com.zaxxer.hikari.HikariDataSource
11 | hikari:
12 | minimum-idle: 5
13 | # 空闲连接存活最大时间,默认600000(10分钟)
14 | idle-timeout: 180000
15 | # 连接池最大连接数,默认是10
16 | maximum-pool-size: 10
17 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
18 | auto-commit: true
19 | # 连接池名称
20 | pool-name: MyHikariCP
21 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
22 | max-lifetime: 1800000
23 | # 数据库连接超时时间,默认30秒,即30000
24 | connection-timeout: 30000
25 | connection-test-query: SELECT 1
26 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/exception/handler/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.exception.handler;
2 |
3 | import com.cloud.common.exception.AuthException;
4 | import com.cloud.common.response.ResponseResult;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 | import org.springframework.web.bind.annotation.RestControllerAdvice;
8 |
9 | /**
10 | * Description: webflux 异常属性
11 | *
12 | * @author zhuwj
13 | * @version V1.0
14 | * @date 2020-09-27
15 | */
16 | @Slf4j
17 | @RestControllerAdvice
18 | public class GlobalExceptionHandler {
19 |
20 | @ExceptionHandler(Exception.class)
21 | private ResponseResult handleException(Exception e) {
22 | return ResponseResult.error(e.getMessage());
23 | }
24 |
25 | @ExceptionHandler(AuthException.class)
26 | private ResponseResult handleAuthException(Exception e) {
27 | return ResponseResult.error(e.getMessage());
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/IntegralApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.cloud.client.SpringCloudApplication;
7 | import org.springframework.cloud.openfeign.EnableFeignClients;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.transaction.annotation.EnableTransactionManagement;
10 |
11 | /**
12 | * @author zhuwj
13 | * @description: 积分服务启动类
14 | */
15 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
16 | @EnableTransactionManagement
17 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
18 | @MapperScan(GlobalConstant.MAPPER_SCAN)
19 | @SpringCloudApplication
20 | public class IntegralApplication {
21 | public static void main(String[] args) {
22 | SpringApplication.run(IntegralApplication.class, args);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | //package com.cloud.common.config;
2 | //
3 | //import org.springframework.context.annotation.Configuration;
4 | //
5 | ///**
6 | // * @author: zhuwj
7 | // * @date: 2020/9/22 23:38
8 | // * @description: RedisConfig 配置信息
9 | // */
10 | //@Configuration
11 | //public class RedisConfig {
12 | //
13 | //// @Bean
14 | //// public RedisTemplate redisTemplate(LettuceConnectionFactory connectionFactory) {
15 | //// RedisTemplate redisTemplate = new RedisTemplate<>();
16 | //// redisTemplate.setKeySerializer(new StringRedisSerializer());
17 | //// redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
18 | //// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
19 | //// redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
20 | //// redisTemplate.setConnectionFactory(connectionFactory);
21 | //// return redisTemplate;
22 | //// }
23 | //
24 | //}
25 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/entity/Resource.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 |
10 | /**
11 | *
12 | *
13 | *
14 | *
15 | * @author zhuwj
16 | * @since 2022-05-15
17 | */
18 | @Getter
19 | @Setter
20 | @TableName("auth_resource")
21 | @ApiModel(value = "Resource对象", description = "资源")
22 | public class Resource extends BaseEntity {
23 |
24 | @TableField("resource_key")
25 | private String resourceKey;
26 |
27 | @TableField("resource_name")
28 | private String resourceName;
29 |
30 | @TableField("p_id")
31 | private Long pId;
32 |
33 | @TableField("remark")
34 | private String remark;
35 |
36 | @TableField("resource_type")
37 | private Integer resourceType;
38 |
39 | @TableField("url")
40 | private String url;
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/controller/RoleController.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.controller;
2 |
3 | import com.cloud.auth.entity.Role;
4 | import com.cloud.auth.service.IRoleService;
5 | import com.cloud.common.response.ResponseResult;
6 | import lombok.RequiredArgsConstructor;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | /**
11 | * Description: TODO
12 | *
13 | * @author zhuwj
14 | * @version V1.0
15 | * @date 2020-10-10
16 | */
17 | @Slf4j
18 | @RequestMapping("/role")
19 | @RestController
20 | @RequiredArgsConstructor
21 | public class RoleController {
22 |
23 | private final IRoleService roleService;
24 |
25 | @PostMapping
26 | public ResponseResult create(@RequestBody Role role) {
27 | roleService.save(role);
28 | return ResponseResult.ok("创建成功");
29 | }
30 |
31 | @PutMapping
32 | public ResponseResult update(@RequestBody Role role) {
33 | roleService.updateById(role);
34 | return ResponseResult.ok("更新成功");
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/service/impl/ProductServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search.service.impl;
2 |
3 | import com.cloud.search.model.Product;
4 | import com.cloud.search.repository.ProductRepository;
5 | import com.cloud.search.service.ProductService;
6 | import lombok.RequiredArgsConstructor;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.springframework.stereotype.Service;
9 |
10 | import java.util.Optional;
11 |
12 | /**
13 | * @author zhuwj
14 | * @date 2022/07/23 23:12
15 | * @description:
16 | **/
17 | @Slf4j
18 | @Service
19 | @RequiredArgsConstructor
20 | public class ProductServiceImpl implements ProductService {
21 |
22 | private final ProductRepository productRepository;
23 |
24 | @Override
25 | public void save(Product product) {
26 | Product result = productRepository.save(product);
27 | log.info(result.toString());
28 | }
29 |
30 | @Override
31 | public Product findById(String id) {
32 | Optional optional = productRepository.findById(id);
33 | return optional.get();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/test/java/com/cloud/integral/mapper/IntegralRecordMapperTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.mapper;
2 |
3 | import cn.hutool.core.date.DateUtil;
4 | import cn.hutool.core.lang.Console;
5 | import cn.hutool.core.util.StrUtil;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import javax.annotation.Resource;
11 |
12 | import java.util.Date;
13 |
14 | import static org.junit.jupiter.api.Assertions.*;
15 |
16 | @Slf4j
17 | @SpringBootTest
18 | class IntegralRecordMapperTest {
19 |
20 | @Resource
21 | IntegralRecordMapper integralRecordMapper;
22 |
23 | @Test
24 | void createTable() {
25 | String prefixTable = "integral_record";
26 | int year = DateUtil.year(new Date());
27 | log.info("year {}", year);
28 | for (int i = 1; i <= 256; i++) {
29 | String tableName = StrUtil.format("{}_{}_{}", prefixTable, year, i);
30 | Console.log(tableName);
31 | integralRecordMapper.createTable(tableName);
32 |
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/service-component/service-search/src/test/java/com/cloud/search/SearchApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search;
2 |
3 | import cn.hutool.core.lang.Console;
4 | import com.cloud.search.model.Product;
5 | import com.cloud.search.service.ProductService;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 | import org.springframework.test.context.junit4.SpringRunner;
11 |
12 | import java.io.IOException;
13 |
14 |
15 | @RunWith(SpringRunner.class)
16 | @SpringBootTest
17 | public class SearchApplicationTest {
18 |
19 | @Autowired
20 | private ProductService productService;
21 |
22 | @Test
23 | public void insertData() throws IOException {
24 | Product product = new Product();
25 | product.setId("1");
26 | product.setProductName("苹果手机");
27 | product.setProductType("phone");
28 | productService.save(product);
29 | }
30 |
31 | @Test
32 | public void findById(){
33 | Console.log(productService.findById("1"));
34 | }
35 | }
--------------------------------------------------------------------------------
/service-component/service-pay/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8970
3 | spring:
4 | application:
5 | name: service-seckill
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: root
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 | redis:
31 | database: 0
32 | host: 103.39.210.10
33 | password: cXLtoAfE85WkUi5R
34 |
--------------------------------------------------------------------------------
/service-component/service-ware/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8960
3 | spring:
4 | application:
5 | name: service-order
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: root
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 | redis:
31 | database: 0
32 | host: 103.39.210.10
33 | password: cXLtoAfE85WkUi5R
34 |
--------------------------------------------------------------------------------
/service-component/service-seckill/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8980
3 | spring:
4 | application:
5 | name: service-seckill
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: root
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 | redis:
31 | database: 0
32 | host: 103.39.210.10
33 | password: cXLtoAfE85WkUi5R
34 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/test/java/com/cloud/auth/controller/UserControllerTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.controller;
2 |
3 | import com.cloud.auth.entity.User;
4 | import com.cloud.common.constant.GlobalConstant;
5 | import com.cloud.common.utils.PasswordUtil;
6 | import org.junit.Test;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.boot.test.context.SpringBootTest;
9 |
10 | import java.time.LocalDateTime;
11 |
12 | @SpringBootTest
13 | public class UserControllerTest {
14 |
15 | @Autowired
16 | private UserController userController;
17 |
18 | @Test
19 | public void create() {
20 | User user = new User();
21 | user.init(GlobalConstant.ANONYMOUS_USER_ID);
22 | user.setGender(0);
23 | user.setEmail("774623096@qq.com");
24 | user.setNickName("sysadmin");
25 | user.setPhone("123456789");
26 | user.setLastLoginTime(LocalDateTime.now());
27 | user.setUsername("sysadmin");
28 | user.setPassword(PasswordUtil.generatePassword(user.getUsername(), "123456789"));
29 | userController.create(user);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/test/java/com/cloud/integral/service/IIntegralErrorRecordServiceTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import com.cloud.common.enums.IntegralSourceEnum;
5 | import com.cloud.common.model.dto.IntegralDTO;
6 | import com.cloud.integral.entity.IntegralErrorRecord;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.junit.jupiter.api.Test;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 |
11 | import javax.annotation.Resource;
12 |
13 | @Slf4j
14 | @SpringBootTest
15 | class IIntegralErrorRecordServiceTest {
16 |
17 | @Resource
18 | private IIntegralErrorRecordService integralErrorRecordService;
19 |
20 | @Test
21 | public void test() {
22 | IntegralErrorRecord errorRecord = new IntegralErrorRecord();
23 | errorRecord.init(1528729738571960322L);
24 | errorRecord.setErrorContent("测试");
25 | errorRecord.setIntegralObject(JSONUtil.toJsonStr(IntegralDTO.builder()));
26 | errorRecord.setIntegralSource(IntegralSourceEnum.USER_REGISTER.getLabel());
27 | integralErrorRecordService.save(errorRecord);
28 | }
29 | }
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/entity/User.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 |
10 | import java.time.LocalDateTime;
11 |
12 | /**
13 | *
14 | *
15 | *
16 | *
17 | * @author zhuwj
18 | * @since 2022-05-15
19 | */
20 | @Getter
21 | @Setter
22 | @TableName("auth_user")
23 | @ApiModel(value = "User对象", description = "用户")
24 | public class User extends BaseEntity {
25 |
26 | @TableField("email")
27 | private String email;
28 |
29 | @TableField("gender")
30 | private Integer gender;
31 |
32 | @TableField("last_login_time")
33 | private LocalDateTime lastLoginTime;
34 |
35 | @TableField("nick_name")
36 | private String nickName;
37 |
38 | @TableField("password")
39 | private String password;
40 |
41 | @TableField("phone")
42 | private String phone;
43 |
44 | @TableField("username")
45 | private String username;
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/test/java/com/cloud/auth/facade/kafka/producer/IntegralProducerTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.facade.kafka.producer;
2 |
3 | import cn.hutool.core.util.IdUtil;
4 | import com.cloud.common.enums.IntegralSourceEnum;
5 | import com.cloud.common.enums.IntegralTypeEnum;
6 | import com.cloud.common.model.dto.IntegralDTO;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.junit.jupiter.api.Test;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 |
11 | import javax.annotation.Resource;
12 | import java.time.LocalDateTime;
13 |
14 | @Slf4j
15 | @SpringBootTest
16 | class IntegralProducerTest {
17 |
18 | @Resource
19 | IntegralProducer integralProducer;
20 |
21 | @Test
22 | void sendMessage() throws InterruptedException {
23 | IntegralDTO integral = IntegralDTO.builder().num(200).integralTime(LocalDateTime.now())
24 | .integralSourceEnum(IntegralSourceEnum.USER_REGISTER).integralTypeEnum(IntegralTypeEnum.GIVE)
25 | .integralNo(IdUtil.objectId())
26 | .userId(1528729738571960322L).build();
27 | integralProducer.sendMessage(integral);
28 | Thread.sleep(10000);
29 | }
30 | }
--------------------------------------------------------------------------------
/service-gateway/src/test/java/com/cloud/gateway/filter/AuthFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.filter;
2 |
3 | import com.cloud.common.auth.UserInfo;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 | import org.redisson.api.RBucket;
7 | import org.redisson.api.RedissonClient;
8 | import org.redisson.codec.JsonJacksonCodec;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 | import org.springframework.test.context.junit4.SpringRunner;
12 |
13 | import java.time.LocalDateTime;
14 |
15 |
16 | /**
17 | * @author zhuwj
18 | */
19 | @RunWith(SpringRunner.class)
20 | @SpringBootTest
21 | public class AuthFilterTest {
22 |
23 | @Autowired
24 | private RedissonClient redissonClient;
25 |
26 | @Test
27 | public void test() {
28 | UserInfo userInfo = new UserInfo();
29 | userInfo.setLastLoginTime(LocalDateTime.now());
30 | userInfo.setUsername("zhuwj");
31 | RBucket rBucket = redissonClient.getBucket("userInfoTest", new JsonJacksonCodec());
32 | rBucket.set(userInfo);
33 | System.out.println(rBucket.get());
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/service-component/service-order/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8940
3 | spring:
4 | application:
5 | name: service-order
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 |
31 | redis:
32 | database: 0
33 | host: 103.39.210.10
34 | password: cXLtoAfE85WkUi5R
35 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/auth/TokenProvider.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.auth;
2 |
3 | import cn.hutool.core.date.DateUtil;
4 | import cn.hutool.core.util.IdUtil;
5 | import com.auth0.jwt.JWT;
6 | import com.auth0.jwt.algorithms.Algorithm;
7 |
8 | import java.util.Date;
9 |
10 | /**
11 | * @author: zhuwj
12 | * @date: 2020/9/22 22:53
13 | * @description: token 创建 解析 获取
14 | */
15 | public class TokenProvider {
16 |
17 | private static final int EXPIRES_AT = 120;
18 | private static final String AUDIENCE = "web";
19 | private static final String KEY = "JldM90LCIQNZ3cQXrER3Jqyq3bkXttLNNVaTsc1TaEPQ9p1gZM8Z0TtvZL88S0bb";
20 |
21 |
22 | /**
23 | * 创建token 使用jwt方式
24 | *
25 | * @return token
26 | */
27 | public static String createToken(String username) {
28 | Date date = DateUtil.offsetMinute(new Date(), EXPIRES_AT);
29 | return JWT.create()
30 | .withExpiresAt(date)
31 | .withNotBefore(new Date())
32 | .withSubject(username)
33 | .withAudience(AUDIENCE)
34 | .withJWTId(IdUtil.randomUUID())
35 | .sign(Algorithm.HMAC256(KEY));
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/facade/kafka/conveter/IntegralConverter.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.facade.kafka.conveter;
2 |
3 | import com.cloud.common.model.dto.IntegralDTO;
4 | import com.cloud.integral.entity.IntegralRecord;
5 |
6 | import java.time.LocalDateTime;
7 |
8 | /**
9 | * @author zhuwj
10 | * @date 2022/05/28 16:49
11 | * @description:
12 | **/
13 | public class IntegralConverter {
14 |
15 | public static IntegralRecord toIntegralRecord(IntegralDTO integralDTO) {
16 | if (integralDTO == null) {
17 | return null;
18 | }
19 | IntegralRecord integralRecord = new IntegralRecord();
20 | integralRecord.setIntegralNo(integralDTO.getIntegralNo());
21 | integralRecord.setNum(integralDTO.getNum());
22 | integralRecord.setSource(integralDTO.getIntegralSourceEnum().getCode());
23 | integralRecord.setIntegralType(integralDTO.getIntegralTypeEnum().getCode());
24 | integralRecord.init(integralDTO.getUserId());
25 | integralRecord.setCreateTime(integralDTO.getIntegralTime());
26 | integralRecord.setLoseEfficacyTime(LocalDateTime.now().plusYears(1));
27 | return integralRecord;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/entity/IntegralErrorRecord.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import io.swagger.annotations.ApiModelProperty;
8 | import lombok.Getter;
9 | import lombok.Setter;
10 |
11 | /**
12 | *
13 | * 积分错误信息表
14 | *
15 | *
16 | * @author zhuwj
17 | * @since 2022-05-29
18 | */
19 | @Getter
20 | @Setter
21 | @TableName("integral_error_record")
22 | @ApiModel(value = "IntegralErrorRecord对象", description = "积分错误信息表")
23 | public class IntegralErrorRecord extends BaseEntity {
24 |
25 | @ApiModelProperty("积分对象")
26 | @TableField("integral_object")
27 | private String integralObject;
28 |
29 | @ApiModelProperty("错误消息")
30 | @TableField("error_content")
31 | private String errorContent;
32 |
33 | @ApiModelProperty("积分来源")
34 | @TableField("integral_source")
35 | private String integralSource;
36 |
37 | @ApiModelProperty("是否补推(默认否)")
38 | @TableField("whether_fill_push")
39 | private Boolean whetherFillPush;
40 |
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/mapper/UserRoleRelationMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | id,
21 | create_by,
22 | create_time,
23 | is_deleted,
24 | modified_by,
25 | modified_time,
26 | version,
27 | role_id, user_id
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/service-gateway/src/main/resources/mapper/RequestLogMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | id,
21 | create_by,
22 | create_time,
23 | is_deleted,
24 | modified_by,
25 | modified_time,
26 | version,
27 | request_url, request_username
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/mapper/RoleResourceRelationMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | id,
21 | create_by,
22 | create_time,
23 | is_deleted,
24 | modified_by,
25 | modified_time,
26 | version,
27 | resource_id, role_id
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/service-component/service-product/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8920
3 | spring:
4 | application:
5 | name: service-product
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: root
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 | redis:
31 | database: 0
32 | host: 103.39.210.10
33 | password: cXLtoAfE85WkUi5R
34 | feign:
35 | client:
36 | config:
37 | default:
38 | connectTimeout: 5000
39 | readTimeout: 5000
40 | loggerLevel: basic
41 |
--------------------------------------------------------------------------------
/service-component/service-message/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8930
3 | spring:
4 | application:
5 | name: service-message
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | datasource:
10 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
11 | username: root
12 | password: root
13 | driver-class: com.mysql.cj.jdbc.Driver
14 | type: com.zaxxer.hikari.HikariDataSource
15 | hikari:
16 | minimum-idle: 5
17 | # 空闲连接存活最大时间,默认600000(10分钟)
18 | idle-timeout: 180000
19 | # 连接池最大连接数,默认是10
20 | maximum-pool-size: 10
21 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
22 | auto-commit: true
23 | # 连接池名称
24 | pool-name: MyHikariCP
25 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
26 | max-lifetime: 1800000
27 | # 数据库连接超时时间,默认30秒,即30000
28 | connection-timeout: 30000
29 | connection-test-query: SELECT 1
30 |
31 | redis:
32 | database: 0
33 | host: 103.39.210.10
34 | password: cXLtoAfE85WkUi5R
35 | feign:
36 | client:
37 | config:
38 | default:
39 | connectTimeout: 5000
40 | readTimeout: 5000
41 | loggerLevel: basic
42 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/mapper/RoleMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | id,
22 | create_by,
23 | create_time,
24 | is_deleted,
25 | modified_by,
26 | modified_time,
27 | version,
28 | role_key, role_name, remark
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/service-component/service-pay/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | com.cloud.zhuwj
7 | service-component
8 | ${revision}
9 |
10 |
11 | 4.0.0
12 |
13 | service-pay
14 | 支付服务
15 |
16 | ${project.artifactId}
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-maven-plugin
21 |
22 |
23 | org.apache.maven.plugins
24 | maven-deploy-plugin
25 | ${maven-deploy-plugin.version}
26 |
27 | true
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/service-web/src/utils/request.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import {ElMessage} from 'element-plus'
3 |
4 | import {getToken} from './token'
5 |
6 | const service = axios.create({
7 | baseURL: process.env.VUE_APP_API,
8 | timeout: 30000,
9 | })
10 | service.interceptors.request.use(config => {
11 | if (process.env.NODE_ENV === "development") {
12 | config.headers['Authorization'] = "Bearer " + getToken();
13 | } else {
14 | config.headers['Authorization'] = "Bearer " + getToken();
15 | }
16 | return config
17 | }, error => {
18 | console.log(error)
19 | Promise.reject(error).then(() => {
20 | ElMessage({
21 | message: '系统异常,请稍后在操作!',
22 | center: true,
23 | type: 'error'
24 | });
25 | })
26 | })
27 |
28 | service.interceptors.response.use(
29 | response => {
30 |
31 | let res = response.data;
32 | if (res.code !== '00000') {
33 | ElMessage({
34 | message: res.message,
35 | center: true,
36 | type: 'error'
37 | });
38 | return Promise.reject(res.message)
39 | }
40 | return res.data;
41 | },
42 | error => {
43 | return Promise.reject(error)
44 | }
45 | )
46 |
47 | export default service
--------------------------------------------------------------------------------
/service-component/service-order/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | service-component
10 | ${revision}
11 |
12 |
13 | service-order
14 | 订单服务
15 |
16 | ${project.artifactId}
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-maven-plugin
21 |
22 |
23 | org.apache.maven.plugins
24 | maven-deploy-plugin
25 | ${maven-deploy-plugin.version}
26 |
27 | true
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/service-component/service-message/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | service-component
10 | ${revision}
11 |
12 |
13 | service-message
14 | 消息服务
15 |
16 | ${project.artifactId}
17 |
18 |
19 | org.springframework.boot
20 | spring-boot-maven-plugin
21 |
22 |
23 | org.apache.maven.plugins
24 | maven-deploy-plugin
25 | ${maven-deploy-plugin.version}
26 |
27 | true
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/service-component/service-ware/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | com.cloud.zhuwj
7 | service-component
8 | ${revision}
9 |
10 |
11 | 4.0.0
12 |
13 | service-ware
14 | 仓储服务
15 |
16 |
17 | ${project.artifactId}
18 |
19 |
20 | org.springframework.boot
21 | spring-boot-maven-plugin
22 |
23 |
24 | org.apache.maven.plugins
25 | maven-deploy-plugin
26 | ${maven-deploy-plugin.version}
27 |
28 | true
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/constant/GlobalConstant.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.constant;
2 |
3 | /**
4 | * @author: zhuwj
5 | * @date: 2020/9/22 22:47
6 | * @description: 全局常量
7 | */
8 | public interface GlobalConstant {
9 | /**
10 | * 请求授权头部信息
11 | */
12 | String HEADER = "Authorization";
13 | /**
14 | * 自定义头部用户信息
15 | */
16 | String HEADER_USER = "Authorization-User";
17 | /**
18 | * 请求token前缀
19 | */
20 | String TOKEN_PREFIX = "Bearer";
21 | /**
22 | * token 名称
23 | */
24 | String TOKEN_NAME = "accessToken";
25 | /**
26 | * 匿名用户
27 | */
28 | String ANONYMOUS_USER = "anonymousUser";
29 | /**
30 | * 请求id
31 | */
32 | String REQUEST_ID = "request_id";
33 | /**
34 | * 请求路径
35 | */
36 | String REQUEST_PATH = "request_path";
37 | /**
38 | * 组件解析路径
39 | */
40 | String COMPONENT_SCAN = "com.cloud";
41 | /**
42 | * mapper解析路径
43 | */
44 | String MAPPER_SCAN = "com.cloud.*.mapper";
45 | /**
46 | * feign解析路径
47 | */
48 | String FEIGN_SCAN = "com.cloud.*.facade.feign";
49 | /**
50 | * 匿名用户id
51 | */
52 | long ANONYMOUS_USER_ID = 0L;
53 | /**
54 | * redis 中用户缓存时间
55 | */
56 | long REDIS_USER_TIME = 3600 * 2L;
57 | }
58 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/entity/IntegralUserCount.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import io.swagger.annotations.ApiModel;
7 | import io.swagger.annotations.ApiModelProperty;
8 | import lombok.Getter;
9 | import lombok.Setter;
10 |
11 | /**
12 | *
13 | *
14 | *
15 | *
16 | * @author zhuwj
17 | * @since 2022-05-29
18 | */
19 | @Getter
20 | @Setter
21 | @TableName("integral_user_count")
22 | @ApiModel(value = "IntegralUserCount对象", description = "积分统计对象")
23 | public class IntegralUserCount extends BaseEntity {
24 |
25 | @ApiModelProperty("用户名称")
26 | @TableField("username")
27 | private String username;
28 |
29 | @ApiModelProperty("总积分(获取积分-消费积分)")
30 | @TableField("sum_integral")
31 | private Integer sumIntegral;
32 |
33 | @ApiModelProperty("消费积分")
34 | @TableField("consume_integral")
35 | private Integer consumeIntegral;
36 |
37 | @ApiModelProperty("获取积分")
38 | @TableField("give_integral")
39 | private Integer giveIntegral;
40 |
41 | @ApiModelProperty("积分排名")
42 | @TableField("integral_rank")
43 | private Integer integralRank;
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/service-web/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "service-web",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "axios": "^0.21.1",
12 | "core-js": "^3.6.5",
13 | "element-plus": "^1.0.1-alpha.19",
14 | "less": "^4.0.0",
15 | "less-loader": "^7.1.0",
16 | "vue": "^3.0.0",
17 | "vue-router": "4.0.0-beta.13"
18 | },
19 | "devDependencies": {
20 | "@vue/cli-plugin-babel": "~4.5.0",
21 | "@vue/cli-plugin-eslint": "~4.5.0",
22 | "@vue/cli-service": "~4.5.0",
23 | "@vue/compiler-sfc": "^3.0.0",
24 | "babel-eslint": "^10.1.0",
25 | "eslint": "^6.7.2",
26 | "eslint-plugin-vue": "^7.0.0-0",
27 | "sass": "^1.27.0",
28 | "sass-loader": "^10.0.4",
29 | "vue-cli-plugin-element-plus": "~0.0.8"
30 | },
31 | "eslintConfig": {
32 | "root": true,
33 | "env": {
34 | "node": true
35 | },
36 | "extends": [
37 | "plugin:vue/vue3-essential",
38 | "eslint:recommended"
39 | ],
40 | "parserOptions": {
41 | "parser": "babel-eslint"
42 | },
43 | "rules": {}
44 | },
45 | "browserslist": [
46 | "> 1%",
47 | "last 2 versions",
48 | "not dead"
49 | ]
50 | }
51 |
--------------------------------------------------------------------------------
/service-component/service-product/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | service-component
10 | ${revision}
11 |
12 |
13 | service-product
14 | 商品服务
15 |
16 |
17 |
18 | ${project.artifactId}
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-maven-plugin
23 |
24 |
25 | org.apache.maven.plugins
26 | maven-deploy-plugin
27 | ${maven-deploy-plugin.version}
28 |
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/service-component/service-auth/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | service-component
10 | ${revision}
11 |
12 |
13 | service-auth
14 | 权限服务
15 |
16 |
17 |
18 |
19 |
20 | ${project.artifactId}
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-maven-plugin
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-deploy-plugin
29 | ${maven-deploy-plugin.version}
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/service-component/service-search/src/main/java/com/cloud/search/SearchApplication.java:
--------------------------------------------------------------------------------
1 | package com.cloud.search;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.SpringBootConfiguration;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
9 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
11 | import org.springframework.cloud.openfeign.EnableFeignClients;
12 | import org.springframework.context.annotation.ComponentScan;
13 | import org.springframework.transaction.annotation.EnableTransactionManagement;
14 |
15 | /**
16 | * @author zhuwj
17 | */
18 | @EnableFeignClients(basePackages = GlobalConstant.FEIGN_SCAN)
19 | @EnableTransactionManagement
20 | @ComponentScan(GlobalConstant.COMPONENT_SCAN)
21 | @MapperScan(GlobalConstant.MAPPER_SCAN)
22 | @SpringBootConfiguration
23 | @SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
24 | @EnableDiscoveryClient
25 | @EnableCircuitBreaker
26 | public class SearchApplication {
27 | public static void main(String[] args) {
28 | SpringApplication.run(SearchApplication.class, args);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/service-web/vue.config.js:
--------------------------------------------------------------------------------
1 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
2 | const path = require('path');
3 |
4 | function resolve(dir) {
5 | return path.join(__dirname, dir)
6 | }
7 |
8 | module.exports = {
9 |
10 | publicPath: '/',
11 |
12 | outputDir: 'dist',
13 |
14 | lintOnSave: true,
15 | chainWebpack: config => {
16 | config
17 | .plugin('html')
18 | .tap(args => {
19 | args[0].title = '网站学习'
20 | return args
21 | })
22 | },
23 | // 配置 webpack-dev-server 行为。
24 | devServer: {
25 | open: process.platform === 'darwin',
26 | host: 'localhost',
27 | port: 8080,
28 | https: false,
29 | hotOnly: false,
30 | open: false,
31 | // 查阅 https://github.com/vuejs/vue-docs-zh-cn/blob/master/vue-cli/cli-service.md#配置代理
32 | before: app => {
33 | },
34 | disableHostCheck: true
35 | },
36 |
37 | devServer: {
38 | proxy: {
39 | '/api': {
40 | target: 'http://127.0.0.1:8900/', // 后台接口域名
41 | ws: false, //如果要代理 websockets,配置这个参数
42 | secure: false, // 如果是https接口,需要配置这个参数
43 | changeOrigin: true, //是否跨域
44 | pathRewrite: {
45 | '^/api': ''
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/service-component/service-seckill/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | com.cloud.zhuwj
7 | service-component
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | service-seckill
13 | 秒杀服务
14 |
15 | 8
16 | 8
17 |
18 |
19 | ${project.artifactId}
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-maven-plugin
24 |
25 |
26 | org.apache.maven.plugins
27 | maven-deploy-plugin
28 | ${maven-deploy-plugin.version}
29 |
30 | true
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/config/IntegralDatabaseStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.config;
2 |
3 | import cn.hutool.core.convert.Convert;
4 | import cn.hutool.core.util.HashUtil;
5 | import cn.hutool.core.util.StrUtil;
6 | import io.shardingsphere.api.algorithm.sharding.PreciseShardingValue;
7 | import io.shardingsphere.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | import java.util.Collection;
11 |
12 | /**
13 | * @author zhuwj
14 | * @date 2022/05/22 22:34
15 | * @description: 积分库分库策略 标准分片策略
16 | **/
17 | @Slf4j
18 | public class IntegralDatabaseStrategy implements PreciseShardingAlgorithm {
19 | @Override
20 | public String doSharding(Collection collection, PreciseShardingValue preciseShardingValue) {
21 | String logicTableName = preciseShardingValue.getLogicTableName();
22 | String columnName = preciseShardingValue.getColumnName();
23 | Comparable value = preciseShardingValue.getValue();
24 | log.info("logicTableName:{},columnName:{},value:{}", logicTableName, columnName, value);
25 | int hashValue = HashUtil.fnvHash(Convert.toStr(value));
26 | int suffix = hashValue % IntegralRecordConfig.DATABASE_NODES;
27 | String database = StrUtil.format("{}{}", IntegralRecordConfig.DATABASE_PREFIX_NAME, suffix);
28 | log.info("IntegralDatabaseStrategy database: {}", database);
29 | return database;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/resources/mapper/IntegralErrorRecordMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | id,
23 | create_by,
24 | create_time,
25 | is_deleted,
26 | modified_by,
27 | modified_time,
28 | version,
29 | integral_object, error_content, integral_source, whether_fill_push
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | cloud:
3 | nacos:
4 | server-addr: 127.0.0.1:8848
5 | datasource:
6 | url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
7 | username: root
8 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
9 | driver-class: com.mysql.cj.jdbc.Driver
10 | type: com.zaxxer.hikari.HikariDataSource
11 | hikari:
12 | minimum-idle: 5
13 | # 空闲连接存活最大时间,默认600000(10分钟)
14 | idle-timeout: 180000
15 | # 连接池最大连接数,默认是10
16 | maximum-pool-size: 10
17 | # 此属性控制从池返回的连接的默认自动提交行为,默认值:true
18 | auto-commit: true
19 | # 连接池名称
20 | pool-name: MyHikariCP
21 | # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认1800000即30分钟
22 | max-lifetime: 1800000
23 | # 数据库连接超时时间,默认30秒,即30000
24 | connection-timeout: 30000
25 | connection-test-query: SELECT 1
26 | redis:
27 | redisson:
28 | file: classpath:redisson/redisson-dev.yml
29 | kafka:
30 | client-id: service-auth
31 | bootstrap-servers: 127.0.0.1:9092
32 | producer:
33 | retries: 3
34 | acks: all
35 | value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
36 | streams:
37 | replication-factor: 3
38 | consumer:
39 | enable-auto-commit: false
40 | value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
--------------------------------------------------------------------------------
/service-common/src/test/java/com/cloud/common/tree/TreeUtilTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.tree;
2 |
3 | import cn.hutool.core.collection.CollUtil;
4 | import cn.hutool.core.lang.Console;
5 | import org.junit.jupiter.api.Test;
6 |
7 | import java.util.List;
8 |
9 | public class TreeUtilTest {
10 |
11 | @Test
12 | public void build() {
13 |
14 | DefaultTree defaultTree = new DefaultTree();
15 | defaultTree.setId(1L);
16 | defaultTree.setLabel("公司");
17 | defaultTree.setPid(-1L);
18 |
19 | DefaultTree defaultTree2 = new DefaultTree();
20 | defaultTree2.setId(2L);
21 | defaultTree2.setLabel("行政部");
22 | defaultTree2.setPid(1L);
23 |
24 | DefaultTree defaultTree3 = new DefaultTree();
25 | defaultTree3.setId(3L);
26 | defaultTree3.setLabel("技术部");
27 | defaultTree3.setPid(1L);
28 |
29 | DefaultTree defaultTree4 = new DefaultTree();
30 | defaultTree4.setId(4L);
31 | defaultTree4.setLabel("产品组");
32 | defaultTree4.setPid(3L);
33 |
34 | DefaultTree defaultTree5 = new DefaultTree();
35 | defaultTree5.setId(5L);
36 | defaultTree5.setLabel("开发组");
37 | defaultTree5.setPid(3L);
38 |
39 | List list = CollUtil.newArrayList(defaultTree,defaultTree2,defaultTree3,defaultTree4,defaultTree5);
40 |
41 | List treeList = TreeUtil.build(list,-1L);
42 | Console.error("-----输出树状结构-----");
43 | Console.error(treeList);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/mapper/ResourceMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | id,
25 | create_by,
26 | create_time,
27 | is_deleted,
28 | modified_by,
29 | modified_time,
30 | version,
31 | resource_key, resource_name, p_id, remark, resource_type, url
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/tree/TreeUtil.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.tree;
2 |
3 | import cn.hutool.core.collection.CollUtil;
4 |
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | /**
11 | * 树工具类
12 | *
13 | * @author zhuwj
14 | */
15 | public class TreeUtil {
16 |
17 | /**
18 | * 构造树状结构
19 | *
20 | * @param trees 记录
21 | * @param pid 父级id
22 | * @param
23 | * @return
24 | */
25 | public static List build(List trees, Long pid) {
26 | Map> map = new HashMap<>(16);
27 | for (T t : trees) {
28 | Long parentId = t.getPid();
29 | List childrens = map.get(parentId);
30 | if (childrens == null) {
31 | childrens = new ArrayList<>();
32 | map.put(parentId, childrens);
33 | }
34 | childrens.add(t);
35 | }
36 | List treeList = new ArrayList<>();
37 | childBuild(map, pid, treeList);
38 | return treeList;
39 | }
40 |
41 | private static void childBuild(Map> map, Long pid, List treeList) {
42 | List tList = map.get(pid);
43 | if (!CollUtil.isEmpty(tList)) {
44 | for (T tree : tList) {
45 | treeList.add(tree);
46 | childBuild(map, tree.getId(), tree.getChildren());
47 | }
48 | }
49 |
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/resources/mapper/IntegralUserCountMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | id,
24 | create_by,
25 | create_time,
26 | is_deleted,
27 | modified_by,
28 | modified_time,
29 | version,
30 | username, sum_integral, consume_integral, give_integral, `integralRank`
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/test/java/com/cloud/integral/service/IIntegralRecordServiceTest.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service;
2 |
3 | import cn.hutool.core.util.IdUtil;
4 | import com.cloud.common.enums.IntegralSourceEnum;
5 | import com.cloud.common.enums.IntegralTypeEnum;
6 | import com.cloud.integral.entity.IntegralRecord;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.junit.jupiter.api.Test;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 |
12 | import java.time.LocalDateTime;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | @Slf4j
17 | @SpringBootTest
18 | public class IIntegralRecordServiceTest {
19 |
20 | @Autowired
21 | IIntegralRecordService integralRecordService;
22 |
23 | @Test
24 | public void test() {
25 | List list = new ArrayList<>();
26 | for (int i = 0; i < 1; i++) {
27 | IntegralRecord record = new IntegralRecord();
28 | record.init(1528729738571960322L);
29 | record.setIntegralNo(IdUtil.objectId());
30 | record.setSource(IntegralSourceEnum.USER_REGISTER.getCode());
31 | record.setIntegralType(IntegralTypeEnum.CONSUMER.getCode());
32 | record.setNum(100);
33 | record.setLoseEfficacyTime(LocalDateTime.now());
34 | list.add(record);
35 | log.info("插入{},i", i);
36 | integralRecordService.saveBatch(list);
37 | list.clear();
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | id,
26 | create_by,
27 | create_time,
28 | is_deleted,
29 | modified_by,
30 | modified_time,
31 | version,
32 | email, gender, last_login_time, nick_name, password, phone, username
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/service-component/service-search/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | com.cloud.zhuwj
7 | service-component
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | service-search
13 | 3.0.0-SNAPSHOT
14 | 检索服务
15 |
16 |
17 | org.springframework.boot
18 | spring-boot-starter-data-elasticsearch
19 |
20 |
21 |
22 | ${project.artifactId}
23 |
24 |
25 | org.springframework.boot
26 | spring-boot-maven-plugin
27 |
28 |
29 | org.apache.maven.plugins
30 | maven-deploy-plugin
31 | ${maven-deploy-plugin.version}
32 |
33 | true
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/tree/DefaultTree.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.tree;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * Description: 默认的树
8 | *
9 | * @author zhuwj
10 | * @version V1.0
11 | * @date 2020-10-12
12 | */
13 |
14 | public class DefaultTree implements Tree {
15 | /**
16 | * 名称
17 | */
18 | private String label;
19 |
20 | private Long id;
21 |
22 | private Long pid;
23 |
24 | /**
25 | * 子集
26 | */
27 | private List children = new ArrayList<>();
28 |
29 | @Override
30 | public Long getId() {
31 | return id;
32 | }
33 |
34 | @Override
35 | public Long getPid() {
36 | return pid;
37 | }
38 |
39 | public void setId(Long id) {
40 | this.id = id;
41 | }
42 |
43 | public void setPid(Long pid) {
44 | this.pid = pid;
45 | }
46 |
47 | public String getLabel() {
48 | return label;
49 | }
50 |
51 | public void setLabel(String label) {
52 | this.label = label;
53 | }
54 |
55 | public List getChildren() {
56 | return children;
57 | }
58 |
59 | public void setChildren(List children) {
60 | this.children = children;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "DefaultTree{" +
66 | "label='" + label + '\'' +
67 | ", id=" + id +
68 | ", pid=" + pid +
69 | ", children=" + children +
70 | '}';
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/config/IntegralTableStrategy.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.config;
2 |
3 | import cn.hutool.core.convert.Convert;
4 | import cn.hutool.core.util.HashUtil;
5 | import cn.hutool.core.util.StrUtil;
6 | import io.shardingsphere.api.algorithm.sharding.PreciseShardingValue;
7 | import io.shardingsphere.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | import java.time.LocalDateTime;
11 | import java.util.Collection;
12 |
13 | /**
14 | * @author zhuwj
15 | * @date 2022/05/22 22:34
16 | * @description: 积分表分表策略 标准分片策略
17 | **/
18 | @Slf4j
19 | public class IntegralTableStrategy implements PreciseShardingAlgorithm {
20 | @Override
21 | public String doSharding(Collection collection, PreciseShardingValue preciseShardingValue) {
22 | String logicTableName = preciseShardingValue.getLogicTableName();
23 | String columnName = preciseShardingValue.getColumnName();
24 | Comparable value = preciseShardingValue.getValue();
25 | int year = LocalDateTime.now().getYear();
26 | log.info("logicTableName:{},columnName:{},value:{}", logicTableName, columnName, value);
27 | int hashValue = HashUtil.fnvHash(Convert.toStr(value));
28 | int suffix = hashValue % IntegralRecordConfig.TABLE_NODES;
29 | String tableName = StrUtil.format("{}_{}_{}", IntegralRecordConfig.TABLE_PREFIX_NAME, year, suffix);
30 | log.info("IntegralTableStrategy tableName: {}", tableName);
31 | return tableName;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/auth/UserInfo.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.auth;
2 |
3 | import com.fasterxml.jackson.annotation.JsonFormat;
4 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
5 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
6 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
7 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
8 | import lombok.Data;
9 |
10 | import java.io.Serializable;
11 | import java.time.LocalDateTime;
12 | import java.util.Set;
13 |
14 | /**
15 | * @author zhuwj
16 | * @desc 用户信息
17 | */
18 | @Data
19 | public class UserInfo implements Serializable {
20 |
21 | /**
22 | * 用户id
23 | */
24 | private Long userId;
25 |
26 | /**
27 | * 用户名
28 | */
29 | private String username;
30 | /**
31 | * 昵称
32 | */
33 | private String nickName;
34 | /**
35 | * 电话号码
36 | */
37 | private String phone;
38 | /**
39 | * 邮箱
40 | */
41 | private String email;
42 | /**
43 | * 性别
44 | */
45 | private Integer gender;
46 | /**
47 | * 最后登入时间
48 | */
49 | @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
50 | @JsonDeserialize(using = LocalDateTimeDeserializer.class)
51 | @JsonSerialize(using = LocalDateTimeSerializer.class)
52 | private LocalDateTime lastLoginTime;
53 | /**
54 | * 角色列表
55 | */
56 | private Set roles;
57 | /**
58 | * 资源列表
59 | */
60 | private Set resources;
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/facade/kafka/producer/ShortMessageProducer.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.facade.kafka.producer;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import com.cloud.common.constant.KafkaConstant;
5 | import com.cloud.common.model.dto.ShortMessageDTO;
6 | import lombok.RequiredArgsConstructor;
7 | import lombok.extern.slf4j.Slf4j;
8 | import org.springframework.kafka.core.KafkaTemplate;
9 | import org.springframework.kafka.support.SendResult;
10 | import org.springframework.stereotype.Component;
11 | import org.springframework.util.concurrent.ListenableFuture;
12 |
13 | /**
14 | * @author zhuwj
15 | * @date 2022/05/23 22:42
16 | * @description: 短信生产者
17 | **/
18 | @Slf4j
19 | @Component
20 | @RequiredArgsConstructor
21 | public class ShortMessageProducer {
22 |
23 |
24 | private final KafkaTemplate kafkaTemplate;
25 |
26 | /**
27 | * 发送积分消息
28 | */
29 | public void sendMessage(ShortMessageDTO shortMessage) {
30 | ListenableFuture> future = kafkaTemplate.send(KafkaConstant.SHORT_MESSAGE_TOPIC, shortMessage);
31 | future.addCallback(
32 | result -> {
33 | log.info("sendMessage Success topic:{} partition:{}的消息", result.getRecordMetadata().topic(), result.getRecordMetadata().partition());
34 | },
35 | ex -> {
36 | log.error("sendMessage error, {}", ex.getMessage());
37 | //异步处理失败数据
38 | log.error("shortMessage data :{}", JSONUtil.toJsonStr(shortMessage));
39 |
40 | });
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/model/dto/IntegralDTO.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.model.dto;
2 |
3 | import com.cloud.common.enums.IntegralSourceEnum;
4 | import com.cloud.common.enums.IntegralTypeEnum;
5 | import com.fasterxml.jackson.annotation.JsonFormat;
6 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
8 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
9 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
10 | import lombok.Builder;
11 | import lombok.Data;
12 |
13 | import java.io.Serializable;
14 | import java.time.LocalDateTime;
15 |
16 | /**
17 | * @author zhuwj
18 | * @date 2022/05/23 22:50
19 | * @description: 积分对象
20 | **/
21 | @Data
22 | @Builder
23 | public class IntegralDTO implements Serializable {
24 | private static final long serialVersionUID = 510364419281184694L;
25 | /**
26 | * 积分编号
27 | */
28 | private String integralNo;
29 | /**
30 | * 积分数量
31 | */
32 | private Integer num;
33 | /**
34 | * 积分来源类型
35 | */
36 | private IntegralSourceEnum integralSourceEnum;
37 | /**
38 | * 积分数据类型
39 | */
40 | private IntegralTypeEnum integralTypeEnum;
41 | /**
42 | * 用户id
43 | */
44 | private Long userId;
45 | /**
46 | * 积分获取时间
47 | */
48 | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
49 | @JsonDeserialize(using = LocalDateTimeDeserializer.class)
50 | @JsonSerialize(using = LocalDateTimeSerializer.class)
51 | private LocalDateTime integralTime;
52 | }
53 |
--------------------------------------------------------------------------------
/service-component/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | spring-cloud-framework
10 | ${revision}
11 |
12 |
13 | service-component
14 | pom
15 |
16 | service-auth
17 | service-product
18 | service-order
19 | service-message
20 | service-integral
21 | service-ware
22 | service-pay
23 | service-seckill
24 | service-search
25 |
26 |
27 |
28 |
29 | com.cloud.zhuwj
30 | service-common
31 | ${project.version}
32 |
33 |
34 |
35 |
36 |
37 | org.apache.maven.plugins
38 | maven-deploy-plugin
39 | ${maven-deploy-plugin.version}
40 |
41 | true
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/facade/kafka/consumer/IntegralConsumer.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.facade.kafka.consumer;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import com.cloud.common.constant.KafkaConstant;
5 | import com.cloud.common.model.dto.IntegralDTO;
6 | import com.cloud.integral.service.IIntegralUserCountService;
7 | import lombok.RequiredArgsConstructor;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.apache.kafka.clients.consumer.ConsumerRecord;
10 | import org.springframework.kafka.annotation.KafkaListener;
11 | import org.springframework.kafka.support.Acknowledgment;
12 | import org.springframework.stereotype.Component;
13 |
14 | /**
15 | * @author zhuwj
16 | * @date 2022/05/23 21:46
17 | * @description: 积分消费者
18 | **/
19 | @Slf4j
20 | @Component
21 | @RequiredArgsConstructor
22 | public class IntegralConsumer {
23 |
24 | private final IIntegralUserCountService integralUserCountService;
25 |
26 |
27 | @KafkaListener(topics = KafkaConstant.INTEGRAL_TOPIC)
28 | public void onMessage(ConsumerRecord record, Acknowledgment ack) {
29 | try {
30 | log.info("IntegralConsumer onMessage topic: {} , partition: {} ", record.topic(), record.partition());
31 | String value = record.value();
32 | log.info("IntegralConsumer : {} ", value);
33 | IntegralDTO integral = JSONUtil.toBean(value, IntegralDTO.class);
34 | log.info("integral : {} ", integral.toString());
35 | integralUserCountService.integralCountAndRecordChange(integral);
36 | ack.acknowledge();
37 | } catch (Exception e) {
38 | log.error("IntegralConsumer integral_topic error ", e);
39 | }
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/response/ResponseResult.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.response;
2 |
3 |
4 | import com.cloud.common.auth.WebContext;
5 | import com.cloud.common.enums.ResponseCodeEnum;
6 | import lombok.Builder;
7 | import lombok.Data;
8 |
9 | import java.io.Serializable;
10 |
11 | /**
12 | * @desc:返回处理结果
13 | * @author:zhuwj
14 | * @date:2020.05.10
15 | * @version:1.0.0
16 | */
17 | @Data
18 | @Builder
19 | public class ResponseResult implements Serializable {
20 |
21 | private static final long serialVersionUID = 8992436576262574064L;
22 | /**
23 | * 响应吗
24 | */
25 | private String code;
26 | /**
27 | * 请求路径
28 | */
29 | private String path;
30 | /**
31 | * 请求时间戳
32 | */
33 | private Long timestamp;
34 | /**
35 | * 请求id
36 | */
37 | private String requestId;
38 | /**
39 | * 消息描述
40 | */
41 | private String message;
42 | /**
43 | * 请求结果
44 | */
45 | private T data;
46 |
47 | public static ResponseResult ok(T result) {
48 |
49 | return (ResponseResult) ResponseResult.builder().code(ResponseCodeEnum.OK.getCode()).path(WebContext.getRequestPath())
50 | .timestamp(System.currentTimeMillis()).requestId(WebContext.getRequestId())
51 | .message(ResponseCodeEnum.OK.getMsg()).data(result).build();
52 | }
53 |
54 | public static ResponseResult error(String message) {
55 |
56 | return (ResponseResult) ResponseResult.builder().code(ResponseCodeEnum.ERROR.getCode()).path(WebContext.getRequestPath())
57 | .timestamp(System.currentTimeMillis()).requestId(WebContext.getRequestId())
58 | .message(message).data(null).build();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/entity/IntegralRecord.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.entity;
2 |
3 | import com.baomidou.mybatisplus.annotation.TableField;
4 | import com.baomidou.mybatisplus.annotation.TableName;
5 | import com.cloud.common.base.BaseEntity;
6 | import com.fasterxml.jackson.annotation.JsonFormat;
7 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
8 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
9 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
10 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
11 | import io.swagger.annotations.ApiModel;
12 | import io.swagger.annotations.ApiModelProperty;
13 | import lombok.Getter;
14 | import lombok.Setter;
15 |
16 | import java.time.LocalDateTime;
17 |
18 | /**
19 | *
20 | *
21 | *
22 | *
23 | * @author zhuwj
24 | * @since 2022-05-15
25 | */
26 | @Getter
27 | @Setter
28 | @TableName("integral_record")
29 | @ApiModel(value = "IntegralRecord对象", description = "积分记录")
30 | public class IntegralRecord extends BaseEntity {
31 |
32 | @ApiModelProperty("积分编号")
33 | @TableField("integral_no")
34 | private String integralNo;
35 |
36 | @ApiModelProperty("积分来源")
37 | @TableField("source")
38 | private Integer source;
39 |
40 | @ApiModelProperty("积分类型:增加,消费")
41 | @TableField("integral_type")
42 | private Integer integralType;
43 |
44 | @ApiModelProperty("积分数量")
45 | @TableField("num")
46 | private Integer num;
47 |
48 | @ApiModelProperty("积分失效时间")
49 | @TableField("lose_efficacy_time")
50 | @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
51 | @JsonDeserialize(using = LocalDateTimeDeserializer.class)
52 | @JsonSerialize(using = LocalDateTimeSerializer.class)
53 | private LocalDateTime loseEfficacyTime;
54 |
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/service-web/src/views/workflow/taskList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
13 |
14 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
62 |
63 |
--------------------------------------------------------------------------------
/service-component/service-integral/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | com.cloud.zhuwj
7 | service-component
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | service-integral
13 | 积分服务
14 |
15 |
16 | 3.1.0
17 |
18 |
19 |
20 | io.shardingsphere
21 | sharding-jdbc-spring-boot-starter
22 | ${sharding-sphere.version}
23 |
24 |
25 |
26 |
27 | io.shardingsphere
28 | sharding-jdbc-spring-namespace
29 | ${sharding-sphere.version}
30 |
31 |
32 |
33 |
34 | ${project.artifactId}
35 |
36 |
37 | org.springframework.boot
38 | spring-boot-maven-plugin
39 |
40 |
41 | org.apache.maven.plugins
42 | maven-deploy-plugin
43 | ${maven-deploy-plugin.version}
44 |
45 | true
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spring-cloud-framework
2 |
3 | > - SpringCloud 微服务学习使用与实践,结合相关业务进行验证等。
4 | > 使用nacos作为服务注册中心,[nacos文档](https://nacos.io/zh-cn/index.html)
5 | > [阿里云maven](https://packages.aliyun.com/maven)
6 | > - zookeeper
7 | > - Kafka
8 | > - Redis
9 | > - Mysql
10 |
11 | ## 模块版本
12 |
13 | | 名称 | 版本 |
14 | |----------------------|----------------|
15 | | spring-boot | 2.3.7.RELEASE |
16 | | spring-cloud | Hoxton.SR9 |
17 | | spring-cloud-alibaba | 2.2.3.RELEASE |
18 | | lombok | 1.18.12 |
19 | | hutool | 5.8.1 |
20 | | Kafka | 2.5.10.RELEASE |
21 | | sharding-jdbc | 3.1.0 |
22 |
23 | ## 服务列表
24 |
25 | | 名称 | 端口 | 描述 |
26 | |------------------|------|-----------|
27 | | service-common | | 模块公用功能和属性 |
28 | | service-gateway | 8900 | 网关服务 |
29 | | service-auth | 8910 | 权限服务 |
30 | | service-product | 8920 | 商品服务 |
31 | | service-message | 8930 | 消息服务 |
32 | | service-order | 8940 | 订单服务 |
33 | | service-integral | 8950 | 积分服务 |
34 | | service-ware | 8960 | 仓储服务 |
35 | | service-pay | 8970 | 支付服务 |
36 | | service-seckill | 8980 | 秒杀服务 |
37 | | service-search | 8990 | 检索服务 |
38 | ## 公共模块(services-common)
39 |
40 | > 各个模块需要共同使用的一些功能或属性等
41 |
42 | ### 功能列表
43 |
44 | - 通用的返回结果
45 | - 通用的异常定义
46 | - 全局常量定义
47 | - 全局处理异常
48 | - 基础的实体类定义信息
49 | - 权限模块用户信息
50 | - 系统启动成功与失败事件
51 | - 权限拦截器
52 | - 分布式锁
53 | - 构造树状结构数据
54 | - 通用的工具类(密码,redis等)
55 |
56 | ## 网关服务(service-gateway)
57 |
58 | > 微服务的统一入口,拥有授权,鉴权,请求日志等功能。
59 |
60 | ### 功能列表
61 |
62 | - 自定义模板
63 |
64 | ## 权限服务(service-auth)
65 |
66 | > 权限相关信息功能
67 |
68 | ## 商品服务(service-product)
69 |
70 | > 商品相关功能
71 |
72 | ## 消息服务(service-message)
73 |
74 | > 消息相关功能
75 |
76 | ## 订单服务(service-order)
77 |
78 | > 订单相关功能
79 |
80 | ## 积分服务(service-integral)
81 |
82 | > 积分相关功能
83 |
84 | ## 支付服务(service-pay)
85 |
86 | > 支付相关功能
87 |
88 | ## 秒杀服务(service-seckill)
89 |
90 | > 秒杀相关功能
91 | >
92 | ## 搜索服务(service-search)
93 |
94 | > 搜索相关功能
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/auth/WebContext.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.auth;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import cn.hutool.json.JSONUtil;
5 | import com.cloud.common.constant.GlobalConstant;
6 | import com.cloud.common.exception.AuthException;
7 | import org.springframework.web.context.request.RequestContextHolder;
8 | import org.springframework.web.context.request.ServletRequestAttributes;
9 |
10 | import javax.servlet.http.HttpServletRequest;
11 |
12 | /**
13 | * 上下文信息
14 | *
15 | * @author zhuwj
16 | */
17 | public class WebContext {
18 |
19 | /**
20 | * 获取用户信息
21 | *
22 | */
23 | public static UserInfo getUserInfo() {
24 | String userInfo = getHeaderInfoByKey(GlobalConstant.HEADER_USER);
25 | if (StrUtil.isBlank(userInfo)) {
26 | throw new AuthException("user is not exist");
27 | }
28 | return JSONUtil.toBean(userInfo, UserInfo.class);
29 | }
30 |
31 |
32 | /**
33 | * 获取用户名称
34 | *
35 | */
36 | public static String getUsername() {
37 | UserInfo userInfo = getUserInfo();
38 | return userInfo.getUsername();
39 | }
40 |
41 | /**
42 | * 获取用户id
43 | *
44 | * @return
45 | */
46 | public static Long getUserId() {
47 | UserInfo userInfo = getUserInfo();
48 | return userInfo.getUserId();
49 | }
50 |
51 | /**
52 | * 获取请求id
53 | *
54 | * @return
55 | */
56 | public static String getRequestId() {
57 | return getHeaderInfoByKey(GlobalConstant.REQUEST_ID);
58 | }
59 |
60 | /**
61 | * 获取请求路径
62 | *
63 | * @return
64 | */
65 | public static String getRequestPath() {
66 | return getHeaderInfoByKey(GlobalConstant.REQUEST_PATH);
67 | }
68 |
69 | /**
70 | * 获取头部信息信息通过key值
71 | *
72 | * @param key
73 | * @return
74 | */
75 | private static String getHeaderInfoByKey(String key) {
76 | ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
77 | HttpServletRequest request = attrs.getRequest();
78 | return request.getHeader(key);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/service-gateway/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | spring-cloud-framework
10 | ${revision}
11 |
12 |
13 | service-gateway
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | com.cloud.zhuwj
22 | service-common
23 | ${project.version}
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 |
31 |
32 | org.springframework.boot
33 | spring-boot-starter-webflux
34 |
35 |
36 | org.springframework.cloud
37 | spring-cloud-starter-gateway
38 |
39 |
40 |
41 |
42 |
43 | ${project.artifactId}
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-maven-plugin
48 |
49 |
50 | org.apache.maven.plugins
51 | maven-deploy-plugin
52 | ${maven-deploy-plugin.version}
53 |
54 | true
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.controller;
2 |
3 | import cn.hutool.core.util.IdUtil;
4 | import com.cloud.auth.entity.User;
5 | import com.cloud.auth.facade.kafka.producer.IntegralProducer;
6 | import com.cloud.auth.service.IUserService;
7 | import com.cloud.common.base.PageEntity;
8 | import com.cloud.common.enums.IntegralSourceEnum;
9 | import com.cloud.common.enums.IntegralTypeEnum;
10 | import com.cloud.common.model.dto.IntegralDTO;
11 | import com.cloud.common.response.ResponseResult;
12 | import lombok.RequiredArgsConstructor;
13 | import lombok.extern.slf4j.Slf4j;
14 | import org.springframework.transaction.annotation.Transactional;
15 | import org.springframework.web.bind.annotation.*;
16 |
17 | import java.time.LocalDateTime;
18 |
19 | /**
20 | * Description: 用户控制器
21 | *
22 | * @author zhuwj
23 | * @version V1.0
24 | * @date 2020-10-10
25 | */
26 |
27 | @Slf4j
28 | @RequestMapping("/user")
29 | @RestController
30 | @RequiredArgsConstructor
31 | public class UserController {
32 |
33 | private final IUserService userService;
34 |
35 | private final IntegralProducer integralProducer;
36 |
37 | @Transactional(rollbackFor = Exception.class)
38 | @PostMapping
39 | public ResponseResult create(@RequestBody User user) {
40 | userService.save(user);
41 | IntegralDTO integral = IntegralDTO.builder().num(IntegralSourceEnum.USER_REGISTER.getIntegralNum()).integralTime(LocalDateTime.now())
42 | .integralSourceEnum(IntegralSourceEnum.USER_REGISTER).integralTypeEnum(IntegralTypeEnum.GIVE)
43 | .integralNo(IdUtil.objectId())
44 | .userId(user.getId()).build();
45 | integralProducer.sendMessage(integral);
46 | return ResponseResult.ok("创建成功");
47 | }
48 |
49 | @PutMapping
50 | public ResponseResult update(@RequestBody User user) {
51 | userService.updateById(user);
52 | return ResponseResult.ok("更新成功");
53 | }
54 |
55 | /**
56 | * 页数从0开始
57 | *
58 | * @param pageEntity
59 | * @return
60 | */
61 | @PostMapping("page")
62 | public ResponseResult page(@RequestBody PageEntity pageEntity) {
63 |
64 | return ResponseResult.ok("");
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/facade/kafka/producer/IntegralProducer.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.facade.kafka.producer;
2 |
3 | import cn.hutool.core.collection.ListUtil;
4 | import cn.hutool.core.util.IdUtil;
5 | import cn.hutool.json.JSONUtil;
6 | import com.cloud.common.constant.KafkaConstant;
7 | import com.cloud.common.enums.MessageTemplateCodeEnum;
8 | import com.cloud.common.model.dto.IntegralDTO;
9 | import com.cloud.common.model.dto.ShortMessageDTO;
10 | import lombok.RequiredArgsConstructor;
11 | import lombok.extern.slf4j.Slf4j;
12 | import org.springframework.kafka.core.KafkaTemplate;
13 | import org.springframework.kafka.support.SendResult;
14 | import org.springframework.stereotype.Component;
15 | import org.springframework.util.concurrent.ListenableFuture;
16 |
17 | /**
18 | * @author zhuwj
19 | * @date 2022/05/23 22:42
20 | * @description: 积分生产者
21 | **/
22 | @Slf4j
23 | @Component
24 | @RequiredArgsConstructor
25 | public class IntegralProducer {
26 |
27 |
28 | private final KafkaTemplate kafkaTemplate;
29 |
30 | private final ShortMessageProducer shortMessageProducer;
31 |
32 | /**
33 | * 发送积分消息
34 | */
35 | public void sendMessage(IntegralDTO integral) {
36 | ListenableFuture> future = kafkaTemplate.send(KafkaConstant.INTEGRAL_TOPIC, integral);
37 | future.addCallback(
38 | result -> {
39 | log.info("sendMessage Success topic:{} partition:{}的消息", result.getRecordMetadata().topic(), result.getRecordMetadata().partition());
40 | },
41 | ex -> {
42 | log.error("sendMessage error, {}", ex.getMessage());
43 | //异步处理失败数据
44 | log.error("integral data :{}", JSONUtil.toJsonStr(integral));
45 | //发送邮件,短信等通知相关人员(运维人员,开发人员)
46 | ShortMessageDTO shortMessage = ShortMessageDTO.builder()
47 | .shortMessageNo(IdUtil.objectId())
48 | .messageParams(ListUtil.toList(JSONUtil.toJsonStr(integral), ex.getMessage()))
49 | .templateCode(MessageTemplateCodeEnum.INTEGRAL_ERROR_NOTIFY_TEMPLATE).build();
50 | shortMessageProducer.sendMessage(shortMessage);
51 | });
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/java/com/cloud/integral/service/impl/IntegralUserCountServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.cloud.integral.service.impl;
2 |
3 | import cn.hutool.json.JSONUtil;
4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5 | import com.cloud.common.exception.RedissonException;
6 | import com.cloud.common.model.dto.IntegralDTO;
7 | import com.cloud.integral.entity.IntegralErrorRecord;
8 | import com.cloud.integral.entity.IntegralUserCount;
9 | import com.cloud.integral.manager.IntegralUserCountManager;
10 | import com.cloud.integral.mapper.IntegralErrorRecordMapper;
11 | import com.cloud.integral.mapper.IntegralUserCountMapper;
12 | import com.cloud.integral.service.IIntegralUserCountService;
13 | import lombok.RequiredArgsConstructor;
14 | import lombok.extern.slf4j.Slf4j;
15 | import org.springframework.stereotype.Service;
16 |
17 | /**
18 | *
19 | * 服务实现类
20 | *
21 | *
22 | * @author zhuwj
23 | * @since 2022-05-29
24 | */
25 | @Slf4j
26 | @RequiredArgsConstructor
27 | @Service
28 | public class IntegralUserCountServiceImpl extends ServiceImpl implements IIntegralUserCountService {
29 |
30 |
31 |
32 | private final IntegralUserCountManager integralUserCountManager;
33 |
34 | private final IntegralErrorRecordMapper integralErrorRecordMapper;
35 |
36 |
37 |
38 | @Override
39 | public void integralCountAndRecordChange(IntegralDTO integral) {
40 | try {
41 | Integer totalIntegral = integralUserCountManager.integralCountAndRecordChange(integral);
42 | //排行榜
43 | if (totalIntegral == null) {
44 | return;
45 | }
46 | integralUserCountManager.totalIntegralRankChange(integral.getUserId(), totalIntegral);
47 | } catch (RedissonException redissonException) {
48 | //消息重试
49 | } catch (Exception e) {
50 | log.error("integralCountAndRecordChange error ", e);
51 | IntegralErrorRecord errorRecord = new IntegralErrorRecord();
52 | errorRecord.init(integral.getUserId());
53 | errorRecord.setErrorContent(e.getMessage());
54 | errorRecord.setIntegralObject(JSONUtil.toJsonStr(integral));
55 | errorRecord.setIntegralSource(integral.getIntegralTypeEnum().getLabel());
56 | integralErrorRecordMapper.insert(errorRecord);
57 | }
58 | }
59 |
60 |
61 | }
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/config/SwaggerConfig.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.config;
2 |
3 | import com.cloud.common.constant.GlobalConstant;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 | import springfox.documentation.builders.ApiInfoBuilder;
7 | import springfox.documentation.builders.PathSelectors;
8 | import springfox.documentation.builders.RequestHandlerSelectors;
9 | import springfox.documentation.service.*;
10 | import springfox.documentation.spi.DocumentationType;
11 | import springfox.documentation.spi.service.contexts.SecurityContext;
12 | import springfox.documentation.spring.web.plugins.Docket;
13 |
14 | import java.util.Collections;
15 | import java.util.List;
16 |
17 | /**
18 | * Description: SwaggerConfig 配置信息
19 | *
20 | * @author zhuwj
21 | * @version V1.0
22 | * @date 2020-12-17
23 | */
24 | @Configuration
25 | public class SwaggerConfig {
26 | @Bean
27 | public Docket createRestApi() {
28 | return new Docket(DocumentationType.SWAGGER_2)
29 | .apiInfo(apiInfo())
30 | .select()
31 | .apis(RequestHandlerSelectors.basePackage("com.cloud"))
32 | .paths(PathSelectors.any())
33 | .build()
34 | .securityContexts(securityContext())
35 | .securitySchemes(securitySchemes());
36 | }
37 |
38 | private List securitySchemes() {
39 | return Collections.singletonList(new ApiKey(GlobalConstant.TOKEN_NAME, GlobalConstant.HEADER, "header"));
40 | }
41 |
42 | private List securityContext() {
43 | SecurityContext securityContext = SecurityContext.builder()
44 | .securityReferences(defaultAuth())
45 | .build();
46 | return Collections.singletonList(securityContext);
47 | }
48 |
49 | private List defaultAuth() {
50 | AuthorizationScope authorizationScope
51 | = new AuthorizationScope("global", "accessEverything");
52 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
53 | authorizationScopes[0] = authorizationScope;
54 | return Collections.singletonList(new SecurityReference(GlobalConstant.TOKEN_NAME, authorizationScopes));
55 | }
56 |
57 |
58 | private ApiInfo apiInfo() {
59 | return new ApiInfoBuilder()
60 | .title("Spring Cloud Framework API")
61 | .version("2.0")
62 | .build();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/lock/RedisDistributedLock.java:
--------------------------------------------------------------------------------
1 | //package com.cloud.common.lock;
2 | //
3 | //import lombok.RequiredArgsConstructor;
4 | //import lombok.extern.slf4j.Slf4j;
5 | //import org.springframework.data.redis.core.RedisTemplate;
6 | //import org.springframework.data.redis.core.script.DefaultRedisScript;
7 | //import org.springframework.data.redis.core.script.RedisScript;
8 | //import org.springframework.stereotype.Component;
9 | //
10 | //import java.util.Collections;
11 | //import java.util.concurrent.TimeUnit;
12 | //
13 | ///**
14 | // * Description: redis 分布式锁 不支持集群模式
15 | // *
16 | // * @author zhuwj
17 | // * @version V1.0
18 | // * @date 2020-10-13
19 | // */
20 | //
21 | //@Slf4j
22 | //@Component
23 | //@RequiredArgsConstructor
24 | //public class RedisDistributedLock {
25 | //
26 | // private final RedisTemplate redisTemplate;
27 | //
28 | // private static final String PREFIX = "cloud_lock_";
29 | //
30 | // private static final long RELEASE_LOCK_SUCCESS = 1;
31 | //
32 | // private static final String RELEASE_LOCK_SCRIPT = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
33 | //
34 | //
35 | // public boolean tryLock(String lockName, String requestId, long expiredInMilliseconds, long maxWaitTimeInMilliseconds) {
36 | // long time = System.currentTimeMillis();
37 | // while (!tryLock(lockName, requestId, expiredInMilliseconds)) {
38 | // if (System.currentTimeMillis() - time > maxWaitTimeInMilliseconds) {
39 | // return false;
40 | // }
41 | // }
42 | // return true;
43 | // }
44 | //
45 | // public boolean unLock(final String lockName, final String requestId) {
46 | // RedisScript redisScript = new DefaultRedisScript<>(RELEASE_LOCK_SCRIPT, Long.class);
47 | // Long result = redisTemplate.execute(redisScript, Collections.singletonList(PREFIX + lockName), requestId);
48 | // if (result == RELEASE_LOCK_SUCCESS) {
49 | // return true;
50 | // }
51 | // return false;
52 | //
53 | // }
54 | //
55 | // private boolean tryLock(final String lockName, final String requestId, final long expiredInMilliseconds) {
56 | // try {
57 | // return redisTemplate.opsForValue().setIfAbsent(PREFIX + lockName, requestId, expiredInMilliseconds, TimeUnit.MILLISECONDS);
58 | // } catch (Exception e) {
59 | // log.error("RedisDistributedLock tryLock failed -- lockName :{} ", lockName, e);
60 | // return false;
61 | // }
62 | //
63 | // }
64 | //}
65 |
--------------------------------------------------------------------------------
/service-component/service-auth/src/main/java/com/cloud/auth/controller/AuthController.java:
--------------------------------------------------------------------------------
1 | package com.cloud.auth.controller;
2 |
3 | import cn.hutool.core.bean.BeanUtil;
4 | import com.cloud.auth.entity.User;
5 | import com.cloud.auth.facade.MessageFeignService;
6 | import com.cloud.auth.service.IUserService;
7 | import com.cloud.common.auth.TokenProvider;
8 | import com.cloud.common.auth.UserInfo;
9 | import com.cloud.common.auth.WebContext;
10 | import com.cloud.common.response.ResponseResult;
11 | import com.cloud.common.utils.PasswordUtil;
12 | import io.swagger.annotations.Api;
13 | import io.swagger.annotations.ApiOperation;
14 | import lombok.RequiredArgsConstructor;
15 | import lombok.extern.slf4j.Slf4j;
16 | import org.springframework.web.bind.annotation.*;
17 |
18 | import javax.validation.Valid;
19 |
20 | /**
21 | * @author zhuwj
22 | */
23 | @Api(tags = "权限服务接口")
24 | @Slf4j
25 | @RequestMapping("/auth")
26 | @RestController
27 | @RequiredArgsConstructor
28 | public class AuthController {
29 |
30 | private final IUserService userService;
31 |
32 | private final MessageFeignService messageFeignService;
33 |
34 | @ApiOperation(value = "获取访问token")
35 | @PostMapping("token")
36 | public ResponseResult token(@RequestBody @Valid User user) {
37 | String username = user.getUsername();
38 | String password = user.getPassword();
39 | User queryResult = userService.lambdaQuery().eq(User::getUsername, username).one();
40 | if (queryResult == null) {
41 | return ResponseResult.error("账号不存在!");
42 | }
43 | boolean isSuccess = PasswordUtil.verifyPassword(username, password, queryResult.getPassword());
44 | if (!isSuccess) {
45 | return ResponseResult.error("账号或密码错误!");
46 | }
47 | String accessToken = TokenProvider.createToken(username);
48 | //cache user info
49 | UserInfo userInfo = new UserInfo();
50 | BeanUtil.copyProperties(queryResult, userInfo);
51 | userInfo.setUserId(queryResult.getId());
52 | //RedisUtil.set(accessToken, userInfo, GlobalConstant.REDIS_USER_TIME);
53 | return ResponseResult.ok(accessToken);
54 | }
55 |
56 | @ApiOperation(value = "获取用户信息")
57 | @GetMapping("userInfo")
58 | public ResponseResult getUserInfo() {
59 | return ResponseResult.ok(WebContext.getUserInfo());
60 | }
61 |
62 | @ApiOperation(value = "获取版本信息")
63 | @GetMapping("version")
64 | public ResponseResult getVersion() {
65 | return ResponseResult.ok(messageFeignService.getVersion());
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/handler/GlobalGatewayExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.handler;
2 |
3 | import com.cloud.common.enums.ResponseCodeEnum;
4 | import com.cloud.common.response.ResponseResult;
5 | import com.fasterxml.jackson.core.JsonProcessingException;
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import lombok.RequiredArgsConstructor;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
10 | import org.springframework.context.annotation.Configuration;
11 | import org.springframework.core.annotation.Order;
12 | import org.springframework.core.io.buffer.DataBufferFactory;
13 | import org.springframework.http.MediaType;
14 | import org.springframework.http.server.reactive.ServerHttpResponse;
15 | import org.springframework.web.server.ResponseStatusException;
16 | import org.springframework.web.server.ServerWebExchange;
17 | import reactor.core.publisher.Mono;
18 |
19 | /**
20 | * Description: 网关异常通用处理器,只作用在webflux 环境下
21 | *
22 | * @author zhuwj
23 | * @version V1.0
24 | * @date 2020-12-14
25 | */
26 | @Slf4j
27 | @Order(-1)
28 | @Configuration
29 | @RequiredArgsConstructor
30 | public class GlobalGatewayExceptionHandler implements ErrorWebExceptionHandler {
31 |
32 | private final ObjectMapper objectMapper;
33 |
34 | @Override
35 | public Mono handle(ServerWebExchange exchange, Throwable ex) {
36 | ServerHttpResponse response = exchange.getResponse();
37 | String requestId = exchange.getRequest().getId();
38 | String path = exchange.getRequest().getPath().value();
39 | if (response.isCommitted()) {
40 | return Mono.error(ex);
41 | }
42 |
43 | // header set
44 | response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
45 | if (ex instanceof ResponseStatusException) {
46 | response.setStatusCode(((ResponseStatusException) ex).getStatus());
47 | }
48 |
49 | return response.writeWith(Mono.fromSupplier(() -> {
50 | DataBufferFactory bufferFactory = response.bufferFactory();
51 | try {
52 | return bufferFactory.wrap(objectMapper.writeValueAsBytes(
53 | ResponseResult.builder().code(ResponseCodeEnum.ERROR.getCode()).path(path)
54 | .timestamp(System.currentTimeMillis()).requestId(requestId)
55 | .message(ex.getMessage()).build()));
56 | } catch (JsonProcessingException e) {
57 | log.error("Error writing response", ex);
58 | return bufferFactory.wrap(new byte[0]);
59 | }
60 | }));
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/base/BaseEntity.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.base;
2 |
3 | import com.baomidou.mybatisplus.annotation.*;
4 | import com.cloud.common.auth.WebContext;
5 | import com.fasterxml.jackson.annotation.JsonFormat;
6 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
7 | import com.fasterxml.jackson.databind.annotation.JsonSerialize;
8 | import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
9 | import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
10 | import lombok.Data;
11 |
12 | import java.io.Serializable;
13 | import java.time.LocalDateTime;
14 |
15 | /**
16 | * Description: 基础实体
17 | *
18 | * @author zhuwj
19 | * @version V1.0
20 | * @date 2020-09-21
21 | */
22 |
23 | @Data
24 | public class BaseEntity implements Serializable {
25 |
26 | private static final long serialVersionUID = 1L;
27 |
28 | /**
29 | * 主键id
30 | */
31 | @TableId(type = IdType.ASSIGN_ID)
32 | private Long id;
33 | /**
34 | * 创建人
35 | */
36 | private Long createBy;
37 | /**
38 | * 创建时间
39 | */
40 | @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
41 | @JsonDeserialize(using = LocalDateTimeDeserializer.class)
42 | @JsonSerialize(using = LocalDateTimeSerializer.class)
43 | private LocalDateTime createTime;
44 | /**
45 | * 修改人
46 | */
47 | private Long modifiedBy;
48 | /**
49 | * 修改时间
50 | */
51 | @JsonFormat(shape =JsonFormat.Shape.STRING,pattern ="yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
52 | @JsonDeserialize(using = LocalDateTimeDeserializer.class)
53 | @JsonSerialize(using = LocalDateTimeSerializer.class)
54 | private LocalDateTime modifiedTime;
55 | /**
56 | * 删除标志
57 | */
58 | @TableLogic
59 | @TableField("is_deleted")
60 | private Boolean deleted;
61 | /**
62 | * 版本号
63 | */
64 | @Version
65 | private Integer version;
66 |
67 |
68 | public void init() {
69 | init(WebContext.getUserId());
70 | }
71 |
72 | public void init(Long userId) {
73 | LocalDateTime now = LocalDateTime.now();
74 | this.createBy = userId;
75 | this.createTime = now;
76 | this.modifiedBy = userId;
77 | this.modifiedTime = now;
78 | this.deleted = Boolean.FALSE;
79 | this.version = 0;
80 | }
81 |
82 | public void modify(T t) {
83 | LocalDateTime now = LocalDateTime.now();
84 | this.setId(t.getId());
85 | this.setModifiedBy(WebContext.getUserId());
86 | this.setModifiedTime(now);
87 | this.setVersion(t.getVersion() + 1);
88 |
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/resources/mapper/IntegralRecordMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | id
24 | ,
25 | create_by,
26 | create_time,
27 | is_deleted,
28 | modified_by,
29 | modified_time,
30 | version,
31 | integral_no, source, integral_type, num, lose_efficacy_time
32 |
33 |
34 |
35 |
36 | CREATE TABLE ${tableName}
37 | (
38 | `id` bigint NOT NULL COMMENT '主键id',
39 | `create_by` bigint NOT NULL COMMENT '创建人',
40 | `create_time` datetime(6) NOT NULL COMMENT '创建时间',
41 | `is_deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标志',
42 | `modified_by` bigint NOT NULL COMMENT '更新人',
43 | `modified_time` datetime(6) NOT NULL COMMENT '更新时间',
44 | `version` int NOT NULL DEFAULT 0 COMMENT '版本',
45 | `integral_no` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '积分编号',
46 | `source` int NOT NULL COMMENT '积分来源',
47 | `integral_type` int NOT NULL COMMENT '积分类型:增加,消费',
48 | `num` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '积分数量',
49 | `lose_efficacy_time` datetime NOT NULL COMMENT '积分失效时间',
50 | PRIMARY KEY (`id`) USING BTREE
51 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic COMMENT '积分记录表';
52 |
53 |
54 |
--------------------------------------------------------------------------------
/service-web/src/views/workflow/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | 提交申请
39 |
40 |
41 |
42 |
43 |
44 |
45 | 审批
46 | 完成
47 |
48 |
49 |
50 |
51 |
52 |
53 |
86 |
87 |
--------------------------------------------------------------------------------
/service-component/service-integral/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8950
3 | spring:
4 | application:
5 | name: service-integral
6 | cloud:
7 | nacos:
8 | server-addr: 127.0.0.1:8848
9 | main:
10 | allow-bean-definition-overriding: true # 意思是后来发现的bean会覆盖之前相同名称的bean
11 | redis:
12 | redisson:
13 | file: classpath:redisson.yml
14 | kafka:
15 | client-id: service-integral
16 | bootstrap-servers: 127.0.0.1:9092
17 | producer:
18 | retries: 3
19 | acks: all
20 | value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
21 | streams:
22 | replication-factor: 3
23 | consumer:
24 | enable-auto-commit: false
25 | value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
26 | group-id: defaultConsumerGroup
27 | auto-offset-reset: earliest
28 | auto-commit-interval: 1000
29 | listener:
30 | ack-mode: MANUAL_IMMEDIATE
31 | mybatis-plus:
32 | mapper-locations: classpath:mapper/*Mapper.xml
33 |
34 | #Sharding Sphere 不支持数据库健康检查,关闭actuate 的数据库健康检查即可。
35 | management:
36 | health:
37 | db:
38 | enabled: false
39 | sharding:
40 | jdbc:
41 | datasource:
42 | names: defaultds,ds0,ds1,ds2,ds3
43 | defaultds:
44 | type: com.zaxxer.hikari.HikariDataSource
45 | driver-class-name: com.mysql.cj.jdbc.Driver
46 | jdbc-url: jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
47 | username: root
48 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
49 | ds0:
50 | type: com.zaxxer.hikari.HikariDataSource
51 | driver-class-name: com.mysql.cj.jdbc.Driver
52 | jdbc-url: jdbc:mysql://127.0.0.1:3306/service_integral_1?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
53 | username: root
54 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
55 | ds1:
56 | type: com.zaxxer.hikari.HikariDataSource
57 | driver-class-name: com.mysql.cj.jdbc.Driver
58 | jdbc-url: jdbc:mysql://127.0.0.1:3306/service_integral_2?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
59 | username: root
60 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
61 | ds2:
62 | type: com.zaxxer.hikari.HikariDataSource
63 | driver-class-name: com.mysql.cj.jdbc.Driver
64 | jdbc-url: jdbc:mysql://127.0.0.1:3306/service_integral_3?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
65 | username: root
66 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
67 | ds3:
68 | type: com.zaxxer.hikari.HikariDataSource
69 | driver-class-name: com.mysql.cj.jdbc.Driver
70 | jdbc-url: jdbc:mysql://127.0.0.1:3306/service_integral_4?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT
71 | username: root
72 | password: 81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17
73 | config:
74 | props:
75 | sql.show: true
76 | sharding:
77 | default-data-source-name: defaultds
78 | tables:
79 | integral_record:
80 | tableStrategy:
81 | standard:
82 | shardingColumn: create_by
83 | precise-algorithm-class-name: com.cloud.integral.config.IntegralTableStrategy
84 | databaseStrategy:
85 | standard:
86 | shardingColumn: create_by
87 | precise-algorithm-class-name: com.cloud.integral.config.IntegralDatabaseStrategy
88 |
--------------------------------------------------------------------------------
/service-common/src/main/java/com/cloud/common/utils/CodeAutoGeneratorUtil.java:
--------------------------------------------------------------------------------
1 | package com.cloud.common.utils;
2 |
3 | import cn.hutool.core.lang.Console;
4 | import cn.hutool.system.SystemUtil;
5 | import com.baomidou.mybatisplus.generator.FastAutoGenerator;
6 | import com.baomidou.mybatisplus.generator.config.OutputFile;
7 | import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
8 |
9 | import java.util.Collections;
10 |
11 | /**
12 | * @author zhuwj
13 | * @date 2022/05/14 22:10
14 | * @description: 代码生成工具类
15 | **/
16 | public class CodeAutoGeneratorUtil {
17 |
18 | public static final String URL = "jdbc:mysql://127.0.0.1:3306/spring_cloud_framework?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT";
19 | public static final String USERNAME = "root";
20 | public static final String PASSWORD = "81ce7571cf55f1aa41d6d9d5d7f25b09415fee188a720f13b0ef686f183b2f17";
21 | public static final String SERVICE = "service-";
22 | public static final String GATEWAY = "gateway";
23 | public static final String AUTH = "auth";
24 | public static final String INTEGRAL = "integral";
25 |
26 | public static final String SERVICE_COMPONENT = "service-component/";
27 |
28 |
29 | public static void main(String[] argus) {
30 | String module = INTEGRAL;
31 | String tableName = "integral_user_count";
32 | //是否存在下一级
33 | String next = SERVICE_COMPONENT;
34 | generator(module, tableName, next);
35 | }
36 |
37 | public static void generator(String parentName, String tableName, String next) {
38 | String projectPath = System.getProperty(SystemUtil.USER_DIR);
39 | String moduleName = SERVICE + parentName;
40 | String outputDir = projectPath + "/" + next + moduleName + "/src/main/java/";
41 | Console.log(outputDir);
42 | FastAutoGenerator.create(URL, USERNAME, PASSWORD)
43 | .globalConfig(builder -> {
44 | builder.author("zhuwj") // 设置作者
45 | .enableSwagger() // 开启 swagger 模式
46 | .disableOpenDir()
47 | .outputDir(outputDir); // 指定输出目录
48 | })
49 | .packageConfig(builder -> {
50 | builder.parent("com.cloud") // 设置父包名
51 | .moduleName(parentName) // 设置父包模块名
52 | .pathInfo(Collections.singletonMap(OutputFile.xml, projectPath + "/" + next + moduleName + "/src/main/resources/mapper/")); // 设置mapperXml生成路径
53 | })
54 | .strategyConfig(builder -> {
55 | builder.addInclude(tableName) // 设置需要生成的表名
56 | // .addTablePrefix(parentName)// 设置过滤表前缀
57 | .entityBuilder()
58 | .superClass("com.cloud.common.base.BaseEntity")
59 | .versionColumnName("version")
60 | .logicDeleteColumnName("is_deleted")
61 | .logicDeletePropertyName("deleted")
62 | .enableTableFieldAnnotation()
63 | .fileOverride()
64 | .enableLombok()
65 | .disableSerialVersionUID()
66 | .enableRemoveIsPrefix()
67 | .disableSerialVersionUID()
68 | .addSuperEntityColumns(new String[]{"id", "create_by", "create_time", "is_deleted", "modified_by", "modified_time", "version"})
69 | .serviceBuilder()
70 | .fileOverride()
71 | .controllerBuilder()
72 | .enableRestStyle()
73 | .fileOverride()
74 | .mapperBuilder().enableBaseResultMap()
75 | .enableBaseColumnList().fileOverride();
76 | })
77 | .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
78 | .templateConfig(builder -> builder.controller(""))
79 | .execute();
80 |
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.3.7.RELEASE
11 |
12 |
13 |
14 | com.cloud.zhuwj
15 | spring-cloud-framework
16 | pom
17 | ${revision}
18 |
19 | service-component
20 | service-common
21 | service-gateway
22 |
23 |
24 |
25 |
26 | 3.0.0-SNAPSHOT
27 |
28 |
29 | UTF-8
30 | UTF-8
31 | 1.8
32 |
33 |
34 | Hoxton.SR9
35 | 2.2.3.RELEASE
36 |
37 |
38 |
39 | 1.1.0
40 | 2.8.2
41 |
42 |
43 |
44 |
45 |
46 |
47 | org.springframework.cloud
48 | spring-cloud-dependencies
49 | ${spring.cloud-version}
50 | pom
51 | import
52 |
53 |
54 | com.alibaba.cloud
55 | spring-cloud-alibaba-dependencies
56 | ${spring.alibaba.cloud-version}
57 | pom
58 | import
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | org.springframework.boot
68 | spring-boot-maven-plugin
69 |
70 |
71 |
72 | org.apache.maven.plugins
73 | maven-surefire-plugin
74 | 3.0.0-M4
75 |
76 | true
77 |
78 |
79 |
80 |
81 |
82 |
83 | org.codehaus.mojo
84 | flatten-maven-plugin
85 | ${flatten-maven-plugin.version}
86 |
87 | true
88 | resolveCiFriendliesOnly
89 |
90 |
91 |
92 | flatten
93 | process-resources
94 |
95 | flatten
96 |
97 |
98 |
99 | flatten.clean
100 | clean
101 |
102 | clean
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/service-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.cloud.zhuwj
9 | spring-cloud-framework
10 | ${revision}
11 |
12 |
13 | service-common
14 |
15 |
16 | 5.8.1
17 | 3.10.3
18 | 3.0.0
19 | 3.0.2
20 | 3.5.1
21 | 3.5.2
22 | 3.17.1
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-web
28 |
29 |
30 | org.springframework.cloud
31 | spring-cloud-starter-openfeign
32 |
33 |
34 | org.springframework.cloud
35 | spring-cloud-starter-netflix-hystrix
36 |
37 |
38 | com.alibaba.cloud
39 | spring-cloud-starter-alibaba-nacos-discovery
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-starter-data-redis
48 |
49 |
50 | org.springframework.kafka
51 | spring-kafka
52 |
53 |
54 | org.springframework.boot
55 | spring-boot-starter-jdbc
56 |
57 |
58 | org.springframework.boot
59 | spring-boot-starter-validation
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-configuration-processor
64 |
65 |
66 | mysql
67 | mysql-connector-java
68 |
69 |
70 | org.springframework.boot
71 | spring-boot-starter-test
72 |
73 |
74 | cn.hutool
75 | hutool-all
76 | ${hutool.version}
77 |
78 |
79 | org.projectlombok
80 | lombok
81 |
82 |
83 | com.auth0
84 | java-jwt
85 | ${java-jwt.version}
86 |
87 |
88 | com.baomidou
89 | mybatis-plus-boot-starter
90 | ${mybatis-plus-boot.version}
91 |
92 |
93 | com.baomidou
94 | mybatis-plus-generator
95 | ${mybatis-plus-generator.version}
96 |
97 |
98 | org.springframework.boot
99 | spring-boot-starter-freemarker
100 |
101 |
102 |
103 | io.springfox
104 | springfox-boot-starter
105 | ${springfox.version}
106 |
107 |
108 | com.github.xiaoymin
109 | knife4j-spring-boot-starter
110 | ${knife4j.version}
111 |
112 |
113 |
114 | org.redisson
115 | redisson-spring-boot-starter
116 | ${redisson-spring-boot-starter.version}
117 |
118 |
119 | org.springframework.kafka
120 | spring-kafka-test
121 | test
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | org.apache.maven.plugins
130 | maven-deploy-plugin
131 | ${maven-deploy-plugin.version}
132 |
133 | false
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/service-gateway/src/main/java/com/cloud/gateway/filter/AuthFilter.java:
--------------------------------------------------------------------------------
1 | package com.cloud.gateway.filter;
2 |
3 | import cn.hutool.core.util.StrUtil;
4 | import cn.hutool.http.HttpUtil;
5 | import cn.hutool.json.JSONUtil;
6 | import com.cloud.common.auth.UserInfo;
7 | import com.cloud.common.constant.GlobalConstant;
8 | import com.cloud.common.exception.AuthException;
9 | import com.cloud.gateway.config.AuthProperties;
10 | import com.cloud.gateway.entity.RequestLog;
11 | import lombok.RequiredArgsConstructor;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.core.annotation.Order;
14 | import org.springframework.http.HttpHeaders;
15 | import org.springframework.http.server.reactive.ServerHttpRequest;
16 | import org.springframework.stereotype.Component;
17 | import org.springframework.util.AntPathMatcher;
18 | import org.springframework.web.server.ServerWebExchange;
19 | import org.springframework.web.server.WebFilter;
20 | import org.springframework.web.server.WebFilterChain;
21 | import reactor.core.publisher.Mono;
22 |
23 | import java.net.URI;
24 | import java.nio.charset.Charset;
25 | import java.time.LocalDateTime;
26 | import java.util.Map;
27 | import java.util.Set;
28 | import java.util.function.Consumer;
29 |
30 | /**
31 | * @description: 权限过滤器 进行权限校验
32 | * @author: zhuwj
33 | * @create: 2020-09-21 14:37
34 | **/
35 | @Order(-1)
36 | @Slf4j
37 | @Component
38 | @RequiredArgsConstructor
39 | public class AuthFilter implements WebFilter {
40 |
41 | private final AuthProperties authProperties;
42 |
43 |
44 | @Override
45 | public Mono filter(ServerWebExchange exchange, WebFilterChain chain) {
46 | log.debug("AuthFilter request start");
47 | Set ignoreUrlPatterns = authProperties.getIgnoreUrlPatterns();
48 | String requestUrl = exchange.getRequest().getPath().value();
49 | //权限认证豁免验证
50 | for (String urlPatterns : ignoreUrlPatterns) {
51 | if (new AntPathMatcher().match(urlPatterns, requestUrl)) {
52 | log(requestUrl, GlobalConstant.ANONYMOUS_USER, GlobalConstant.ANONYMOUS_USER_ID);
53 | Consumer httpHeaders = httpHeader -> {
54 | httpHeader.set(GlobalConstant.REQUEST_ID, exchange.getRequest().getId());
55 | httpHeader.set(GlobalConstant.REQUEST_PATH, exchange.getRequest().getPath().value());
56 | };
57 | ServerHttpRequest serverHttpRequest = exchange.getRequest().mutate().headers(httpHeaders).build();
58 | exchange.mutate().request(serverHttpRequest).build();
59 | return chain.filter(exchange);
60 | }
61 | }
62 | //权限认证校验
63 | String accessToken = getToken(exchange);
64 | if (StrUtil.isBlank(accessToken)) {
65 | log.warn("AuthFilter accessToken is blank");
66 | log(requestUrl, GlobalConstant.ANONYMOUS_USER, GlobalConstant.ANONYMOUS_USER_ID);
67 | throw new AuthException("accessToken not exist");
68 | }
69 | //UserInfo userInfo = RedisUtil.get(accessToken, UserInfo.class);
70 | UserInfo userInfo = null;
71 | if (userInfo == null) {
72 | log.info("AuthFilter userInfo is null ");
73 | log(requestUrl, GlobalConstant.ANONYMOUS_USER, GlobalConstant.ANONYMOUS_USER_ID);
74 | throw new AuthException("userInfo not exist");
75 | }
76 | log(requestUrl, userInfo.getUsername(), GlobalConstant.ANONYMOUS_USER_ID);
77 | Consumer httpHeaders = httpHeader -> {
78 | httpHeader.set(GlobalConstant.HEADER_USER, JSONUtil.toJsonStr(userInfo));
79 | httpHeader.set(GlobalConstant.REQUEST_ID, exchange.getRequest().getId());
80 | httpHeader.set(GlobalConstant.REQUEST_PATH, exchange.getRequest().getPath().value());
81 | };
82 | ServerHttpRequest serverHttpRequest = exchange.getRequest().mutate().headers(httpHeaders).build();
83 | exchange.mutate().request(serverHttpRequest).build();
84 | log.debug("AuthFilter request end ");
85 | return chain.filter(exchange);
86 | }
87 |
88 |
89 | private void log(String requestUrl, String username, long userId) {
90 | RequestLog requestLog = new RequestLog();
91 | requestLog.setCreateTime(LocalDateTime.now());
92 | requestLog.setModifiedTime(LocalDateTime.now());
93 | requestLog.setCreateBy(userId);
94 | requestLog.setModifiedBy(userId);
95 | requestLog.setRequestUrl(requestUrl);
96 | requestLog.setRequestUsername(username);
97 | requestLog.setDeleted(Boolean.FALSE);
98 | requestLog.setVersion(0);
99 | try {
100 | // requestLogService.create(requestLog);
101 | } catch (Exception e) {
102 | log.error("gateway log create error !!!", e);
103 | }
104 | }
105 |
106 | private String getToken(ServerWebExchange exchange) {
107 | ServerHttpRequest request = exchange.getRequest();
108 | HttpHeaders httpHeaders = request.getHeaders();
109 | String bearerToken = httpHeaders.getFirst(GlobalConstant.HEADER);
110 | if (StrUtil.isBlank(bearerToken)) {
111 | URI uri = request.getURI();
112 | String queryParams = uri.getQuery();
113 | Map mapQueryParams = HttpUtil.decodeParamMap(queryParams, Charset.defaultCharset());
114 | bearerToken = mapQueryParams.get(GlobalConstant.TOKEN_NAME);
115 | }
116 | String accessToken = resolveToken(bearerToken);
117 | return accessToken;
118 | }
119 |
120 | /**
121 | * 获取去除前缀的token
122 | *
123 | * @param bearerToken
124 | * @return
125 | */
126 | private String resolveToken(String bearerToken) {
127 | if (StrUtil.isNotBlank(bearerToken) && bearerToken.startsWith(GlobalConstant.TOKEN_PREFIX)) {
128 | return StrUtil.removePrefix(bearerToken, GlobalConstant.TOKEN_PREFIX).trim();
129 | }
130 | return null;
131 | }
132 | }
133 |
--------------------------------------------------------------------------------