瀏覽代碼

Merge branch 'dev' of lifang/NB_NetPump into master

lifang 3 年之前
父節點
當前提交
eee1e956dc
共有 100 個文件被更改,包括 3253 次插入2569 次删除
  1. 25 122
      README.md
  2. 0 41
      doc/db/coffee.sql
  3. 946 0
      doc/db/create.sql
  4. 38 0
      doc/db/insert.sql
  5. 0 1
      doc/db/schema.sql
  6. 0 59
      doc/db/update.sql
  7. 3 3
      nb-admin/Dockerfile
  8. 150 27
      nb-admin/pom.xml
  9. 15 7
      nb-admin/src/main/java/com/nb/admin/AdminApplication.java
  10. 13 4
      nb-admin/src/main/java/com/nb/admin/StartUpRunner.java
  11. 0 99
      nb-admin/src/main/java/com/nb/admin/controller/common/CommonController.java
  12. 3 3
      nb-admin/src/main/java/com/nb/admin/controller/monitor/OnlineUserController.java
  13. 0 120
      nb-admin/src/main/java/com/nb/admin/controller/system/SysLoginController.java
  14. 0 37
      nb-admin/src/main/java/com/nb/admin/controller/system/vo/UserPassVo.java
  15. 6 16
      nb-admin/src/main/resources/application-dev.yml
  16. 5 14
      nb-admin/src/main/resources/application-prod.yml
  17. 1 1
      nb-admin/src/main/resources/application-test.yml
  18. 2 3
      nb-admin/src/main/resources/application.yml
  19. 24 0
      nb-admin/src/main/resources/assembly.xml
  20. 1 1
      nb-admin/src/main/resources/logback-spring.xml
  21. 0 44
      nb-admin/src/main/test/java/com/coffee/admin/BusDeviceRegisterTest.java
  22. 7 8
      nb-admin/src/test/java/com/nb/admin/AliyunTest.java
  23. 8 8
      nb-admin/src/test/java/com/nb/admin/BusClinicTest.java
  24. 8 8
      nb-admin/src/test/java/com/nb/admin/BusDeviceAlarmTest.java
  25. 6 6
      nb-admin/src/test/java/com/nb/admin/BusDeviceTest.java
  26. 3 3
      nb-admin/src/test/java/com/nb/admin/BusHospitalLogTest.java
  27. 9 9
      nb-admin/src/test/java/com/nb/admin/BusHospitalTest.java
  28. 2 2
      nb-admin/src/test/java/com/nb/admin/BusNetpumpTest.java
  29. 13 13
      nb-admin/src/test/java/com/nb/admin/BusPatientTest.java
  30. 6 6
      nb-admin/src/test/java/com/nb/admin/DelayMessageTest.java
  31. 5 9
      nb-admin/src/test/java/com/nb/admin/DeviceOperateTest.java
  32. 1 1
      nb-admin/src/test/java/com/nb/admin/FileUploadTest.java
  33. 7 7
      nb-admin/src/test/java/com/nb/admin/HisStrategyTest.java
  34. 3 10
      nb-admin/src/test/java/com/nb/admin/NotifyTest.java
  35. 5 5
      nb-admin/src/test/java/com/nb/admin/SpringBootApplicationTests.java
  36. 0 15
      nb-api/pom.xml
  37. 9 4
      nb-auth/pom.xml
  38. 43 0
      nb-auth/src/main/java/com/nb/auth/GlobalAuthExceptionHandler.java
  39. 37 0
      nb-auth/src/main/java/com/nb/auth/bean/UserPassVo.java
  40. 44 0
      nb-auth/src/main/java/com/nb/auth/config/AuthDocConfig.java
  41. 30 0
      nb-auth/src/main/java/com/nb/auth/config/CustomStpInterface.java
  42. 77 0
      nb-auth/src/main/java/com/nb/auth/controller/AccountController.java
  43. 17 61
      nb-auth/src/main/java/com/nb/auth/controller/AuthController.java
  44. 62 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/AccountInfoVO.java
  45. 17 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/BaseTemplateVO.java
  46. 21 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/RoleInfoVO.java
  47. 30 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/RouteItemVO.java
  48. 49 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/RouteMetoVO.java
  49. 35 0
      nb-auth/src/main/java/com/nb/auth/controller/vo/UserInfoVO.java
  50. 5 3
      nb-auth/src/main/java/com/nb/auth/granter/IAccountOperator.java
  51. 2 2
      nb-auth/src/main/java/com/nb/auth/granter/IAuthGranter.java
  52. 1 0
      nb-auth/src/main/java/com/nb/auth/granter/TokenParameter.java
  53. 26 0
      nb-auth/src/main/java/com/nb/auth/sa/SaConfig.java
  54. 169 0
      nb-auth/src/main/java/com/nb/auth/sa/SaTokenActionDefaultImpl.java
  55. 61 0
      nb-auth/src/main/java/com/nb/auth/sa/SaTokenConfig.java
  56. 0 51
      nb-auth/src/main/java/com/nb/auth/utils/AddressUtil.java
  57. 0 53
      nb-auth/src/main/java/com/nb/auth/utils/IpUtil.java
  58. 0 62
      nb-auth/src/main/java/com/nb/auth/vo/AccountInfoVO.java
  59. 0 17
      nb-auth/src/main/java/com/nb/auth/vo/BaseTemplateVO.java
  60. 0 21
      nb-auth/src/main/java/com/nb/auth/vo/RoleInfoVO.java
  61. 0 30
      nb-auth/src/main/java/com/nb/auth/vo/RouteItemVO.java
  62. 0 49
      nb-auth/src/main/java/com/nb/auth/vo/RouteMetoVO.java
  63. 0 35
      nb-auth/src/main/java/com/nb/auth/vo/UserInfoVO.java
  64. 0 37
      nb-codegen/pom.xml
  65. 0 219
      nb-codegen/src/main/java/com/nb/codegen/CodeGenerator.java
  66. 0 119
      nb-codegen/src/main/resources/templates/addDTO.java.vm
  67. 0 110
      nb-codegen/src/main/resources/templates/controller.java.vm
  68. 0 120
      nb-codegen/src/main/resources/templates/editDTO.java.vm
  69. 0 193
      nb-codegen/src/main/resources/templates/entity.java.vm
  70. 0 20
      nb-codegen/src/main/resources/templates/mapper.java.vm
  71. 0 39
      nb-codegen/src/main/resources/templates/mapper.xml.vm
  72. 0 94
      nb-codegen/src/main/resources/templates/queryDTO.java.vm
  73. 0 75
      nb-codegen/src/main/resources/templates/service.java.vm
  74. 0 113
      nb-codegen/src/main/resources/templates/serviceImpl.java.vm
  75. 0 24
      nb-codegen/src/main/resources/templates/sql.vm
  76. 0 65
      nb-codegen/src/main/resources/templates/vue/FormModal.vue.vm
  77. 0 37
      nb-codegen/src/main/resources/templates/vue/api.ts.vm
  78. 0 65
      nb-codegen/src/main/resources/templates/vue/data.ts.vm
  79. 0 139
      nb-codegen/src/main/resources/templates/vue/index.vue.vm
  80. 50 0
      nb-common/config-common/pom.xml
  81. 25 0
      nb-common/config-common/src/main/java/com/nb/common/config/ApplicationConfig.java
  82. 18 0
      nb-common/config-common/src/main/java/com/nb/common/config/ConfigAutoConfiguration.java
  83. 34 0
      nb-common/config-common/src/main/java/com/nb/common/config/ValidatorConfig.java
  84. 141 0
      nb-common/config-common/src/main/java/com/nb/common/config/WebAppMvcConfig.java
  85. 82 0
      nb-common/config-common/src/main/java/com/nb/common/config/apply/ApplyManager.java
  86. 59 0
      nb-common/config-common/src/main/java/com/nb/common/config/aspect/DataSourceAspect.java
  87. 17 0
      nb-common/config-common/src/main/java/com/nb/common/config/bo/DictModel.java
  88. 49 0
      nb-common/config-common/src/main/java/com/nb/common/config/convert/ExcelDictConverter.java
  89. 107 0
      nb-common/config-common/src/main/java/com/nb/common/config/datasource/DruidConfig.java
  90. 25 0
      nb-common/config-common/src/main/java/com/nb/common/config/datasource/DynamicDataSource.java
  91. 40 0
      nb-common/config-common/src/main/java/com/nb/common/config/datasource/DynamicDataSourceContextHolder.java
  92. 38 0
      nb-common/config-common/src/main/java/com/nb/common/config/event/EventConfig.java
  93. 12 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/GetNameInterface.java
  94. 61 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/MybatisPlusConfig.java
  95. 60 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/TenantNameHandler.java
  96. 84 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java
  97. 118 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/interceptor/DefaultTenantLineInnerInterceptor.java
  98. 33 0
      nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/interceptor/TenantIdManager.java
  99. 63 0
      nb-common/config-common/src/main/java/com/nb/common/config/notice/NotifyEnums.java
  100. 87 0
      nb-common/config-common/src/main/java/com/nb/common/config/notice/SystemMonitor.java

+ 25 - 122
README.md

@@ -1,5 +1,5 @@
 <div align="center">
-<h1>Coffee Admin</h1>
+<h1>nb-netpump</h1>
 </div>
 
 <p align="center">
@@ -10,7 +10,7 @@
 
 ### 简介
 
-Coffee Admin权限管理系统,基于VUE3.x、SpringBoot2.x、Sa-Token、MyBatis-Plus等技术实现的前后端分离的权限管理系统。 可用于学习参考和项目开发
+n该项目是基于VUE3.x、SpringBoot2.x、Sa-Token、MyBatis-Plus、Redssion等技术实现帮助医患沟通、远程监控设备、辅助医生诊断的中央监护管理系统
 
 ### 特性
 
@@ -27,6 +27,7 @@ Coffee Admin权限管理系统,基于VUE3.x、SpringBoot2.x、Sa-Token、MyBat
 - Fastjson,方便了JSON的格式化和解析。
 - Alibaba Java Coding Guidelines插件,IDEA插件,提高代码质量。
 - MinIO,分布式文件存储。
+- Redssion 分布式锁、延迟队列
 - 前端框架采用最新技术栈,Vue3 & Vite,打包更快更轻。
 - 前端框架采用TypeScript和Eslint,规范代码,提高项目可持续性和可维护性。
 
@@ -39,13 +40,21 @@ Coffee Admin权限管理系统,基于VUE3.x、SpringBoot2.x、Sa-Token、MyBat
 ### 项目结构
 
 ```
-coffee-boot
-├── coffee-admin -- 内置功能,后台管理
-├── coffee-codegen -- 内置功能,代码生成
-├── coffee-common --内置功能,通用工具
-├── coffee-framework -- 内置功能,核心模块
-├── coffee-system -- 内置功能,系统模块
-├── coffee-oss -- 内置功能,OSS文件存储模块
+nb-root
+├── nb-admin        -- 项目启动地址
+├── nb-auth         -- 权限模块
+├── nb-common       -- 通用模块
+    ├── config-common      -- 通用配置模块,web配置、redis配置、mybatis配置等 
+    ├── crud-common        -- 单表查询通用配置模块 
+    ├── delay-queue-common -- 延迟队列模块,使用redisson延迟队列功能
+    ├── log-common         -- 日志模块
+    ├── ws-common          -- websocket模块,根据主题实现订阅发布功能
+├── nb-core         -- 内置功能,核心模块
+├── nb-oss          -- 文件存储模块
+├── nb-service      -- 服务实现模块
+    ├── iot-service         -- 物联网设备对接模块
+    ├── web-service         -- web端后台管理模块
+├── nb-service-api  -- 服务api模块
 ```
 
 ### 核心依赖
@@ -61,21 +70,15 @@ coffee-boot
 | EasyExcel              | 3.0.5        |
 | Fastjson               | 1.2.79       |
 | Minio                  | 8.3.7        |
-
+| Redssion                  | 3.17.0        |
 ### 内置功能
 
 ```
-1、菜单管理
-2、字典管理
-3、部门管理
-4、岗位管理
-5、角色管理
-6、用户管理
-7、参数设置
-8、行政区域
-9、在线用户
-10、操作日志
-11、账户设置
+1、输注信息
+2、统计查询
+3、信息维护
+4、系统监控
+5、系统管理
 ```
 ### 环境安装
 
@@ -184,104 +187,4 @@ docker run -d -p 9000:9000 -p 9001:9001 --name=minio -v /opt/docker/minio/data:/
     ├──── coffee-boot
     ├────── startup.sh
     ├────── coffee-admin.jar
-```
-
-### nginx配置
-
-```
-    location / {
-        root   /opt/coffee/coffee-ui;
-        try_files $uri $uri/ @router;
-        index  index.html index.htm;
-    }
-    
-    location @router {
-        rewrite ^.*$ /index.html last;
-    }
-    
-    location ^~ /api {
-        proxy_pass  http://localhost:9090/api;
-        proxy_set_header Host $host;
-        proxy_set_header X-Real-IP $remote_addr;
-        proxy_set_header REMOTE-HOST $remote_addr;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-    }
-```
-
-### 使用帮助
-
-#### 代码同步方法(示例)
-
-1、fork代码,fork from https://gitee.com/skysong/coffee-ui <br/>
-2、创建自己的分支,进行开发,feature-dev <br/>
-3、码云强制同步 <br/>
-<img src="./doc/images/doc/1.png"/>
-<br/>
-4、合并代码,merge into feature-dev <br/>
-<img src="./doc/images/doc/2.png"/>
-
-#### 代码生成(CodeGenerator)
-
-```
-    /** 按照个人需要,进行修改 */
-    public static final String AUTHOR = "Kevin";
-    public static final String PROJECT_PATH = "D:\\tempCode";
-    public static final String PACKAGE_PARENT = "com.coffee";
-    public static final String MODULE_NAME = "system";
-
-    /** 生成SQL脚本的上级菜单的ID,要开发的功能,需要放到XXX菜单下面,请找到XXX菜单的ID */
-    public static final String PARENT_MENU_ID = "1406064334403878913";
-
-    /** admin的ID,可以不用修改 */
-    public static final String CREATE_BY = "1";
-    public static final String UPDATE_BY = "1";
-
-    /** 默认菜单图标,可以不用修改,SQL脚本生成之后,在页面选择图标,进行修改即可 */
-    public static final String ICON = "ant-design:unordered-list-outlined";
-
-    // 是否导出excel
-    public static final Boolean exportExcel = false;
-
-    public static void main(String[] args) {
-        new CodeGenerator().generate(
-                "sys_example"
-        );
-    }
-```
-
-#### EasyExcel使用
-
-```
-excel标题宽度
-两个字:@ColumnWidth(10)
-四个字:@ColumnWidth(15)
-```
-
-#### Java编码规范(Java开发手册更新至嵩山版)
-
-[Java开发手册](./doc/java开发手册/阿里巴巴Java开发手册(嵩山版).pdf)
-
-#### Java规范
-
-```
-1、大道至简
-
-2、IDEA安装Alibaba Java Coding Guidelines插件,编码规约扫描,代码中不要出现警告
-
-3、尽量用@Resource,基于BeanName查找注入,少用@Autowired,基于BeanType查找注入
-
-4、尽量用Service互相注入,少用直接注入Mapper
-
-5、详细开发范例请见 com.coffee.framework.test.controller下类,Service层直接使用Service,抛弃接口类
-
-```
-
-#### 建表规范
-
-```
-1、ID主键,bigint(20),雪花算法
-
-2、审计字段,create_by、create_time、update_by、update_time
-
-3、表中字段类型,主要采用varchar,万一迁移oracle、sqlserver数据库呢,好兼容
-```
+```

文件差異過大導致無法顯示
+ 0 - 41
doc/db/coffee.sql


+ 946 - 0
doc/db/create.sql

@@ -0,0 +1,946 @@
+/*
+SQLyog Ultimate v12.09 (64 bit)
+MySQL - 5.7.33 : Database - nbnetpump
+*********************************************************************
+*/

