clay commit : tree=util使用,sentinel dashboard简介
continuous-integration/drone/push Build is passing Details

This commit is contained in:
clay 2023-01-28 16:33:54 +08:00
parent fe7b21ba53
commit aec78ec5cb
8 changed files with 259 additions and 81 deletions

View File

@ -30,20 +30,20 @@ module.exports = {
// sidebarDepth: 0, //0读取1级标题 1读取1级和2级标题 2读取1级、2级、3级标题 // sidebarDepth: 0, //0读取1级标题 1读取1级和2级标题 2读取1级、2级、3级标题
// 设置侧边栏内容 // 设置侧边栏内容
sidebar: [ sidebar: [
{ // {
title: '本文档使用教程', // title: '本文档使用教程',
collapsable: false, // collapsable: false,
children: [ // children: [
'/document/', // '/document/',
// { // // {
// title: '侧边栏组合', // // title: '侧边栏组合',
// // collapsable: true, // // // collapsable: true,
// children: [ // // children: [
// '/second/child/' // // '/second/child/'
// ] // // ]
// } // // }
] // ]
}, // },
{ {
title: '文档', title: '文档',
collapsable: false, collapsable: false,
@ -52,6 +52,18 @@ module.exports = {
'/wiki/back-build/' '/wiki/back-build/'
] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md ] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md
}, },
{
title: '模块介绍',
collapsable: false,
children: [
'/module/',
'/module/common/',
'/module/gateway/',
'/module/auth/',
'/module/umps/',
'/module/visual/',
] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md
},
{ {
title: '功能使用', title: '功能使用',
collapsable: false, collapsable: false,
@ -66,19 +78,6 @@ module.exports = {
'/util/tree-util/', '/util/tree-util/',
] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md ] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md
}, },
// {
// title: '模块介绍',
// collapsable: false,
// children: [
// '/module/',
// '/module/gateway/',
// '/module/auth/',
// '/module/umps/',
// '/module/common/',
// '/module/visual/',
// ] // 根据自己的需求来订对应自己在docs下的文件夹名默认首页是README.md
// },
{ {
title: 'CI/CD', title: 'CI/CD',
collapsable: false, collapsable: false,

View File

@ -11,11 +11,16 @@ security-cloud
├── common-security -- 安全工具类 ├── common-security -- 安全工具类
├── common-swagger -- 接口文档 ├── common-swagger -- 接口文档
├── common-feign -- feign 扩展封装 ├── common-feign -- feign 扩展封装
├── common-oss -- 阿里云oss封装
└── common-log -- 系统日志记录 └── common-log -- 系统日志记录
└── upms -- 通用用户权限管理模块 └── upms -- 通用用户权限管理模块
── upms-api -- 通用用户权限管理系统公共api模块 ── upms-api -- 通用用户权限管理系统公共api模块
└── upms-biz -- 通用用户权限管理系统业务处理模块[4000] └── upms-biz -- 通用用户权限管理系统业务处理模块[4000]
└── visual -- 图形化管理模块 └── visual -- 图形化管理模块
└── monitor -- 服务监控 ├── code-gen -- 分布式可视化代码生成
└── codegen -- 图形化代码生成 ├── custom-query -- 自定义查询
├── flowable -- workflow工作流模块
├── monitor -- 服务监控
├── sentinel-dashboard -- sentinel监控面板
└── sentinel-dashboard-pro -- sentinel监控面板,配置规则同步到nacos管理
``` ```

View File

@ -1 +1,2 @@
# 授权服务模块 # 授权服务模块
为整个集群提供授权登录服务,先阶段实现账号密码登录,后续可以扩展实现微信登录,微信扫码登录,QQ等第三方登录方式

View File

@ -1 +1,105 @@
# 系统公共模块 # 系统公共模块
系统公共模块主要对集群中的基础公共工具进行封装,现阶段对如需模块进行封装:
## common-core 基础核心组件
对系统中的基础服务实体进行定义,基础的工具类进行定义.例如:
### TreeUtil
自定义树形结构实体转换,可以将A对象结构具有树形关系的list转换成B对象的树形结构, 可以自定义A B两个对象之间的映射关系例如:
将Dept映射到OptionTree对象:
```javascript
//Dept 类
public class Dept extends BaseEntity {
private Long deptId;
private Long parentId;
private String ancestors;
@NotBlank(message = "部门名称不能为空!")
private String deptName;
@NotBlank(message = "显示顺序不能为空!")
private String orderNum;
@NotBlank(message = "负责人不能为空!")
private String leader;
@NotNull(message = "负责人id不能为空!")
private Long leaderId;
}
//OptionTree 目标对象
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OptionTree implements Serializable {
/**
* 节点ID
*/
private Object value;
/**
* 节点名称
*/
private String label;
/**
* 子节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<OptionTree> children;
}
//转换代码
List<OptionTree> optionTreeList = TreeUtil.build(deptList,OptionTree.class,(config)->{
config.setIdField("deptId");
config.setOption("deptId","deptName");
});
```
并且TreeUtil可以通过config进行自定义配置,配置项如下:
- 是否启用BeanUtils.copyProperties方法进行字段的copy(默认为ture)
- 父级关系字段名称定义
- id字段定义
- tree子级字段定义
- mapper其余字段关系映射
- exclude排除字段
## common-feign
对openfeign进行基础的配置,比如让OpenFeign 使用 OkHttp 配置类,以及Ribbon做rpc的负载均衡
## common-log
自定义操作日志模块,完成使用自定义注解实现操作日志的记录
```javascript
@ApiOperation("新增部门")
@PostMapping
@PreAuthorize("@ss.hasPermission('admin:dept:add')")
@Log(title = "新增部门",businessType = BusinessType.INSERT)
public Result<Void> add(@RequestBody @Validated Dept dept){
if (UserConstants.DEPT_DISABLE.equals(deptService.checkDeptNameUnique(dept))){
return Result.error("新增部门: "+ dept.getDeptName() +"'失败,部门名称以存在!");
}
deptService.saveDept(dept);
return Result.ok();
}
```
通过LogAspect实现当前注解的apo切面,切面中将操作的日志封装成一个操作日志对象,然后使用spring的事件发布机制发布这个日志操作对象,再使用OperationLogListener异步监听到发布的事件,再通过rpc远程调用到umps中的日志存储接口,将当前对象落地到数据库
## common-mybatis
对mybatis的基本分页功能进行封装
## common-oss
对接阿里云的oos分布式对象储存服务,
## common-redis
使redis使用FastJson序列化,对RedisTemplate进行进一步的函数封装
## common-security
集群中最核心的部分,spring security 安全校验封装,自定义PermissionService实现spring security自定校验方法,实现自定义校验逻辑,使用Inner注解实现集群内rpc远程调用接口的区分
## common-swagger
swagger接口文档配置,通过SwaggerConfig类从nacos中获取到当前服务对应的swagger配置信息,生成当前服务的swagger接口文档数据,配合gateway swagger聚合生成集群的swagger聚合文档

View File

@ -1,7 +1,87 @@
# 网关服务模块 # 网关服务模块
security-cloud使用spring官方的网关主键,spring gateway。 在集群环境中gateway将会是集群网络的唯一出入口是系统安全的重要节点同时gateway承担Sentinel限流服务分发负载均衡和提供swagger文档等工作。
## 文件结构
```lua
gateway
└── java
├── config -- 配置包
├── controller -- swagger聚合需要使用的到的接口
├── filter -- 全局过滤器
├── handler -- 异常处理
├── util -- 工具
└── GatewayApplication.java -- 启动类
└── resources
├── bootstrap.yml -- 配置文件
└── logback-spring.xml -- 日志记录文件
```
## 配置文件
```yaml
# Tomcat
server:
port: 5000
# Spring
spring:
application:
# 应用名称
name: monitor
profiles:
# 环境配置
active: local
security:
user:
name: root
password: password
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 192.168.101.108:8848
username: nacos
password: nacos
namespace: ${spring.profiles.active}
metadata:
management:
context-path: /actuator
config:
# 配置中心地址
server-addr: ${spring.cloud.nacos.discovery.server-addr}
file-extension: yaml
namespace: ${spring.profiles.active}
shared-configs:
- ${spring.application.name}-${spring.profiles.active}.yml
```
配置文件相当简洁,主要为设置运行端口,active的环境以及注册到nacos,并从nacos读取到gateway自身的配置文件
属于gateway的配置文件:
```yaml
spring:
cloud:
gateway:
discovery:
locator:
# gateway 能够进行服务发现
enabled: true
routes:
# 认证中心
- id: auth
uri: lb://auth
predicates:
- Path=/auth/**
```
## 路由分发
路由分发是gateway的一个重要功能,当gateway启动后会向nacos发起注册,并从nacos cconfig中心获取到gateway的那一份配置文件,gateway再将文件加载到自己的路由中,当又接口请求到后,gateway则可以根据路由表对请求进行分发。
## 路由配置

View File

@ -1 +1,8 @@
# 通用用户权限管理模块 # 通用用户权限管理模块
通用用户权限管理模块主要集成用户管理,角色管理,菜单管理,部门管理,岗位管理,字典管理,字典类型配置,在线用户管理等
## umps-api rpc api服务模块
为集群远程rpc 实体对象和fegin 的远程接口调用
## umps-biz 业务服务模块
提供真实的业务需求,对用户管理,角色管理,菜单管理,部门管理,岗位管理,字典管理,字典类型配置,在线用户管理等服务的具体实现

View File

@ -1 +1,32 @@
# 图形化管理模块 # 图形化管理模块
主要实现集群中的一些扩展功能:
- code-gen -- 分布式可视化代码生成
- custom-query -- 自定义查询
- flowable -- workflow工作流模块
- monitor -- 服务监控
- sentinel-dashboard -- sentinel监控面板
- sentinel-dashboard-pro -- sentinel监控面板,配置规则同步到nacos管理
## code-gen(正在开发)
提供数据库数据源的配置,支持mysql,MariaDB,以及oracle三种数据库
支持可视化的代码生成配置,并且根据数据源不同生成对应数据库的标准curd代码
## custom-query(正在规划)
将ebts中的自定义查询和er可视化查询集群化,ebts网站:https://demo.ebts.top/
## flowable(开发中)
使用flowable实现workflow的开发,新阶段实现了json转bnpm,流程发布,流程流转,流程流转的位置等
demo(访问时提示无权限时请刷新,刷新后正常使用): http://workflow.mytwins.top/
## sentinel-dashboard
sentinel的控制面板
## sentinel-dashboard-pro
实现了sentinel配置规则落地到nacos中

View File

@ -1,50 +1 @@
# 介绍 # 介绍
## 它是如何工作的?
**卡拉兹(Callatz)猜想**
对任何一个自然数n如果它是偶数那么把它砍掉一半如果它是奇数那么把(3n+1)砍掉一半。这样一直反复砍下去最后一定在某一步得到n=1。卡拉兹在1950年的世界数学家大会上公布了这个猜想传说当时耶鲁大学师生齐动员拼命想证明这个貌似很傻很天真的命题结果闹得学生们无心学业一心只证(3n+1),以至于有人说这是一个阴谋,卡拉兹是在蓄意延缓美国数学界教学与科研的进展……
我们今天的题目不是证明卡拉兹猜想而是对给定的任一不超过1000的正整数n简单地数一下需要多少步(砍几下)才能得到n=1
**输入格式**
每个测试输入包含1个测试用例即给出自然数n的值。
**输出格式**
输出从 n 计算到1需要的步数。
**输入样例**:
~~~ bash
3
~~~
**输出样例**:
~~~ bash
5
~~~
代码实现:
~~~ java
//java代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
int N = scanner.nextInt();
int steps =0;
while (N !=1) {
if (N %2 ==0) {
N = N /2;
} else {
N = (3 * N +1) / 2;
}
steps++;
}
System.out.println(steps);
}
}
~~~