+
+/*!40101 SET NAMES utf8 */;
+
+/*!40101 SET SQL_MODE=''*/;
+
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+CREATE DATABASE /*!32312 IF NOT EXISTS*/`nbnetpump` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
+
+USE `nbnetpump`;
+
+/*Table structure for table `bus_clinic` */
+
+DROP TABLE IF EXISTS `bus_clinic`;
+
+CREATE TABLE `bus_clinic` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `patient_id` varchar(255) DEFAULT NULL COMMENT '住院号在系统中的存储id',
+  `patient_code` varchar(50) DEFAULT NULL COMMENT '医院原始住院号',
+  `start_time` datetime(3) DEFAULT NULL COMMENT '临床开始就诊时间',
+  `end_time` datetime(3) DEFAULT NULL COMMENT '临床结束就诊时间',
+  `patient_name` varchar(255) DEFAULT NULL COMMENT '患者姓名',
+  `patient_gender` tinyint(4) DEFAULT NULL COMMENT '患者性别',
+  `patient_age` int(11) DEFAULT NULL COMMENT '患者年龄',
+  `ward` varchar(255) DEFAULT NULL COMMENT '病区',
+  `bed_no` varchar(255) DEFAULT NULL COMMENT '床号',
+  `weight` varchar(255) DEFAULT NULL COMMENT '体重',
+  `height` varchar(255) DEFAULT NULL COMMENT '身高',
+  `ana_doctor` varchar(255) DEFAULT NULL COMMENT '麻醉医生',
+  `ana_type` varchar(255) DEFAULT NULL COMMENT '麻醉方式',
+  `anal_type` varchar(255) DEFAULT NULL COMMENT '镇痛方式',
+  `surgery_doctor` varchar(255) DEFAULT NULL COMMENT '手术医生',
+  `surgery_name` varchar(255) DEFAULT NULL COMMENT '手术名称',
+  `asa` varchar(255) DEFAULT NULL COMMENT 'asa',
+  `formula` text COMMENT '配方',
+  `entrust` varchar(255) DEFAULT NULL COMMENT ' 医嘱',
+  `remark` varchar(255) DEFAULT NULL COMMENT ' 备注',
+  `finished` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否结束',
+  `config_person` varchar(255) DEFAULT NULL COMMENT '配置人员',
+  `device_codes` varchar(1024) DEFAULT NULL COMMENT '使用设备号',
+  `monitor_start_time` datetime(3) DEFAULT NULL COMMENT '手术监护开始时间,即该临床手术后第一次上传数据时间',
+  `eval_time` datetime(3) DEFAULT NULL COMMENT '最后一次评价时间',
+  `visit_record` text COMMENT '术前方式记录单',
+  `undo_config` varchar(255) DEFAULT NULL COMMENT '撤泵配置',
+  `monitor_type` tinyint(1) DEFAULT NULL COMMENT '监护类型,0、无泵 1、有泵',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `tenant_id` varchar(255) NOT NULL COMMENT '医院编号',
+  PRIMARY KEY (`id`) USING BTREE,
+  KEY `patient_code` (`tenant_id`,`patient_code`) USING BTREE,
+  KEY `tenant_id` (`tenant_id`,`start_time`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='临床(每条记录表示患者的一次就诊记录)';
+
+/*Table structure for table `bus_con_alarm` */
+
+DROP TABLE IF EXISTS `bus_con_alarm`;
+
+CREATE TABLE `bus_con_alarm` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `remark` varchar(512) DEFAULT NULL COMMENT '备注',
+  `type` tinyint(4) DEFAULT NULL COMMENT '报警原因',
+  `cause` varchar(255) DEFAULT NULL COMMENT '报警信息',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `tenant_id` varchar(255) NOT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常量-报警原因表';
+
+/*Table structure for table `bus_con_doctor` */
+
+DROP TABLE IF EXISTS `bus_con_doctor`;
+
+CREATE TABLE `bus_con_doctor` (
+  `id` varchar(255) NOT NULL COMMENT '主键',
+  `remark` varchar(512) DEFAULT NULL COMMENT '备注',
+  `name` varchar(255) DEFAULT NULL COMMENT '姓名',
+  `surgeon` tinyint(1) DEFAULT NULL COMMENT '是否为手术医生',
+  `anesthetists` tinyint(1) DEFAULT NULL COMMENT '是否为麻醉医生',
+  `reviewer` tinyint(1) DEFAULT NULL COMMENT '是否为配置、撤泵、评价人员',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime DEFAULT NULL COMMENT '记录添加时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',
+  `tenant_id` varchar(255) DEFAULT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `tenant_id` (`tenant_id`,`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常量-医生人员表';
+
+/*Table structure for table `bus_con_mix` */
+
+DROP TABLE IF EXISTS `bus_con_mix`;
+
+CREATE TABLE `bus_con_mix` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `name` varchar(255) NOT NULL COMMENT '常量名称',
+  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
+  `type` tinyint(4) DEFAULT NULL COMMENT '常量类型(0、病区;1、手术名称;2、asa;3、麻醉方式;4、镇痛方式;5、药品分类;6、医嘱)',
+  `code` varchar(255) DEFAULT NULL COMMENT '常量编码',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',
+  `create_time` datetime DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `tenant_id` varchar(255) NOT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `tenant_id` (`tenant_id`,`type`,`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常量-混合表 (病区、镇痛方式、asa等)';
+
+/*Table structure for table `bus_device` */
+
+DROP TABLE IF EXISTS `bus_device`;
+
+CREATE TABLE `bus_device` (
+  `id` varchar(20) NOT NULL COMMENT '主键id',
+  `device_id` varchar(255) NOT NULL COMMENT '设备唯一编码',
+  `infusion_id` varchar(255) DEFAULT NULL COMMENT '设备当前输注id',
+  `alias` varchar(255) DEFAULT NULL COMMENT '设备别名',
+  `type` varchar(255) DEFAULT '' COMMENT '设备类型,1网络泵,2脉冲泵,3智能泵',
+  `version` varchar(255) DEFAULT NULL COMMENT ' 版本号',
+  `config` varchar(255) DEFAULT NULL COMMENT '云平台配置参数',
+  `mqtt_conn_info` varchar(500) DEFAULT NULL COMMENT '嵌入式用到的一个阿里云返回的加密串',
+  `sim_iccid` varchar(255) DEFAULT '' COMMENT 'sim卡的卡号',
+  `sim_mno` varchar(255) DEFAULT '' COMMENT '移动网络运营商',
+  `enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `description` varchar(255) DEFAULT NULL COMMENT '记录描述信息',
+  `tenant_id` varchar(255) NOT NULL COMMENT '所属医院编号',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  `status` tinyint(4) DEFAULT '0' COMMENT '设备状态,0未激活,1在线,2离线',
+  PRIMARY KEY (`id`) USING BTREE,
+  UNIQUE KEY `device_code` (`device_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备-设备信息表';
+
+/*Table structure for table `bus_device_alarm` */
+
+DROP TABLE IF EXISTS `bus_device_alarm`;
+
+CREATE TABLE `bus_device_alarm` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `device_id` varchar(255) DEFAULT '' COMMENT '设备唯一编码',
+  `upload_time` datetime(3) DEFAULT NULL COMMENT '设备数据上传时间',
+  `device_type` varchar(255) DEFAULT NULL COMMENT '设备类型',
+  `cause` varchar(255) DEFAULT NULL COMMENT '报警原因',
+  `alarm` tinyint(1) DEFAULT NULL COMMENT '报警内容',
+  `history_id` varchar(255) DEFAULT '' COMMENT '对应报警的历史记录',
+  `infusion_id` varchar(255) DEFAULT '' COMMENT '输注记录',
+  `run_state` tinyint(4) DEFAULT NULL COMMENT '设备运行状态',
+  `alarm_state` tinyint(4) DEFAULT NULL COMMENT '设备报警状态',
+  `warn_flow` tinyint(4) DEFAULT NULL COMMENT '智能泵提醒',
+  `warn_will_finished` tinyint(1) DEFAULT NULL COMMENT '输液结束提醒',
+  `warn_low_battery` tinyint(1) DEFAULT NULL COMMENT '低电量提醒',
+  `warn_analgesic_poor` tinyint(1) DEFAULT NULL COMMENT '镇痛不足提醒',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime DEFAULT NULL COMMENT '记录添加时间',
+  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `tenant_id` varchar(255) NOT NULL DEFAULT '' COMMENT '医院id',
+  PRIMARY KEY (`id`),
+  KEY `alarm_time` (`tenant_id`,`device_id`,`alarm`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备-设备报警表';
+
+/*Table structure for table `bus_device_history` */
+
+DROP TABLE IF EXISTS `bus_device_history`;
+
+CREATE TABLE `bus_device_history` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `device_id` varchar(255) NOT NULL DEFAULT '' COMMENT '设备唯一编码',
+  `patient_code` varchar(255) DEFAULT '' COMMENT '住院号(设备上传的住院号)',
+  `ward` varchar(255) DEFAULT NULL COMMENT '病区(仅记录,不展示,以临床信息为主)',
+  `bed_no` varchar(255) DEFAULT NULL COMMENT '床号(仅记录,不展示,以临床信息为主)',
+  `infusion_id` varchar(255) DEFAULT '' COMMENT '所绑定输注id',
+  `classification` varchar(255) DEFAULT NULL COMMENT '设备数据标识',
+  `data_number` int(11) DEFAULT NULL COMMENT '数据编号',
+  `infusion_modify_id` varchar(255) DEFAULT '' COMMENT '所绑定输注修改id',
+  `total_append_dose` decimal(20,2) DEFAULT NULL COMMENT '此次输注过程中此时的总追加量',
+  `total_dose` int(11) DEFAULT NULL COMMENT '总量',
+  `first_dose` int(11) DEFAULT NULL COMMENT '公共-首次量',
+  `remain_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-剩余量',
+  `input_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-已输入量',
+  `append_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-追加量',
+  `append_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-追加锁时',
+  `max_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-极限量',
+  `self_control_count` int(11) DEFAULT NULL COMMENT '公共-自控次数',
+  `self_control_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-自控锁时',
+  `pca_valid_count` int(11) DEFAULT NULL COMMENT '公共-有效次数',
+  `pca_invalid_count` int(11) DEFAULT NULL COMMENT '公共-无效次数',
+  `pca_total_count` int(11) DEFAULT NULL COMMENT '公共-总按次数',
+  `continue_dose` decimal(20,3) DEFAULT NULL COMMENT '持续-持续量',
+  `pulse_dose` int(11) DEFAULT NULL COMMENT '脉冲-脉冲量',
+  `pulse_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲锁时',
+  `pulse_first_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲首次锁时',
+  `flow_up_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-加档周期',
+  `flow_down_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-减档周期',
+  `flow_count` int(11) DEFAULT NULL COMMENT '智能-计次',
+  `flow_up_limit` decimal(20,2) DEFAULT NULL COMMENT '智能-上限',
+  `electric_quantity` int(11) DEFAULT NULL COMMENT ' 电量',
+  `flow_down_limit` decimal(20,3) DEFAULT NULL COMMENT '智能-下限',
+  `flow_adjust_rate` decimal(20,3) DEFAULT NULL COMMENT '智能-自调比例',
+  `run_state` tinyint(4) unsigned DEFAULT NULL COMMENT '镇痛泵运行状态',
+  `warn_will_finished` tinyint(1) DEFAULT NULL COMMENT '输液将结束',
+  `warn_analgesic_poor` tinyint(1) DEFAULT NULL COMMENT '镇痛不足',
+  `warn_low_battery` tinyint(1) DEFAULT NULL COMMENT '电量偏低',
+  `warn_flow` tinyint(4) DEFAULT NULL COMMENT '智能-加减档提示',
+  `alarm_cause` varchar(255) DEFAULT NULL COMMENT '报警原因',
+  `alarm` tinyint(4) DEFAULT NULL COMMENT '报警信息',
+  `upload_time` datetime(3) DEFAULT NULL COMMENT '数据上传时间',
+  `master` tinyint(1) DEFAULT '0' COMMENT '是否为主泵',
+  `type` tinyint(4) DEFAULT NULL COMMENT '泵类型',
+  `tenant_id` varchar(50) NOT NULL COMMENT '医院编码',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录更新人',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  PRIMARY KEY (`id`),
+  KEY `upload_time` (`tenant_id`,`upload_time`,`infusion_id`) USING BTREE,
+  KEY `infusion_id` (`tenant_id`,`infusion_id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=1555014379545993218 DEFAULT CHARSET=utf8mb4 COMMENT='设备-设备历史数据表';
+
+/*Table structure for table `bus_device_manual` */
+
+DROP TABLE IF EXISTS `bus_device_manual`;
+
+CREATE TABLE `bus_device_manual` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `type` tinyint(255) DEFAULT NULL COMMENT ' 设备类型(0、机械泵 1、电子脉冲泵 2、电子泵)',
+  `clinic_id` varchar(255) DEFAULT NULL COMMENT '所绑定的临床id',
+  `total_dose` int(11) DEFAULT NULL COMMENT '公共参数-总量',
+  `self_control_lock_time` int(11) DEFAULT NULL COMMENT '公共参数-自控锁时',
+  `self_control_dose` decimal(20,2) DEFAULT NULL COMMENT '公共参数-自控量',
+  `continue_dose` decimal(20,2) DEFAULT NULL COMMENT '机械泵、电子脉冲泵-持续量',
+  `first_dose` int(11) DEFAULT NULL COMMENT '电子泵、电子脉冲泵-首次量',
+  `first_lock_time` int(11) DEFAULT NULL COMMENT '电子脉冲泵-脉冲首次锁时',
+  `pulse_lock_time` int(11) DEFAULT NULL COMMENT '电子脉冲泵-脉冲锁时',
+  `pulse_dose` int(11) DEFAULT NULL COMMENT '电子脉冲泵-脉冲量',
+  `max_dose` decimal(20,2) DEFAULT NULL COMMENT '电子脉冲泵、电子泵-极限量',
+  `config` varchar(2048) DEFAULT NULL COMMENT '自定义参数配置',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime DEFAULT NULL COMMENT '记录添加时间',
+  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `tenant_id` varchar(255) NOT NULL DEFAULT '' COMMENT '医院id',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `clinic_id` (`clinic_id`,`tenant_id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备-非网络泵设备表';
+
+/*Table structure for table `bus_doc` */
+
+DROP TABLE IF EXISTS `bus_doc`;
+
+CREATE TABLE `bus_doc` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `content` text COMMENT '文档内容',
+  `type` varchar(255) NOT NULL COMMENT '文档类型(具体由前端自行定义)',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `type` (`type`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文档-帮助文档、使用文档记录表';
+
+/*Table structure for table `bus_drug` */
+
+DROP TABLE IF EXISTS `bus_drug`;
+
+CREATE TABLE `bus_drug` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `name` varchar(255) DEFAULT NULL COMMENT '药品名称',
+  `type` varchar(255) DEFAULT NULL COMMENT '药品类型(在常量中的药品类型选择)',
+  `unit` varchar(255) DEFAULT NULL COMMENT '药品单位',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `tenant_id` varchar(255) NOT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常量-药品表';
+
+/*Table structure for table `bus_evaluation` */
+
+DROP TABLE IF EXISTS `bus_evaluation`;
+
+CREATE TABLE `bus_evaluation` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `patient_code` varchar(50) DEFAULT NULL COMMENT '病号',
+  `patient_id` varchar(255) DEFAULT NULL COMMENT '病人id',
+  `clinic_id` varchar(255) DEFAULT NULL COMMENT '临床号',
+  `infusion_id` varchar(255) DEFAULT NULL COMMENT '输注id',
+  `device_id` varchar(50) DEFAULT NULL COMMENT '泵号',
+  `tenant_id` bigint(20) DEFAULT NULL COMMENT '医院id',
+  `evaluate_time` datetime(3) DEFAULT NULL COMMENT '评价时间',
+  `evaluator` varchar(255) DEFAULT NULL COMMENT '评价人',
+  `statics` int(11) DEFAULT NULL COMMENT '疼痛评分静止',
+  `activity` int(11) DEFAULT NULL COMMENT '疼痛评分活动',
+  `calm` int(11) DEFAULT NULL COMMENT '镇静评分',
+  `left_arm` int(11) DEFAULT NULL COMMENT '左上肢',
+  `left_leg` int(11) DEFAULT NULL COMMENT '左下肢',
+  `right_arm` int(11) DEFAULT NULL COMMENT '右上肢',
+  `right_leg` int(11) DEFAULT NULL COMMENT '右下肢',
+  `nausea_vomit` int(11) DEFAULT NULL COMMENT '恶心呕吐',
+  `itch` int(11) DEFAULT NULL COMMENT '瘙痒',
+  `vertigo` int(11) DEFAULT NULL COMMENT '眩晕',
+  `sore_throat` int(11) DEFAULT NULL COMMENT '咽喉疼痛',
+  `uroschesis` int(11) DEFAULT NULL COMMENT '尿潴留',
+  `breath_depression` int(11) DEFAULT NULL COMMENT '呼吸抑制',
+  `hoarseness` int(11) DEFAULT NULL COMMENT '声音嘶哑',
+  `cognition_obstacle` int(11) DEFAULT NULL COMMENT '认知障碍',
+  `other` varchar(50) DEFAULT NULL COMMENT '其他',
+  `satisfaction` int(11) DEFAULT NULL COMMENT '满意度',
+  `shrink_pressure` decimal(10,2) DEFAULT NULL COMMENT '收缩压',
+  `diastens_pressure` decimal(10,2) DEFAULT NULL COMMENT '舒张压',
+  `heart_rate` decimal(10,2) DEFAULT NULL COMMENT '心率',
+  `fetal_heart_rate` decimal(10,2) DEFAULT NULL COMMENT '胎心',
+  `breath_rate` decimal(10,2) DEFAULT NULL COMMENT '呼吸频率',
+  `blood_oxygen_saturation` decimal(10,2) DEFAULT NULL COMMENT '血氧饱和度',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录更新人',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  PRIMARY KEY (`id`) USING BTREE,
+  KEY `tenant_id` (`tenant_id`,`clinic_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评价信息记录表';
+
+/*Table structure for table `bus_formula` */
+
+DROP TABLE IF EXISTS `bus_formula`;
+
+CREATE TABLE `bus_formula` (
+  `id` varchar(255) NOT NULL COMMENT '主键id',
+  `name` varchar(255) DEFAULT NULL COMMENT '配方名称',
+  `content` varchar(2048) DEFAULT NULL COMMENT '配方内容',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `tenant_id` varchar(255) NOT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='常量-配方表';
+
+/*Table structure for table `bus_hospital` */
+
+DROP TABLE IF EXISTS `bus_hospital`;
+
+CREATE TABLE `bus_hospital` (
+  `tenant_id` bigint(255) NOT NULL COMMENT '主键id',
+  `area_code` varchar(255) DEFAULT NULL COMMENT '医院所在区域编码',
+  `address` varchar(255) DEFAULT NULL COMMENT '医院地址',
+  `name` varchar(255) DEFAULT NULL COMMENT '医院名称',
+  `telephone` varchar(255) DEFAULT NULL COMMENT '联系电话',
+  `strategy` tinyint(4) DEFAULT NULL COMMENT '与医院系统的对接策略',
+  `email` varchar(255) DEFAULT NULL COMMENT '邮箱联系地址',
+  `coordinate` varchar(255) DEFAULT NULL COMMENT '经纬度坐标',
+  `script_version` varchar(255) DEFAULT NULL COMMENT ' 医院在线脚本版本号',
+  `draft_script` json DEFAULT NULL COMMENT '与医院系统对接的脚本草稿',
+  `script_online` tinyint(1) DEFAULT NULL COMMENT '医院脚本是否在线',
+  `script` json DEFAULT NULL COMMENT '医院解析脚本',
+  `device_count` int(255) DEFAULT NULL COMMENT '医院下的设备数量',
+  `update_config` varchar(255) DEFAULT NULL COMMENT 'his数据更新配置',
+  `code` varchar(255) DEFAULT NULL COMMENT '医院唯一编码,在医院脚本中使用',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标记',
+  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`tenant_id`) USING BTREE,
+  UNIQUE KEY `name` (`name`),
+  UNIQUE KEY `code` (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院-医院信息表';
+
+/*Table structure for table `bus_hospital_config` */
+
+DROP TABLE IF EXISTS `bus_hospital_config`;
+
+CREATE TABLE `bus_hospital_config` (
+  `id` varchar(50) NOT NULL COMMENT '主键id',
+  `type` tinyint(4) DEFAULT NULL COMMENT '功能配置类型',
+  `config` text COMMENT '配置内容',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `tenant_id` varchar(50) NOT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `tenant_id` (`tenant_id`,`type`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院-医院功能配置表';
+
+/*Table structure for table `bus_hospital_log` */
+
+DROP TABLE IF EXISTS `bus_hospital_log`;
+
+CREATE TABLE `bus_hospital_log` (
+  `id` varchar(20) NOT NULL COMMENT '主键id',
+  `receive_time` datetime(3) DEFAULT NULL COMMENT '数据接收时间',
+  `type` varchar(255) DEFAULT NULL COMMENT '消息类型',
+  `msg_id` varchar(255) DEFAULT NULL COMMENT '消息唯一id',
+  `success` tinyint(1) DEFAULT NULL COMMENT '消息是否处理成功',
+  `result` text COMMENT '当消息为系统对接数据时,处理成功的处理结果',
+  `identity_code` varchar(255) DEFAULT NULL COMMENT '标识码,住院号或设备唯一标识',
+  `input` text COMMENT '输入消息',
+  `message` text COMMENT '错误消息',
+  `use_time` int(255) DEFAULT NULL COMMENT '消息处理时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `tenant_id` varchar(20) DEFAULT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院-医院下的阿里云、系统对接传输日志';
+
+/*Table structure for table `bus_infusion_history` */
+
+DROP TABLE IF EXISTS `bus_infusion_history`;
+
+CREATE TABLE `bus_infusion_history` (
+  `id` varchar(20) NOT NULL COMMENT '主键',
+  `device_id` varchar(255) DEFAULT '' COMMENT '设备唯一编码',
+  `clinic_id` varchar(255) DEFAULT '' COMMENT '所绑定的临床id',
+  `classification` varchar(255) DEFAULT NULL COMMENT '设备数据标识',
+  `data_number` int(11) DEFAULT NULL COMMENT '输注过程中的数据编号',
+  `patient_code` varchar(50) DEFAULT '' COMMENT '住院号(设备上传的住院号)',
+  `ward` varchar(255) DEFAULT '' COMMENT '病区(仅记录,不展示,以临床信息为主)',
+  `bed_no` varchar(255) DEFAULT '' COMMENT '床号(仅记录,不展示,以临床信息为主)',
+  `total_dose` int(11) DEFAULT NULL COMMENT '总量',
+  `total_append_dose` decimal(20,2) DEFAULT NULL COMMENT '此次输注过程中此时的总追加量',
+  `first_dose` int(11) DEFAULT NULL COMMENT '公共-首次量',
+  `patient_id` varchar(255) DEFAULT NULL COMMENT '病人在此系统中的id',
+  `remain_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-剩余量',
+  `input_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-已输入量',
+  `append_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-追加量',
+  `append_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-追加锁时',
+  `max_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-极限量',
+  `self_control_count` int(11) DEFAULT NULL COMMENT '公共-自控次数',
+  `self_control_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-自控锁时',
+  `pca_valid_count` int(11) DEFAULT NULL COMMENT '公共-有效次数',
+  `pca_invalid_count` int(11) DEFAULT NULL COMMENT '公共-无效次数',
+  `pca_total_count` int(11) DEFAULT NULL COMMENT '公共-总按次数',
+  `continue_dose` decimal(20,3) DEFAULT NULL COMMENT '持续-持续量',
+  `pulse_dose` int(11) DEFAULT NULL COMMENT '脉冲-脉冲量',
+  `pulse_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲锁时',
+  `pulse_first_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲首次锁时',
+  `flow_up_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-加档周期',
+  `flow_down_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-减档周期',
+  `flow_count` int(11) DEFAULT NULL COMMENT '智能-计次',
+  `flow_up_limit` decimal(20,3) DEFAULT NULL COMMENT '智能-上限',
+  `flow_down_limit` decimal(20,3) DEFAULT NULL COMMENT '智能-下限',
+  `flow_adjust_rate` decimal(20,3) DEFAULT NULL COMMENT '智能-自调比例',
+  `flow_restricted` tinyint(1) DEFAULT NULL COMMENT '智能-输注过程中是否出现过加档受限',
+  `warn_flow` tinyint(4) unsigned DEFAULT NULL COMMENT '智能-加减档提示',
+  `electric_quantity` int(11) DEFAULT NULL COMMENT '电量',
+  `run_state` tinyint(4) unsigned DEFAULT NULL COMMENT '镇痛泵运行状态',
+  `warn_will_finished` tinyint(1) unsigned zerofill DEFAULT NULL COMMENT '输液将结束',
+  `warn_analgesic_poor` tinyint(1) unsigned zerofill DEFAULT NULL COMMENT '镇痛不足',
+  `warn_low_battery` tinyint(1) unsigned zerofill DEFAULT NULL COMMENT '电量偏低',
+  `alarm` tinyint(4) DEFAULT NULL COMMENT '报警信息',
+  `start_time` datetime(3) NOT NULL COMMENT '开始时间',
+  `remark` varchar(200) DEFAULT NULL COMMENT '备注',
+  `last_upload_time` datetime(3) NOT NULL COMMENT '一次输注最后上传时间',
+  `is_undo` tinyint(1) DEFAULT '0' COMMENT '是否已撤泵',
+  `undo_by` varchar(255) DEFAULT NULL COMMENT '撤泵人',
+  `destroyer` varchar(255) DEFAULT NULL COMMENT '销毁人',
+  `witnesses` varchar(255) DEFAULT NULL COMMENT '见证人',
+  `undo_time` datetime(3) DEFAULT NULL COMMENT '撤泵时间',
+  `clinic_start_time` datetime(3) DEFAULT NULL COMMENT '临床手术的开始时间',
+  `anal_poor_msg_id` varchar(255) DEFAULT NULL COMMENT '当引起镇痛不足时,从阿里云接收到的消息id',
+  `finished` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0' COMMENT '输注是否已结束 0、未结束 1、已结束',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '记录更新人',
+  `type` tinyint(4) DEFAULT NULL COMMENT '设备类型',
+  `tenant_id` varchar(50) NOT NULL COMMENT '医院编码',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  PRIMARY KEY (`id`),
+  KEY `tenant_id` (`tenant_id`,`clinic_id`),
+  KEY `device_id` (`tenant_id`,`start_time`,`device_id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='输注-输注历史记录表';
+
+/*Table structure for table `bus_infusion_modify` */
+
+DROP TABLE IF EXISTS `bus_infusion_modify`;
+
+CREATE TABLE `bus_infusion_modify` (
+  `id` varchar(50) NOT NULL COMMENT '主键',
+  `device_id` varchar(255) DEFAULT '' COMMENT '设备唯一编码',
+  `type` tinyint(4) DEFAULT '1' COMMENT '设备类型',
+  `data_number` int(11) DEFAULT NULL COMMENT '输注过程中的数据编号',
+  `classification` varchar(255) DEFAULT NULL COMMENT '设备数据标识',
+  `infusion_id` varchar(255) DEFAULT NULL COMMENT '输注id',
+  `total_dose` int(11) DEFAULT NULL COMMENT '总量',
+  `first_dose` int(11) DEFAULT NULL COMMENT '公共-首次量',
+  `remain_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-剩余量',
+  `input_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-已输入量',
+  `append_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-追加量',
+  `append_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-追加锁时',
+  `max_dose` decimal(20,3) DEFAULT NULL COMMENT '公共-极限量',
+  `self_control_count` int(11) DEFAULT NULL COMMENT '公共-自控次数',
+  `self_control_lock_time` decimal(20,3) DEFAULT NULL COMMENT '公共-自控锁时',
+  `pca_valid_count` int(11) DEFAULT NULL COMMENT '公共-有效次数',
+  `pca_invalid_count` int(11) DEFAULT NULL COMMENT '公共-无效次数',
+  `electric_quantity` int(11) DEFAULT NULL COMMENT '公共-电量',
+  `pca_total_count` int(11) DEFAULT NULL COMMENT '公共-总按次数',
+  `continue_dose` decimal(20,3) DEFAULT NULL COMMENT '持续-持续量',
+  `pulse_dose` int(11) DEFAULT NULL COMMENT '脉冲-脉冲量',
+  `pulse_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲锁时',
+  `pulse_first_lock_time` int(11) DEFAULT NULL COMMENT '脉冲-脉冲首次锁时',
+  `flow_up_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-加档周期',
+  `flow_down_cycle` decimal(20,3) DEFAULT NULL COMMENT '智能-减档周期',
+  `flow_count` int(11) DEFAULT NULL COMMENT '智能-计次',
+  `flow_up_limit` decimal(20,3) DEFAULT NULL COMMENT '智能-上限',
+  `flow_down_limit` decimal(20,3) DEFAULT NULL COMMENT '智能-下限',
+  `flow_adjust_rate` decimal(20,3) DEFAULT NULL COMMENT '智能-自调比例',
+  `modify_time` datetime(3) DEFAULT NULL COMMENT '参数修改时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime DEFAULT NULL COMMENT '记录修改时间',
+  `create_time` datetime DEFAULT NULL COMMENT '记录添加时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录修改人',
+  `tenant_id` varchar(255) DEFAULT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='输注-输注参数修改记录';
+
+/*Table structure for table `bus_patient` */
+
+DROP TABLE IF EXISTS `bus_patient`;
+
+CREATE TABLE `bus_patient` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT,
+  `origin_code` varchar(255) DEFAULT NULL COMMENT '设备上传住院号',
+  `name` varchar(255) DEFAULT NULL,
+  `gender` varchar(255) DEFAULT NULL,
+  `code` varchar(255) DEFAULT NULL COMMENT '格式化后的住院号(即向用户展示的住院号)',
+  `alarm` tinyint(4) DEFAULT NULL COMMENT '病人报警(无泵、泵重复)',
+  `infusion_id` varchar(255) DEFAULT NULL COMMENT '病人当前对应的输注id',
+  `clinic_id` varchar(255) DEFAULT NULL COMMENT ' 病人当前手术id',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录修改时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录修改人',
+  `is_delete` tinyint(1) DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)',
+  `tenant_id` varchar(50) DEFAULT NULL COMMENT '医院id',
+  PRIMARY KEY (`id`) USING BTREE,
+  UNIQUE KEY `code` (`tenant_id`,`code`) USING BTREE,
+  KEY `tenant_id` (`tenant_id`,`clinic_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=1554747099112861699 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='病人表-仅记录使用网络泵的病人';
+
+/*Table structure for table `sys_apply` */
+
+DROP TABLE IF EXISTS `sys_apply`;
+
+CREATE TABLE `sys_apply` (
+  `id` varchar(255) NOT NULL,
+  `app_key` varchar(255) DEFAULT NULL,
+  `app_secret` varchar(255) DEFAULT NULL,
+  `name` varchar(255) DEFAULT NULL,
+  `tenant_id` varchar(255) DEFAULT NULL,
+  `remark` varchar(255) DEFAULT NULL,
+  `create_by` varchar(255) DEFAULT NULL,
+  `create_time` datetime(3) DEFAULT NULL,
+  `update_by` varchar(255) DEFAULT NULL,
+  `update_time` datetime(3) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `app_key` (`app_key`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+/*Table structure for table `sys_apply_menu` */
+
+DROP TABLE IF EXISTS `sys_apply_menu`;
+
+CREATE TABLE `sys_apply_menu` (
+  `id` varchar(255) NOT NULL COMMENT '主键',
+  `app_key` varchar(255) DEFAULT NULL COMMENT '第三方应用id',
+  `menu_id` varchar(255) DEFAULT NULL COMMENT '菜单ID',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色菜单表';
+
+/*Table structure for table `sys_area` */
+
+DROP TABLE IF EXISTS `sys_area`;
+
+CREATE TABLE `sys_area` (
+  `area_code` varchar(128) NOT NULL COMMENT '区域编码',
+  `area_name` varchar(128) DEFAULT NULL COMMENT '区域名称',
+  `area_type` varchar(128) DEFAULT NULL COMMENT '区域类型 1省市/直辖市;2地市;3区县',
+  `parent_code` varchar(128) DEFAULT NULL COMMENT '父编码',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`area_code`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='行政区域';
+
+/*Table structure for table `sys_config` */
+
+DROP TABLE IF EXISTS `sys_config`;
+
+CREATE TABLE `sys_config` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `config_name` varchar(128) DEFAULT NULL COMMENT '参数名称',
+  `config_key` varchar(128) DEFAULT NULL COMMENT '参数键名',
+  `config_value` varchar(512) DEFAULT NULL COMMENT '参数键值',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统参数';
+
+/*Table structure for table `sys_dept` */
+
+DROP TABLE IF EXISTS `sys_dept`;
+
+CREATE TABLE `sys_dept` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `parent_id` bigint(20) DEFAULT NULL COMMENT '父部门ID',
+  `dept_name` varchar(32) DEFAULT NULL COMMENT '部门名称',
+  `dept_fullname` varchar(128) DEFAULT NULL COMMENT '部门全名',
+  `ancestors` varchar(1024) DEFAULT NULL COMMENT '祖级列表',
+  `org_type` varchar(1) DEFAULT NULL COMMENT '机构类型 1公司;2部门;3小组;4其他',
+  `leader` varchar(32) DEFAULT NULL COMMENT '负责人',
+  `leader_phone` varchar(32) DEFAULT NULL COMMENT '负责人电话',
+  `phone` varchar(32) DEFAULT NULL COMMENT '办公电话',
+  `email` varchar(128) DEFAULT NULL COMMENT '邮箱',
+  `post_code` varchar(32) DEFAULT NULL COMMENT '邮政编码',
+  `address` varchar(512) DEFAULT NULL COMMENT '联系地址',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `tenant_id` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部门表';
+
+/*Table structure for table `sys_dict` */
+
+DROP TABLE IF EXISTS `sys_dict`;
+
+CREATE TABLE `sys_dict` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `dict_code` varchar(128) DEFAULT NULL COMMENT '字典编码',
+  `dict_name` varchar(128) DEFAULT NULL COMMENT '字典名称',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典表';
+
+/*Table structure for table `sys_dict_item` */
+
+DROP TABLE IF EXISTS `sys_dict_item`;
+
+CREATE TABLE `sys_dict_item` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `dict_id` bigint(20) DEFAULT NULL COMMENT '字典ID',
+  `dict_item_code` varchar(128) DEFAULT NULL COMMENT '字典项编码',
+  `dict_item_name` varchar(128) DEFAULT NULL COMMENT '字典项名称',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字典项';
+
+/*Table structure for table `sys_log` */
+
+DROP TABLE IF EXISTS `sys_log`;
+
+CREATE TABLE `sys_log` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `title` varchar(128) DEFAULT NULL COMMENT '标题',
+  `log_status` varchar(1) DEFAULT NULL COMMENT '日志状态 0成功;1失败',
+  `user_platform` varchar(32) DEFAULT NULL COMMENT '用户平台 WEB:WEB管理后台;APP:前端用户平台',
+  `requset_uri` varchar(128) DEFAULT NULL COMMENT '请求地址',
+  `requset_type` varchar(128) DEFAULT NULL COMMENT '请求方式',
+  `requset_method` varchar(128) DEFAULT NULL COMMENT '请求方法',
+  `requset_params` text COMMENT '请求参数',
+  `response_result` text COMMENT '返回参数',
+  `requset_time` varchar(128) DEFAULT NULL COMMENT '请求耗时',
+  `exception` text COMMENT '异常信息',
+  `oper_name` varchar(128) DEFAULT NULL COMMENT '操作人员',
+  `ip_address` varchar(128) DEFAULT NULL COMMENT 'IP地址',
+  `oper_location` varchar(128) DEFAULT NULL COMMENT '操作地点',
+  `browser` varchar(128) DEFAULT NULL COMMENT '浏览器类型',
+  `os` varchar(128) DEFAULT NULL COMMENT '操作系统',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `create_by` varchar(255) DEFAULT NULL,
+  `update_by` varchar(255) DEFAULT NULL,
+  `tenant_id` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日志表';
+
+/*Table structure for table `sys_menu` */
+
+DROP TABLE IF EXISTS `sys_menu`;
+
+CREATE TABLE `sys_menu` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `menu_type` varchar(32) DEFAULT NULL COMMENT '菜单类型 dir目录;menu菜单;button按钮',
+  `menu_name` varchar(128) DEFAULT NULL COMMENT '菜单名称',
+  `parent_id` bigint(20) DEFAULT NULL COMMENT '上级菜单',
+  `route_path` varchar(512) DEFAULT NULL COMMENT '路由地址',
+  `component` varchar(512) DEFAULT NULL COMMENT '组件路径',
+  `permission` varchar(128) DEFAULT NULL COMMENT '权限标识',
+  `icon` varchar(128) DEFAULT NULL COMMENT '图标',
+  `keepalive` varchar(1) DEFAULT NULL COMMENT '是否缓存 0缓存;1不缓存',
+  `link_external` varchar(1) DEFAULT NULL COMMENT '是否外链 0是;1否',
+  `visible` varchar(1) DEFAULT NULL COMMENT '是否显示 0显示;1隐藏',
+  `frame` varchar(1) DEFAULT NULL COMMENT '是否内嵌 0内嵌;1不内嵌',
+  `link_url` varchar(512) DEFAULT NULL COMMENT '外部链接',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `tenant_menu` tinyint(1) unsigned zerofill NOT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
+
+/*Table structure for table `sys_post` */
+
+DROP TABLE IF EXISTS `sys_post`;
+
+CREATE TABLE `sys_post` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `post_code` varchar(128) DEFAULT NULL COMMENT '岗位编码',
+  `post_name` varchar(128) DEFAULT NULL COMMENT '岗位名称',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `status` tinyint(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `tenant_id` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='岗位表';
+
+/*Table structure for table `sys_role` */
+
+DROP TABLE IF EXISTS `sys_role`;
+
+CREATE TABLE `sys_role` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `role_code` varchar(128) DEFAULT NULL COMMENT '角色编码',
+  `role_name` varchar(128) DEFAULT NULL COMMENT '角色名称',
+  `data_scope` varchar(1) DEFAULT NULL COMMENT '数据范围 1全部数据权限;2自定义数据权限;3本部门数据权限;4本部门及以下数据权限',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `tenant_id` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
+
+/*Table structure for table `sys_role_dept` */
+
+DROP TABLE IF EXISTS `sys_role_dept`;
+
+CREATE TABLE `sys_role_dept` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
+  `dept_id` bigint(20) DEFAULT NULL COMMENT '部门ID',
+  `tenant_id` varchar(255) DEFAULT NULL,
+  `create_time` datetime(3) DEFAULT NULL,
+  `create_by` varchar(255) DEFAULT NULL,
+  `update_time` datetime(3) DEFAULT NULL,
+  `update_by` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色部门表';
+
+/*Table structure for table `sys_role_menu` */
+
+DROP TABLE IF EXISTS `sys_role_menu`;
+
+CREATE TABLE `sys_role_menu` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `role_id` bigint(20) DEFAULT NULL COMMENT '角色ID',
+  `menu_id` bigint(20) DEFAULT NULL COMMENT '菜单ID',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色菜单表';
+
+/*Table structure for table `sys_running_log` */
+
+DROP TABLE IF EXISTS `sys_running_log`;
+
+CREATE TABLE `sys_running_log` (
+  `id` varchar(255) NOT NULL,
+  `name` varchar(255) DEFAULT NULL COMMENT '日志名称',
+  `thread_name` varchar(255) DEFAULT NULL COMMENT '线程名称',
+  `level` varchar(255) DEFAULT NULL COMMENT '日志级别',
+  `class_name` varchar(255) DEFAULT NULL COMMENT '类名',
+  `method_name` varchar(255) DEFAULT NULL COMMENT '方法名',
+  `line_number` int(11) DEFAULT NULL COMMENT '行号',
+  `message` text COMMENT '日志内容',
+  `exception_stack` text COMMENT '异常栈',
+  `thread_id` varchar(255) DEFAULT NULL COMMENT '线程id',
+  `create_time` datetime DEFAULT NULL,
+  `create_by` varchar(255) DEFAULT NULL,
+  `update_by` varchar(255) DEFAULT NULL,
+  `update_time` datetime DEFAULT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+/*Table structure for table `sys_storage` */
+
+DROP TABLE IF EXISTS `sys_storage`;
+
+CREATE TABLE `sys_storage` (
+  `id` varchar(32) NOT NULL,
+  `real_name` varchar(255) DEFAULT NULL COMMENT '文件真实的名称',
+  `name` varchar(255) DEFAULT NULL COMMENT '文件名',
+  `url_prefix` varchar(255) DEFAULT NULL COMMENT 'url前缀名称',
+  `suffix` varchar(255) DEFAULT NULL COMMENT '后缀',
+  `url` varchar(255) DEFAULT NULL COMMENT '路径',
+  `type` varchar(255) DEFAULT NULL COMMENT '类型',
+  `size` varchar(100) DEFAULT NULL COMMENT '大小',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '创建者',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '更新者',
+  `create_time` datetime DEFAULT NULL COMMENT '创建日期',
+  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='文件存储';
+
+/*Table structure for table `sys_user` */
+
+DROP TABLE IF EXISTS `sys_user`;
+
+CREATE TABLE `sys_user` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `account` varchar(128) NOT NULL COMMENT '账号',
+  `password` varchar(128) NOT NULL COMMENT '密码',
+  `psw_modified` varchar(1) DEFAULT NULL COMMENT '修改密码标记 0未修改;1已修改',
+  `nickname` varchar(128) DEFAULT NULL COMMENT '昵称',
+  `realname` varchar(128) DEFAULT NULL COMMENT '姓名',
+  `english_name` varchar(128) DEFAULT NULL COMMENT '英文名',
+  `avatar` varchar(128) DEFAULT NULL COMMENT '头像',
+  `email` varchar(128) DEFAULT NULL COMMENT '邮箱',
+  `phone` varchar(32) DEFAULT NULL COMMENT '手机号',
+  `staff_number` varchar(32) DEFAULT NULL COMMENT '工号',
+  `birthday` datetime(3) DEFAULT NULL COMMENT '生日',
+  `sex` varchar(1) DEFAULT NULL COMMENT '性别 1男;2女;3未知',
+  `dept_id` varchar(32) DEFAULT NULL COMMENT '部门ID',
+  `lock_flag` varchar(1) DEFAULT NULL COMMENT '锁定标记 0正常;1锁定',
+  `sort` int(11) DEFAULT NULL COMMENT '排序',
+  `remarks` varchar(512) DEFAULT NULL COMMENT '备注',
+  `status` varchar(1) DEFAULT '0' COMMENT '状态 0正常;1停用',
+  `del_flag` varchar(1) DEFAULT '0' COMMENT '删除标记 0存在;1删除',
+  `create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
+  `is_sys` int(1) DEFAULT NULL,
+  `tenant_id` varchar(255) NOT NULL,
+  PRIMARY KEY (`id`) USING BTREE,
+  UNIQUE KEY `tenant_id` (`account`,`create_time`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
+
+/*Table structure for table `sys_user_post` */
+
+DROP TABLE IF EXISTS `sys_user_post`;
+
+CREATE TABLE `sys_user_post` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `user_id` bigint(20) DEFAULT NULL COMMENT '用户ID',
+  `post_id` bigint(20) DEFAULT NULL COMMENT '岗位ID',
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户岗位表';
+
+/*Table structure for table `sys_user_role` */
+
+DROP TABLE IF EXISTS `sys_user_role`;
+
+CREATE TABLE `sys_user_role` (
+  `id` bigint(20) NOT NULL COMMENT '主键',
+  `user_id` bigint(20) DEFAULT NULL COMMENT '用户编号',
+  `role_id` bigint(20) DEFAULT NULL COMMENT '角色编号',
+  `tenant_id` varchar(255) DEFAULT NULL,
+  `create_time` datetime(3) DEFAULT NULL,
+  `create_by` varchar(255) DEFAULT NULL,
+  `update_time` datetime(3) DEFAULT NULL,
+  `update_by` varchar(255) DEFAULT NULL,
+  PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色表';
+
+/*Table structure for table `sys_version` */
+
+DROP TABLE IF EXISTS `sys_version`;
+
+CREATE TABLE `sys_version` (
+  `id` varchar(32) NOT NULL COMMENT '主键id',
+  `type` varchar(255) DEFAULT NULL COMMENT '安装包类型,即安卓、平板',
+  `name` varchar(255) DEFAULT NULL COMMENT '安装包名称',
+  `apk_md5` varchar(255) DEFAULT NULL,
+  `apk_size` varchar(255) DEFAULT NULL,
+  `storage_id` varchar(255) DEFAULT NULL COMMENT '存储id',
+  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
+  `url` varchar(255) DEFAULT NULL COMMENT '文件路径',
+  `version_name` varchar(255) DEFAULT NULL COMMENT '版本名称',
+  `version` varchar(255) DEFAULT NULL COMMENT '版本号',
+  `create_time` datetime(3) DEFAULT NULL COMMENT '记录添加时间',
+  `create_by` varchar(255) DEFAULT NULL COMMENT '记录添加人',
+  `update_time` datetime(3) DEFAULT NULL COMMENT '记录更新时间',
+  `update_by` varchar(255) DEFAULT NULL COMMENT '记录更新人',
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='app升级包记录表';
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

文件差異過大導致無法顯示
+ 38 - 0
doc/db/insert.sql


+ 0 - 1
doc/db/schema.sql

@@ -1 +0,0 @@
-CREATE DATABASE `coffee-dev` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';

+ 0 - 59
doc/db/update.sql

@@ -1,59 +0,0 @@
-UPDATE sys_area
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_config
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_dept
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_dict
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_dict_item
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_log
-SET create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_menu
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_post
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_role
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-UPDATE sys_user
-SET create_by = '1',
-    update_by = '1',
-    create_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' ),
-    update_time = STR_TO_DATE( '2022-01-01 00:00:00', '%Y-%m-%d %H:%i:%s' );
-
-DELETE FROM sys_log;

+ 3 - 3
nb-admin/Dockerfile

@@ -1,13 +1,13 @@
 FROM docker.io/java:8
 
-ADD target/nb-admin.jar /pump.jar
+ADD target/nb-admin-1.0.jar /nb.jar
 ADD src/main/resources/python/jython-standalone-2.7.1.jar /jython-standalone-2.7.1.jar
-RUN bash -c "touch /pump.jar"
+RUN bash -c "touch /nb.jar"
 RUN echo "Asia/shanghai" > /etc/timezone
 ENV LANG C.UTF-8
 ENV LANGUAGE zh_CN.UTF-8
 ENV LC_ALL C.UTF-8
 ENV TZ Asia/Shanghai
 
-ENTRYPOINT ["java", "-jar", "/pump.jar"]
+ENTRYPOINT ["java", "-jar", "/nb.jar"]
 EXPOSE 9090

+ 150 - 27
nb-admin/pom.xml

@@ -12,11 +12,22 @@
     <artifactId>nb-admin</artifactId>
 
     <dependencies>
-        <!-- 核心模块 -->
+
+        <dependency>
+            <groupId>com.tuoren</groupId>
+            <artifactId>config-common</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.tuoren</groupId>
-            <artifactId>nb-framework</artifactId>
+            <artifactId>web-service</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+
         <!-- OSS文件存储模块 -->
         <dependency>
             <groupId>com.tuoren</groupId>
@@ -28,45 +39,157 @@
             <artifactId>spring-boot-starter-test</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.tuoren</groupId>
+            <artifactId>iot-service</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-tomcat</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+        </dependency>
     </dependencies>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-maven-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
 
     <!--<build>-->
+        <!--<resources>-->
+            <!--<resource>-->
+                <!--<directory>src/main/resources</directory>-->
+                <!--<includes>-->
+                    <!--&lt;!&ndash; **/* &ndash;&gt;-->
+                    <!--<include>**/*.xml</include>-->
+                    <!--<include>**/*.yml</include>-->
+                <!--</includes>-->
+                <!--<filtering>true</filtering>-->
+            <!--</resource>-->
+        <!--</resources>-->
         <!--<plugins>-->
-            <!--<plugin>-->
-                <!--<groupId>org.springframework.boot</groupId>-->
-                <!--<artifactId>spring-boot-maven-plugin</artifactId>-->
-                <!--<configuration>-->
-                    <!--<mainClass>com.coffee.admin.AdminApplication</mainClass>-->
-                <!--</configuration>-->
-                <!--<executions>-->
-                    <!--<execution>-->
-                        <!--<goals>-->
-                            <!--<goal>repackage</goal>-->
-                        <!--</goals>-->
-                    <!--</execution>-->
-                <!--</executions>-->
-            <!--</plugin>-->
-            <!--&lt;!&ndash; 跳过单元测试 &ndash;&gt;-->
             <!--<plugin>-->
                 <!--<groupId>org.apache.maven.plugins</groupId>-->
-                <!--<artifactId>maven-surefire-plugin</artifactId>-->
+                <!--<artifactId>maven-compiler-plugin</artifactId>-->
+                <!--<version>3.6.2</version>-->
                 <!--<configuration>-->
-                    <!--<skipTests>true</skipTests>-->
+                    <!--<source>${maven.compile.source}</source>-->
+                    <!--<target>${maven.compile.target}</target>-->
+                    <!--<encoding>${project.build.sourceEncoding}</encoding>-->
                 <!--</configuration>-->
             <!--</plugin>-->
+
+            <!--&lt;!&ndash;<plugin>&ndash;&gt;-->
+                <!--&lt;!&ndash;<artifactId>maven-assembly-plugin</artifactId>&ndash;&gt;-->
+                <!--&lt;!&ndash;<configuration>&ndash;&gt;-->
+                    <!--&lt;!&ndash;<archive>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<manifest>&ndash;&gt;-->
+                            <!--&lt;!&ndash;<mainClass>com.nb.admin.AdminApplication</mainClass>&ndash;&gt;-->
+                        <!--&lt;!&ndash;</manifest>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<manifestEntries>&ndash;&gt;-->
+                            <!--&lt;!&ndash;<Class-Path>.</Class-Path>&ndash;&gt;-->
+                        <!--&lt;!&ndash;</manifestEntries>&ndash;&gt;-->
+                    <!--&lt;!&ndash;</archive>&ndash;&gt;-->
+                <!--&lt;!&ndash;</configuration>&ndash;&gt;-->
+                <!--&lt;!&ndash;<executions>&ndash;&gt;-->
+                    <!--&lt;!&ndash;<execution>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<id>make-assembly</id>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<phase>package</phase>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<goals>&ndash;&gt;-->
+                            <!--&lt;!&ndash;<goal>single</goal>&ndash;&gt;-->
+                        <!--&lt;!&ndash;</goals>&ndash;&gt;-->
+                        <!--&lt;!&ndash;<configuration>&ndash;&gt;-->
+                            <!--&lt;!&ndash;<descriptors>&ndash;&gt;-->
+                                <!--&lt;!&ndash;<descriptor>src/main/resources/assembly.xml</descriptor>&ndash;&gt;-->
+                            <!--&lt;!&ndash;</descriptors>&ndash;&gt;-->
+                        <!--&lt;!&ndash;</configuration>&ndash;&gt;-->
+                    <!--&lt;!&ndash;</execution>&ndash;&gt;-->
+                <!--&lt;!&ndash;</executions>&ndash;&gt;-->
+            <!--&lt;!&ndash;</plugin>&ndash;&gt;-->
         <!--</plugins>-->
     <!--</build>-->
+
+    <build>
+        <finalName>${project.name}</finalName>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
+        <!--<pluginManagement>-->
+            <plugins>
+                <plugin>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-maven-plugin</artifactId>
+                    <version>${spring-boot.version}</version>
+                    <configuration>
+                        <mainClass>com.nb.admin.AdminApplication</mainClass>
+                        <finalName>${project.build.finalName}</finalName>
+                        <layers>
+                            <enabled>true</enabled>
+                        </layers>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>repackage</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        <!--</pluginManagement>-->
+    </build>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <properties>
+                <!-- 环境标识,需要与配置文件的名称相对应 -->
+                <profiles.active>dev</profiles.active>
+                <logging.level>debug</logging.level>
+            </properties>
+            <activation>
+                <!-- 默认环境 -->
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+        <profile>
+            <id>test</id>
+            <properties>
+                <profiles.active>test</profiles.active>
+                <logging.level>warn</logging.level>
+            </properties>
+        </profile>
+        <profile>
+            <id>prod</id>
+            <properties>
+                <profiles.active>prod</profiles.active>
+                <logging.level>warn</logging.level>
+            </properties>
+        </profile>
+    </profiles>
 </project>

+ 15 - 7
nb-admin/src/main/java/com/nb/admin/AdminApplication.java

@@ -1,10 +1,12 @@
 package com.nb.admin;
 
+import com.nb.common.config.properties.DruidProperties;
 import com.nb.common.config.web.RequestCheckProperties;
-import com.nb.common.config.AppConfig;
+import org.mybatis.spring.annotation.MapperScan;
+import org.redisson.spring.starter.RedissonAutoConfiguration;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.boot.web.servlet.ServletComponentScan;
 import org.springframework.context.annotation.Import;
@@ -12,23 +14,29 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.tio.websocket.starter.EnableTioWebSocketServer;
 
+
 /**
  * Admin启动类
  *
  * @author Kevin
  */
-@SpringBootApplication(scanBasePackages ={"com.nb","springfox.documentation.schema"}, exclude = {DataSourceAutoConfiguration.class})
+@SpringBootApplication(scanBasePackages ={
+        "com.nb.aliyun",
+        "com.nb.web",
+        "com.nb.auth",
+        "com.nb.admin",
+        "springfox.documentation.schema"},
+exclude = {RedisAutoConfiguration.class,RedissonAutoConfiguration.class})
 @Import(cn.hutool.extra.spring.SpringUtil.class)
 @EnableTioWebSocketServer
 @EnableScheduling
 @EnableAsync
-@EnableConfigurationProperties(RequestCheckProperties.class)
+@MapperScan({"com.nb.**.mapper"})
+@EnableConfigurationProperties({RequestCheckProperties.class, DruidProperties.class})
 @ServletComponentScan(basePackages = "com.nb.common.config")
 public class AdminApplication {
 
-    public static void main(String[] args) {
-        SpringApplication.run(AdminApplication.class, args);
-        System.out.println(String.format("============ %s API 启动成功 ============", AppConfig.getName().toUpperCase()));
+    public static void main(String[] args) { SpringApplication.run(AdminApplication.class, args);
     }
 
 }

+ 13 - 4
nb-admin/src/main/java/com/nb/admin/StartUpRunner.java

@@ -1,8 +1,11 @@
 package com.nb.admin;
 
-import com.nb.system.service.ISysConfigService;
-import com.nb.system.service.ISysDictService;
+import com.nb.web.service.system.service.ISysConfigService;
+import com.nb.web.service.system.service.ISysDictService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.web.context.WebServerInitializedEvent;
+import org.springframework.context.ApplicationListener;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
@@ -13,7 +16,8 @@ import javax.annotation.Resource;
  * @author Kevin
  */
 @Component
-public class StartUpRunner implements CommandLineRunner {
+@Slf4j
+public class StartUpRunner implements CommandLineRunner , ApplicationListener<WebServerInitializedEvent> {
 
     @Resource
     ISysDictService sysDictService;
@@ -23,9 +27,14 @@ public class StartUpRunner implements CommandLineRunner {
 
     @Override
     public void run(String... args) {
-        System.out.println("============ 服务器启动中....,开始加载数据 ============");
+        log.info("============  web is running ,start load data============");
         sysDictService.loadAllDictCache();
         sysConfigService.loadAllConfig();
     }
 
+
+    @Override
+    public void onApplicationEvent(WebServerInitializedEvent event) {
+        log.info("web start success ,port:【{}】",event.getWebServer().getPort());
+    }
 }

+ 0 - 99
nb-admin/src/main/java/com/nb/admin/controller/common/CommonController.java

@@ -1,99 +0,0 @@
-package com.nb.admin.controller.common;
-
-import cn.hutool.core.io.FileUtil;
-import com.nb.core.exception.CustomException;
-import com.nb.core.result.R;
-import com.nb.core.result.ResultCode;
-import com.nb.oss.strategy.FileStorageStrategy;
-import com.nb.oss.strategy.context.FileStorageContext;
-import com.nb.oss.strategy.storage.SysStorage;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.SneakyThrows;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.Objects;
-
-
-/**
- * <p>
- * 通用common 前端控制器
- * </p>
- *
- * @author Kevin
- */
-@RestController
-@RequestMapping("/common")
-@Slf4j
-@Api(tags = "通用控制器,用于文件的上传和下载",description = "关于病人的相关操作,查询操作权限【bus:patient:query】")
-public class CommonController {
-
-    @Resource
-    private FileStorageContext fileStorageContext;
-
-    /**
-     * 下载文件名重新编码
-     *
-     * @param response     响应对象
-     * @param realFileName 真实文件名
-     * @return
-     */
-    public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
-        String percentEncodedFileName = percentEncode(realFileName);
-        StringBuilder contentDispositionValue = new StringBuilder();
-        contentDispositionValue.append("attachment; filename=")
-                .append(percentEncodedFileName)
-                .append(";")
-                .append("filename*=")
-                .append("utf-8''")
-                .append(percentEncodedFileName);
-        response.setHeader("Content-disposition", contentDispositionValue.toString());
-    }
-
-    /**
-     * 百分号编码工具方法
-     *
-     * @param s 需要百分号编码的字符串
-     * @return 百分号编码后的字符串
-     */
-    public static String percentEncode(String s) throws UnsupportedEncodingException {
-        String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
-        return encode.replaceAll("\\+", "%20");
-    }
-
-    @PostMapping("/upload")
-    @SneakyThrows
-    @ApiOperation("文件上传")
-    public R<SysStorage> upload(@RequestParam("file") MultipartFile file) {
-//        if (StrUtil.isBlank(bizPath)) {
-//            throw new CustomException(ResultCode.PARAM_TYPE_ERROR.getMessage());
-//        }
-        if (Objects.isNull(file)) {
-            throw new CustomException(ResultCode.PARAM_TYPE_ERROR.getMessage());
-        }
-        FileStorageStrategy fileStorageStrategy = fileStorageContext.getContext();
-        SysStorage storage = fileStorageStrategy.upload(file, String.valueOf(System.currentTimeMillis()));
-        return R.success(storage);
-    }
-
-
-    @GetMapping("/download")
-    @SneakyThrows
-    @ApiOperation("文件下载")
-    public void download(@RequestParam String filepath, HttpServletResponse response) {
-        response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
-        // 文件名称转换,用户列表_uuid.xlsx -> 用户列表_1637469159968.xlsx
-        setAttachmentResponseHeader(response, FileUtil.getName(filepath));
-        FileUtil.writeToStream(FileUtil.file(URI.create(filepath)),response.getOutputStream());
-    }
-
-}

+ 3 - 3
nb-admin/src/main/java/com/nb/admin/controller/monitor/OnlineUserController.java

@@ -6,9 +6,9 @@ import cn.hutool.core.text.CharSequenceUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.nb.auth.bean.LoginUser;
-import com.nb.common.Constants;
+import com.nb.auth.utils.SecurityUtil;
 import com.nb.core.annotation.Log;
-import com.nb.common.redis.RedisUtils;
+import com.nb.common.config.redis.RedisUtils;
 import com.nb.core.result.R;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.Api;
@@ -45,7 +45,7 @@ public class OnlineUserController {
         for (String key : keys) {
             // token sample, Authorization:login:token:8734da0866f4440daeea3d836d5ecf8c
             String tokenValue = CharSequenceUtil.subAfter(key, StpUtil.getTokenName() + ":" + StpUtil.TYPE + ":token:", true);
-            LoginUser item = (LoginUser) StpUtil.getTokenSessionByToken(tokenValue).get(Constants.LOGIN_USER_KEY);
+            LoginUser item =   SecurityUtil.getLoginUser(tokenValue);
             if (CharSequenceUtil.isNotBlank(username) && CharSequenceUtil.isNotBlank(userPlatform)) {
                 if (CharSequenceUtil.contains(item.getUsername(), username) && item.getUserPlatform().equals(userPlatform)) {
                     loginUserList.add(item);

+ 0 - 120
nb-admin/src/main/java/com/nb/admin/controller/system/SysLoginController.java

@@ -1,120 +0,0 @@
-//package com.nb.admin.controller.system;
-//
-//import cn.dev33.satoken.stp.StpUtil;
-//import com.alibaba.fastjson.JSONObject;
-//import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-//import com.nb.admin.controller.system.vo.UserPassVo;
-//import com.nb.core.annotation.Log;
-//import com.nb.common.dto.TokenParameter;
-//import com.nb.core.exception.CustomException;
-//import com.nb.core.result.R;
-//import com.nb.common.util.SecurityUtil;
-//import com.nb.framework.web.service.IUserService;
-//import com.nb.system.common.vo.AccountInfoVO;
-//import com.nb.system.entity.SysUser;
-//import com.nb.system.service.ISysUserService;
-//import io.swagger.annotations.Api;
-//import io.swagger.annotations.ApiOperation;
-//import org.springframework.beans.factory.annotation.Value;
-//import org.springframework.validation.annotation.Validated;
-//import org.springframework.web.bind.annotation.GetMapping;
-//import org.springframework.web.bind.annotation.PostMapping;
-//import org.springframework.web.bind.annotation.RequestBody;
-//import org.springframework.web.bind.annotation.RestController;
-//
-//import javax.annotation.Resource;
-//
-///**
-// * <p>
-// * 登录 前端控制器
-// * </p>
-// *
-// * @author Kevin
-// */
-//@RestController
-//@Api(tags = "登录接口")
-//public class SysLoginController {
-//
-//    @Resource
-//    IUserService userService;
-//
-//    @Resource
-//    ISysUserService sysUserService;
-//
-//    @Value("${sa-token.token-name}")
-//    private String tokenName;
-//    @Value("${sa-token.activity-timeout}")
-//    private String activityTimeout;
-//    @Log(title = "登录")
-//    @PostMapping({"/login","/token"})
-//    @ApiOperation("登录")
-//    public R login(@Validated @RequestBody TokenParameter req) {
-//        String token = userService.login(req);
-//        JSONObject result = new JSONObject();
-//        result.put("token", token);
-//        result.put("tokenName",tokenName);
-//        result.put("activityTimeout",activityTimeout);
-//        return R.success(result);
-//    }
-//
-//    @ApiOperation("修改密码")
-//    @PostMapping(value = "/updatePass")
-//    public R<Boolean> updatePass(@RequestBody @Validated UserPassVo passVo) {
-//        // 密码解密
-//        Long userId = SecurityUtil.getSysUser().getId();
-//        SysUser sysUser = sysUserService.getById(userId);
-//        if (!SecurityUtil.matchesPassword(passVo.getOldPass(), sysUser.getPassword())) {
-//            throw new CustomException("旧密码不正确");
-//        }
-//        String encryptPassword = SecurityUtil.encryptPassword(passVo.getNewPass());
-//        sysUserService
-//                .update(new UpdateWrapper<SysUser>()
-//                        .lambda().eq(SysUser::getId,userId)
-//                        .set(SysUser::getPassword,encryptPassword));
-//        return R.success(true);
-//    }
-//    @Log(title = "获取当前用户信息")
-//    @ApiOperation("获取当前用户信息")
-//    @GetMapping("/getUserInfo")
-//    public R getUserInfo() {
-//        return R.success(userService.getUserInfo());
-//    }
-//
-//    @Log(title = "获取权限集合")
-//    @ApiOperation("获取当前用户权限集合")
-//    @GetMapping("/getPermCode")
-//    public R getPermCode() {
-//        return R.success(userService.getPermCode());
-//    }
-//
-//    @Log(title = "获取菜单集合")
-//    @ApiOperation("获取当前用户菜单集合")
-//    @GetMapping("/getMenuList")
-//    public R getMenuList() {
-//        return R.success(userService.getMenuList());
-//    }
-//
-//    @Log(title = "获取账户信息")
-//    @ApiOperation("获取当前用户账户信息")
-//    @GetMapping("/getAccountInfo")
-//    public R getAccountInfo() {
-//        return R.success(userService.getAccountInfo());
-//    }
-//
-//    @Log(title = "保存用户信息")
-//    @ApiOperation("保存用户信息")
-//    @PostMapping("/saveAccountInfo")
-//    public R saveAccountInfo(@Validated @RequestBody AccountInfoVO req) {
-//        userService.saveAccountInfo(req);
-//        return R.success();
-//    }
-//
-//    @Log(title = "退出")
-//    @ApiOperation("用户登出")
-//    @PostMapping("/logout")
-//    public R logout() {
-//        StpUtil.logout();
-//        return R.success();
-//    }
-//
-//}

+ 0 - 37
nb-admin/src/main/java/com/nb/admin/controller/system/vo/UserPassVo.java

@@ -1,37 +0,0 @@
-/*
- *  Copyright 2019-2020 Zheng Jie
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package com.nb.admin.controller.system.vo;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
-
-/**
- * 修改密码的 Vo 类
- * @author Zheng Jie
- * @date 2019年7月11日13:59:49
- */
-@Data
-@ApiModel("密码修改")
-public class UserPassVo {
-    @ApiModelProperty("旧密码")
-    private String oldPass;
-    @ApiModelProperty("新密码")
-    @NotBlank(message = "新密码不能为空")
-    private String newPass;
-}

+ 6 - 16
nb-admin/src/main/resources/application-dev.yml

@@ -1,7 +1,7 @@
 # 项目相关配置
 app:
   # 项目名称
-  name: nbnetpump
+  name: nb
   # 实例演示开关
   demoEnabled: false
   # 获取ip地址开关
@@ -12,7 +12,6 @@ app:
   uploadDir: D:/${app.name}-files
   # 缓存前缀
   cachePrefix: ${app.name}:dev
-
 # MinIO相关配置
 minio:
   endpoint: 192.168.100.32
@@ -27,19 +26,10 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driverClassName: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://192.168.100.32:3306/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
+    username: root
+    password: 123456
     druid:
-      # 主库数据源
-      master:
-        url: jdbc:mysql://192.168.100.32:3306/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
-        username: root
-        password: 123456
-      # 从库数据源
-      slave:
-        # 从数据源开关/默认关闭
-        enabled: false
-        url:
-        username:
-        password:
       # 初始连接数
       initialSize: 5
       # 最小连接池数量
@@ -61,9 +51,9 @@ spring:
       testOnReturn: false
         # 通过别名的方式配置扩展插件,多个英文逗号分隔,常用的插件有:
         # 监控统计用的filter:stat
-        # 日志用的filter:log4j
+        # 日志用的filter:log4j2
         # 防御sql注入的filter:wall
-      filters: stat,wall,log4j #log4j
+      filters: stat,wall,lo4j2 #log4j
       webStatFilter:
         enabled: true
       statViewServlet:

+ 5 - 14
nb-admin/src/main/resources/application-prod.yml

@@ -1,7 +1,7 @@
 # 项目相关配置
 app:
   # 项目名称
-  name: nbnetpump
+  name: nb
   # 实例演示开关
   demoEnabled: false
   # 获取ip地址开关
@@ -28,19 +28,10 @@ spring:
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
     driverClassName: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://47.101.214.91:7001/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
+    username: root
+    password: 123456
     druid:
-      # 主库数据源
-      master:
-        url: jdbc:mysql://47.101.214.91:7001/nbnetpump?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&autoReconnect=true
-        username: root
-        password: 123456
-      # 从库数据源
-      slave:
-        # 从数据源开关/默认关闭
-        enabled: false
-        url:
-        username:
-        password:
       # 初始连接数
       initialSize: 5
       # 最小连接池数量
@@ -64,7 +55,7 @@ spring:
       # 监控统计用的filter:stat
       # 日志用的filter:log4j
       # 防御sql注入的filter:wall
-      filters: stat,wall,log4j #log4j
+      filters: stat,wall,log4j2 #log4j
       webStatFilter:
         enabled: true
       statViewServlet:

+ 1 - 1
nb-admin/src/main/resources/application-test.yml

@@ -1,7 +1,7 @@
 # 项目相关配置
 app:
   # 项目名称
-  name: coffee
+  name: nbpump
   # 实例演示开关
   demoEnabled: false
   # 获取ip地址开关

+ 2 - 3
nb-admin/src/main/resources/application.yml

@@ -4,7 +4,7 @@ spring:
       max-file-size: 10MB
       max-request-size: 15MB
   application:
-    name: nb-service.
+    name: nb
   profiles:
     active: @profiles.active@
   jackson:
@@ -66,7 +66,6 @@ logging:
     console: UTF-8
 
 mybatis-plus:
-  mapperPackage: com.nb.**.mapper
   mapperLocations: classpath*:mapper/**/*Mapper.xml
   checkConfigLocation: false
   global-config:
@@ -78,7 +77,7 @@ mybatis-plus:
       logic-not-delete-value: 0
       logic-delete-value: 1
   configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
     default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
   type-aliases-package: com.nb.bus.entity
 

+ 24 - 0
nb-admin/src/main/resources/assembly.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+    <id>jar-with-dependencies</id>
+    <formats>
+        <format>jar</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <!-- 默认的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>runtime</scope>
+        </dependencySet>
+        <!-- 增加scope类型为system的配置 -->
+        <dependencySet>
+            <outputDirectory>/</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <unpack>true</unpack>
+            <scope>system</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>

+ 1 - 1
nb-admin/src/main/resources/logback-spring.xml

@@ -6,7 +6,7 @@
     <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
 
 
-    <appender name="ERRORLOGEventPublisher" class="com.nb.framework.logback.SystemLoggingAppender">
+    <appender name="ERRORLOGEventPublisher" class="com.nb.common.log.SystemLoggingAppender">
         <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
             <level>WARN</level>
         </filter>

+ 0 - 44
nb-admin/src/main/test/java/com/coffee/admin/BusDeviceRegisterTest.java

@@ -1,44 +0,0 @@
-package com.nb.admin;
-
-import com.nb.bus.entity.BusDeviceEntity;
-import com.nb.bus.service.LocalBusDeviceService;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusHospitalTest.java
- * @Description TODO
- * @createTime 2022年03月19日 10:27:00
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = AdminApplication.class)
-public class BusDeviceRegisterTest {
-    @Autowired
-    private LocalBusDeviceService registeredService;
-
-    @Test
-    public void save(){
-        BusDeviceEntity deviceEntity = new BusDeviceEntity();
-        deviceEntity.setAlias("测试泵");
-        deviceEntity.setDeviceId("123");
-        deviceEntity.setEnable(true);
-        registeredService.save(deviceEntity);
-
-    }
-
-    @Test
-    public void query(){
-
-    }
-
-    @Test
-    public void Delete(){
-//        boolean b = busHospitalService.removeById(1505789328745721857L);
-//        System.out.println(b);
-    }
-}

+ 7 - 8
nb-admin/src/test/java/com/nb/admin/AliyunTest.java

@@ -1,14 +1,13 @@
 package com.nb.admin;
 
-import com.aliyuncs.iot.model.v20180120.QueryDeviceResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.nb.aliyun.sdk.AliyunIotSdk;
-import com.nb.bus.entity.BusDeviceEntity;
-import com.nb.bus.entity.BusDeviceRunningEntity;
-import com.nb.bus.entity.BusInfusionHistoryEntity;
-import com.nb.bus.listener.event.bean.DeviceInfoEvent;
-import com.nb.bus.service.LocalBusDeviceService;
-import com.nb.bus.service.LocalBusInfusionHistoryService;
+import com.nb.aliyun.api.service.AliyunIotSdk;
+import com.nb.web.api.entity.BusDeviceEntity;
+import com.nb.web.service.bus.entity.BusInfusionHistoryEntity;
+import com.nb.web.service.bus.listener.event.bean.DeviceInfoEvent;
+import com.nb.web.service.bus.service.LocalBusDeviceService;
+import com.nb.web.service.bus.service.LocalBusInfusionHistoryService;
+import com.nb.web.api.entity.common.BusDeviceRunningEntity;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 8 - 8
nb-admin/src/test/java/com/nb/admin/BusClinicTest.java

@@ -5,14 +5,14 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.nb.bus.controller.vo.ClinicStatsVo;
-import com.nb.bus.entity.BusClinicEntity;
-import com.nb.bus.entity.BusDocEntity;
-import com.nb.bus.entity.BusInfusionHistoryEntity;
-import com.nb.bus.service.LocalBusClinicService;
-import com.nb.bus.service.LocalBusDocService;
-import com.nb.bus.service.LocalBusInfusionHistoryService;
-import com.nb.bus.service.dto.ClinicStatsReturnResult;
+import com.nb.web.service.bus.controller.vo.ClinicStatsVo;
+import com.nb.web.service.bus.entity.BusClinicEntity;
+import com.nb.web.service.bus.entity.BusDocEntity;
+import com.nb.web.service.bus.entity.BusInfusionHistoryEntity;
+import com.nb.web.service.bus.service.LocalBusClinicService;
+import com.nb.web.service.bus.service.LocalBusDocService;
+import com.nb.web.service.bus.service.LocalBusInfusionHistoryService;
+import com.nb.web.service.bus.service.dto.ClinicStatsReturnResult;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 8 - 8
nb-admin/src/test/java/com/nb/admin/BusDeviceAlarmTest.java

@@ -1,13 +1,13 @@
 package com.nb.admin;
 
-import com.nb.bus.controller.BusDeviceHistoryController;
-import com.nb.bus.entity.BusDeviceAlarmEntity;
-import com.nb.bus.entity.BusInfusionHistoryEntity;
-import com.nb.bus.enums.DeviceStatusEnum;
-import com.nb.bus.mapper.BusDeviceAlarmMapper;
-import com.nb.bus.service.LocalBusDeviceAlarmService;
-import com.nb.bus.service.LocalBusInfusionHistoryService;
-import com.nb.bus.service.dto.DeviceAlarmQuery;
+import com.nb.web.service.bus.controller.BusDeviceHistoryController;
+import com.nb.web.service.bus.entity.BusDeviceAlarmEntity;
+import com.nb.web.service.bus.entity.BusInfusionHistoryEntity;
+import com.nb.web.api.enums.DeviceStatusEnum;
+import com.nb.web.service.bus.mapper.BusDeviceAlarmMapper;
+import com.nb.web.service.bus.service.LocalBusDeviceAlarmService;
+import com.nb.web.service.bus.service.LocalBusInfusionHistoryService;
+import com.nb.web.service.bus.service.dto.DeviceAlarmQuery;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 6 - 6
nb-admin/src/test/java/com/nb/admin/BusDeviceTest.java

@@ -3,12 +3,12 @@ package com.nb.admin;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.nb.bus.entity.BusDeviceEntity;
-import com.nb.bus.entity.BusDeviceHistoryEntity;
-import com.nb.bus.service.LocalBusDeviceHistoryService;
-import com.nb.bus.service.LocalBusDeviceService;
-import com.nb.bus.service.dto.ClinicAnalInfusionRecord;
-import com.nb.common.util.RedissonUtil;
+import com.nb.web.api.entity.BusDeviceEntity;
+import com.nb.web.service.bus.entity.BusDeviceHistoryEntity;
+import com.nb.web.service.bus.service.LocalBusDeviceHistoryService;
+import com.nb.web.service.bus.service.LocalBusDeviceService;
+import com.nb.web.service.bus.service.dto.ClinicAnalInfusionRecord;
+import com.nb.common.config.utils.RedissonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 3 - 3
nb-admin/src/test/java/com/nb/admin/BusHospitalLogTest.java

@@ -1,8 +1,8 @@
 package com.nb.admin;
 
-import com.nb.bus.controller.BusHospitalLogController;
-import com.nb.bus.entity.BusHospitalLogEntity;
-import com.nb.bus.service.LocalBusHospitalLogService;
+import com.nb.web.service.bus.controller.BusHospitalLogController;
+import com.nb.web.api.entity.BusHospitalLogEntity;
+import com.nb.web.service.bus.service.LocalBusHospitalLogService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 9 - 9
nb-admin/src/test/java/com/nb/admin/BusHospitalTest.java

@@ -1,14 +1,14 @@
 package com.nb.admin;
 
-import com.nb.bus.bean.GeoPoint;
-import com.nb.bus.bean.Script;
-import com.nb.bus.controller.BusHospitalController;
-import com.nb.bus.entity.BusHospitalEntity;
-import com.nb.bus.service.LocalBusHospitalService;
-import com.nb.bus.service.LocalBusPatientService;
-import com.nb.bus.service.constant.LocalBusConMixService;
-import com.nb.bus.service.dto.MonitorStatusStatsCountResult;
-import com.nb.bus.utils.CodeUtils;
+import com.nb.web.api.bean.GeoPoint;
+import com.nb.web.api.bean.Script;
+import com.nb.web.service.bus.controller.BusHospitalController;
+import com.nb.web.service.bus.entity.BusHospitalEntity;
+import com.nb.web.service.bus.service.LocalBusHospitalService;
+import com.nb.web.service.bus.service.LocalBusPatientService;
+import com.nb.web.service.bus.service.constant.LocalBusConMixService;
+import com.nb.web.service.bus.service.dto.MonitorStatusStatsCountResult;
+import com.nb.web.service.bus.utils.CodeUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 2 - 2
nb-admin/src/test/java/com/nb/admin/BusNetpumpTest.java

@@ -2,8 +2,8 @@ package com.nb.admin;
 
 import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.nb.bus.entity.BusDeviceEntity;
-import com.nb.bus.service.LocalBusDeviceService;
+import com.nb.web.api.entity.BusDeviceEntity;
+import com.nb.web.service.bus.service.LocalBusDeviceService;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.junit.Test;

+ 13 - 13
nb-admin/src/test/java/com/nb/admin/BusPatientTest.java

@@ -5,19 +5,19 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.nb.bus.controller.BusDeviceManualController;
-import com.nb.bus.controller.vo.ClinicEditVo;
-import com.nb.bus.entity.BusClinicEntity;
-import com.nb.bus.entity.BusDeviceManualEntity;
-import com.nb.bus.entity.BusInfusionHistoryEntity;
-import com.nb.bus.entity.BusPatientEntity;
-import com.nb.bus.enums.DeviceManualEnum;
-import com.nb.bus.hospital.his.strategy.all.EqualsStrategyHandler;
-import com.nb.bus.service.LocalBusClinicService;
-import com.nb.bus.service.LocalBusInfusionHistoryService;
-import com.nb.bus.service.LocalBusPatientService;
-import com.nb.bus.service.dto.PatientDeviceRepeatResult;
-import com.nb.common.enums.SexEnum;
+import com.nb.web.service.bus.controller.BusDeviceManualController;
+import com.nb.web.service.bus.controller.vo.ClinicEditVo;
+import com.nb.web.service.bus.entity.BusClinicEntity;
+import com.nb.web.service.bus.entity.BusDeviceManualEntity;
+import com.nb.web.service.bus.entity.BusInfusionHistoryEntity;
+import com.nb.web.service.bus.entity.BusPatientEntity;
+import com.nb.web.service.bus.enums.DeviceManualEnum;
+import com.nb.web.service.bus.hospital.his.strategy.all.EqualsStrategyHandler;
+import com.nb.web.service.bus.service.LocalBusClinicService;
+import com.nb.web.service.bus.service.LocalBusInfusionHistoryService;
+import com.nb.web.service.bus.service.LocalBusPatientService;
+import com.nb.web.service.bus.service.dto.PatientDeviceRepeatResult;
+import com.nb.core.enums.SexEnum;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 6 - 6
nb-admin/src/test/java/com/nb/admin/DelayMessageTest.java

@@ -1,11 +1,11 @@
 package com.nb.admin;
 
-import com.nb.bus.hospital.config.HospitalDeviceAutoUndoConfigHandler;
-import com.nb.bus.hospital.config.handler.HandlerConstant;
-import com.nb.common.cache.value.Value;
-import com.nb.common.delay_queue.manager.DelayMessageManager;
-import com.nb.common.delay_queue.message.DelayMessage;
-import com.nb.common.delay_queue.message.DelayMessageProperties;
+import com.nb.web.service.bus.hospital.config.HospitalDeviceAutoUndoConfigHandler;
+import com.nb.web.service.bus.hospital.config.handler.HandlerConstant;
+import com.nb.core.Value;
+import com.nb.common.queue.delay.manager.DelayMessageManager;
+import com.nb.common.queue.delay.message.DelayMessage;
+import com.nb.common.queue.delay.message.DelayMessageProperties;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 5 - 9
nb-admin/src/test/java/com/nb/admin/DeviceOperateTest.java

@@ -1,11 +1,10 @@
 package com.nb.admin;
 
-import com.nb.bus.registry.device.DeviceOperator;
-import com.nb.bus.registry.device.DeviceRegistry;
+import com.nb.web.service.bus.registry.device.DeviceOperator;
+import com.nb.web.service.bus.registry.device.DeviceRegistry;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -24,12 +23,9 @@ public class DeviceOperateTest {
 
     @Test
     public void test(){
-        DeviceOperator operator = deviceRegistry.getOperator("51066208333702B6");
+        DeviceOperator operator = deviceRegistry.getOperator("43177015333402A6");
 
-        operator.setFlowLimit(true);
-        boolean flowLimit = operator.isFlowLimit();
-        while (true){
-
-        }
+        boolean exist = operator.getExist();
+        System.out.println(exist);
     }
 }

+ 1 - 1
nb-admin/src/test/java/com/nb/admin/FileUploadTest.java

@@ -1,7 +1,7 @@
 package com.nb.admin;
 
 import cn.hutool.core.io.FileUtil;
-import com.nb.common.util.MinioUtil;
+import com.nb.oss.strategy.MinioUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 7 - 7
nb-admin/src/test/java/com/nb/admin/HisStrategyTest.java

@@ -5,13 +5,13 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.nb.bus.entity.BusClinicEntity;
-import com.nb.bus.hospital.his.strategy.HisStrategyEnum;
-import com.nb.bus.hospital.his.strategy.HisStrategyHandler;
-import com.nb.bus.hospital.his.strategy.HisStrategyManager;
-import com.nb.bus.hospital.his.strategy.HisStrategyManagerRegister;
-import com.nb.bus.service.LocalBusClinicService;
-import com.nb.common.enums.SexEnum;
+import com.nb.web.service.bus.entity.BusClinicEntity;
+import com.nb.web.service.bus.hospital.his.strategy.HisStrategyEnum;
+import com.nb.web.service.bus.hospital.his.strategy.HisStrategyHandler;
+import com.nb.web.service.bus.hospital.his.strategy.HisStrategyManager;
+import com.nb.web.service.bus.hospital.his.strategy.HisStrategyManagerRegister;
+import com.nb.web.service.bus.service.LocalBusClinicService;
+import com.nb.core.enums.SexEnum;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 3 - 10
nb-admin/src/test/java/com/nb/admin/NotifyTest.java

@@ -1,23 +1,16 @@
 package com.nb.admin;
 
 import cn.hutool.json.JSONUtil;
-import com.nb.bus.job.DeviceFlowStatsJob;
-import com.nb.common.notice.msg.DiskMsg;
-import com.nb.common.notice.msg.LifeCycleMsg;
-import com.nb.common.notice.wechat.EnterpriseWeChatNotify;
+import com.nb.web.service.bus.job.DeviceFlowStatsJob;
+import com.nb.common.config.notice.msg.DiskMsg;
+import com.nb.common.config.notice.wechat.EnterpriseWeChatNotify;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.actuate.redis.RedisHealthIndicator;
 import org.springframework.boot.actuate.system.DiskSpaceHealthIndicator;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import javax.jws.Oneway;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.OperatingSystemMXBean;
-import java.util.Date;
 import java.util.Map;
 
 /**

+ 5 - 5
nb-admin/src/test/java/com/nb/admin/SpringBootApplicationTests.java

@@ -1,11 +1,11 @@
 package com.nb.admin;
 
 import cn.hutool.json.JSONUtil;
-import com.nb.bus.hospital.HospitalManagerRegister;
-import com.nb.bus.hospital.config.HospitalDeviceAutoUndoConfigHandler;
-import com.nb.bus.hospital.config.handler.DeputyDeviceAutoUndoHandler;
-import com.nb.common.cache.value.Value;
-import com.nb.common.delay_queue.message.DelayMessage;
+import com.nb.web.service.bus.hospital.HospitalManagerRegister;
+import com.nb.web.service.bus.hospital.config.HospitalDeviceAutoUndoConfigHandler;
+import com.nb.web.service.bus.hospital.config.handler.DeputyDeviceAutoUndoHandler;
+import com.nb.core.Value;
+import com.nb.common.queue.delay.message.DelayMessage;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;

+ 0 - 15
nb-api/pom.xml

@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>nb-root</artifactId>
-        <groupId>com.tuoren</groupId>
-        <version>1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>nb-api</artifactId>
-
-
-</project>

+ 9 - 4
nb-auth/pom.xml

@@ -19,8 +19,8 @@
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <optional>true</optional>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>
@@ -33,8 +33,9 @@
             <version>${hutool.version}</version>
         </dependency>
         <dependency>
-            <groupId>javax.validation</groupId>
-            <artifactId>validation-api</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
@@ -45,5 +46,9 @@
             <groupId>cn.dev33</groupId>
             <artifactId>sa-token-spring-boot-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>cn.dev33</groupId>
+            <artifactId>sa-token-dao-redis-jackson</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 43 - 0
nb-auth/src/main/java/com/nb/auth/GlobalAuthExceptionHandler.java

@@ -0,0 +1,43 @@
+package com.nb.auth;
+
+import cn.dev33.satoken.exception.NotLoginException;
+import cn.dev33.satoken.exception.NotPermissionException;
+import cn.dev33.satoken.exception.NotRoleException;
+import com.nb.core.exception.*;
+import com.nb.core.exception.apply.ApplyTokenParamException;
+import com.nb.core.exception.apply.NoExistAppKeyException;
+import com.nb.core.result.R;
+import com.nb.core.result.ResultCode;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.BindException;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.validation.ConstraintViolationException;
+import java.util.Objects;
+
+/**
+ * 全局异常处理器
+ *
+ * @author Kevin
+ */
+@RestControllerAdvice
+@Slf4j
+public class GlobalAuthExceptionHandler {
+
+    @ExceptionHandler(NotLoginException.class)
+    public R handleNotLoginException(NotLoginException e) {
+        return R.result(ResultCode.TOKEN_ERROR);
+    }
+
+    @ExceptionHandler(NotRoleException.class)
+    public R handleNotRoleException(NotRoleException e) {
+        return R.result(ResultCode.UN_AUTHORIZED);
+    }
+
+    @ExceptionHandler(NotPermissionException.class)
+    public R handleNotPermissionException(NotPermissionException e) {
+        return R.result(ResultCode.UN_AUTHORIZED);
+    }
+}

+ 37 - 0
nb-auth/src/main/java/com/nb/auth/bean/UserPassVo.java

@@ -0,0 +1,37 @@
+/*
+ *  Copyright 2019-2020 Zheng Jie
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package com.nb.auth.bean;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * 修改密码的 Vo 类
+ * @author Zheng Jie
+ * @date 2019年7月11日13:59:49
+ */
+@Data
+@ApiModel("密码修改")
+public class UserPassVo {
+    @ApiModelProperty("旧密码")
+    private String oldPass;
+    @ApiModelProperty("新密码")
+    @NotBlank(message = "新密码不能为空")
+    private String newPass;
+}

+ 44 - 0
nb-auth/src/main/java/com/nb/auth/config/AuthDocConfig.java

@@ -0,0 +1,44 @@
+package com.nb.auth.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Profile;
+import org.springframework.stereotype.Component;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName SwaggerDocConfig.java
+ * @Description TODO
+ * @createTime 2022年08月01日 22:01:00
+ */
+@Component
+public class AuthDocConfig {
+
+
+    @Bean
+    public Docket admin(){
+        ParameterBuilder ticketPar = new ParameterBuilder();
+        List<Parameter> pars = new ArrayList<Parameter>();
+        ticketPar.name("tenantId").description("租户id")
+                .modelRef(new ModelRef("string")).parameterType("query")
+                .required(true).build();
+        pars.add(ticketPar.build());
+
+        return new Docket(DocumentationType.SWAGGER_2)
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.nb.auth.controller"))
+                .paths(PathSelectors.any())
+                .build()
+                .groupName("授权模块");
+    }
+}

+ 30 - 0
nb-auth/src/main/java/com/nb/auth/config/CustomStpInterface.java

@@ -0,0 +1,30 @@
+package com.nb.auth.config;
+
+import cn.dev33.satoken.stp.StpInterface;
+import com.nb.auth.bean.SysRoleInfo;
+import com.nb.auth.utils.SecurityUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+/**
+ * 自定义SaToken权限验证
+ *
+ * @author Kevin
+ */
+@Component
+public class CustomStpInterface implements StpInterface {
+    @Override
+    public List<String> getPermissionList(Object loginId, String loginType) {
+        return new ArrayList<>(SecurityUtil.getLoginUser().getPermissions());
+    }
+
+    @Override
+    public List<String> getRoleList(Object loginId, String loginType) {
+        List<SysRoleInfo> roles = SecurityUtil.getLoginUser().getRoles();
+        return roles.stream().map(SysRoleInfo::getRoleCode).collect(Collectors.toList());
+    }
+}

+ 77 - 0
nb-auth/src/main/java/com/nb/auth/controller/AccountController.java

@@ -0,0 +1,77 @@
+package com.nb.auth.controller;
+
+import com.nb.auth.bean.UserPassVo;
+import com.nb.auth.granter.IAccountOperator;
+import com.nb.auth.controller.vo.AccountInfoVO;
+import com.nb.auth.utils.SecurityUtil;
+import com.nb.core.annotation.Log;
+import com.nb.core.exception.CustomException;
+import com.nb.core.result.R;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName AccountController.java
+ * @Description TODO
+ * @createTime 2022年08月01日 17:22:00
+ */
+@AllArgsConstructor
+@RestController
+@Api(tags = "账号信息接口")
+public class AccountController {
+    private final IAccountOperator accountOperator;
+
+    @ApiOperation("修改密码")
+    @PostMapping(value = "/updatePass")
+    public R<Boolean> updatePass(@RequestBody @Validated UserPassVo passVo) {
+        if (accountOperator.updatePass(passVo.getOldPass(),passVo.getNewPass())) {
+            return R.success();
+        }else {
+            throw new CustomException("修改失败,请重试");
+        }
+    }
+
+    @Log(title = "获取当前用户信息")
+    @ApiOperation("获取当前用户信息")
+    @GetMapping("/getUserInfo")
+    public R getUserInfo() {
+        return R.success(accountOperator.getUserInfo());
+    }
+
+    @Log(title = "获取权限集合")
+    @ApiOperation("获取当前用户权限集合")
+    @GetMapping("/getPermCode")
+    public R getPermCode() {
+        return R.success(accountOperator.getPermCode());
+    }
+
+    @Log(title = "获取菜单集合")
+    @ApiOperation("获取当前用户菜单集合")
+    @GetMapping("/getMenuList")
+    public R getMenuList() {
+        return R.success(accountOperator.getMenuList());
+    }
+
+    @Log(title = "获取账户信息")
+    @ApiOperation("获取当前用户账户信息")
+    @GetMapping("/getAccountInfo")
+    public R getAccountInfo() {
+        return R.success(accountOperator.getAccountInfo());
+    }
+
+    @Log(title = "保存用户信息")
+    @ApiOperation("保存用户信息")
+    @PostMapping("/saveAccountInfo")
+    public R saveAccountInfo(@Validated @RequestBody AccountInfoVO req) {
+        accountOperator.saveAccountInfo(req);
+        return R.success();
+    }
+}

+ 17 - 61
nb-auth/src/main/java/com/nb/auth/controller/AuthController.java

@@ -2,10 +2,8 @@ package com.nb.auth.controller;
 import cn.dev33.satoken.stp.StpUtil;
 import com.nb.auth.bean.AuthInfo;
 import com.nb.auth.bean.LoginUser;
-import com.nb.auth.granter.IAccountOperator;
 import com.nb.auth.granter.IAuthGranter;
 import com.nb.auth.granter.TokenParameter;
-import com.nb.auth.vo.AccountInfoVO;
 import com.nb.core.exception.CustomException;
 import com.nb.core.result.R;
 import io.swagger.annotations.Api;
@@ -19,8 +17,6 @@ import org.springframework.web.bind.annotation.RestController;
 import java.util.*;
 import com.nb.core.annotation.Log;
 
-import javax.validation.constraints.NotBlank;
-
 /**
  * @author lifang
  * @version 1.0.0
@@ -28,19 +24,14 @@ import javax.validation.constraints.NotBlank;
  * @Description 授权接口
  * @createTime 2022年08月01日 13:33:00
  */
-
 @RestController
 @Api(tags = "登录、授权接口")
 public class AuthController {
 
     private final List<IAuthGranter> tokenGranter;
 
-    private final IAccountOperator accountOperator;
-
-    public AuthController(List<IAuthGranter> tokenGranter,
-                          IAccountOperator accountOperator) {
+    public AuthController(List<IAuthGranter> tokenGranter) {
         this.tokenGranter = tokenGranter;
-        this.accountOperator = accountOperator;
     }
 
     @Value("${sa-token.token-name}")
@@ -49,7 +40,7 @@ public class AuthController {
     @Value("${sa-token.activity-timeout}")
     private Long activityTimeout;
 
-    //    @Log(title = "登录")
+    @Log(title = "登录")
     @PostMapping({"/login","/token"})
     @ApiOperation("登录")
     public R<AuthInfo> login(@Validated @RequestBody TokenParameter req) {
@@ -69,56 +60,21 @@ public class AuthController {
                 .build());
     }
 
-//    @ApiOperation("修改密码")
-//    @PostMapping(value = "/updatePass")
-//    public R<Boolean> updatePass(@RequestBody @Validated UserPassVo passVo) {
-//        // 密码解密
-//        Long userId = SecurityUtil.getSysUser().getId();
-//        SysUser sysUser = sysUserService.getById(userId);
-//        if (!SecurityUtil.matchesPassword(passVo.getOldPass(), sysUser.getPassword())) {
-//            throw new CustomException("旧密码不正确");
-//        }
-//        String encryptPassword = SecurityUtil.encryptPassword(passVo.getNewPass());
-//        sysUserService
-//                .update(new UpdateWrapper<SysUser>()
-//                        .lambda().eq(SysUser::getId,userId)
-//                        .set(SysUser::getPassword,encryptPassword));
-//        return R.success(true);
-//    }
-
-    @Log(title = "获取当前用户信息")
-    @ApiOperation("获取当前用户信息")
-    @GetMapping("/getUserInfo")
-    public R getUserInfo() {
-        return R.success(accountOperator.getUserInfo());
-    }
-
-    @Log(title = "获取权限集合")
-    @ApiOperation("获取当前用户权限集合")
-    @GetMapping("/getPermCode")
-    public R getPermCode() {
-        return R.success(accountOperator.getPermCode());
-    }
-
-    @Log(title = "获取菜单集合")
-    @ApiOperation("获取当前用户菜单集合")
-    @GetMapping("/getMenuList")
-    public R getMenuList() {
-        return R.success(accountOperator.getMenuList());
-    }
-
-    @Log(title = "获取账户信息")
-    @ApiOperation("获取当前用户账户信息")
-    @GetMapping("/getAccountInfo")
-    public R getAccountInfo() {
-        return R.success(accountOperator.getAccountInfo());
-    }
-
-    @Log(title = "保存用户信息")
-    @ApiOperation("保存用户信息")
-    @PostMapping("/saveAccountInfo")
-    public R saveAccountInfo(@Validated @RequestBody AccountInfoVO req) {
-        accountOperator.saveAccountInfo(req);
+    /*
+     * 根据键值,获取value
+     */
+    @ApiOperation("刷新token时间")
+    @GetMapping("/refresh")
+    public R getTime() {
+        if (StpUtil.isLogin()) {
+            try {
+                StpUtil.checkActivityTimeout();
+                //手动续签
+                StpUtil.updateLastActivityToNow();
+            }catch (Exception e){
+
+            }
+        }
         return R.success();
     }
 

+ 62 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/AccountInfoVO.java

@@ -0,0 +1,62 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+
+/**
+ * 账户信息VO
+ *
+ * @author Kevin
+ */
+@Data
+public class AccountInfoVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 昵称
+     */
+    @NotBlank(message = "昵称不能为空")
+    @Size(max = 100, message = "昵称长度不能超过100个字符")
+    private String nickname;
+
+    /**
+     * 姓名
+     */
+    @Size(max = 100, message = "姓名长度不能超过100个字符")
+    private String realname;
+
+    /**
+     * 英文名
+     */
+    @Size(max = 100, message = "英文名长度不能超过100个字符")
+    private String englishName;
+
+    /**
+     * 头像
+     */
+    @Size(max = 100, message = "头像长度不能超过100个字符")
+    private String avatar;
+
+    /**
+     * 邮箱
+     */
+    @Size(max = 100, message = "邮箱长度不能超过100个字符")
+    private String email;
+
+    /**
+     * 性别 1男;2女;3未知
+     */
+    @NotBlank(message = "性别不能为空")
+    private String sex;
+
+    /**
+     * 备注
+     */
+    @Size(max = 500, message = "备注长度不能超过500个字符")
+    private String remarks;
+
+}

+ 17 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/BaseTemplateVO.java

@@ -0,0 +1,17 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * VO模板类,方便复制该类,创建新类
+ *
+ * @author Kevin
+ */
+@Data
+public class BaseTemplateVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+}

+ 21 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/RoleInfoVO.java

@@ -0,0 +1,21 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 角色VO
+ *
+ * @author Kevin
+ */
+@Data
+public class RoleInfoVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String roleName;
+
+    private String value;
+
+}

+ 30 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/RouteItemVO.java

@@ -0,0 +1,30 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 路由项VO
+ *
+ * @author Kevin
+ */
+@Data
+public class RouteItemVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String path;
+
+    private String component;
+
+    private RouteMetoVO meta;
+
+    private String name;
+
+    private String redirect;
+
+    private List<RouteItemVO> children;
+
+}

+ 49 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/RouteMetoVO.java

@@ -0,0 +1,49 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 路由MetoVO
+ *
+ * @author Kevin
+ */
+@Data
+public class RouteMetoVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String title;
+
+    private Boolean ignoreAuth;
+
+    private String roles;
+
+    private Boolean ignoreKeepAlive;
+
+    private Boolean affix;
+
+    private String icon;
+
+    private String frameSrc;
+
+    private String transitionName;
+
+    private Boolean hideBreadcrumb;
+
+    private Boolean hideChildrenInMenu;
+
+    private Boolean carryParam;
+
+    private Boolean single;
+
+    private String currentActiveMenu;
+
+    private Boolean hideTab;
+
+    private Boolean hideMenu;
+
+    private Boolean isLink;
+
+}

+ 35 - 0
nb-auth/src/main/java/com/nb/auth/controller/vo/UserInfoVO.java

@@ -0,0 +1,35 @@
+package com.nb.auth.controller.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 用户信息VO
+ *
+ * @author Kevin
+ */
+@Data
+public class UserInfoVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String userId;
+
+    private String username;
+
+    private String realName;
+
+    private String avatar;
+
+    private String desc;
+
+    private String tenantId;
+
+    private String tenantName;
+
+    private List<RoleInfoVO> roles;
+
+    private Boolean isSys;
+}

+ 5 - 3
nb-auth/src/main/java/com/nb/auth/granter/IAccountOperator.java

@@ -1,8 +1,8 @@
 package com.nb.auth.granter;
 
-import com.nb.auth.vo.AccountInfoVO;
-import com.nb.auth.vo.RouteItemVO;
-import com.nb.auth.vo.UserInfoVO;
+import com.nb.auth.controller.vo.AccountInfoVO;
+import com.nb.auth.controller.vo.RouteItemVO;
+import com.nb.auth.controller.vo.UserInfoVO;
 
 import java.util.List;
 import java.util.Set;
@@ -51,4 +51,6 @@ public interface IAccountOperator {
      * @return Set<String>
      */
     void saveAccountInfo(AccountInfoVO req);
+
+    boolean updatePass(String oldPass, String newPass);
 }

+ 2 - 2
nb-auth/src/main/java/com/nb/auth/granter/IAuthGranter.java

@@ -21,8 +21,8 @@ import cn.hutool.http.useragent.UserAgent;
 import cn.hutool.http.useragent.UserAgentUtil;
 import com.nb.auth.bean.LoginUser;
 import com.nb.auth.enums.GrantTypeEnum;
-import com.nb.auth.utils.AddressUtil;
-import com.nb.auth.utils.IpUtil;
+import com.nb.core.utils.AddressUtil;
+import com.nb.core.utils.IpUtil;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Date;

+ 1 - 0
nb-auth/src/main/java/com/nb/auth/granter/TokenParameter.java

@@ -14,6 +14,7 @@ import javax.validation.constraints.NotBlank;
 @Data
 public class TokenParameter {
 
+    @ApiModelProperty("授权方式,1、web账密登录 2、手机短信登录 3、第三方应用登陆")
     GrantTypeEnum grantType;
 
     String username;

+ 26 - 0
nb-auth/src/main/java/com/nb/auth/sa/SaConfig.java

@@ -0,0 +1,26 @@
+package com.nb.auth.sa;
+
+import cn.dev33.satoken.SaManager;
+import cn.dev33.satoken.dao.SaTokenDaoRedisJackson;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName SaConfig.java
+ * @Description TODO
+ * @createTime 2022年03月15日 16:51:00
+ */
+@Component
+@AllArgsConstructor
+public class SaConfig {
+    private final SaTokenDaoRedisJackson saTokenDaoRedisJackson;
+    @PostConstruct
+    public void init(){
+        SaManager.setSaTokenAction(new SaTokenActionDefaultImpl());
+        SaManager.setSaTokenDao(saTokenDaoRedisJackson);
+    }
+}

+ 169 - 0
nb-auth/src/main/java/com/nb/auth/sa/SaTokenActionDefaultImpl.java

@@ -0,0 +1,169 @@
+package com.nb.auth.sa;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+import cn.dev33.satoken.SaManager;
+import cn.dev33.satoken.action.SaTokenAction;
+import cn.dev33.satoken.annotation.SaCheckBasic;
+import cn.dev33.satoken.annotation.SaCheckLogin;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.annotation.SaCheckRole;
+import cn.dev33.satoken.annotation.SaCheckSafe;
+import cn.dev33.satoken.basic.SaBasicUtil;
+import cn.dev33.satoken.session.SaSession;
+import cn.dev33.satoken.strategy.SaStrategy;
+import cn.dev33.satoken.util.SaFoxUtil;
+import cn.dev33.satoken.util.SaTokenConsts;
+
+/**
+ * <h1> v1.27+ 此接口已废弃,目前版本暂时向下兼容,请及时更换为 SaStrategy </h1>
+ * <p> Sa-Token 逻辑代理接口 [默认实现类]  </p> 
+ * @author kong
+ *
+ */
+public class SaTokenActionDefaultImpl implements SaTokenAction {
+
+	/**
+	 * 创建一个Token 
+	 */
+	@Override
+	public String createToken(Object loginId, String loginType) {
+		// 根据配置的tokenStyle生成不同风格的token 
+		String tokenStyle = SaManager.getConfig().getTokenStyle();
+		// uuid 
+		if(SaTokenConsts.TOKEN_STYLE_UUID.equals(tokenStyle)) {
+			return UUID.randomUUID().toString();
+		}
+		// 简单uuid (不带下划线)
+		if(SaTokenConsts.TOKEN_STYLE_SIMPLE_UUID.equals(tokenStyle)) {
+			return UUID.randomUUID().toString().replaceAll("-", "");
+		}
+		// 32位随机字符串
+		if(SaTokenConsts.TOKEN_STYLE_RANDOM_32.equals(tokenStyle)) {
+			return SaFoxUtil.getRandomString(32);
+		}
+		// 64位随机字符串
+		if(SaTokenConsts.TOKEN_STYLE_RANDOM_64.equals(tokenStyle)) {
+			return SaFoxUtil.getRandomString(64);
+		}
+		// 128位随机字符串
+		if(SaTokenConsts.TOKEN_STYLE_RANDOM_128.equals(tokenStyle)) {
+			return SaFoxUtil.getRandomString(128);
+		}
+		// tik风格 (2_14_16)
+		if(SaTokenConsts.TOKEN_STYLE_TIK.equals(tokenStyle)) {
+			return SaFoxUtil.getRandomString(2) + "_" + SaFoxUtil.getRandomString(14) + "_" + SaFoxUtil.getRandomString(16) + "__";
+		}
+		// 默认,还是uuid 
+		return UUID.randomUUID().toString();
+	}
+
+	/**
+	 * 创建一个Session 
+	 */
+	@Override
+	public SaSession createSession(String sessionId) {
+		return new SaSession(sessionId);
+	}
+
+	/**
+	 * 判断:集合中是否包含指定元素(模糊匹配) 
+	 */
+	@Override
+	public boolean hasElement(List<String> list, String element) {
+		
+		// 空集合直接返回false
+		if(list == null || list.size() == 0) {
+			return false;
+		}
+
+		// 先尝试一下简单匹配,如果可以匹配成功则无需继续模糊匹配 
+		if (list.contains(element)) {
+			return true;
+		}
+		
+		// 开始模糊匹配 
+		for (String patt : list) {
+			if(vagueMatch(patt, element)) {
+				return true;
+			}
+		}
+		
+		// 走出for循环说明没有一个元素可以匹配成功 
+		return false;
+	}
+
+	/**
+	 * 对一个Method对象进行注解检查(注解鉴权内部实现) 
+	 */
+	@Override
+	public void checkMethodAnnotation(Method method) {
+
+		// 先校验 Method 所属 Class 上的注解 
+		validateAnnotation(method.getDeclaringClass());
+		
+		// 再校验 Method 上的注解  
+		validateAnnotation(method);
+	}
+
+	/**
+	 * 从指定元素校验注解 
+	 * @param target see note 
+	 */
+	@Override
+	public void validateAnnotation(AnnotatedElement target) {
+		
+		// 校验 @SaCheckLogin 注解 
+		SaCheckLogin checkLogin = (SaCheckLogin) SaStrategy.me.getAnnotation.apply(target, SaCheckLogin.class);
+		if(checkLogin != null) {
+			SaManager.getStpLogic(checkLogin.type()).checkByAnnotation(checkLogin);
+		}
+		
+		// 校验 @SaCheckRole 注解 
+		SaCheckRole checkRole = (SaCheckRole) SaStrategy.me.getAnnotation.apply(target, SaCheckRole.class);
+		if(checkRole != null) {
+			SaManager.getStpLogic(checkRole.type()).checkByAnnotation(checkRole);
+		}
+		
+		// 校验 @SaCheckPermission 注解
+		SaCheckPermission checkPermission = (SaCheckPermission) SaStrategy.me.getAnnotation.apply(target, SaCheckPermission.class);
+		if(checkPermission != null) {
+			SaManager.getStpLogic(checkPermission.type()).checkByAnnotation(checkPermission);
+		}
+
+		// 校验 @SaCheckSafe 注解
+		SaCheckSafe checkSafe = (SaCheckSafe) SaStrategy.me.getAnnotation.apply(target, SaCheckSafe.class);
+		if(checkSafe != null) {
+			SaManager.getStpLogic(checkSafe.type()).checkByAnnotation(checkSafe);
+		}
+		
+		// 校验 @SaCheckBasic 注解
+		SaCheckBasic checkBasic = (SaCheckBasic) SaStrategy.me.getAnnotation.apply(target, SaCheckBasic.class);
+		if(checkBasic != null) {
+			SaBasicUtil.check(checkBasic.realm(), checkBasic.account());
+		}
+		
+	}
+
+
+	/**
+	 * 字符串模糊匹配
+	 * <p>example:
+	 * <p> user-add user*    --  true
+	 * <p> art-add user*     --  false
+	 * @param patt 表达式
+	 * @param str 待匹配的字符串
+	 * @return 是否可以匹配
+	 */
+	public static boolean vagueMatch(String patt, String str) {
+		// 如果表达式不带有*号,则只需简单equals即可 (速度提升200倍)
+		if(!str.contains("*")&&!patt.contains("*")) {
+			return patt.equals(str);
+		}
+		return Pattern.matches(str.replaceAll("\\*", ".*"), patt)||Pattern.matches(patt.replaceAll("\\*", ".*"), str);
+	}
+}

+ 61 - 0
nb-auth/src/main/java/com/nb/auth/sa/SaTokenConfig.java

@@ -0,0 +1,61 @@
+package com.nb.auth.sa;
+
+import cn.dev33.satoken.interceptor.SaRouteInterceptor;
+import cn.dev33.satoken.router.SaRouter;
+import cn.dev33.satoken.stp.StpUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Sa Token 注册拦截器
+ *
+ * @author Kevin
+ */
+@Slf4j
+@Configuration
+public class SaTokenConfig {
+
+    @Bean
+    @Order(1)
+    public HandlerInterceptor handlerInterceptor(){
+        return new SaRouteInterceptor((req, res, handler) -> {
+            SaRouter.match("/**")
+                    .notMatch(IGNORE_URL)
+                    .check(StpUtil::checkLogin);
+        });
+    }
+    private static final List<String> IGNORE_URL = new ArrayList<>();
+
+    static {
+        IGNORE_URL.add("/actuator/**");
+        IGNORE_URL.add("/bus/version/page");
+        IGNORE_URL.add("/druid/**");
+        IGNORE_URL.add("/favicon.ico");
+        IGNORE_URL.add("/sys/app/get");
+        IGNORE_URL.add("/index");
+        IGNORE_URL.add("/login");
+        IGNORE_URL.add("/token");
+        IGNORE_URL.add("/logout");
+        IGNORE_URL.add("/common/**");
+        IGNORE_URL.add("/*.html");
+        IGNORE_URL.add("/**/*.html");
+        IGNORE_URL.add("/error");
+        IGNORE_URL.add("/swagger-resources/**");
+        IGNORE_URL.add("/swagger-ui/**");
+        IGNORE_URL.add("/webjars/**");
+        IGNORE_URL.add("/v2/api-docs/*");
+        IGNORE_URL.add("/v2/api-docs");
+        IGNORE_URL.add("/v1/**");
+        IGNORE_URL.add("/authority/captcha/**");
+        IGNORE_URL.add("/system/curl/**");
+        IGNORE_URL.add("/system/sysConfig/getTime");
+        IGNORE_URL.add("/system/sysDept/**");
+    }
+
+}

+ 0 - 51
nb-auth/src/main/java/com/nb/auth/utils/AddressUtil.java

@@ -1,51 +0,0 @@
-package com.nb.auth.utils;
-
-import lombok.extern.slf4j.Slf4j;
-
-/**
- * 获取地址类
- *
- * @author Kevin
- */
-@Slf4j
-public class AddressUtil {
-    /**
-     * IP地址查询
-     */
-    public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
-
-    /**
-     * 未知地址
-     */
-    public static final String UNKNOWN = "XX XX";
-
-    public static String getRealAddressByIp(String ip) {
-        String address = UNKNOWN;
-        // 内网不查询
-//        try {
-//            if (NetUtil.isInnerIP(ip)) {
-//                return "内网IP";
-//            }
-//            if (AppConfig.isAddressEnabled()) {
-//                try {
-//                    String rspStr = HttpUtil.get(IP_URL + "?ip=" + ip + "&json=true", CharsetUtil.CHARSET_GBK);
-//                    if (CharSequenceUtil.isEmpty(rspStr)) {
-//                        log.error("获取地理位置异常 {}", ip);
-//                        return UNKNOWN;
-//                    }
-//                    JSONObject obj = JSONUtil.parseObj(rspStr);
-//                    String region = obj.getStr("pro");
-//                    String city = obj.getStr("city");
-//                    return String.format("%s %s", region, city);
-//                } catch (Exception e) {
-//                    log.error("获取地理位置异常 {}", ip);
-//                }
-//            }
-//            return address;
-//        }catch (Exception e){
-//            return UNKNOWN;
-//        }
-        return address;
-
-    }
-}

+ 0 - 53
nb-auth/src/main/java/com/nb/auth/utils/IpUtil.java

@@ -1,53 +0,0 @@
-package com.nb.auth.utils;
-
-import cn.hutool.core.util.StrUtil;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * IP获取工具
- *
- * @author Kevin
- */
-public class IpUtil {
-
-    public static String getClientIp(HttpServletRequest request) {
-//        // natapp穿透工具搭建的环境,通过header,X-Natapp-Ip,获取
-//        String ipAddress = ServletUtil.getClientIPByHeader(request, "X-Natapp-Ip");
-//        if (StrUtil.isBlank(ipAddress)) {
-//            ipAddress = ServletUtil.getClientIP(request);
-//        }
-//        // 本地开发,客户端和服务器在同一台机器,获取到是0:0:0:0:0:0:0:1,ip6地址,需要进行转换
-//        ipAddress = "0:0:0:0:0:0:0:1".equals(ipAddress) ? "127.0.0.1" : ipAddress;
-        return getIpAddress(request);
-    }
-
-    public static String getIpAddress(HttpServletRequest request) {
-
-        String sourceIp = null;
-
-        String ipAddresses = request.getHeader("x-forwarded-for");
-
-        if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
-            ipAddresses = request.getHeader("Proxy-Client-IP");
-        }
-        if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
-            ipAddresses = request.getHeader("WL-Proxy-Client-IP");
-        }
-        if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
-            ipAddresses = request.getHeader("HTTP_CLIENT_IP");
-        }
-        if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
-            ipAddresses = request.getHeader("HTTP_X_FORWARDED_FOR");
-        }
-        if (ipAddresses == null || ipAddresses.length() == 0 || "unknown".equalsIgnoreCase(ipAddresses)) {
-            ipAddresses = request.getRemoteAddr();
-        }
-        if (!StrUtil.isEmpty(ipAddresses)) {
-            sourceIp = ipAddresses.split(",")[0];
-        }
-
-        return sourceIp;
-    }
-
-}

+ 0 - 62
nb-auth/src/main/java/com/nb/auth/vo/AccountInfoVO.java

@@ -1,62 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Size;
-import java.io.Serializable;
-
-/**
- * 账户信息VO
- *
- * @author Kevin
- */
-@Data
-public class AccountInfoVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 昵称
-     */
-    @NotBlank(message = "昵称不能为空")
-    @Size(max = 100, message = "昵称长度不能超过100个字符")
-    private String nickname;
-
-    /**
-     * 姓名
-     */
-    @Size(max = 100, message = "姓名长度不能超过100个字符")
-    private String realname;
-
-    /**
-     * 英文名
-     */
-    @Size(max = 100, message = "英文名长度不能超过100个字符")
-    private String englishName;
-
-    /**
-     * 头像
-     */
-    @Size(max = 100, message = "头像长度不能超过100个字符")
-    private String avatar;
-
-    /**
-     * 邮箱
-     */
-    @Size(max = 100, message = "邮箱长度不能超过100个字符")
-    private String email;
-
-    /**
-     * 性别 1男;2女;3未知
-     */
-    @NotBlank(message = "性别不能为空")
-    private String sex;
-
-    /**
-     * 备注
-     */
-    @Size(max = 500, message = "备注长度不能超过500个字符")
-    private String remarks;
-
-}

+ 0 - 17
nb-auth/src/main/java/com/nb/auth/vo/BaseTemplateVO.java

@@ -1,17 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * VO模板类,方便复制该类,创建新类
- *
- * @author Kevin
- */
-@Data
-public class BaseTemplateVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-}

+ 0 - 21
nb-auth/src/main/java/com/nb/auth/vo/RoleInfoVO.java

@@ -1,21 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * 角色VO
- *
- * @author Kevin
- */
-@Data
-public class RoleInfoVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String roleName;
-
-    private String value;
-
-}

+ 0 - 30
nb-auth/src/main/java/com/nb/auth/vo/RouteItemVO.java

@@ -1,30 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * 路由项VO
- *
- * @author Kevin
- */
-@Data
-public class RouteItemVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String path;
-
-    private String component;
-
-    private RouteMetoVO meta;
-
-    private String name;
-
-    private String redirect;
-
-    private List<RouteItemVO> children;
-
-}

+ 0 - 49
nb-auth/src/main/java/com/nb/auth/vo/RouteMetoVO.java

@@ -1,49 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-
-/**
- * 路由MetoVO
- *
- * @author Kevin
- */
-@Data
-public class RouteMetoVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String title;
-
-    private Boolean ignoreAuth;
-
-    private String roles;
-
-    private Boolean ignoreKeepAlive;
-
-    private Boolean affix;
-
-    private String icon;
-
-    private String frameSrc;
-
-    private String transitionName;
-
-    private Boolean hideBreadcrumb;
-
-    private Boolean hideChildrenInMenu;
-
-    private Boolean carryParam;
-
-    private Boolean single;
-
-    private String currentActiveMenu;
-
-    private Boolean hideTab;
-
-    private Boolean hideMenu;
-
-    private Boolean isLink;
-
-}

+ 0 - 35
nb-auth/src/main/java/com/nb/auth/vo/UserInfoVO.java

@@ -1,35 +0,0 @@
-package com.nb.auth.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * 用户信息VO
- *
- * @author Kevin
- */
-@Data
-public class UserInfoVO implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String userId;
-
-    private String username;
-
-    private String realName;
-
-    private String avatar;
-
-    private String desc;
-
-    private String tenantId;
-
-    private String tenantName;
-
-    private List<RoleInfoVO> roles;
-
-    private Boolean isSys;
-}

+ 0 - 37
nb-codegen/pom.xml

@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns="http://maven.apache.org/POM/4.0.0"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>nb-root</artifactId>
-        <groupId>com.tuoren</groupId>
-        <version>1.0</version>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>nb-codegen</artifactId>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-jdbc</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.baomidou</groupId>
-            <artifactId>mybatis-plus-generator</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.velocity</groupId>
-            <artifactId>velocity-engine-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.tuoren</groupId>
-            <artifactId>nb-common</artifactId>
-        </dependency>
-    </dependencies>
-
-</project>

+ 0 - 219
nb-codegen/src/main/java/com/nb/codegen/CodeGenerator.java

@@ -1,219 +0,0 @@
-package com.nb.codegen;
-
-import com.baomidou.mybatisplus.annotation.FieldFill;
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
-import com.baomidou.mybatisplus.generator.AutoGenerator;
-import com.baomidou.mybatisplus.generator.InjectionConfig;
-import com.baomidou.mybatisplus.generator.config.*;
-import com.baomidou.mybatisplus.generator.config.po.TableFill;
-import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-import com.baomidou.mybatisplus.generator.config.rules.DateType;
-import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
-import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
-import com.nb.common.util.IdUtil;
-import com.google.common.collect.Maps;
-
-import java.util.*;
-
-/**
- * 代码生成工具类
- * @author Kevin
- */
-@SuppressWarnings("ALL")
-public class CodeGenerator {
-
-    public static final String JDBC_URL = "jdbc:mysql://localhost:3306/nb-dev?characterEncoding=utf8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai";
-    public static final String JDBC_USERNAME = "root";
-    public static final String JDBC_PASSWORD = "123456";
-    public static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
-
-    /** 按照个人需要,进行修改 */
-    public static final String AUTHOR = "Kevin";
-    public static final String PROJECT_PATH = "D:\\tempCode";
-    public static final String PACKAGE_PARENT = "com.nb";
-    public static final String MODULE_NAME = "system";
-
-    /** 生成SQL脚本的上级菜单的ID,要开发的功能,需要放到XXX菜单下面,请找到XXX菜单的ID */
-    public static final String PARENT_MENU_ID = "1406064334403878913";
-
-    /** admin的ID,可以不用修改 */
-    public static final String CREATE_BY = "1";
-    public static final String UPDATE_BY = "1";
-
-    /** 默认菜单图标,可以不用修改,SQL脚本生成之后,在页面选择图标,进行修改即可 */
-    public static final String ICON = "ant-design:unordered-list-outlined";
-
-    // 是否导出excel
-    public static final Boolean exportExcel = false;
-
-    public static void main(String[] args) {
-        new CodeGenerator().generate(
-                "sys_example"
-        );
-    }
-
-    private void generate(String... tableNamesInclude) {
-        // 代码生成器
-        AutoGenerator mpg = new AutoGenerator();
-
-        // 全局配置
-        GlobalConfig gc = new GlobalConfig();
-        String projectPath = PROJECT_PATH;
-        gc.setOutputDir(projectPath + "/src/main/java");
-        gc.setAuthor(AUTHOR);
-        gc.setOpen(false);
-        gc.setDateType(DateType.ONLY_DATE);
-        //默认不覆盖,如果文件存在,将不会再生成,配置true就是覆盖
-        gc.setFileOverride(true);
-        // gc.setSwagger2(true); 实体属性 Swagger2 注解
-        gc.setBaseResultMap(true);
-        // gc.setBaseColumnList(true); // XML column list
-        mpg.setGlobalConfig(gc);
-
-        // 数据源配置
-        DataSourceConfig dsc = new DataSourceConfig();
-        dsc.setUrl(JDBC_URL);
-        dsc.setDriverName(JDBC_DRIVER);
-        dsc.setUsername(JDBC_USERNAME);
-        dsc.setPassword(JDBC_PASSWORD);
-        mpg.setDataSource(dsc);
-
-        // 包配置
-        PackageConfig pc = new PackageConfig();
-        // 设置模块名,会在指定parent包下生成一个指定的模块包
-        pc.setModuleName(MODULE_NAME);
-        pc.setParent(PACKAGE_PARENT);
-        mpg.setPackageInfo(pc);
-
-        // 自定义配置
-        InjectionConfig cfg = new InjectionConfig() {
-            @Override
-            public void initMap() {
-                // to do nothing
-                Arrays.asList(tableNamesInclude).forEach(item -> {
-                    Map params = Objects.isNull(this.getMap()) ? Maps.newHashMap() : this.getMap();
-                    params.put(item +"menuId", IdUtil.getSnowflakeId());
-                    params.put(item +"parentMenuId", PARENT_MENU_ID);
-                    params.put(item +"icon", ICON);
-                    params.put(item +"pageButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"addButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"editButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"removeButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"viewButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"exportButtonId", IdUtil.getSnowflakeId());
-                    params.put(item +"createBy", CREATE_BY);
-                    params.put(item +"updateBy", UPDATE_BY);
-                    params.put(item +"exportExcel", exportExcel);
-                    this.setMap(params);
-                });
-            }
-        };
-
-        // 如果模板引擎是 freemarker
-        // String templatePath = "/templates/mapper.xml.ftl";
-        // 如果模板引擎是 velocity
-        // String templatePath = "/templates/mapper.xml.vm";
-
-        // 自定义输出配置
-        List<FileOutConfig> focList = new ArrayList<>();
-        // 自定义配置会被优先输出
-        // 调整xml生成目录
-        focList.add(new FileOutConfig("/templates/mapper.xml.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
-            }
-        });
-        // 生成自定义模板
-        focList.add(new FileOutConfig("/templates/addDTO.java.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                String path = PACKAGE_PARENT.replaceAll("\\." , "/") + "/" + MODULE_NAME.replaceAll("\\." , "/");
-                return projectPath + "/src/main/java/" + path + "/common/dto/" + tableInfo.getEntityName() + "AddDTO" + StringPool.DOT_JAVA;
-            }
-        });
-        // 生成自定义模板
-        focList.add(new FileOutConfig("/templates/editDTO.java.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                String path = PACKAGE_PARENT.replaceAll("\\." , "/") + "/" + MODULE_NAME.replaceAll("\\." , "/");
-                return projectPath + "/src/main/java/" + path + "/common/dto/" + tableInfo.getEntityName() + "EditDTO" + StringPool.DOT_JAVA;
-            }
-        });
-        // 生成自定义模板
-        focList.add(new FileOutConfig("/templates/queryDTO.java.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                String path = PACKAGE_PARENT.replaceAll("\\." , "/") + "/" + MODULE_NAME.replaceAll("\\." , "/");
-                return projectPath + "/src/main/java/" + path + "/common/dto/" + tableInfo.getEntityName() + "QueryDTO" + StringPool.DOT_JAVA;
-            }
-        });
-        // 生成自定义模板,SQL
-        focList.add(new FileOutConfig("/templates/sql.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/" + tableInfo.getName() + "_sql.sql";
-            }
-        });
-        // 生成自定义模板,VUE
-        focList.add(new FileOutConfig("/templates/vue/api.ts.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/vue/" + tableInfo.getEntityPath() +"/" + tableInfo.getEntityPath() + "Api.ts";
-            }
-        });
-        // 生成自定义模板,VUE
-        focList.add(new FileOutConfig("/templates/vue/data.ts.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/vue/" + tableInfo.getEntityPath() +"/" + "data.ts";
-            }
-        });
-        // 生成自定义模板,VUE
-        focList.add(new FileOutConfig("/templates/vue/FormModal.vue.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/vue/" + tableInfo.getEntityPath() +"/" + "FormModal.vue";
-            }
-        });
-        // 生成自定义模板,VUE
-        focList.add(new FileOutConfig("/templates/vue/index.vue.vm") {
-            @Override
-            public String outputFile(TableInfo tableInfo) {
-                return projectPath + "/vue/" + tableInfo.getEntityPath() +"/" + "index.vue";
-            }
-        });
-        cfg.setFileOutConfigList(focList);
-        mpg.setCfg(cfg);
-
-        // 配置模板
-        TemplateConfig templateConfig = new TemplateConfig();
-        templateConfig.setXml(null)
-                .setEntity("/templates/entity.java.vm")
-                .setMapper("/templates/mapper.java.vm")
-                .setController("/templates/controller.java.vm")
-                .setService("/templates/service.java.vm")
-                .setServiceImpl("/templates/serviceImpl.java.vm");
-        mpg.setTemplate(templateConfig);
-
-        // 策略配置
-        StrategyConfig strategy = new StrategyConfig();
-        strategy.setNaming(NamingStrategy.underline_to_camel);
-        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
-        strategy.setEntityLombokModel(true);
-        strategy.setRestControllerStyle(true);
-        strategy.setInclude(tableNamesInclude);
-        strategy.setChainModel(false);
-        List<TableFill> tableFillList = new ArrayList<>();
-        tableFillList.add(new TableFill("create_by" , FieldFill.INSERT));
-        tableFillList.add(new TableFill("create_time" , FieldFill.INSERT));
-        tableFillList.add(new TableFill("update_by" , FieldFill.INSERT_UPDATE));
-        tableFillList.add(new TableFill("update_time" , FieldFill.INSERT_UPDATE));
-        strategy.setTableFillList(tableFillList);
-        mpg.setStrategy(strategy);
-        mpg.setTemplateEngine(new VelocityTemplateEngine());
-        mpg.execute();
-        System.out.println(mpg.getTemplateEngine().getObjectMap(new TableInfo()));
-    }
-
-}

+ 0 - 119
nb-codegen/src/main/resources/templates/addDTO.java.vm

@@ -1,119 +0,0 @@
-package ${package.Controller.replace(".controller", "")}.common.dto;
-
-#foreach($pkg in ${table.importPackages})
-#if(${pkg.indexOf("baomidou")}==-1)
-import ${pkg};
-#end
-#end
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-#if(${entityLombokModel})
-import lombok.Data;
-#if(${chainModel})
-import lombok.experimental.Accessors;
-#end
-#end
-
-/**
-* <p>
-* $!{table.comment}
-* </p>
-*
-* @author ${author}
-* @since ${date}
-*/
-#if(${entityLombokModel})
-@Data
-#if(${chainModel})
-@Accessors(chain = true)
-#end
-#end
-public class ${entity}AddDTO implements Serializable {
-
-#if(${entitySerialVersionUID})
-    private static final long serialVersionUID = 1L;
-#end
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-
-#if("$!field.comment" != "")
-    /**
-    * ${field.comment}
-    */
-#end
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-## String
-#if(${field.propertyType.equals("String")})
-#if("$!field.comment" != "")
-    @NotBlank(message = "${field.comment}不能为空")
-    @Size(max = 100, message = "${field.comment}长度不能超过100个字符")
-#else
-    @NotBlank(message = "${field.propertyName}不能为空")
-    @Size(max = 100, message = "${field.propertyName}长度不能超过100个字符")
-#end
-#else
-#if("$!field.comment" != "")
-    @NotNull(message = "${field.comment}不能为空")
-#else
-    @NotNull(message = "${field.propertyName}不能为空")
-#end
-#end
-#end
-    private ${field.propertyType} ${field.propertyName};
-#end
-## ----------END 字段循环遍历----------
-
-#if(!${entityLombokModel})
-#foreach($field in ${table.fields})
-#if(${field.propertyType.equals("boolean")})
-#set($getprefix="is")
-#else
-#set($getprefix="get")
-#end
-
-    public ${field.propertyType} ${getprefix}${field.capitalName}() {
-        return ${field.propertyName};
-    }
-
-#if(${chainModel})
-    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#else
-    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#end
-        this.${field.propertyName} = ${field.propertyName};
-#if(${chainModel})
-        return this;
-#end
-    }
-#end
-## --foreach end---
-#end
-## --end of #if(!${entityLombokModel})--
-
-#if(${entityColumnConstant})
-#foreach($field in ${table.fields})
-    public static final String ${field.name.toUpperCase()} = "${field.name}";
-
-#end
-#end
-#if(!${entityLombokModel})
-    @Override
-    public String toString() {
-        return "${entity}{" +
-#foreach($field in ${table.fields})
-#if($!{foreach.index}==0)
-                "${field.propertyName}=" + ${field.propertyName} +
-#else
-                ", ${field.propertyName}=" + ${field.propertyName} +
-#end
-#end
-        "}";
-    }
-#end
-}

+ 0 - 110
nb-codegen/src/main/resources/templates/controller.java.vm

@@ -1,110 +0,0 @@
-package ${package.Controller};
-
-import com.nb.core.annotation.Log;
-import ${package.Controller.replace(".${package.ModuleName}.controller", "")}.common.result.R;
-import ${package.Controller.replace(".${package.ModuleName}.controller", "")}.common.utils.ExcelUtils;
-import ${package.Controller.replace(".controller", "")}.common.dto.${table.entityName}AddDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${table.entityName}EditDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${table.entityName}QueryDTO;
-import ${package.Entity}.${entity};
-import ${package.Service}.${table.serviceName};
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-
-/**
- * <p>
- * $!{table.comment} 前端控制器
- * </p>
- *
- * @author ${author}
- * @since ${date}
- */
-#if(${restControllerStyle})
-@RestController
-#else
-@Controller
-#end
-@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
-#if(${kotlin})
-class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
-
-#else
-#if(${superControllerClass})
-public class ${table.controllerName} extends ${superControllerClass} {
-#else
-public class ${table.controllerName} {
-#end
-
-    @Resource
-    private ${table.serviceName} ${table.entityPath}Service;
-
-    /**
-    * 分页查询
-    */
-    @GetMapping("/page")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:page')")
-    @Log(title = "$!{table.comment}分页查询")
-    public R page(Page reqPage, ${table.entityName}QueryDTO req) {
-        return R.success(${table.entityPath}Service.page(reqPage, req));
-    }
-
-    /**
-    * 新增
-    */
-    @PostMapping("/add")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:add')")
-    @Log(title = "$!{table.comment}新增")
-    public R add(@Validated @RequestBody ${table.entityName}AddDTO req) {
-        ${table.entityPath}Service.add(req);
-        return R.success();
-    }
-
-    /**
-    * 修改
-    */
-    @PostMapping("/edit")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:edit')")
-    @Log(title = "$!{table.comment}修改")
-    public R edit(@Validated @RequestBody ${table.entityName}EditDTO req) {
-        ${table.entityPath}Service.edit(req);
-        return R.success();
-    }
-
-    /**
-    * 删除
-    */
-    @PostMapping("/remove")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:remove')")
-    @Log(title = "$!{table.comment}删除")
-    public R remove(@RequestParam String ids) {
-        ${table.entityPath}Service.remove(ids);
-        return R.success();
-    }
-
-    /**
-    * 查看
-    */
-    @GetMapping("/view")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:view')")
-    @Log(title = "$!{table.comment}查看")
-    public R view(@RequestParam String id) {
-        return R.success(${table.entityPath}Service.view(id));
-    }
-#if(${cfg.get("${table.name}exportExcel")})
-    /**
-    * 导出
-    */
-    @GetMapping("/export")
-    @PreAuthorize("@ss.hasPermission('#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:export')")
-    @Log(title = "$!{table.comment}导出")
-    public R export(${table.entityName}QueryDTO req) {
-        String filepath = ExcelUtils.export("$!{table.comment}列表", ${table.entityName}.class, ${table.entityPath}Service.list(req));
-        return R.success(filepath);
-    }
-#end
-}
-
-#end

+ 0 - 120
nb-codegen/src/main/resources/templates/editDTO.java.vm

@@ -1,120 +0,0 @@
-package ${package.Controller.replace(".controller", "")}.common.dto;
-
-#foreach($pkg in ${table.importPackages})
-#if(${pkg.indexOf("baomidou")}==-1)
-import ${pkg};
-#end
-#end
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-#if(${entityLombokModel})
-import lombok.Data;
-#if(${chainModel})
-import lombok.experimental.Accessors;
-#end
-#end
-
-/**
-* <p>
-* $!{table.comment}
-* </p>
-*
-* @author ${author}
-* @since ${date}
-*/
-#if(${entityLombokModel})
-@Data
-#if(${chainModel})
-@Accessors(chain = true)
-#end
-#end
-public class ${entity}EditDTO implements Serializable {
-
-#if(${entitySerialVersionUID})
-    private static final long serialVersionUID = 1L;
-#end
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-
-#if("$!field.comment" != "")
-    /**
-    * ${field.comment}
-    */
-#end
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-    @NotNull(message = "主键不能为空")
-#end
-## 普通字段
-#else
-## String
-#if(${field.propertyType.equals("String")})
-#if("$!field.comment" != "")
-    @NotBlank(message = "${field.comment}不能为空")
-    @Size(max = 100, message = "${field.comment}长度不能超过100个字符")
-#else
-    @NotBlank(message = "${field.propertyName}不能为空")
-    @Size(max = 100, message = "${field.propertyName}长度不能超过100个字符")
-#end
-#else
-#if("$!field.comment" != "")
-    @NotNull(message = "${field.comment}不能为空")
-#else
-    @NotNull(message = "${field.propertyName}不能为空")
-#end
-#end
-#end
-    private ${field.propertyType} ${field.propertyName};
-#end
-## ----------END 字段循环遍历----------
-
-#if(!${entityLombokModel})
-#foreach($field in ${table.fields})
-#if(${field.propertyType.equals("boolean")})
-#set($getprefix="is")
-#else
-#set($getprefix="get")
-#end
-
-    public ${field.propertyType} ${getprefix}${field.capitalName}() {
-        return ${field.propertyName};
-    }
-
-#if(${chainModel})
-    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#else
-    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#end
-        this.${field.propertyName} = ${field.propertyName};
-#if(${chainModel})
-        return this;
-#end
-    }
-#end
-## --foreach end---
-#end
-## --end of #if(!${entityLombokModel})--
-
-#if(${entityColumnConstant})
-#foreach($field in ${table.fields})
-    public static final String ${field.name.toUpperCase()} = "${field.name}";
-
-#end
-#end
-#if(!${entityLombokModel})
-    @Override
-    public String toString() {
-        return "${entity}{" +
-#foreach($field in ${table.fields})
-#if($!{foreach.index}==0)
-                "${field.propertyName}=" + ${field.propertyName} +
-#else
-                ", ${field.propertyName}=" + ${field.propertyName} +
-#end
-#end
-        "}";
-    }
-#end
-}

+ 0 - 193
nb-codegen/src/main/resources/templates/entity.java.vm

@@ -1,193 +0,0 @@
-package ${package.Entity};
-
-#if(${cfg.get("${table.name}exportExcel")})
-import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
-import com.alibaba.excel.annotation.ExcelProperty;
-import com.alibaba.excel.annotation.write.style.*;
-import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
-#end
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-#foreach($pkg in ${table.importPackages})
-import ${pkg};
-#end
-#if(${swagger2})
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
-#if(${entityLombokModel})
-import lombok.Data;
-#if(${superEntityClass})
-import lombok.EqualsAndHashCode;
-#end
-#if(${chainModel})
-import lombok.experimental.Accessors;
-#end
-#end
-
-/**
-* <p>
-* $!{table.comment}
-* </p>
-*
-* @author ${author}
-* @since ${date}
-*/
-#if(${entityLombokModel})
-@Data
-#if(${superEntityClass})
-@EqualsAndHashCode(callSuper = true)
-#end
-#if(${chainModel})
-@Accessors(chain = true)
-#end
-#end
-#if(${cfg.get("${table.name}exportExcel")})
-@ColumnWidth(15)
-@HeadRowHeight(15)
-@ContentRowHeight(15)
-@HeadStyle
-@HeadFontStyle(fontHeightInPoints = 12)
-@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER)
-@ContentFontStyle(fontHeightInPoints = 10)
-@ExcelIgnoreUnannotated
-#end
-#if(${table.convert})
-@TableName("${table.name}")
-#end
-#if(${swagger2})
-@ApiModel(value="${entity}对象", description="$!{table.comment}")
-#end
-#if(${superEntityClass})
-public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
-#elseif(${activeRecord})
-public class ${entity} extends Model<${entity}> {
-#else
-public class ${entity} implements Serializable {
-#end
-
-#if(${entitySerialVersionUID})
-    private static final long serialVersionUID = 1L;
-#end
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-
-#if(${field.keyFlag})
-#set($keyPropertyName=${field.propertyName})
-#end
-#if("$!field.comment" != "")
-#if(${swagger2})
-    @ApiModelProperty(value = "${field.comment}")
-#else
-    /**
-    * ${field.comment}
-    */
-#end
-#end
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#elseif(${field.fill})
-## -----存在字段填充设置-----
-#if(${field.convert})
-    @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
-#else
-    @TableField(fill = FieldFill.${field.fill})
-#end
-#elseif(${field.convert})
-    @TableField("${field.annotationColumnName}")
-#end
-## 乐观锁注解
-#if(${versionFieldName}==${field.name})
-    @Version
-#end
-## 逻辑删除注解
-#if(${logicDeleteFieldName}==${field.name})
-    @TableLogic
-#end
-## Long
-#if(${field.propertyType.equals("Long")})
-    @JsonSerialize(using = ToStringSerializer.class)
-#end
-## LocalDateTime
-#if(${field.propertyType.equals("LocalDateTime")} || ${field.propertyType.equals("Date")})
-    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss")
-#if(${cfg.get("${table.name}exportExcel")})
-    @ColumnWidth(20)
-#end
-#end
-#if("$!field.comment" != "")
-    #if(${cfg.get("${table.name}exportExcel")})
-    @ExcelProperty(value = "${field.comment}" , index = ${foreach.index})
-    #end
-#else
-    #if(${cfg.get("${table.name}exportExcel")})
-    @ExcelProperty(value = "${field.propertyName}" , index = ${foreach.index})
-    #end
-#end
-    private ${field.propertyType} ${field.propertyName};
-#end
-## ----------END 字段循环遍历----------
-
-#if(!${entityLombokModel})
-#foreach($field in ${table.fields})
-#if(${field.propertyType.equals("boolean")})
-#set($getprefix="is")
-#else
-#set($getprefix="get")
-#end
-
-    public ${field.propertyType} ${getprefix}${field.capitalName}() {
-        return ${field.propertyName};
-    }
-
-#if(${chainModel})
-    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#else
-    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#end
-        this.${field.propertyName} = ${field.propertyName};
-#if(${chainModel})
-        return this;
-#end
-    }
-#end
-## --foreach end---
-#end
-## --end of #if(!${entityLombokModel})--
-
-#if(${entityColumnConstant})
-#foreach($field in ${table.fields})
-    public static final String ${field.name.toUpperCase()} = "${field.name}";
-
-#end
-#end
-#if(${activeRecord})
-    @Override
-    protected Serializable pkVal() {
-#if(${keyPropertyName})
-        return this.${keyPropertyName};
-#else
-        return null;
-#end
-    }
-
-#end
-#if(!${entityLombokModel})
-    @Override
-    public String toString() {
-        return "${entity}{" +
-#foreach($field in ${table.fields})
-#if($!{foreach.index}==0)
-                "${field.propertyName}=" + ${field.propertyName} +
-#else
-                ", ${field.propertyName}=" + ${field.propertyName} +
-#end
-#end
-        "}";
-    }
-#end
-}

+ 0 - 20
nb-codegen/src/main/resources/templates/mapper.java.vm

@@ -1,20 +0,0 @@
-package ${package.Mapper};
-
-import ${package.Entity}.${entity};
-import ${superMapperClassPackage};
-
-/**
- * <p>
- * $!{table.comment} Mapper 接口
- * </p>
- *
- * @author ${author}
- * @since ${date}
- */
-#if(${kotlin})
-interface ${table.mapperName} : ${superMapperClass}<${entity}>
-#else
-public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
-
-}
-#end

+ 0 - 39
nb-codegen/src/main/resources/templates/mapper.xml.vm

@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="${package.Mapper}.${table.mapperName}">
-
-#if(${enableCache})
-    <!-- 开启二级缓存 -->
-    <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
-
-#end
-#if(${baseResultMap})
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})##生成主键排在第一位
-        <id column="${field.name}" property="${field.propertyName}"/>
-#end
-#end
-#foreach($field in ${table.commonFields})##生成公共字段
-        <result column="${field.name}" property="${field.propertyName}"/>
-#end
-#foreach($field in ${table.fields})
-#if(!${field.keyFlag})##生成普通字段
-        <result column="${field.name}" property="${field.propertyName}"/>
-#end
-#end
-    </resultMap>
-
-#end
-#if(${baseColumnList})
-    <!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-    #foreach($field in ${table.commonFields})
-    ${field.columnName},
-    #end
-    ${table.fieldNames}
-    </sql>
-
-#end
-</mapper>

+ 0 - 94
nb-codegen/src/main/resources/templates/queryDTO.java.vm

@@ -1,94 +0,0 @@
-package ${package.Controller.replace(".controller", "")}.common.dto;
-
-#foreach($pkg in ${table.importPackages})
-#if(${pkg.indexOf("baomidou")}==-1)
-import ${pkg};
-#end
-#end
-#if(${entityLombokModel})
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-#if(${chainModel})
-import lombok.experimental.Accessors;
-#end
-#end
-
-/**
-* <p>
-* $!{table.comment}
-* </p>
-*
-* @author ${author}
-* @since ${date}
-*/
-#if(${entityLombokModel})
-@Data
-#if(${chainModel})
-@Accessors(chain = true)
-#end
-#end
-public class ${entity}QueryDTO implements Serializable {
-
-#if(${entitySerialVersionUID})
-    private static final long serialVersionUID = 1L;
-#end
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-
-#if("$!field.comment" != "")
-    /**
-    * ${field.comment}
-    */
-#end
-    private ${field.propertyType} ${field.propertyName};
-#end
-## ----------END 字段循环遍历----------
-
-#if(!${entityLombokModel})
-#foreach($field in ${table.fields})
-#if(${field.propertyType.equals("boolean")})
-#set($getprefix="is")
-#else
-#set($getprefix="get")
-#end
-
-    public ${field.propertyType} ${getprefix}${field.capitalName}() {
-        return ${field.propertyName};
-    }
-
-#if(${chainModel})
-    public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#else
-    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
-#end
-        this.${field.propertyName} = ${field.propertyName};
-#if(${chainModel})
-        return this;
-#end
-    }
-#end
-## --foreach end---
-#end
-## --end of #if(!${entityLombokModel})--
-
-#if(${entityColumnConstant})
-#foreach($field in ${table.fields})
-    public static final String ${field.name.toUpperCase()} = "${field.name}";
-
-#end
-#end
-#if(!${entityLombokModel})
-    @Override
-    public String toString() {
-        return "${entity}{" +
-#foreach($field in ${table.fields})
-#if($!{foreach.index}==0)
-                "${field.propertyName}=" + ${field.propertyName} +
-#else
-                ", ${field.propertyName}=" + ${field.propertyName} +
-#end
-#end
-        "}";
-    }
-#end
-}

+ 0 - 75
nb-codegen/src/main/resources/templates/service.java.vm

@@ -1,75 +0,0 @@
-package ${package.Service};
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import ${superServiceClassPackage};
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}AddDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}EditDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}QueryDTO;
-import ${package.Entity}.${entity};
-
-import java.util.List;
-
-/**
- * <p>
- * $!{table.comment} 服务类
- * </p>
- *
- * @author ${author}
- * @since ${date}
- */
-#if(${kotlin})
-interface ${table.serviceName} : ${superServiceClass}<${entity}>
-#else
-public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
-    
-    /**
-     * 分页查询
-     *
-     * @param reqPage
-     * @param req
-     * @return
-     */
-    IPage<${entity}> page(Page reqPage, ${entity}QueryDTO req);
-#if(${cfg.get("${table.name}exportExcel")})
-
-    /**
-     * 查询列表
-     *
-     * @param req
-     * @return
-     */
-    List<${entity}> list(${entity}QueryDTO req);
-#end
-
-    /**
-     * 新增
-     *
-     * @param req
-     */
-    void add(${entity}AddDTO req);
-    
-    /**
-     * 修改
-     *
-     * @param req
-     */
-    void edit(${entity}EditDTO req);
-    
-    /**
-     * 删除
-     *
-     * @param deviceIds
-     */
-    void remove(String ids);
-    
-    /**
-     * 查看
-     *
-     * @param id
-     * @return
-     */
-    ${entity} view(String id);
-
-}
-#end

+ 0 - 113
nb-codegen/src/main/resources/templates/serviceImpl.java.vm

@@ -1,113 +0,0 @@
-package ${package.ServiceImpl};
-
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}AddDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}EditDTO;
-import ${package.Controller.replace(".controller", "")}.common.dto.${entity}QueryDTO;
-import ${package.Entity}.${entity};
-import ${package.Mapper}.${table.mapperName};
-import ${package.Service}.${table.serviceName};
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * <p>
- * $!{table.comment} 服务实现类
- * </p>
- *
- * @author ${author}
- * @since ${date}
- */
-@Service
-#if(${kotlin})
-open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {
-
-}
-#else
-public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {
-
-    @Override
-    public IPage<${entity}> page(Page reqPage, ${entity}QueryDTO req) {
-        LambdaQueryWrapper<${entity}> queryWrapper = Wrappers.lambdaQuery();
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-## String
-#if(${field.propertyType.equals("String")})
-        queryWrapper.like(StrUtil.isNotBlank(req.get${field.capitalName}()), ${entity}::get${field.capitalName}, req.get${field.capitalName}());
-#else
-        queryWrapper.eq(Objects.nonNull(req.get${field.capitalName}()), ${entity}::get${field.capitalName}, req.get${field.capitalName}());
-#end
-#end
-#end
-## ----------END 字段循环遍历----------
-        return this.page(reqPage, queryWrapper);
-    }
-#if(${cfg.get("${table.name}exportExcel")})
-    
-    @Override
-    public List<${entity}> list(${entity}QueryDTO req) {
-        LambdaQueryWrapper<${entity}> queryWrapper = Wrappers.lambdaQuery();
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-## String
-#if(${field.propertyType.equals("String")})
-        queryWrapper.like(StrUtil.isNotBlank(req.get${field.capitalName}()), ${entity}::get${field.capitalName}, req.get${field.capitalName}());
-#else
-        queryWrapper.eq(Objects.nonNull(req.get${field.capitalName}()), ${entity}::get${field.capitalName}, req.get${field.capitalName}());
-#end
-#end
-#end
-## ----------END 字段循环遍历----------
-        return this.list(queryWrapper);
-    }
-#end
-    
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void add(${entity}AddDTO req) {
-        ${entity} entity = BeanUtil.copyProperties(req, ${entity}.class);
-        this.save(entity);
-    }
-    
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void edit(${entity}EditDTO req) {
-        ${entity} entity = BeanUtil.copyProperties(req, ${entity}.class);
-        this.updateById(entity);
-    }
-    
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void remove(String ids) {
-        this.removeByIds(Arrays.asList(ids.split(",")));
-    }
-    
-    @Override
-    public ${entity} view(String id) {
-        return this.getById(id);
-    }
-
-}
-#end

+ 0 - 24
nb-codegen/src/main/resources/templates/sql.vm

@@ -1,24 +0,0 @@
--- 菜单 SQL
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}menuId")}', 'menu', '${table.comment}管理', '${cfg.get("${table.name}parentMenuId")}', '${table.entityPath}', '/modules/${package.ModuleName}/${table.entityPath}/index', null, '${cfg.get("${table.name}icon")}', '0', '1', '0', null, null, 1, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
--- 按钮 SQL
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}pageButtonId")}', 'button', '${table.comment}查询', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:page', null, null, null, null, null, null, 1, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}addButtonId")}', 'button', '${table.comment}新增', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:add', null, null, null, null, null, null, 2, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}editButtonId")}', 'button', '${table.comment}修改', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:edit', null, null, null, null, null, null, 3, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}removeButtonId")}', 'button', '${table.comment}删除', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:remove', null, null, null, null, null, null, 4, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}viewButtonId")}', 'button', '${table.comment}查看', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:view', null, null, null, null, null, null, 5, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-
-#if(${cfg.get("${table.name}exportExcel")})
-insert into sys_menu (id, menu_type, menu_name, parent_id, route_path, component, permission, icon, keepalive, link_external, visible, frame, link_url, sort, remarks, create_by, create_time, update_by, update_time)
-values('${cfg.get("${table.name}exportButtonId")}', 'button', '${table.comment}导出', '${cfg.get("${table.name}menuId")}', null, null, '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:export', null, null, null, null, null, null, 6, null, '${cfg.get("${table.name}createBy")}', sysdate(), '${cfg.get("${table.name}updateBy")}', sysdate());
-#end

+ 0 - 65
nb-codegen/src/main/resources/templates/vue/FormModal.vue.vm

@@ -1,65 +0,0 @@
-<template>
-  <BasicModal
-    v-bind="$attrs"
-    destroyOnClose
-    @register="registerModal"
-    :title="getTitle"
-    @ok="handleSubmit"
-  >
-    <BasicForm @register="registerForm" />
-  </BasicModal>
-</template>
-<script lang="ts" setup>
-  import { ref, computed, unref } from 'vue';
-  import { BasicModal, useModalInner } from '/@/components/Modal';
-  import { BasicForm, useForm } from '/@/components/Form';
-  import { useMessage } from '/@/hooks/web/useMessage';
-  import { dataFormSchema } from './data';
-
-  import { addObj, editObj, viewObj } from '/@/api/modules#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}Api';
-
-  const emit = defineEmits(['success', 'register']);
-
-  const getTitle = computed(() => (!unref(isUpdate) ? '新增#if("$!table.comment" != "")${table.comment}#end' : '编辑#if("$!table.comment" != "")${table.comment}#end'));
-  const isUpdate = ref(false);
-  const rowId = ref();
-
-  const { createMessage } = useMessage();
-  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
-    labelWidth: 100,
-    schemas: dataFormSchema,
-    showActionButtonGroup: false,
-    actionColOptions: {
-      span: 23,
-    },
-  });
-  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
-    await resetFields();
-    setModalProps({ confirmLoading: false });
-    isUpdate.value = !!data?.isUpdate;
-
-    if (unref(isUpdate)) {
-      rowId.value = data.record.id;
-      const resData = await viewObj({ id: data.record.id });
-      await setFieldsValue({
-        ...resData,
-      });
-    }
-  });
-
-  // 提交按钮事件
-  async function handleSubmit() {
-    try {
-      const values = await validate();
-      setModalProps({ confirmLoading: true });
-      !unref(isUpdate)
-        ? await addObj({ ...values })
-        : await editObj({ ...values, id: rowId.value });
-      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
-      closeModal();
-      emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
-    } finally {
-      setModalProps({ confirmLoading: false });
-    }
-  }
-</script>

+ 0 - 37
nb-codegen/src/main/resources/templates/vue/api.ts.vm

@@ -1,37 +0,0 @@
-import { defHttp } from '/@/utils/http/axios';
-
-enum Api {
-    fetchList = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/page',
-    addObj = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/add',
-    editObj = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/edit',
-    removeObj = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/remove',
-    viewObj = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/view',
-#if(${cfg.get("${table.name}exportExcel")})
-    exportList = '#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}/export',
-#end
-}
-
-export function fetchList(params?: object) {
-    return defHttp.get({ url: Api.fetchList, params: params });
-}
-
-export function addObj(params?: object) {
-    return defHttp.post({ url: Api.addObj, params: params });
-}
-
-export function editObj(params?: object) {
-    return defHttp.post({ url: Api.editObj, params: params });
-}
-
-export function removeObj(params?: object) {
-    return defHttp.post({ url: Api.removeObj, params: params }, { joinParamsToUrl: true });
-}
-
-export function viewObj(params?: object) {
-    return defHttp.get({ url: Api.viewObj, params: params });
-}
-#if(${cfg.get("${table.name}exportExcel")})
-export function exportList(params?: object) {
-    return defHttp.get({ url: Api.exportList, params: params });
-}
-#end

+ 0 - 65
nb-codegen/src/main/resources/templates/vue/data.ts.vm

@@ -1,65 +0,0 @@
-import { BasicColumn, FormSchema } from '/@/components/Table';
-
-export const columns: BasicColumn[] = [
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-    {
-        title: '#if("$!field.comment" != "")${field.comment}#else${field.propertyName}#end',
-        dataIndex: '${field.propertyName}',
-        width: 120,
-    },
-#end
-#end
-## ----------END 字段循环遍历----------
-];
-
-export const searchFormSchema: FormSchema[] = [
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-    {
-        field: '${field.propertyName}',
-        label: '#if("$!field.comment" != "")${field.comment}#else${field.propertyName}#end',
-        component: 'Input',
-        componentProps: {
-            placeholder: '请输入#if("$!field.comment" != "")${field.comment}#else${field.propertyName}#end',
-        },
-    },
-#end
-#end
-## ----------END 字段循环遍历----------
-];
-
-export const dataFormSchema: FormSchema[] = [
-## ----------BEGIN 字段循环遍历----------
-#foreach($field in ${table.fields})
-#if(${field.keyFlag})
-## 主键
-#if(${field.keyIdentityFlag})
-#end
-## 普通字段
-#else
-    {
-        field: '${field.propertyName}',
-        label: '#if("$!field.comment" != "")${field.comment}#else${field.propertyName}#end',
-        component: 'Input',
-        required: true,
-        componentProps: {
-            placeholder: '请输入#if("$!field.comment" != "")${field.comment}#else${field.propertyName}#end',
-        },
-    },
-#end
-#end
-## ----------END 字段循环遍历----------
-];

+ 0 - 139
nb-codegen/src/main/resources/templates/vue/index.vue.vm

@@ -1,139 +0,0 @@
-<template>
-  <div>
-    <BasicTable @register="registerTable">
-      <template #toolbar>
-        <a-button
-          v-auth="['#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:add']"
-          type="primary"
-          @click="handleCreate"
-          preIcon="ant-design:plus-outlined"
-          >新增</a-button
-        >
-#if(${cfg.get("${table.name}exportExcel")})
-        <a-button
-          v-auth="['#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:export']"
-          color="warning"
-          @click="handleExport"
-          preIcon="ant-design:download-outlined"
-          >导出</a-button
-        >
-#end
-      </template>
-      <template #action="{ record }">
-        <TableAction
-          :actions="[
-            {
-              auth: '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:edit',
-              icon: 'clarity:note-edit-line',
-              tooltip: '编辑',
-              onClick: handleEdit.bind(null, record),
-            },
-            {
-              auth: ['#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:remove'],
-              icon: 'ant-design:delete-outlined',
-              tooltip: '删除',
-              color: 'error',
-              popConfirm: {
-                title: '是否确认删除',
-                confirm: handleDelete.bind(null, record),
-              },
-            },
-          ]"
-        />
-      </template>
-    </BasicTable>
-    <FormModal @register="registerModal" @success="handleSuccess" />
-  </div>
-</template>
-<script lang="ts" setup>
-  import { ref } from 'vue';
-  import { Tag } from 'ant-design-vue';
-  import { BasicTable, useTable, TableAction } from '/@/components/Table';
-  import { useModal } from '/@/components/Modal';
-  import { useMessage } from '/@/hooks/web/useMessage';
-  import FormModal from './FormModal.vue';
-  import { columns, searchFormSchema } from './data';
-
-  import { fetchList, removeObj#if(${cfg.get("${table.name}exportExcel")}), exportList#end } from '/@/api/modules#if(${package.ModuleName})/${package.ModuleName}#end/${table.entityPath}Api';
-#if(${cfg.get("${table.name}exportExcel")})
-  import { downloadFile } from '/@/api/common';
-#end
-
-  const { createMessage, createConfirm } = useMessage();
-  const [registerModal, { openModal }] = useModal();
-  const [registerTable, { reload, getForm }] = useTable({
-    title: '#if("$!table.comment" != "")${table.comment}列表#end',
-    api: fetchList,
-    rowKey: 'id',
-    columns,
-    formConfig: {
-      labelWidth: 120,
-      schemas: searchFormSchema,
-      autoSubmitOnEnter: true,
-      resetButtonOptions: {
-        preIcon: 'ant-design:delete-outlined',
-      },
-      submitButtonOptions: {
-        preIcon: 'ant-design:search-outlined',
-      },
-    },
-    showIndexColumn: false,
-    useSearchForm: true,
-    showTableSetting: true,
-    bordered: true,
-    actionColumn: {
-      auth: ['#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:edit', '#if(${package.ModuleName})${package.ModuleName}:#end${table.entityPath}:remove'],
-      width: 80,
-      title: '操作',
-      dataIndex: 'action',
-      slots: { customRender: 'action' },
-    },
-  });
-
-  // 新增按钮事件
-  function handleCreate() {
-    openModal(true, {
-      isUpdate: false,
-    });
-  }
-
-  // 编辑按钮事件
-  function handleEdit(record: Recordable) {
-    console.log(record);
-    openModal(true, {
-      record,
-      isUpdate: true,
-    });
-  }
-
-  // 删除按钮事件
-  async function handleDelete(record: Recordable) {
-    console.log(record);
-    await removeObj({ ids: record.id });
-    createMessage.success('删除成功!');
-    await reload();
-  }
-#if(${cfg.get("${table.name}exportExcel")})
-
-  // 导出按钮事件
-  async function handleExport() {
-    createConfirm({
-      iconType: 'warning',
-      title: '提示',
-      content: '确认导出?',
-      onOk: async () => {
-        const params = getForm().getFieldsValue();
-        const filepath = await exportList(params);
-        downloadFile(filepath);
-      },
-    });
-  }
-#end
-
-  // 弹窗回调事件
-  async function handleSuccess({ isUpdate, values }) {
-    console.log(isUpdate);
-    console.log(values);
-    await reload();
-  }
-</script>

+ 50 - 0
nb-common/config-common/pom.xml

@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>nb-common</artifactId>
+        <groupId>com.tuoren</groupId>
+        <version>1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>config-common</artifactId>
+
+    <description>一些通用配置</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.tuoren</groupId>
+            <artifactId>nb-auth</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-undertow</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 25 - 0
nb-common/config-common/src/main/java/com/nb/common/config/ApplicationConfig.java

@@ -0,0 +1,25 @@
+//package com.nb.common.config;
+//
+//import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.context.annotation.EnableAspectJAutoProxy;
+//import java.util.TimeZone;
+//
+///**
+// * 开启AOP代理自动配置
+// *
+// * @author Kevin
+// */
+//@Configuration
+//@EnableAspectJAutoProxy(exposeProxy = true)
+//public class ApplicationConfig {
+//    /**
+//     * 时区配置
+//     */
+//    @Bean
+//    public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
+//        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
+//    }
+//
+//}

+ 18 - 0
nb-common/config-common/src/main/java/com/nb/common/config/ConfigAutoConfiguration.java

@@ -0,0 +1,18 @@
+package com.nb.common.config;
+
+import com.nb.common.config.mybatisplus.MybatisPlusConfig;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ConfigAutoConfiguration.java
+ * @Description TODO
+ * @createTime 2022年08月02日 10:03:00
+ */
+@Configuration
+@ComponentScan("com.nb.common.config")
+public class ConfigAutoConfiguration {
+}

+ 34 - 0
nb-common/config-common/src/main/java/com/nb/common/config/ValidatorConfig.java

@@ -0,0 +1,34 @@
+package com.nb.common.config;
+
+import org.hibernate.validator.HibernateValidator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+/**
+ * 校验框架配置类
+ *
+ * @author Kevin
+ */
+@Configuration
+public class ValidatorConfig {
+
+    /**
+     * 配置校验框架 快速返回模式
+     * <p>
+     * Spring Validation默认会校验完所有字段,然后才抛出异常。
+     * 可以通过一些简单的配置,开启Fali Fast模式,一旦校验失败就立即返回。
+     */
+    @Bean
+    public Validator validator() {
+        ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
+                .configure()
+                .failFast(true)
+                .buildValidatorFactory();
+        return validatorFactory.getValidator();
+    }
+
+}

+ 141 - 0
nb-common/config-common/src/main/java/com/nb/common/config/WebAppMvcConfig.java

@@ -0,0 +1,141 @@
+package com.nb.common.config;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.StringSerializer;
+import com.nb.common.config.serializer.BooleanToIntegerSerializer;
+import com.nb.common.config.serializer.EnumDeserializer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * @Description TODO
+ * @Classname Knife4jWebMvcConfig
+ * @Date 2021/3/2 15:27
+ * @Created by jianxiapc
+ */
+@Configuration
+@EnableAutoConfiguration
+@EnableAspectJAutoProxy(exposeProxy = true)
+public class WebAppMvcConfig implements WebMvcConfigurer {
+    @Autowired
+    @Lazy
+    private ObjectMapper objectMapper;
+
+    @Autowired(required = false)
+    private List<HandlerInterceptor> interceptors;
+
+
+    @Bean
+    public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
+        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
+    }
+
+    @Override
+    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
+        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
+        // 时间格式化
+        SerializerProvider serializerProvider = objectMapper.getSerializerProvider();
+        serializerProvider.setNullValueSerializer(new JsonSerializer<Object>() {
+            @Override
+            public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+                gen.writeNull();
+            }
+        });
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
+
+        SimpleModule booleanSimpleModule = new SimpleModule();
+        booleanSimpleModule.addSerializer(Boolean.class, new BooleanToIntegerSerializer());
+        booleanSimpleModule.addDeserializer(Boolean.class, new StdScalarDeserializer<Boolean>(Object.class) {
+            @Override
+            public Boolean deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+                String text = p.getText();
+                if (StrUtil.isBlank(text)) {
+                    return null;
+                }
+                String lowerCase = text.toLowerCase();
+                if("true".equals(lowerCase)||"1".equals(lowerCase)){
+                    return Boolean.TRUE;
+                }else if("false".equals(lowerCase)||"0".equals(lowerCase)){
+                    return Boolean.FALSE;
+                }
+                return null;
+            }
+        });
+
+        SimpleModule stringModule = new SimpleModule();
+        stringModule.addSerializer(String.class,new StringSerializer());
+        stringModule.addDeserializer(String.class, new StdScalarDeserializer<String>(String.class) {
+            @Override
+            public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+                String text = p.getText();
+                return StrUtil.isBlankIfStr(text)?null:text;
+            }
+        });
+        SimpleModule enumModule = new SimpleModule();
+        enumModule.addDeserializer(Enum.class, new EnumDeserializer());
+
+//        objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>() {
+//            @Override
+//            public void serialize(Object param, JsonGenerator jsonGenerator,
+//                                  SerializerProvider paramSerializerProvider) throws IOException {
+//                jsonGenerator.writeString("");
+//            }
+//        });
+
+        objectMapper.registerModule(enumModule);
+        objectMapper.registerModule(stringModule);
+        objectMapper.registerModule(booleanSimpleModule);
+        // 设置格式化内容
+        converter.setObjectMapper(objectMapper);
+        converters.add(0, converter);
+    }
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+
+        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
+
+        /** 配置knife4j 显示文档 */
+        registry.addResourceHandler("doc.html")
+                .addResourceLocations("classpath:/META-INF/resources/");
+
+        /**
+         * 配置swagger-ui显示文档
+         */
+        registry.addResourceHandler("swagger-ui.html")
+                .addResourceLocations("classpath:/META-INF/resources/");
+        /** 公共部分内容 */
+        registry.addResourceHandler("/webjars/**")
+                .addResourceLocations("classpath:/META-INF/resources/webjars/");
+    }
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        if(CollectionUtil.isNotEmpty(interceptors)){
+            interceptors.forEach(registry::addInterceptor);
+        }
+    }
+}

+ 82 - 0
nb-common/config-common/src/main/java/com/nb/common/config/apply/ApplyManager.java

@@ -0,0 +1,82 @@
+package com.nb.common.config.apply;
+
+import java.util.Collection;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName ApplyManagerc.java
+ * @Description
+ * @see  com.nb.web.service.system.config.DefaultApplyManager
+ * @createTime 2022年07月27日 10:46:00
+ */
+public interface ApplyManager {
+    /**
+     * 描述: 产生appKey
+     * @author lifang
+     * @date 2022/7/27 10:52
+     * @param timestamp
+     * @return String
+     */
+    String generateAppKey(Long timestamp);
+
+    /**
+     * 描述: 根据appKey产生appSecret
+     * @author lifang
+     * @date 2022/7/27 10:53
+     * @param appKey
+     * @return String
+     */
+    String generateAppSecret(String appKey);
+
+    /**
+     * 描述: 根据appKey获取appSecret
+     * @author lifang
+     * @date 2022/7/27 10:53
+     * @param appKey
+     * @return String
+     */
+    String getAppSecret(String appKey);
+
+    /**
+     * 描述: 缓存appKey和appSecret
+     * @author lifang
+     * @date 2022/7/27 10:54
+     * @param appKey
+     * @param appSecret
+     * @return void
+     */
+    void setApply(String appKey,String appSecret,String tenantId);
+
+    /**
+     * 描述: 获取相应的医院id
+     * @author lifang
+     * @date 2022/7/27 14:37
+     * @param appKey
+     * @return String
+     */
+    String getTenantId(String appKey);
+
+
+    /**
+     * 描述: 获取相应的全现集合
+     * @author lifang
+     * @date 2022/7/27 14:38
+     * @param appKey
+     * @return Collection<String>
+     */
+    Collection<String> getPermission(String appKey);
+
+    void setPermission(String appKey, Collection<String> permission);
+
+    void refreshPermission(String appKey);
+
+    /**
+     * 描述: 删除appKey
+     * @author lifang
+     * @date 2022/7/27 16:12
+     * @param appKey
+     * @return void
+     */
+    void remove(String appKey);
+}

+ 59 - 0
nb-common/config-common/src/main/java/com/nb/common/config/aspect/DataSourceAspect.java

@@ -0,0 +1,59 @@
+package com.nb.common.config.aspect;
+
+import com.nb.core.annotation.DataSource;
+import com.nb.common.config.datasource.DynamicDataSourceContextHolder;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+import java.util.Objects;
+
+/**
+ * 多数据源处理
+ *
+ * @author Kevin
+ */
+@Aspect
+@Order(1)
+@Component
+@Slf4j
+public class DataSourceAspect {
+
+    @Pointcut("@annotation(com.nb.core.annotation.DataSource)"
+            + "|| @within(com.nb.core.annotation.DataSource)")
+    public void dsPointCut() {
+
+    }
+
+    @Around("dsPointCut()")
+    public Object around(ProceedingJoinPoint point) throws Throwable {
+        DataSource dataSource = getDataSource(point);
+        if (Objects.nonNull(dataSource)) {
+            DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name());
+        }
+        try {
+            return point.proceed();
+        } finally {
+            // 销毁数据源 在执行方法之后
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
+    }
+
+    /**
+     * 获取需要切换的数据源
+     */
+    public DataSource getDataSource(ProceedingJoinPoint point) {
+        MethodSignature signature = (MethodSignature) point.getSignature();
+        DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);
+        if (Objects.nonNull(dataSource)) {
+            return dataSource;
+        }
+        return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
+    }
+}

+ 17 - 0
nb-common/config-common/src/main/java/com/nb/common/config/bo/DictModel.java

@@ -0,0 +1,17 @@
+package com.nb.common.config.bo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 字典模型
+ *
+ * @author Kevin
+ */
+@Data
+public class DictModel implements Serializable {
+
+    String label;
+    String value;
+}

+ 49 - 0
nb-common/config-common/src/main/java/com/nb/common/config/convert/ExcelDictConverter.java

@@ -0,0 +1,49 @@
+package com.nb.common.config.convert;
+
+import cn.hutool.core.annotation.AnnotationUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.excel.converters.Converter;
+import com.alibaba.excel.enums.CellDataTypeEnum;
+import com.alibaba.excel.metadata.GlobalConfiguration;
+import com.alibaba.excel.metadata.data.ReadCellData;
+import com.alibaba.excel.metadata.data.WriteCellData;
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
+import com.nb.common.config.utils.DictUtil;
+import com.nb.core.annotation.ExcelDict;
+
+import java.lang.reflect.Field;
+
+/**
+ * Excel数据字典转换器
+ *
+ * @author Kevin
+ */
+public class ExcelDictConverter implements Converter<String> {
+
+    @Override
+    public Class supportJavaTypeKey() {
+        return String.class;
+    }
+
+    @Override
+    public CellDataTypeEnum supportExcelTypeKey() {
+        return CellDataTypeEnum.STRING;
+    }
+
+    @Override
+    public String convertToJavaData(ReadCellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
+        Field field = excelContentProperty.getField();
+        String dictCode = AnnotationUtil.getAnnotationValue(field, ExcelDict.class);
+        String dictValue = DictUtil.getDictValue(dictCode, cellData.getStringValue());
+        return StrUtil.isBlank(dictValue) ? cellData.getStringValue() : dictValue;
+    }
+
+    @Override
+    public WriteCellData convertToExcelData(String s, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
+        Field field = excelContentProperty.getField();
+        String dictCode = AnnotationUtil.getAnnotationValue(field, ExcelDict.class);
+        String dictLabel = DictUtil.getDictLabel(dictCode, s);
+        return new WriteCellData(StrUtil.isBlank(dictLabel) ? s : dictLabel);
+    }
+
+}

+ 107 - 0
nb-common/config-common/src/main/java/com/nb/common/config/datasource/DruidConfig.java

@@ -0,0 +1,107 @@
+package com.nb.common.config.datasource;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
+import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
+import com.alibaba.druid.util.Utils;
+import com.nb.core.enums.DataSourceTypeEnum;
+import com.nb.common.config.properties.DruidProperties;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.servlet.*;
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * druid 配置多数据源
+ *
+ * @author Kevin
+ */
+@Configuration
+public class DruidConfig {
+    @Bean
+    @ConfigurationProperties("spring.datasource.druid.master")
+    public DataSource masterDataSource(DruidProperties druidProperties) {
+        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        return druidProperties.dataSource(dataSource);
+    }
+
+    @Bean
+    @ConfigurationProperties("spring.datasource.druid.slave")
+    @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
+    public DataSource slaveDataSource(DruidProperties druidProperties) {
+        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        return druidProperties.dataSource(dataSource);
+    }
+
+    @Bean(name = "dynamicDataSource")
+    @Primary
+    public DynamicDataSource dataSource(DataSource masterDataSource) {
+        Map<Object, Object> targetDataSources = new HashMap<>();
+        targetDataSources.put(DataSourceTypeEnum.MASTER.name(), masterDataSource);
+        setDataSource(targetDataSources, DataSourceTypeEnum.SLAVE.name(), "slaveDataSource");
+        return new DynamicDataSource(masterDataSource, targetDataSources);
+    }
+
+    /**
+     * 设置数据源
+     *
+     * @param targetDataSources 备选数据源集合
+     * @param sourceName        数据源名称
+     * @param beanName          bean名称
+     */
+    public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) {
+        try {
+            DataSource dataSource = SpringUtil.getBean(beanName);
+            targetDataSources.put(sourceName, dataSource);
+        } catch (Exception e) {
+        }
+    }
+
+    /**
+     * 去除监控页面底部的广告
+     */
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    @Bean
+    @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
+    public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
+        // 获取web监控页面的参数
+        DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
+        // 提取common.js的配置路径
+        String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*";
+        String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
+        final String filePath = "support/http/resources/js/common.js";
+        // 创建filter进行过滤
+        Filter filter = new Filter() {
+            @Override
+            public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
+            }
+
+            @Override
+            public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+                chain.doFilter(request, response);
+                String text = Utils.readFromResource(filePath);
+                /** 正则替换banner, 除去底部的广告信息 **/
+                text = text.replaceAll("<a.*?banner\"></a><br/>", "");
+                text = text.replaceAll("powered.*?shrek.wang</a>", "");
+                response.getWriter().write(text);
+            }
+
+            @Override
+            public void destroy() {
+            }
+        };
+        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
+        registrationBean.setFilter(filter);
+        registrationBean.addUrlPatterns(commonJsPattern);
+        return registrationBean;
+    }
+}

+ 25 - 0
nb-common/config-common/src/main/java/com/nb/common/config/datasource/DynamicDataSource.java

@@ -0,0 +1,25 @@
+package com.nb.common.config.datasource;
+
+import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
+
+import javax.sql.DataSource;
+import java.util.Map;
+
+/**
+ * 动态数据源
+ *
+ * @author Kevin
+ */
+public class DynamicDataSource extends AbstractRoutingDataSource {
+
+    public DynamicDataSource(DataSource defaultTargetDataSource, Map<Object, Object> targetDataSources) {
+        super.setDefaultTargetDataSource(defaultTargetDataSource);
+        super.setTargetDataSources(targetDataSources);
+        super.afterPropertiesSet();
+    }
+
+    @Override
+    protected Object determineCurrentLookupKey() {
+        return DynamicDataSourceContextHolder.getDataSourceType();
+    }
+}

+ 40 - 0
nb-common/config-common/src/main/java/com/nb/common/config/datasource/DynamicDataSourceContextHolder.java

@@ -0,0 +1,40 @@
+package com.nb.common.config.datasource;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 数据源切换处理
+ *
+ * @author Kevin
+ */
+@Slf4j
+public class DynamicDataSourceContextHolder {
+
+    /**
+     * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本,
+     * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
+     */
+    private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
+
+    /**
+     * 获得数据源的变量
+     */
+    public static String getDataSourceType() {
+        return CONTEXT_HOLDER.get();
+    }
+
+    /**
+     * 设置数据源的变量
+     */
+    public static void setDataSourceType(String dsType) {
+        log.info("切换到{}数据源", dsType);
+        CONTEXT_HOLDER.set(dsType);
+    }
+
+    /**
+     * 清空数据源变量
+     */
+    public static void clearDataSourceType() {
+        CONTEXT_HOLDER.remove();
+    }
+}

+ 38 - 0
nb-common/config-common/src/main/java/com/nb/common/config/event/EventConfig.java

@@ -0,0 +1,38 @@
+package com.nb.common.config.event;
+
+import com.nb.common.config.notice.msg.LifeCycleMsg;
+import com.nb.common.config.notice.wechat.EnterpriseWeChatNotify;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName EventConfig.java
+ * @Description TODO
+ * @createTime 2022年07月19日 17:09:00
+ */
+@Configuration
+@ConditionalOnBean(EnterpriseWeChatNotify.class)
+public class EventConfig implements CommandLineRunner, DisposableBean {
+    @Autowired
+    private EnterpriseWeChatNotify notify;
+
+    @Value("${spring.application.name}")
+    private String applicationName;
+
+
+    @Override
+    public void destroy() throws Exception {
+        notify.send(LifeCycleMsg.of(true,applicationName));
+    }
+
+    @Override
+    public void run(String... args) throws Exception {
+        notify.send(LifeCycleMsg.of(false,applicationName));
+    }
+}

+ 12 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/GetNameInterface.java

@@ -0,0 +1,12 @@
+package com.nb.common.config.mybatisplus;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName GetNameInterface.java
+ * @Description TODO
+ * @createTime 2022年03月22日 17:22:00
+ */
+public interface GetNameInterface<PK,T> {
+    T getName(PK id);
+}

+ 61 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/MybatisPlusConfig.java

@@ -0,0 +1,61 @@
+package com.nb.common.config.mybatisplus;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.*;
+import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.MySqlDialect;
+import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+/**
+ * mybatis-plus配置类
+ *
+ * @author Kevin
+ */
+@EnableTransactionManagement(proxyTargetClass = true)
+@Configuration
+public class MybatisPlusConfig {
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor(TenantLineInnerInterceptor tenantLineInnerInterceptor) {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        //多租户插件
+        interceptor.addInnerInterceptor(tenantLineInnerInterceptor);
+
+        // 分页插件
+        interceptor.addInnerInterceptor(paginationInnerInterceptor());
+
+        //禁止全表更新
+        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
+
+        // 乐观锁插件
+        interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());
+
+        return interceptor;
+    }
+
+    /**
+     * 分页插件
+     */
+    @Bean
+    public PaginationInnerInterceptor paginationInnerInterceptor() {
+        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
+
+        // 设置数据库类型为mysql
+        paginationInnerInterceptor.setDbType(DbType.MYSQL);
+        // 设置最大单页限制数量,默认 500 条,-1 不受限制
+        paginationInnerInterceptor.setMaxLimit(-1L);
+        paginationInnerInterceptor.setDialect(new MySqlDialect());
+
+        return paginationInnerInterceptor;
+    }
+
+    /**
+     * 乐观锁插件
+     */
+    public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
+        return new OptimisticLockerInnerInterceptor();
+    }
+
+}

+ 60 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/TenantNameHandler.java

@@ -0,0 +1,60 @@
+package com.nb.common.config.mybatisplus;
+
+import cn.hutool.core.text.CharSequenceUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+import org.apache.ibatis.type.TypeHandler;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DateToBigIntHandler.java
+ * @Description TODO
+ * @createTime 2022年03月21日 09:58:00
+ */
+@MappedTypes(String.class)
+@MappedJdbcTypes(JdbcType.VARCHAR)
+public class TenantNameHandler implements TypeHandler<String> {
+
+    private GetNameInterface<String,String> getHospitalName;
+
+
+    @Override
+    public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) {
+
+    }
+
+    @Override
+    public String getResult(ResultSet rs, String columnName) throws SQLException {
+        if(getHospitalName==null){
+            getHospitalName= SpringUtil.getBean(GetNameInterface.class);
+        }
+        if (CharSequenceUtil.isNotBlank(rs.getString(columnName))) {
+            return getHospitalName.getName( rs.getString(columnName));
+        }
+        return null;
+    }
+
+    @Override
+    public String getResult(ResultSet rs, int columnIndex) throws SQLException {
+        if(getHospitalName==null){
+            getHospitalName= SpringUtil.getBean(GetNameInterface.class);
+        }
+        return getHospitalName.getName( rs.getString(columnIndex));
+    }
+
+    @Override
+    public String getResult(CallableStatement cs, int columnIndex) throws SQLException {
+        if(getHospitalName==null){
+            getHospitalName= SpringUtil.getBean(GetNameInterface.class);
+        }
+        return getHospitalName.getName( cs.getString(columnIndex));
+    }
+}

+ 84 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java

@@ -0,0 +1,84 @@
+package com.nb.common.config.mybatisplus.handler;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import com.nb.auth.bean.LoginUser;
+import com.nb.auth.utils.SecurityUtil;
+import com.nb.core.exception.CustomException;
+import com.nb.core.result.ResultCode;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import java.util.Date;
+import java.util.Objects;
+
+import static org.springframework.web.context.request.RequestAttributes.SCOPE_REQUEST;
+
+/**
+ * MP注入处理器
+ *
+ * @author Kevin
+ */
+@Component
+public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
+
+    public static final String CREATE_TIME = "createTime";
+    public static final String UPDATE_TIME = "updateTime";
+
+    public static final String CREATE_BY = "createBy";
+    public static final String UPDATE_BY = "updateBy";
+
+    public static final String IS_DELETE = "isDelete";
+
+    public static final String TENANT_ID="tenantId";
+
+    @Override
+    public void insertFill(MetaObject metaObject) {
+        try {
+            if (metaObject.hasGetter(CREATE_TIME) && metaObject.getValue(CREATE_TIME) == null) {
+                this.strictInsertFill(metaObject, CREATE_TIME, Date.class, new Date());
+            }
+            if (metaObject.hasGetter(IS_DELETE) && metaObject.getValue(IS_DELETE) == null) {
+                this.strictInsertFill(metaObject, IS_DELETE, Integer.class,0);
+            }
+            if (metaObject.hasGetter(CREATE_BY) && metaObject.getValue(CREATE_BY) == null) {
+                LoginUser loginUser = SecurityUtil.getLoginUser();
+                this.strictInsertFill(metaObject, CREATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
+            }
+            if (metaObject.hasGetter(UPDATE_TIME) && metaObject.getValue(UPDATE_TIME) == null) {
+                this.strictUpdateFill(metaObject, UPDATE_TIME, Date.class, new Date());
+            }
+            if (metaObject.hasGetter(UPDATE_BY) && metaObject.getValue(UPDATE_BY) == null) {
+                LoginUser loginUser = SecurityUtil.getLoginUser();
+                this.strictUpdateFill(metaObject, UPDATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
+            }
+            if (metaObject.hasGetter(TENANT_ID) && metaObject.getValue(TENANT_ID) == null) {
+                ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+                String tenantId ="1";
+                if(request!=null){
+                    tenantId = String.valueOf(request.getAttribute("tenantId", SCOPE_REQUEST));
+                }
+                this.strictInsertFill(metaObject, TENANT_ID, String.class, tenantId);
+            }
+        } catch (Exception e) {
+            throw new CustomException(ResultCode.INTERNAL_SERVER_ERROR.getMessage());
+        }
+    }
+
+    @Override
+    public void updateFill(MetaObject metaObject) {
+        try {
+            if (metaObject.hasGetter(UPDATE_TIME) && metaObject.getValue(UPDATE_TIME) == null) {
+                this.strictUpdateFill(metaObject, UPDATE_TIME, Date.class, new Date());
+            }
+            if (metaObject.hasGetter(UPDATE_BY) && metaObject.getValue(UPDATE_BY) == null) {
+                LoginUser loginUser = SecurityUtil.getLoginUser();
+                this.strictUpdateFill(metaObject, UPDATE_BY, String.class, Objects.isNull(loginUser) ? null : loginUser.getId().toString());
+            }
+        } catch (Exception e) {
+            throw new CustomException(ResultCode.INTERNAL_SERVER_ERROR.getMessage());
+        }
+    }
+
+}

+ 118 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/interceptor/DefaultTenantLineInnerInterceptor.java

@@ -0,0 +1,118 @@
+package com.nb.common.config.mybatisplus.interceptor;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ClassUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
+import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
+import com.nb.auth.bean.LoginUser;
+import com.nb.auth.utils.SecurityUtil;
+import com.nb.core.entity.TenantGenericEntity;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.StringValue;
+import net.sf.jsqlparser.schema.Column;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.springframework.web.context.request.RequestAttributes.SCOPE_REQUEST;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName DefaultTenantLineInnerInterceptor.java
+ * @Description 默认多租户插件
+ * @createTime 2022年08月02日 08:50:00
+ */
+@ConditionalOnMissingBean({TenantLineInnerInterceptor.class})
+@ConditionalOnBean(TenantIdManager.class)
+@Configuration
+public class DefaultTenantLineInnerInterceptor {
+    private final List<String> ignoreUrlTenantId= Arrays.asList("/login","/getUserInfo","/token");
+    private final List<Class<?>> tableClass;
+
+    private Set<String> ignoreTableName;
+
+    public  DefaultTenantLineInnerInterceptor(){
+        Set<Class<?>> classes = ClassUtil.scanPackage("com.nb");
+        //找到所有@TableName修饰的类
+        tableClass = classes.stream()
+                .filter(aClass -> ObjectUtil.isNotNull(aClass.getAnnotation(TableName.class)))
+                .collect(Collectors.toList());
+        if (CollectionUtil.isNotEmpty(tableClass)) {
+            ignoreTableName =
+                    tableClass
+                            .stream()
+                            .filter(aClass -> !ClassUtil.isAssignable(TenantGenericEntity.class,aClass) )
+                            .map(aClass -> {
+                                TableName tableName = aClass.getAnnotation(TableName.class);
+                                return tableName.value();
+                            })
+                            .collect(Collectors.toSet());
+        }
+        ignoreTableName = Optional.ofNullable(ignoreTableName).orElse(new HashSet<>());
+        //兼容框架已有entity
+        ignoreTableName.addAll(classes
+                .stream()
+                .filter(aClass -> ObjectUtil.isNull(aClass.getAnnotation(TableName.class)))
+                .map(aClass -> StrUtil.toUnderlineCase(aClass.getSimpleName()))
+                .collect(Collectors.toSet()));
+    }
+    /**
+     * 多租户插件
+     */
+    @Bean
+    public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantIdManager tenantIdManager) {
+        TenantLineInnerInterceptor tenantInterceptor = new TenantLineInnerInterceptor();
+        tenantInterceptor.setTenantLineHandler(new TenantLineHandler() {
+            @Override
+            public Expression getTenantId() {
+                return new StringValue(tenantIdManager.getCurrentTenantId());
+            }
+
+            @Override
+            public boolean ignoreTable(String tableName) {
+                ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+                //非用户请求,即来自程序自身,则忽略
+                if(request==null||request.getRequest() instanceof MockHttpServletRequest){
+                    return true;
+                }
+                StringBuffer url = request.getRequest().getRequestURL();
+                if(ignoreUrlTenantId.stream().anyMatch(ignoreUrl->url.toString().endsWith(ignoreUrl))){
+                    return true;
+                }
+                if(CollectionUtil.isNotEmpty(ignoreTableName)&&ignoreTableName.contains(tableName)){
+                    return true;
+                }
+                // 判断当前有用户是否为系统级用户,若是,则忽略逻辑隔离
+                LoginUser loginUser = SecurityUtil.getLoginUser();
+                if(loginUser==null){
+                    //未登录
+                    return false;
+                }
+                if(Boolean.TRUE.equals(loginUser.isSys())){
+                    String tenantId = String.valueOf( request.getAttribute("tenantId", SCOPE_REQUEST));
+                    if(StrUtil.isNullOrUndefined(tenantId)){
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            @Override
+            public boolean ignoreInsert(List<Column> columns, String tenantIdColumn) {
+                return columns.stream().anyMatch(column -> column.getColumnName().equals(tenantIdColumn));
+            }
+        });
+        return tenantInterceptor;
+    }
+}

+ 33 - 0
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/interceptor/TenantIdManager.java

@@ -0,0 +1,33 @@
+package com.nb.common.config.mybatisplus.interceptor;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import static org.springframework.web.context.request.RequestAttributes.SCOPE_REQUEST;
+
+/**
+ * 管理当前用户的租户ID
+ */
+@Component
+public class TenantIdManager {
+    /**
+     * 返回当前用户租户ID
+     * @return
+     */
+    public String getCurrentTenantId() {
+        //判断是否为request请求
+        ServletRequestAttributes request = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        if(request==null){
+            return "";
+        }
+        StringBuffer url = request.getRequest().getRequestURL();
+        if(url.toString().endsWith("/login")){
+            return "";
+        }
+        String tenantId = String.valueOf( request.getAttribute("tenantId", SCOPE_REQUEST));
+        return StrUtil.isNullOrUndefined(tenantId)?"":tenantId;
+    }
+
+}

+ 63 - 0
nb-common/config-common/src/main/java/com/nb/common/config/notice/NotifyEnums.java

@@ -0,0 +1,63 @@
+package com.nb.common.config.notice;
+
+import cn.hutool.core.date.DateUtil;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName NotifyEnums.java
+ * @Description 通知类型
+ * @createTime 2022年07月19日 15:24:00
+ */
+@AllArgsConstructor
+@Getter
+public enum  NotifyEnums {
+    ERROR("系统运行错误日志通知"){
+        @Override
+        public String getMarkDownTitle() {
+            return String.format("%s\n" +
+                    "<font color=\"warning\">**%s**</font>,请相关同事注意。\n", DateUtil.now(),ERROR.text);
+        }
+    },
+    LIFECYCLE("服务器生命周期"){
+        @Override
+        public String getMarkDownTitle() {
+            return String.format("%s\n" +
+                    "<font color=\"info\">**%s**</font>,请相关同事注意。\n", DateUtil.now(),LIFECYCLE.text);
+        }
+    },
+    RESOURCE("服务器资源监控"){
+        @Override
+        public  String getMarkDownTitle() {
+            return String.format("%s\n" +
+                    "<font color=\"info\">**%s**</font>,请相关同事注意。\n", DateUtil.now(),RESOURCE.text);
+        }
+    },
+    INTERFACE("接口流量监控"){
+        @Override
+        public String getMarkDownTitle() {
+            return String.format("%s\n" +
+                    "<font color=\"info\">**%s**</font>,请相关同事注意。\n", DateUtil.now(),INTERFACE.text);
+        }
+    },
+    DEVICE("设备流量监控"){
+        @Override
+        public String getMarkDownTitle() {
+            return String.format("%s\n" +
+                    "<font color=\"info\">**%s**</font>,请相关同事注意。\n", DateUtil.now(),DEVICE.text);
+        }
+    }
+    ;
+    private String text;
+
+    /**
+     * 描述: 获取相关通知的markDown标题
+     * @author lifang
+     * @date 2022/7/19 15:52
+     * @param
+     * @return String
+     */
+    public abstract String getMarkDownTitle();
+}

+ 87 - 0
nb-common/config-common/src/main/java/com/nb/common/config/notice/SystemMonitor.java

@@ -0,0 +1,87 @@
+package com.nb.common.config.notice;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.SneakyThrows;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.function.Function;
+
+@AllArgsConstructor
+@Getter
+public enum SystemMonitor {
+    systemCpuUsage("系统CPU使用率"),
+    systemCpuLoad("系统平均负载"),
+    jvmCpuUsage("JVM进程CPU使用率"),
+    freeSystemMemory("系统空闲内存"),
+    totalSystemMemory("系统总内存"),
+    openFileCount("已打开文件数"),
+    maxOpenFileCount("最大打开文件数"),
+    ;
+
+    private String text;
+
+    public double getValue() {
+        return getValue(name());
+    }
+    static OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
+
+    private static Map<String, Callable<Double>> items = new HashMap<>();
+
+        private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
+            "com.sun.management.OperatingSystemMXBean", // HotSpot
+            "com.ibm.lang.management.OperatingSystemMXBean" // J9
+        );
+
+    private static Callable<Double> zero = () -> 0D;
+
+    private static Class<?> mxBeanClass;
+
+    private static void register(String item, String methodName, Function<Double, Double> mapping) {
+        try {
+            Method method = mxBeanClass.getMethod(methodName);
+            items.put(item, () -> mapping.apply(((Number) method.invoke(osMxBean)).doubleValue()));
+        } catch (Exception e) {
+
+        }
+    }
+
+    static {
+        for (String s : OPERATING_SYSTEM_BEAN_CLASS_NAMES) {
+            try {
+                mxBeanClass = Class.forName(s);
+            } catch (Exception ignore) {
+            }
+        }
+        try {
+            if (mxBeanClass != null) {
+                register(systemCpuUsage.name(), "getSystemCpuLoad", usage -> usage * 100D);
+                register(systemCpuLoad.name(), "getSystemLoadAverage", Function.identity());
+                register(jvmCpuUsage.name(), "getProcessCpuLoad", usage -> usage * 100D);
+                register(freeSystemMemory.name(), "getFreePhysicalMemorySize", val -> val / 1024 / 1024);
+                register(totalSystemMemory.name(), "getTotalPhysicalMemorySize", val -> val / 1024 / 1024);
+                register("virtualMemory", "getCommittedVirtualMemorySize", val -> val / 1024 / 1024);
+                register(openFileCount.name(), "getOpenFileDescriptorCount", Function.identity());
+                register(maxOpenFileCount.name(), "getMaxFileDescriptorCount", Function.identity());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @SneakyThrows
+    public static double getValue(String id) {
+        double val = items.getOrDefault(id, zero).call();
+
+        return Double.isNaN(val) ? 0 : val;
+    }
+
+}

部分文件因文件數量過多而無法顯示