feat: base frame

This commit is contained in:
yjz
2024-05-30 17:57:32 +08:00
commit d4937a2428
2787 changed files with 770496 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
*.js linguist-language=Java
*.css linguist-language=Java
*.html linguist-language=Java
*.vue linguist-language=Java
+63
View File
@@ -0,0 +1,63 @@
/target/
/.idea/
jeecg-boot-module-demo
rebel.xml
#java
*.class
#package file
*.war
*.ear
*.zip
*.tar.gz
*.rar
#maven ignore
target/
build/
#eclipse ignore
.settings/
.project
.classpatch
#Intellij idea
.idea/
/idea/
out/
logs/
*.ipr
*.iml
*.iws
# temp file
*.log
*.cache
*.diff
*.patch
*.tmp
.DS_Store
node_modules
/node_modules/
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 jero-boot
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+33
View File
@@ -0,0 +1,33 @@
-- 老法规数据 导入的全部操作 文件位置NAS: \中国重汽法规\3.程序设计文档\老法规系统数据迁移\2023-12-06(最终版)\ 文件夹下
### 1、执行sql文件 【FCC-同步正式环境的数据库结构.sql】 或者直接本地同步结构
### 2、老法规数据导入的操作:
- 导入组织机构对应关系 对应文件 【1.标准清单- 部门对应关系(和IAM对比).xlsx】
### 3、国标数据
- 导入标准数据 【2.国内标准-最终导入数据.xls】
- 导入国标-准入性数据 【3.国标标准-体系(准入性).xlsx】
- 导入国标-推荐性数据 【4.国标标准-体系(推荐性).xlsx】
### 4、海外标准的数据
- 导入海外标准 【5.海外标准-标准清单-导入数据.xls】
### 5、企业标准
- 导入企标数据的文件 【6.企标-能正常导入的数据.xlsx】
- 企标体系 【7.企标-体系导入文件.xlsx】
- 企标权限-所有人【8.企标-标准权限-1 所有人.xlsx】
- 企标权限-个人【9.企标-标准权限-2 个人2.xlsx】
- 企标权限-组织【10.企标-标准权限-部门权限.xlsx】
### 6、海外标准有一些带文字的需要特殊处理
- 【11.海外标准-需要做文件特殊处理的.xls】
### 7、导入角色用户对应关系的接口
- 【laws-sinotruk/laws/localTool/importUtil/importUserPermission】
+132
View File
@@ -0,0 +1,132 @@
框架继承注意要点
===
1. 在本框架中搭建工作流模块,重新设计工作流模块
(包括用户对审批节点配置增减;待办、已办、已发、监控、草稿的设计;流程过程中加签;发起时可配置人员节点选择;
每个人显示自己关联的流程图+显示流程节点对应的办理人;节点未到时发起人可修改已配置的审批人员等等)
2. 所有与工作流相关的表都使用`activiti_`开头
3. 熟悉后端的双语操作(预留但不开发,仅中文即可)
4. 熟悉文档库属性配置相关代码(重汽需要将文档库标签扩充成 国内标准法规标签、海外标准法规标签、企业标准标签三部分),补充注释
5. 去除无效的application配置项
6. 分析代码,删掉不用的代码和包,为后续开发搭好基础。留下相关接口为:文档管理-文档库、文档工具-文档拆分、文档工具-文档对比、业务支持-对外报告管理(改名为资料中心)、
信息中心-文档动态、信息中心-我的消息、个人中心-我的收藏、日志中心-操作日志、系统管理(全部)、开发工具全部(仅给开发用)
7. 分析结果由项目二组提供excel说明项目框架各部分范围(高嵩负责)
中间件要求
===
1. 数据库 Mysql 5.7
2. 缓存 Redis 7.0
3. 搜索引擎 EasticSearch 7.9
4. 文件上传 Minio 任意版本
5. 支持K8S部署 docker
6. 工作流 Activiti 6.0.0
jero-boot 低代码开发平台
===============
当前最新版本: 2.5.1(发布日期:20210126
## 后端技术架构
- 基础框架:Spring Boot 2.3.5.RELEASE
- 持久层框架:Mybatis-plus 3.4.1
- 安全框架:Apache Shiro 1.7.0Jwt 3.11.0
- 数据库连接池:阿里巴巴Druid 1.1.22
- 缓存框架:redis
- 日志打印:logback
- 其他:fastjsonpoiSwagger-uiquartz, lombok(简化代码)等。
## 开发环境
- 语言:Java 8
- IDE(JAVA)IDEA安装lombok插件
- 依赖管理:Maven
- 数据库:MySQL5.7+
- 缓存:Redis
## 数据库设计规范
- 数据库表名全部使用小写,多个单词之间使用 _ 隔开
- 字段内容全部使用小写,多个单词之间使用 _ 隔开,并且每个字段需要有注释
- 每个表中都需要有id,用varchar(36
- 新建的表中必须要有创建人(create_by)、创建时间(create_time)、更新人(update_by)、更新时间(update_time)、所属部门(sys_code)五个字段
- create_by 和 update_by 存用户账号
- id的增长规则设定保持统一,统一按照框架生成的内容形成
## 系统规范
- 日志记录
方法中使用`@AutoLog` 记录日志
- 异常处理
所有异常使用`JeroBootException`抛出
- 权限控制
需要进行数据权限控制
- 项目模块创建
后续创建模块在`jero-boot-modules.com.jero.modules.laws`
`jero-boot-modules.com.jero.modules.project`下创建
- 系统导入
系统导入使用注解`@ExcelImport`进行字段校验
- 系统常量定义在`com.jero.common.constant.CommonConstant`
## 专项文档
#### 一、查询过滤器用法
```
QueryWrapper<?> queryWrapper = QueryGenerator.initQueryWrapper(?, req.getParameterMap());
```
代码示例:
```
@GetMapping(value = "/list")
public Result<IPage<JeroDemo>> list(JeroDemo jeroDemo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<JeroDemo>> result = new Result<IPage<JeroDemo>>();
//调用QueryGenerator的initQueryWrapper
QueryWrapper<JeroDemo> queryWrapper = QueryGenerator.initQueryWrapper(jeroDemo, req.getParameterMap());
Page<JeroDemo> page = new Page<JeroDemo>(pageNo, pageSize);
IPage<JeroDemo> pageList = JeroDemoService.page(page, queryWrapper);
result.setSuccess(true);
result.setResult(pageList);
return result;
}
```
- 查询规则 (本规则不适用于高级查询,高级查询有自己对应的查询类型可以选择 )
| 查询模式 | 用法 | 说明 |
|---------- |-------------------------------------------------------|------------------|
| 模糊查询 | 支持左右模糊和全模糊 需要在查询输入框内前或后带\*或是前后全部带\* | |
| 取非查询 | 在查询输入框前面输入! 则查询该字段不等于输入值的数据(数值类型不支持此种查询,可以将数值字段定义为字符串类型的) | |
| \> \>= < <= | 同取非查询 在输入框前面输入对应特殊字符即表示走对应规则查询 | |
| in查询 | 若传入的数据带,(逗号) 则表示该查询为in查询 | |
| 多选字段模糊查询 | 上述4 有一个特例,若某一查询字段前后都带逗号 则会将其视为走这种查询方式 ,该查询方式是将查询条件以逗号分割再遍历数组 将每个元素作like查询 用or拼接,例如 现在name传入值 ,a,b,c, 那么结果sql就是 name like '%a%' or name like '%b%' or name like '%c%' | |
#### 三、代码生成器
> 功能说明: 一键生成的代码(包括:controller、service、dao、mapper、entity、vue
- 模板位置: src/main/resources/jero/code-template
- 文件配置路径: jero-boot/jero-boot-single-startup/src/main/resources/jero/jero_config.properties
+13
View File
@@ -0,0 +1,13 @@
FROM mysql:8.0.19
MAINTAINER jeecgos@163.com
ENV TZ=Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY ./tables_nacos.sql /docker-entrypoint-initdb.d
COPY jeroboot-mysql-5.7.sql /docker-entrypoint-initdb.d
COPY ./tables_xxl_job.sql /docker-entrypoint-initdb.d
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+285
View File
File diff suppressed because one or more lines are too long
+119
View File
@@ -0,0 +1,119 @@
#
# XXL-JOB v2.2.0
# Copyright (c) 2015-present, xuxueli.
CREATE database if NOT EXISTS `xxl_job` default character set utf8mb4 collate utf8mb4_unicode_ci;
use `xxl_job`;
SET NAMES utf8mb4;
CREATE TABLE `xxl_job_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
`job_cron` varchar(128) NOT NULL COMMENT '任务执行CRON',
`job_desc` varchar(255) NOT NULL,
`add_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
`author` varchar(64) DEFAULT NULL COMMENT '作者',
`alarm_email` varchar(255) DEFAULT NULL COMMENT '报警邮件',
`executor_route_strategy` varchar(50) DEFAULT NULL COMMENT '执行器路由策略',
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_block_strategy` varchar(50) DEFAULT NULL COMMENT '阻塞处理策略',
`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`glue_type` varchar(50) NOT NULL COMMENT 'GLUE类型',
`glue_source` mediumtext COMMENT 'GLUE源代码',
`glue_remark` varchar(128) DEFAULT NULL COMMENT 'GLUE备注',
`glue_updatetime` datetime DEFAULT NULL COMMENT 'GLUE更新时间',
`child_jobid` varchar(255) DEFAULT NULL COMMENT '子任务ID,多个逗号分隔',
`trigger_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '调度状态:0-停止,1-运行',
`trigger_last_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '上次调度时间',
`trigger_next_time` bigint(13) NOT NULL DEFAULT '0' COMMENT '下次调度时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`job_group` int(11) NOT NULL COMMENT '执行器主键ID',
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
`executor_address` varchar(255) DEFAULT NULL COMMENT '执行器地址,本次执行的地址',
`executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
`executor_param` varchar(512) DEFAULT NULL COMMENT '执行器任务参数',
`executor_sharding_param` varchar(20) DEFAULT NULL COMMENT '执行器任务分片参数,格式如 1/2',
`executor_fail_retry_count` int(11) NOT NULL DEFAULT '0' COMMENT '失败重试次数',
`trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',
`trigger_code` int(11) NOT NULL COMMENT '调度-结果',
`trigger_msg` text COMMENT '调度-日志',
`handle_time` datetime DEFAULT NULL COMMENT '执行-时间',
`handle_code` int(11) NOT NULL COMMENT '执行-状态',
`handle_msg` text COMMENT '执行-日志',
`alarm_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '告警状态:0-默认、1-无需告警、2-告警成功、3-告警失败',
PRIMARY KEY (`id`),
KEY `I_trigger_time` (`trigger_time`),
KEY `I_handle_code` (`handle_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_log_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`trigger_day` datetime DEFAULT NULL COMMENT '调度-时间',
`running_count` int(11) NOT NULL DEFAULT '0' COMMENT '运行中-日志数量',
`suc_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行成功-日志数量',
`fail_count` int(11) NOT NULL DEFAULT '0' COMMENT '执行失败-日志数量',
PRIMARY KEY (`id`),
UNIQUE KEY `i_trigger_day` (`trigger_day`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_logglue` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_id` int(11) NOT NULL COMMENT '任务,主键ID',
`glue_type` varchar(50) DEFAULT NULL COMMENT 'GLUE类型',
`glue_source` mediumtext COMMENT 'GLUE源代码',
`glue_remark` varchar(128) NOT NULL COMMENT 'GLUE备注',
`add_time` datetime DEFAULT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_registry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`registry_group` varchar(50) NOT NULL,
`registry_key` varchar(255) NOT NULL,
`registry_value` varchar(255) NOT NULL,
`update_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `i_g_k_v` (`registry_group`,`registry_key`,`registry_value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`app_name` varchar(64) NOT NULL COMMENT '执行器AppName',
`title` varchar(12) NOT NULL COMMENT '执行器名称',
`address_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '执行器地址类型:0=自动注册、1=手动录入',
`address_list` varchar(512) DEFAULT NULL COMMENT '执行器地址列表,多地址逗号分隔',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL COMMENT '账号',
`password` varchar(50) NOT NULL COMMENT '密码',
`role` tinyint(4) NOT NULL COMMENT '角色:0-普通用户、1-管理员',
`permission` varchar(255) DEFAULT NULL COMMENT '权限:执行器ID列表,多个逗号分割',
PRIMARY KEY (`id`),
UNIQUE KEY `i_username` (`username`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `xxl_job_lock` (
`lock_name` varchar(50) NOT NULL COMMENT '锁名称',
PRIMARY KEY (`lock_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `xxl_job_group`(`id`, `app_name`, `title`, `address_type`, `address_list`) VALUES (1, 'xxl-job-executor-sample', '示例执行器', 0, NULL);
INSERT INTO `xxl_job_info`(`id`, `job_group`, `job_cron`, `job_desc`, `add_time`, `update_time`, `author`, `alarm_email`, `executor_route_strategy`, `executor_handler`, `executor_param`, `executor_block_strategy`, `executor_timeout`, `executor_fail_retry_count`, `glue_type`, `glue_source`, `glue_remark`, `glue_updatetime`, `child_jobid`) VALUES (1, 1, '0 0 0 * * ? *', '测试任务1', '2018-11-03 22:21:31', '2018-11-03 22:21:31', 'XXL', '', 'FIRST', 'demoJobHandler', '', 'SERIAL_EXECUTION', 0, 0, 'BEAN', '', 'GLUE代码初始化', '2018-11-03 22:21:31', '');
INSERT INTO `xxl_job_user`(`id`, `username`, `password`, `role`, `permission`) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 1, NULL);
INSERT INTO `xxl_job_lock` ( `lock_name`) VALUES ( 'schedule_lock');
commit;
+95
View File
@@ -0,0 +1,95 @@
-- auto-generated definition
create table process_model_node
(
id varchar(36) not null comment '主键id'
primary key,
model_id varchar(64) null comment '模型id',
node_name varchar(50) null comment '节点名称',
node_type varchar(50) null comment '节点类型',
xml_sub_node_id varchar(50) null comment '子流程id',
xml_node_id varchar(50) null comment 'xml节点Id',
xml_source_ref varchar(50) null comment 'xml来源节点id',
xml_target_ref varchar(50) null comment 'xml目标节点id',
variable_type varchar(50) null comment '变量类型',
variable_name varchar(50) null comment '变量名称',
is_approval_node tinyint null comment '是否审批节点',
is_can_deleted tinyint null comment '是否可删除',
sort tinyint null comment '排序',
create_by varchar(36) null comment '创建人',
create_time datetime null comment '创建时间',
update_by varchar(36) null comment '更新人',
update_time datetime null comment '更新时间',
sys_code varchar(64) null comment '所属部门'
)
comment '流程模型节点表';
create table process_node
(
id varchar(36) not null comment '主键id'
primary key,
process_definition_id varchar(64) null comment '流程定义id',
node_name varchar(50) null comment '节点名称',
variable_type varchar(50) null comment '变量类型',
variable_name varchar(50) null comment '变量名称',
sort tinyint null comment '排序',
create_by varchar(36) null comment '创建人',
create_time datetime null comment '创建时间',
update_by varchar(36) null comment '更新人',
update_time datetime null comment '更新时间',
sys_code varchar(64) null comment '所属部门'
)
comment '流程定义节点表';
create table process_node_link
(
id varchar(36) not null primary key comment '主键id',
process_definition_id varchar(64) comment '流程定义id',
process_node_id varchar(36) comment '流程节点id',
process_instance_id varchar(64) comment '流程实例id',
user_id varchar(36) comment '用户id'
) comment = '流程实例节点关联用户表';
create table process_approval_record
(
id varchar(32) not null comment '主键'
primary key,
task_id varchar(64) comment '任务id',
task_name varchar(255) comment '任务名称',
process_instance_id varchar(64) comment '流程实例id',
msg_type varchar(120) comment '资源类型',
user_id varchar(32) comment '处理人id',
mesg longtext comment '信息',
finish_flag tinyint(4) comment '完成注记(0未完成,1完成)',
project_id varchar(32) comment '项目id',
commit_flag tinyint(4) comment '审批意见(0同意,1不同意)',
commit_text varchar(255) comment '审批内容',
commit_file varchar(1000) comment '审批附件',
has_delegate_task tinyint(4) default 0 comment '是否派发过加签任务',
is_delegate_task tinyint(4) default 0 comment '是否加签任务',
prc_name varchar(255) comment '流程名称',
create_time datetime comment '创建时间',
update_time datetime comment '更新时间',
end_time datetime comment '完成时间'
) comment '流程审批记录表';
create table process_all
(
id varchar(32) not null
primary key,
prc_name varchar(255) comment '流程名称',
process_instance_id varchar(64) comment '流程实例id',
prc_mes varchar(255) comment '流程描述',
prc_num varchar(50) comment '流程编号',
create_user_id varchar(50) comment '创建人id',
prc_type tinyint(4) comment '流程类型',
prc_status tinyint(4) comment '流程状态(1未完成,2已完成,3已撤回)',
create_user_name varchar(255) comment '发起人名称',
mes longtext comment 'json信息',
create_time datetime default current_timestamp comment '创建时间',
end_time datetime comment '完成时间',
over_time varchar(255) comment '耗时',
due_time datetime comment '截止时间',
project_id varchar(255) comment '项目id',
project_name varchar(255) comment '项目名称',
prc_name_en varchar(255) comment '流程名称(英文)'
) comment '流程总表';
+3
View File
@@ -0,0 +1,3 @@
第二行替换为:<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
第三行修改为:isExecutable="true"
camunda: 替换为 activiti:
+51
View File
@@ -0,0 +1,51 @@
#### 镜像上传
# 仓库私服: 81.70.17.111:5000
# 第一步:上传镜像到docker仓库
#docker tag jero-boot-mysql 81.70.17.111:5000/jero-boot-mysql:1.1
#docker tag jero-boot-system 81.70.17.111:5000/jero-boot-system:1.0
#docker tag nginxhtml:jeroboot 81.70.17.111:5000/nginxhtml:1.2
#docker push 81.70.17.111:5000/jero-boot-mysql:1.1
#docker push 81.70.17.111:5000/jero-boot-system:1.0
#docker push 81.70.17.111:5000/nginxhtml:1.2
# 第二步:将此yml文件上传服务器,执行启动命令 docker-compose -f ./docker-compose-server.yml up
version: '2'
services:
jero-boot-mysql:
image: 81.70.17.111:5000/jero-boot-mysql:1.0
environment:
MYSQL_ROOT_PASSWORD: root
restart: always
container_name: jero-boot-mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
ports:
- 3306:3306
jero-boot-redis:
image: redis:5.0
ports:
- 6379:6379
restart: always
container_name: jero-boot-redis
jero-boot-system:
image: 81.70.17.111:5000/jero-boot-system:1.0
restart: always
container_name: jero-boot-system
volumes:
- /data/config:/jero-boot/config
ports:
- 8080:8080
jero-boot-nginx:
image: 81.70.17.111:5000/nginxhtml
restart: always
container_name: jero-boot-nginx
ports:
- 80:80
+35
View File
@@ -0,0 +1,35 @@
version: '2'
services:
jero-boot-mysql:
build:
context: ./db
environment:
MYSQL_ROOT_PASSWORD: root
restart: always
container_name: jero-boot-mysql
image: jero-boot-mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=128M
ports:
- 3306:3306
jero-boot-redis:
image: redis:5.0
ports:
- 6379:6379
restart: always
container_name: jero-boot-redis
jero-boot-system:
build:
context: ./jero-boot-module-system
restart: always
container_name: jero-boot-system
image: jero-boot-system
ports:
- 8080:8080
@@ -0,0 +1,21 @@
<?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>laws-base-api</artifactId>
<groupId>com.jero.boot</groupId>
<version>2.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jero-system-cloud-api</artifactId>
<dependencies>
<!-- feign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,532 @@
package com.jero.common.system.api;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.api.CommonAPI;
import com.jero.common.api.dto.OnlineAuthDTO;
import com.jero.common.api.dto.message.*;
import com.jero.common.constant.ServiceNameConstants;
import com.jero.common.system.api.factory.SysBaseAPIFallbackFactory;
import com.jero.common.system.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 相比较local版
* 去掉了一些方法:
* addLog getDatabaseType queryAllDepart
* queryAllUser(Wrapper wrapper) queryAllUser(String[] userIds, int pageNo, int pageSize)
* 修改了一些方法:
* createLog
* sendSysAnnouncement 只保留了一个,其余全部干掉
*
* cloud接口数量43 local35 common9 额外一个特殊queryAllRole一个当两个用
*/
@Component
@FeignClient(contextId = "sysBaseRemoteApi", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = SysBaseAPIFallbackFactory.class)
public interface ISysBaseAPI extends CommonAPI {
/**
* 1发送系统消息
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
*/
@PostMapping("/sys/api/sendSysAnnouncement")
void sendSysAnnouncement(@RequestBody MessageDTO message);
/**
* 2发送消息 附带业务参数
* @param message 使用构造器赋值参数
*/
@PostMapping("/sys/api/sendBusAnnouncement")
void sendBusAnnouncement(@RequestBody BusMessageDTO message);
/**
* 3通过模板发送消息
* @param message 使用构造器赋值参数
*/
@PostMapping("/sys/api/sendTemplateAnnouncement")
void sendTemplateAnnouncement(@RequestBody TemplateMessageDTO message);
/**
* 4通过模板发送消息 附带业务参数
* @param message 使用构造器赋值参数
*/
@PostMapping("/sys/api/sendBusTemplateAnnouncement")
void sendBusTemplateAnnouncement(@RequestBody BusTemplateMessageDTO message);
/**
* 5通过消息中心模板,生成推送内容
* @param templateDTO 使用构造器赋值参数
* @return
*/
@PostMapping("/sys/api/parseTemplateByCode")
String parseTemplateByCode(@RequestBody TemplateDTO templateDTO);
/**
* 6根据用户id查询用户信息
* @param id
* @return
*/
@GetMapping("/sys/api/getUserById")
LoginUser getUserById(@RequestParam("id") String id);
/**
* 7通过用户账号查询角色集合
* @param username
* @return
*/
@GetMapping("/sys/api/getRolesByUsername")
List<String> getRolesByUsername(@RequestParam("username") String username);
/**
* 8通过用户账号查询部门集合
* @param username
* @return 部门 id
*/
@GetMapping("/sys/api/getDepartIdsByUsername")
List<String> getDepartIdsByUsername(@RequestParam("username") String username);
/**
* 9通过用户账号查询部门 name
* @param username
* @return 部门 name
*/
@GetMapping("/sys/api/getDepartNamesByUsername")
List<String> getDepartNamesByUsername(@RequestParam("username") String username);
/**
* 10获取数据字典
* @param code
* @return
*/
@GetMapping("/sys/api/queryDictItemsByCode")
List<DictModel> queryDictItemsByCode(@RequestParam("code") String code);
/**
* 获取有效的数据字典项
* @param code
* @return
*/
@GetMapping("/sys/api/queryEnableDictItemsByCode")
public List<DictModel> queryEnableDictItemsByCode(@RequestParam("code") String code);
/** 11查询所有的父级字典,按照create_time排序 */
@GetMapping("/sys/api/queryAllDict")
List<DictModel> queryAllDict();
/**
* 12查询所有分类字典
* @return
*/
@GetMapping("/sys/api/queryAllDSysCategory")
List<SysCategoryModel> queryAllDSysCategory();
/**
* 13获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
@GetMapping("/sys/api/queryTableDictItemsByCode")
List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code);
/**
* 14查询所有部门 作为字典信息 id -->value,departName -->text
* @return
*/
@GetMapping("/sys/api/queryAllDepartBackDictModel")
List<DictModel> queryAllDepartBackDictModel();
/**
* 15根据业务类型 busType 及业务 busId 修改消息已读
*/
@GetMapping("/sys/api/updateSysAnnounReadFlag")
public void updateSysAnnounReadFlag(@RequestParam("busType") String busType, @RequestParam("busId") String busId);
/**
* 16查询表字典 支持过滤数据
* @param table
* @param text
* @param code
* @param filterSql
* @return
*/
@GetMapping("/sys/api/queryFilterTableDictInfo")
List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql);
/**
* 17查询指定table的 text code 获取字典,包含text和value
* @param table
* @param text
* @param code
* @param keyArray
* @deprecated 不建议使用
* @return
*/
@Deprecated
@GetMapping("/sys/api/queryTableDictByKeys")
List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray);
/**
* 18查询所有用户 返回ComboModel
* @return
*/
@GetMapping("/sys/api/queryAllUserBackCombo")
List<ComboModel> queryAllUserBackCombo();
/**
* 19分页查询用户 返回JSONObject
* @return
*/
@GetMapping("/sys/api/queryAllUser")
JSONObject queryAllUser(@RequestParam(name = "userIds", required = false) String userIds, @RequestParam(name = "pageNo", required = false) Integer pageNo, @RequestParam(name = "pageSize", required = false) int pageSize);
/**
* 20获取所有角色 带参
* roleIds 默认选中角色
* @return
*/
@GetMapping("/sys/api/queryAllRole")
List<ComboModel> queryAllRole(@RequestParam(name = "roleIds", required = false) String[] roleIds);
/**
* 21通过用户账号查询角色Id集合
* @param username
* @return
*/
@GetMapping("/sys/api/getRoleIdsByUsername")
List<String> getRoleIdsByUsername(@RequestParam("username") String username);
/**
* 22通过部门编号查询部门id
* @param orgCode
* @return
*/
@GetMapping("/sys/api/getDepartIdsByOrgCode")
String getDepartIdsByOrgCode(@RequestParam("orgCode") String orgCode);
/**
* 23查询所有部门
* @return
*/
@GetMapping("/sys/api/getAllSysDepart")
List<SysDepartModel> getAllSysDepart();
/**
* 24查找父级部门
* @param departId
* @return
*/
@GetMapping("/sys/api/getParentDepartId")
DictModel getParentDepartId(@RequestParam("departId") String departId);
/**
* 25根据部门Id获取部门负责人
* @param deptId
* @return
*/
@GetMapping("/sys/api/getDeptHeadByDepId")
List<String> getDeptHeadByDepId(@RequestParam("deptId") String deptId);
/**
* 26给指定用户发消息
* @param userIds
* @param cmd
*/
@GetMapping("/sys/api/sendWebSocketMsg")
void sendWebSocketMsg(@RequestParam("userIds") String[] userIds, @RequestParam("cmd") String cmd);
/**
* 27根据id获取所有参与用户
* userIds
* @return
*/
@GetMapping("/sys/api/queryAllUserByIds")
List<LoginUser> queryAllUserByIds(@RequestParam("userIds") String[] userIds);
/**
* 28将会议签到信息推动到预览
* userIds
* @return
* @param userId
*/
@GetMapping("/sys/api/meetingSignWebsocket")
void meetingSignWebsocket(@RequestParam("userId") String userId);
/**
* 29根据name获取所有参与用户
* userNames
* @return
*/
@GetMapping("/sys/api/queryUserByNames")
List<LoginUser> queryUserByNames(@RequestParam("userNames") String[] userNames);
/**
* 30获取用户的角色集合
* @param username
* @return
*/
@GetMapping("/sys/api/getUserRoleSet")
Set<String> getUserRoleSet(@RequestParam("username") String username);
/**
* 31获取用户的权限集合
* @param username
* @return
*/
@GetMapping("/sys/api/getUserPermissionSet")
Set<String> getUserPermissionSet(@RequestParam("username") String username);
/**
* 32判断是否有online访问的权限
* @param onlineAuthDTO
* @return
*/
@PostMapping("/sys/api/hasOnlineAuth")
boolean hasOnlineAuth(@RequestBody OnlineAuthDTO onlineAuthDTO);
/**
* 33通过部门id获取部门全部信息
*/
@GetMapping("/sys/api/selectAllById")
SysDepartModel selectAllById(@RequestParam("id") String id);
/**
* 34根据用户id查询用户所属公司下所有用户ids
* @param userId
* @return
*/
@GetMapping("/sys/api/queryDeptUsersByUserId")
List<String> queryDeptUsersByUserId(@RequestParam("userId") String userId);
//---
/**
* 35查询用户角色信息
* @param username
* @return
*/
@GetMapping("/sys/api/queryUserRoles")
Set<String> queryUserRoles(@RequestParam("username") String username);
/**
* 36查询用户权限信息
* @param username
* @return
*/
@GetMapping("/sys/api/queryUserAuths")
Set<String> queryUserAuths(@RequestParam("username") String username);
/**
* 37根据 id 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceId
* @return
*/
@GetMapping("/sys/api/getDynamicDbSourceById")
DynamicDataSourceModel getDynamicDbSourceById(@RequestParam("dbSourceId") String dbSourceId);
/**
* 38根据 code 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceCode
* @return
*/
@GetMapping("/sys/api/getDynamicDbSourceByCode")
DynamicDataSourceModel getDynamicDbSourceByCode(@RequestParam("dbSourceCode") String dbSourceCode);
/**
* 39根据用户账号查询用户信息 CommonAPI中定义
* @param username
*/
@GetMapping("/sys/api/getUserByName")
LoginUser getUserByName(@RequestParam("username") String username);
/**
* 40字典表的 翻译
* @param table
* @param text
* @param code
* @param key
* @return
*/
@GetMapping("/sys/api/translateDictFromTable")
String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key);
/**
* 41普通字典的翻译
* @param code
* @param key
* @return
*/
@GetMapping("/sys/api/translateDict")
String translateDict(@RequestParam("code") String code, @RequestParam("key") String key);
/**
* 42查询数据权限
* @return
*/
@GetMapping("/sys/api/queryPermissionDataRule")
List<SysPermissionDataRuleModel> queryPermissionDataRule(@RequestParam("component") String component, @RequestParam("requestPath") String requestPath, @RequestParam("username") String username);
/**
* 43查询用户信息
* @param username
* @return
*/
@GetMapping("/sys/api/getCacheUser")
SysUserCacheInfo getCacheUser(@RequestParam("username") String username);
/**
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
* @param usernames
* @return
*/
@GetMapping("/sys/api/queryUsersByUsernames")
List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames);
/**
* 37根据多个用户ID(逗号分隔),查询返回多个用户信息
* @param ids
* @return
*/
@RequestMapping("/sys/api/queryUsersByIds")
List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids);
/**
* 38根据多个部门编码(逗号分隔),查询返回多个部门信息
* @param orgCodes
* @return
*/
@RequestMapping("/sys/api/queryDepartsByOrgcodes")
List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes);
/**
* 39根据多个部门编码(逗号分隔),查询返回多个部门信息
* @param ids
* @return
*/
@GetMapping("/sys/api/queryDepartsByOrgIds")
List<JSONObject> queryDepartsByOrgIds(@RequestParam("ids") String ids);
/**
* 40发送邮件消息
* @param email
* @param title
* @param content
*/
@GetMapping("/sys/api/sendEmailMsg")
void sendEmailMsg(@RequestParam("email") String email, @RequestParam("title") String title, @RequestParam("content") String content);
/**
* 41根据部门id查询部门所有的父级(不包含自己)
* @author 马志朝
* @date 2021/3/24 8:50
* @param departId 部门id
* @return JSONObject
*/
@GetMapping("/sys/api/listParentDepartsByDepId")
List<SysDepartTreeModel> listParentDepartsByDepId(@RequestParam("departId") String departId);
/**
* 42根据部门id查询部门所有的子级(不包含自己)
* @author 马志朝
* @date 2021/3/24 8:54
* @param departId 部门id
* @return JSONObject
*/
@GetMapping("/sys/api/listSonDepartsByDepId")
List<SysDepartTreeModel> listSonDepartsByDepId(@RequestParam("departId") String departId);
/**
* 41 获取公司下级部门和公司下所有用户id
* @param orgCode
*/
@GetMapping("/sys/api/getDeptUserByOrgCode")
List<Map<String,Object>> getDeptUserByOrgCode(@RequestParam("orgCode")String orgCode);
/**
* 42 查询分类字典翻译
*/
@GetMapping("/sys/api/loadCategoryDictItem")
List<String> loadCategoryDictItem(@RequestParam("ids") String ids);
/**
* 43 根据字典code加载字典text
*
* @param dictCode 顺序:tableName,text,code
* @param keys 要查询的key
* @return
*/
@GetMapping("/sys/api/loadDictItem")
List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys);
/**
* 44 根据字典code查询字典项
*
* @param dictCode 顺序:tableName,text,code
* @param dictCode 要查询的key
* @return
*/
@GetMapping("/sys/api/getDictItems")
List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode);
/**
* 45 根据多个字典code查询多个字典项
*
* @param dictCodeList
* @return key = dictCode value=对应的字典项
*/
@RequestMapping("/sys/api/getManyDictItems")
Map<String, List<DictModel>> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList);
/**
* 46 【JSearchSelectTag下拉搜索组件专用接口】
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
*
* @param dictCode 字典code格式:table,text,code
* @param keyword 过滤关键字
* @return
*/
@GetMapping("/sys/api/loadDictItemByKeyword")
List<DictModel> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize);
/**
* 47 根据多个部门id(逗号分隔),查询返回多个部门信息
* @param ids
* @return
*/
@GetMapping("/sys/api/queryDepartsByIds")
List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids);
/**
* 48 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
* @param dictCodes
* @param keys
* @return
*/
@Override
@GetMapping("/sys/api/translateManyDict")
Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys);
/**
* 49 字典表的 翻译,可批量
* @param table
* @param text
* @param code
* @param keys 多个用逗号分割
* @return
*/
@Override
@GetMapping("/sys/api/translateDictFromTableByKeys")
List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys);
}
@@ -0,0 +1,17 @@
package com.jero.common.system.api.factory;
import feign.hystrix.FallbackFactory;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.api.fallback.SysBaseAPIFallback;
import org.springframework.stereotype.Component;
@Component
public class SysBaseAPIFallbackFactory implements FallbackFactory<ISysBaseAPI> {
@Override
public ISysBaseAPI create(Throwable throwable) {
SysBaseAPIFallback fallback = new SysBaseAPIFallback();
fallback.setCause(throwable);
return fallback;
}
}
@@ -0,0 +1,351 @@
package com.jero.common.system.api.fallback;
import com.alibaba.fastjson.JSONObject;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import com.jero.common.api.dto.OnlineAuthDTO;
import com.jero.common.api.dto.message.*;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 进入fallback的方法 检查是否token未设置
*/
@Slf4j
public class SysBaseAPIFallback implements ISysBaseAPI {
@Setter
private Throwable cause;
private static final String ERROR_MESSAGE = "发送消息失败 {}";
@Override
public void sendSysAnnouncement(MessageDTO message) {
log.error(ERROR_MESSAGE, cause);
}
@Override
public void sendBusAnnouncement(BusMessageDTO message) {
log.error(ERROR_MESSAGE, cause);
}
@Override
public void sendTemplateAnnouncement(TemplateMessageDTO message) {
log.error(ERROR_MESSAGE, cause);
}
@Override
public void sendBusTemplateAnnouncement(BusTemplateMessageDTO message) {
log.error(ERROR_MESSAGE, cause);
}
@Override
public String parseTemplateByCode(TemplateDTO templateDTO) {
log.error("通过模板获取消息内容失败 {}", cause);
return null;
}
@Override
public LoginUser getUserById(String id) {
return null;
}
@Override
public List<String> getRolesByUsername(String username) {
return Collections.emptyList();
}
@Override
public List<String> getDepartIdsByUsername(String username) {
return Collections.emptyList();
}
@Override
public List<String> getDepartNamesByUsername(String username) {
return Collections.emptyList();
}
@Override
public List<DictModel> queryDictItemsByCode(String code) {
return Collections.emptyList();
}
@Override
public List<DictModel> queryEnableDictItemsByCode(String code) {
return Collections.emptyList();
}
@Override
public List<DictModel> queryAllDict() {
return Collections.emptyList();
}
@Override
public List<SysCategoryModel> queryAllDSysCategory() {
return Collections.emptyList();
}
@Override
public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
return Collections.emptyList();
}
@Override
public List<DictModel> queryAllDepartBackDictModel() {
return Collections.emptyList();
}
@Override
public void updateSysAnnounReadFlag(String busType, String busId) {
// do other
}
@Override
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
return Collections.emptyList();
}
@Override
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) {
log.error("queryTableDictByKeys查询失败 {}", cause);
return Collections.emptyList();
}
@Override
public List<ComboModel> queryAllUserBackCombo() {
return Collections.emptyList();
}
@Override
public JSONObject queryAllUser(String userIds, Integer pageNo, int pageSize) {
return new JSONObject();
}
@Override
public List<ComboModel> queryAllRole(String[] roleIds) {
log.error("获取角色信息失败 {}", cause);
return Collections.emptyList();
}
@Override
public List<String> getRoleIdsByUsername(String username) {
return Collections.emptyList();
}
@Override
public String getDepartIdsByOrgCode(String orgCode) {
return null;
}
@Override
public List<SysDepartModel> getAllSysDepart() {
return Collections.emptyList();
}
@Override
public DictModel getParentDepartId(String departId) {
return null;
}
@Override
public List<String> getDeptHeadByDepId(String deptId) {
return Collections.emptyList();
}
@Override
public void sendWebSocketMsg(String[] userIds, String cmd) {
// do other
}
@Override
public List<LoginUser> queryAllUserByIds(String[] userIds) {
return Collections.emptyList();
}
@Override
public void meetingSignWebsocket(String userId) {
// do other
}
@Override
public List<LoginUser> queryUserByNames(String[] userNames) {
return Collections.emptyList();
}
@Override
public Set<String> getUserRoleSet(String username) {
return Collections.emptySet();
}
@Override
public Set<String> getUserPermissionSet(String username) {
return Collections.emptySet();
}
@Override
public boolean hasOnlineAuth(OnlineAuthDTO onlineAuthDTO) {
return false;
}
@Override
public SysDepartModel selectAllById(String id) {
return null;
}
@Override
public List<String> queryDeptUsersByUserId(String userId) {
return Collections.emptyList();
}
@Override
public Set<String> queryUserRoles(String username) {
return Collections.emptySet();
}
@Override
public Set<String> queryUserAuths(String username) {
return Collections.emptySet();
}
@Override
public DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId) {
return null;
}
@Override
public DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode) {
return null;
}
@Override
public LoginUser getUserByName(String username) {
log.error("通过用户名获取当前登录用户信息 {}", cause);
return null;
}
@Override
public String translateDictFromTable(String table, String text, String code, String key) {
return null;
}
@Override
public String translateDict(String code, String key) {
return null;
}
@Override
public List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username) {
return Collections.emptyList();
}
@Override
public SysUserCacheInfo getCacheUser(String username) {
log.error("获取用户信息失败 {}", cause);
return null;
}
@Override
public List<JSONObject> queryUsersByUsernames(String usernames) {
return Collections.emptyList();
}
@Override
public List<JSONObject> queryUsersByIds(String ids) {
return Collections.emptyList();
}
@Override
public List<JSONObject> queryDepartsByOrgcodes(String orgCodes) {
return Collections.emptyList();
}
@Override
public List<JSONObject> queryDepartsByIds(String ids) {
return Collections.emptyList();
}
@Override
public Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys) {
return Collections.emptyMap();
}
@Override
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys) {
return Collections.emptyList();
}
@Override
public List<SysDictItemCore> getDictItemAll() {
return Collections.emptyList();
}
@Override
public String queryTableDictTextByKey(String table, String text, String code, String key) {
return null;
}
@Override
public String translateUserRealNameFromTable(String id) {
return null;
}
@Override
public List<DictModel> translateUserRealNameFromTableByKeys(String values) {
return null;
}
@Override
public void sendEmailMsg(String email,String title,String content) {
// do other
}
@Override
public List<SysDepartTreeModel> listParentDepartsByDepId(String departId) {
return Collections.emptyList();
}
@Override
public List<SysDepartTreeModel> listSonDepartsByDepId(String departId) {
return Collections.emptyList();
}
@Override
public List<Map<String,Object>> getDeptUserByOrgCode(String orgCode) {
return Collections.emptyList();
}
@Override
public List<JSONObject> queryDepartsByOrgIds(String ids) {
return Collections.emptyList();
}
@Override
public List<String> loadCategoryDictItem(String ids) {
return Collections.emptyList();
}
@Override
public List<String> loadDictItem(String dictCode, String keys) {
return Collections.emptyList();
}
@Override
public List<DictModel> getDictItems(String dictCode) {
return Collections.emptyList();
}
@Override
public Map<String, List<DictModel>> getManyDictItems(List<String> dictCodeList) {
return Collections.emptyMap();
}
@Override
public List<DictModel> loadDictItemByKeyword(String dictCode, String keyword, Integer pageSize) {
return Collections.emptyList();
}
}
@@ -0,0 +1,166 @@
package com.jero.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.alibaba.fastjson.support.springfox.SwaggerJsonSerializer;
import com.jero.common.config.mqtoken.UserTokenContext;
import com.jero.common.constant.CommonConstant;
import com.jero.common.util.DateUtils;
import com.jero.common.util.PathMatcherUtil;
import com.jero.config.sign.interceptor.SignAuthConfiguration;
import com.jero.config.sign.util.HttpUtils;
import com.jero.config.sign.util.SignUtil;
import feign.Feign;
import feign.Logger;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.SortedMap;
@ConditionalOnClass(Feign.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
@Slf4j
@Configuration
public class FeignConfig {
@Bean
public RequestInterceptor requestInterceptor() {
return requestTemplate -> {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (null != attributes) {
filterRequest(requestTemplate, attributes);
}else{
String token = UserTokenContext.getToken();
log.debug("Feign request token: {}", token);
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
}
};
}
private void filterRequest(RequestTemplate requestTemplate, ServletRequestAttributes attributes) {
HttpServletRequest request = attributes.getRequest();
log.debug("Feign request: {}", request.getRequestURI());
// 将token信息放入header中
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
if(token==null || "".equals(token)){
token = request.getParameter("token");
}
log.debug("Feign request token: {}", token);
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
//根据URL地址过滤请求 【字典表参数签名验证】
if (PathMatcherUtil.matches(Arrays.asList(SignAuthConfiguration.urlList),requestTemplate.path())) {
try {
log.info("============================ [begin] fegin api url ============================");
log.info(requestTemplate.path());
log.info(requestTemplate.method());
String queryLine = requestTemplate.queryLine();
if(queryLine.startsWith("?")){
queryLine = queryLine.substring(1);
}
log.info(queryLine);
if(requestTemplate.body()!=null){
log.info(new String(requestTemplate.body()));
}
SortedMap<String, String> allParams = HttpUtils.getAllParams(requestTemplate.path(),queryLine,requestTemplate.body(),requestTemplate.method());
String sign = SignUtil.getParamsSign(allParams);
log.info(" Feign request params sign: {}",sign);
log.info("============================ [end] fegin api url ============================");
requestTemplate.header(CommonConstant.X_SIGN, sign);
requestTemplate.header(CommonConstant.X_TIMESTAMP, DateUtils.getCurrentTimestamp().toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Feign 客户端的日志记录,默认级别为NONE
* Logger.Level 的具体级别如下:
* NONE:不记录任何信息
* BASIC:仅记录请求方法、URL以及响应状态码和执行时间
* HEADERS:除了记录 BASIC级别的信息外,还会记录请求和响应的头信息
* FULL:记录所有请求与响应的明细,包括头信息、请求体、元数据
*/
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
/**
* Feign支持文件上传
* @param messageConverters
* @return
*/
@Bean
@Primary
@Scope("prototype")
public Encoder multipartFormEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
// update-begin--Author:sunjianlei Date:20210604 for 给 Feign 添加 FastJson 的解析支持 ----------
@Bean
public Encoder feignEncoder() {
return new SpringEncoder(feignHttpMessageConverter());
}
@Bean
public Decoder feignDecoder() {
return new SpringDecoder(feignHttpMessageConverter());
}
/**
* 设置解码器为fastjson
*
* @return
*/
private ObjectFactory<HttpMessageConverters> feignHttpMessageConverter() {
final HttpMessageConverters httpMessageConverters = new HttpMessageConverters(this.getFastJsonConverter());
return () -> httpMessageConverters;
}
private FastJsonHttpMessageConverter getFastJsonConverter() {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
List<MediaType> supportedMediaTypes = new ArrayList<>();
MediaType mediaTypeJson = MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE);
supportedMediaTypes.add(mediaTypeJson);
converter.setSupportedMediaTypes(supportedMediaTypes);
FastJsonConfig config = new FastJsonConfig();
config.getSerializeConfig().put(JSON.class, new SwaggerJsonSerializer());
config.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
converter.setFastJsonConfig(config);
return converter;
}
// update-end--Author:sunjianlei Date:20210604 for 给 Feign 添加 FastJson 的解析支持 ----------
}
@@ -0,0 +1,14 @@
<?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>laws-base-api</artifactId>
<groupId>com.jero.boot</groupId>
<version>2.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jero-system-local-api</artifactId>
</project>
@@ -0,0 +1,354 @@
package com.jero.common.system.api;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.api.CommonAPI;
import com.jero.common.api.dto.OnlineAuthDTO;
import com.jero.common.api.dto.message.*;
import com.jero.common.system.vo.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Description 底层共通业务API,提供其他独立模块调用
* @Author scott
* @Date 2019-4-20
* @Version V1.0
*/
public interface ISysBaseAPI extends CommonAPI {
/**
* 1发送系统消息
* @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息
*/
void sendSysAnnouncement(MessageDTO message);
/**
* 2发送消息 附带业务参数
* @param message 使用构造器赋值参数
*/
void sendBusAnnouncement(BusMessageDTO message);
/**
* 3通过模板发送消息
* @param message 使用构造器赋值参数
*/
void sendTemplateAnnouncement(TemplateMessageDTO message);
/**
* 4通过模板发送消息 附带业务参数
* @param message 使用构造器赋值参数
*/
void sendBusTemplateAnnouncement(BusTemplateMessageDTO message);
/**
* 5通过消息中心模板,生成推送内容
* @param templateDTO 使用构造器赋值参数
* @return
*/
String parseTemplateByCode(TemplateDTO templateDTO);
/**
* 6根据用户id查询用户信息
* @param id
* @return
*/
LoginUser getUserById(String id);
/**
* 7通过用户账号查询角色集合
* @param username
* @return
*/
List<String> getRolesByUsername(String username);
/**
* 8通过用户账号查询部门集合
* @param username
* @return 部门 id
*/
List<String> getDepartIdsByUsername(String username);
/**
* 9通过用户账号查询部门 name
* @param username
* @return 部门 name
*/
List<String> getDepartNamesByUsername(String username);
/** 11查询所有的父级字典,按照create_time排序 */
public List<DictModel> queryAllDict();
/**
* 12查询所有分类字典
* @return
*/
public List<SysCategoryModel> queryAllDSysCategory();
/**
* 14查询所有部门 作为字典信息 id -->value,departName -->text
* @return
*/
public List<DictModel> queryAllDepartBackDictModel();
/**
* 15根据业务类型及业务id修改消息已读
* @param busType
* @param busId
*/
public void updateSysAnnounReadFlag(String busType, String busId);
/**
* 16查询表字典 支持过滤数据
* @param table
* @param text
* @param code
* @param filterSql
* @return
*/
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql);
/**
* 17查询指定table的 text code 获取字典,包含text和value
* @param table
* @param text
* @param code
* @param keyArray
* @deprecated 不建议使用
* @return
*/
@Deprecated
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray);
/**
* 18查询所有用户 返回ComboModel
* @return
*/
public List<ComboModel> queryAllUserBackCombo();
List<LoginUser> getAllUser();
/**
* 19分页查询用户 返回JSONObject
* @return
*/
public JSONObject queryAllUser(String userIds, Integer pageNo, Integer pageSize);
/**
* 20获取所有角色
* @return
*/
public List<ComboModel> queryAllRole();
/**
* 21获取所有角色 带参
* roleIds 默认选中角色
* @return
*/
public List<ComboModel> queryAllRole(String[] roleIds );
/**
* 22通过用户账号查询角色Id集合
* @param username
* @return
*/
public List<String> getRoleIdsByUsername(String username);
/**
* 23通过部门编号查询部门id
* @param orgCode
* @return
*/
public String getDepartIdsByOrgCode(String orgCode);
/**
* 24查询所有部门
* @return
*/
public List<SysDepartModel> getAllSysDepart();
/**
* 25查找父级部门
* @param departId
* @return
*/
DictModel getParentDepartId(String departId);
/**
* 26根据部门Id获取部门负责人
* @param deptId
* @return
*/
public List<String> getDeptHeadByDepId(String deptId);
/**
* 27给指定用户发消息
* @param userIds
* @param cmd
*/
public void sendWebSocketMsg(String[] userIds, String cmd);
/**
* 28根据id获取所有参与用户
* userIds
* @return
*/
public List<LoginUser> queryAllUserByIds(String[] userIds);
/**
* 29将会议签到信息推动到预览
* userIds
* @return
* @param userId
*/
void meetingSignWebsocket(String userId);
/**
* 30根据name获取所有参与用户
* userNames
* @return
*/
List<LoginUser> queryUserByNames(String[] userNames);
/**
* 31获取用户的角色集合
* @param username
* @return
*/
Set<String> getUserRoleSet(String username);
/**
* 32获取用户的权限集合
* @param username
* @return
*/
Set<String> getUserPermissionSet(String username);
/**
* 33判断是否有online访问的权限
* @param onlineAuthDTO
* @return
*/
boolean hasOnlineAuth(OnlineAuthDTO onlineAuthDTO);
/**
* 34通过部门id获取部门全部信息
*/
SysDepartModel selectAllById(String id);
/**
* 35根据用户id查询用户所属公司下所有用户ids
* @param userId
* @return
*/
List<String> queryDeptUsersByUserId(String userId);
/**
* 36根据多个用户账号(逗号分隔),查询返回多个用户信息
* @param usernames
* @return
*/
List<JSONObject> queryUsersByUsernames(String usernames);
/**
* 37根据多个用户ID(逗号分隔),查询返回多个用户信息
* @param ids
* @return
*/
List<JSONObject> queryUsersByIds(String ids);
/**
* 38根据多个部门编码(逗号分隔),查询返回多个部门信息
* @param orgCodes
* @return
*/
List<JSONObject> queryDepartsByOrgcodes(String orgCodes);
/**
* 39根据多个部门id(逗号分隔),查询返回多个部门信息
* @param ids
* @return
*/
List<JSONObject> queryDepartsByIds(String ids);
/**
* 40发送邮件消息
* @param email
* @param title
* @param content
*/
void sendEmailMsg(String email,String title,String content);
/**
* 41根据部门id查询部门所有的父级(不包含自己)
* @author 马志朝
* @date 2021/3/24 8:50
* @param departId 部门id
* @return JSONObject
*/
List<SysDepartTreeModel> listParentDepartsByDepId(String departId);
/**
* 42根据部门id查询部门所有的子级(不包含自己)
* @author 马志朝
* @date 2021/3/24 8:54
* @param departId 部门id
* @return JSONObject
*/
List<SysDepartTreeModel> listSonDepartsByDepId(String departId);
/**
* 43 获取公司下级部门和公司下所有用户信息
* @param orgCode
*/
List<Map<String,Object>> getDeptUserByOrgCode(String orgCode);
/**
* 查询分类字典翻译
*/
List<String> loadCategoryDictItem(String ids);
/**
* 根据字典code加载字典text
*
* @param dictCode 顺序:tableName,text,code
* @param keys 要查询的key
* @return
*/
List<String> loadDictItem(String dictCode, String keys);
/**
* 根据字典code查询字典项
*
* @param dictCode 顺序:tableName,text,code
* @param dictCode 要查询的key
* @return
*/
List<DictModel> getDictItems(String dictCode);
/**
* 根据多个字典code查询多个字典项
* @param dictCodeList
* @return key = dictCode value=对应的字典项
*/
Map<String, List<DictModel>> getManyDictItems(List<String> dictCodeList);
/**
* 【JSearchSelectTag下拉搜索组件专用接口】
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
*
* @param dictCode 字典code格式:table,text,code
* @param keyword 过滤关键字
* @return
*/
List<DictModel> loadDictItemByKeyword(String dictCode, String keyword, Integer pageSize);
String translateByDictMap(Map<String, String> dictMap, String keys);
}
+26
View File
@@ -0,0 +1,26 @@
<?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>laws-base</artifactId>
<groupId>com.jero.boot</groupId>
<version>2.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>laws-base-api</artifactId>
<packaging>pom</packaging>
<modules>
<module>jero-system-local-api</module>
<module>jero-system-cloud-api</module>
</modules>
<dependencies>
<dependency>
<groupId>com.jero.boot</groupId>
<artifactId>laws-base-core</artifactId>
</dependency>
</dependencies>
</project>
+270
View File
@@ -0,0 +1,270 @@
<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>
<groupId>com.jero.boot</groupId>
<artifactId>laws-base</artifactId>
<version>2.5.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>laws-base-core</artifactId>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jeecg</id>
<name>jeecg Repository</name>
<url>https://maven.jeecg.org/nexus/content/repositories/jeecg</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!--jero-tools-->
<dependency>
<groupId>com.jero.boot</groupId>
<artifactId>laws-base-tools</artifactId>
</dependency>
<!-- 代码生成核心包 -->
<dependency>
<groupId>com.jero.boot</groupId>
<artifactId>laws-base-generater-core</artifactId>
<version>${jero.version}</version>
</dependency>
<!--集成springmvc框架并实现自动配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>tomcat-embed-core</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-el</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
<exclusion>
<artifactId>tomcat-embed-websocket</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- websocket -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--springboot2.3+ 需引入validation对应的包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- tomcat -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>${tomcat.version}</version>
<exclusions>
<exclusion>
<artifactId>tomcat-embed-core</artifactId>
<groupId>org.apache.tomcat.embed</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- commons -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons.version}</version>
</dependency>
<!-- freemarker -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!-- mybatis-plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<!-- druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${dynamic-datasource-spring-boot-starter.version}</version>
</dependency>
<!-- 数据库驱动 -->
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<scope>runtime</scope>
</dependency>
<!-- sqlserver-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqljdbc4.version}</version>
<scope>runtime</scope>
</dependency>
<!-- oracle驱动 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${ojdbc6.version}</version>
<scope>runtime</scope>
</dependency>
<!-- postgresql驱动 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Quartz定时任务 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<!--JWT-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${java-jwt.version}</version>
</dependency>
<!--shiro-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-starter</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- shiro-redis -->
<dependency>
<groupId>org.crazycake</groupId>
<artifactId>shiro-redis</artifactId>
<version>${shiro-redis.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j-spring-boot-starter.version}</version>
</dependency>
<!-- AutoPoi Excel工具类-->
<dependency>
<groupId>org.jeecgframework</groupId>
<artifactId>autopoi-web</artifactId>
<version>${autopoi-web.version}</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- mini文件存储服务 -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- 阿里云短信 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>${aliyun-java-sdk-dysmsapi.version}</version>
</dependency>
<!-- aliyun oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>${aliyun.oss.version}</version>
</dependency>
<!-- 第三方登录 -->
<dependency>
<groupId>com.xkcoding.justauth</groupId>
<artifactId>justauth-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,145 @@
package com.jero.common.api;
import com.jero.common.system.vo.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
public interface CommonAPI {
/**
* 1查询用户角色信息
* @param username
* @return
*/
Set<String> queryUserRoles(String username);
/**
* 2查询用户权限信息
* @param username
* @return
*/
Set<String> queryUserAuths(String username);
/**
* 3根据 id 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceId
* @return
*/
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);
/**
* 4根据 code 查询数据库中存储的 DynamicDataSourceModel
*
* @param dbSourceCode
* @return
*/
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);
/**
* 5根据用户账号查询用户信息
* @param username
* @return
*/
public LoginUser getUserByName(String username);
/**
* 6字典表的 翻译
* @param table
* @param text
* @param code
* @param key
* @return
*/
String translateDictFromTable(String table, String text, String code, String key);
/**
* 7普通字典的翻译
* @param code
* @param key
* @return
*/
String translateDict(String code, String key);
/**
* 8查询数据权限
* @return
*/
List<SysPermissionDataRuleModel> queryPermissionDataRule(String component, String requestPath, String username);
/**
* 9查询用户信息
* @param username
* @return
*/
SysUserCacheInfo getCacheUser(String username);
/**
* 10获取数据字典
* @param code
* @return
*/
public List<DictModel> queryDictItemsByCode(String code);
/**
* 获取有效的数据字典项
* @param code
* @return
*/
public List<DictModel> queryEnableDictItemsByCode(String code);
/**
* 13获取表数据字典
* @param table
* @param text
* @param code
* @return
*/
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
/**
* 14 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
* @param dictCodes 例如:user_status,sex
* @param keys 例如:1,2,0
* @return
*/
Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys);
/**
* 15 字典表的 翻译,可批量
* @param table
* @param text
* @param code
* @param keys 多个用逗号分割
* @return
*/
List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys);
/**
* 14获取全部字典
* @author lqt
* @date 2022/8/16 8:54
* @return JSONObject
*/
List<SysDictItemCore> getDictItemAll();;
/**
* 15通过查询指定table的 text code 获取字典值text
* @author lqt
* @date 2022/8/16 8:54
* @param table 表名
* @param text 文本
* @param code 编码
* @param key 键
* @return JSONObject
*/
String queryTableDictTextByKey(String table,String text,String code, String key);
String translateUserRealNameFromTable(String id);
List<DictModel> translateUserRealNameFromTableByKeys(String values);
}
@@ -0,0 +1,24 @@
package com.jero.common.api;
import com.jero.common.api.vo.OaWpsModel;
/**
* @Description: WPS通用接口
* @Author: wangshuai
* @Date:20200709
* @Version:V1.0
*/
public interface IWpsBaseAPI {
/*根据模板id获取模板信息*/
OaWpsModel getById(String id);
/*根据文件路径下载文件*/
void downloadOosFiles(String objectName, String basePath,String fileName);
/*WPS 设置数据存储,用于逻辑判断*/
void context(String type,String text);
/*删除WPS模板相关信息*/
void deleteById(String id);
}
@@ -0,0 +1,25 @@
package com.jero.common.api;
import com.jero.common.api.dto.message.HiworkTodoAdd;
import java.util.List;
/**
* @Author: liao
* @Date: 2023/10/27 15:15
* @Description: 发送消息
*/
public interface PushWorkflowIntegrationAPI {
/**
* @Author: liao
* @Date: 2023/10/13 15:12
* @Description: 统一待办集成
**/
void sendTodoTask(List<HiworkTodoAdd> hiworkTodoAddList);
void sendActivityComplete(List<HiworkTodoAdd> processInstanceId);
void sendDeleteTask(List<HiworkTodoAdd> todoAddList);
}
@@ -0,0 +1,30 @@
package com.jero.common.api.dto;
import lombok.Data;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
/**
* 文件下载
* cloud api 用到的接口传输对象
*/
@Data
public class FileDownDTO implements Serializable {
private static final long serialVersionUID = 6749126258686446019L;
private String filePath;
private String uploadpath;
private String uploadType;
private transient HttpServletResponse response;
public FileDownDTO(){}
public FileDownDTO(String filePath, String uploadpath, String uploadType,HttpServletResponse response){
this.filePath = filePath;
this.uploadpath = uploadpath;
this.uploadType = uploadType;
this.response = response;
}
}
@@ -0,0 +1,55 @@
package com.jero.common.api.dto;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
/**
* 文件上传
* cloud api 用到的接口传输对象
*/
@Data
public class FileUploadDTO implements Serializable {
private static final long serialVersionUID = -4111953058578954386L;
private transient MultipartFile file;
private String bizPath;
private String uploadType;
private String customBucket;
public FileUploadDTO(){
}
/**
* 简单上传 构造器1
* @param file
* @param bizPath
* @param uploadType
*/
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType){
this.file = file;
this.bizPath = bizPath;
this.uploadType = uploadType;
}
/**
* 申明桶 文件上传 构造器2
* @param file
* @param bizPath
* @param uploadType
* @param customBucket
*/
public FileUploadDTO(MultipartFile file,String bizPath,String uploadType,String customBucket){
this.file = file;
this.bizPath = bizPath;
this.uploadType = uploadType;
this.customBucket = customBucket;
}
}
@@ -0,0 +1,68 @@
package com.jero.common.api.dto;
import lombok.Data;
import com.jero.common.system.vo.LoginUser;
import java.io.Serializable;
import java.util.Date;
/**
* 日志对象
* cloud api 用到的接口传输对象
*/
@Data
public class LogDTO implements Serializable {
private static final long serialVersionUID = 8482720462943906924L;
/**内容*/
private String logContent;
/**日志类型(0:操作日志;1:登录日志;2:定时任务) */
private Integer logType;
/**操作类型(1:添加;2:修改;3:删除;) */
private Integer operateType;
/**登录用户 */
private transient LoginUser loginUser;
private String id;
private String createBy;
private Date createTime;
private Long costTime;
private String ip;
/**请求参数 */
private String requestParam;
/**请求类型*/
private String requestType;
/**请求路径*/
private String requestUrl;
/**请求方法 */
private String method;
/**操作人用户名称*/
private String username;
/**操作人用户账户*/
private String userid;
public LogDTO(){
}
public LogDTO(String logContent, Integer logType, Integer operatetype){
this.logContent = logContent;
this.logType = logType;
this.operateType = operatetype;
}
public LogDTO(String logContent, Integer logType, Integer operatetype, LoginUser loginUser){
this.logContent = logContent;
this.logType = logType;
this.operateType = operatetype;
this.loginUser = loginUser;
}
}
@@ -0,0 +1,41 @@
package com.jero.common.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* online 拦截器权限判断
* cloud api 用到的接口传输对象
*/
@Data
public class OnlineAuthDTO implements Serializable {
private static final long serialVersionUID = 1771827545416418203L;
/**
* 用户名
*/
private String username;
/**
* 可能的请求地址
*/
private List<String> possibleUrl;
/**
* online开发的菜单地址
*/
private String onlineFormUrl;
public OnlineAuthDTO(){
}
public OnlineAuthDTO(String username, List<String> possibleUrl, String onlineFormUrl){
this.username = username;
this.possibleUrl = possibleUrl;
this.onlineFormUrl = onlineFormUrl;
}
}
@@ -0,0 +1,43 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import java.io.Serializable;
/**
* 带业务参数的消息
*/
@Data
public class BusMessageDTO extends MessageDTO implements Serializable {
private static final long serialVersionUID = 9104793287983367669L;
/**
* 业务类型
*/
private String busType;
/**
* 业务id
*/
private String busId;
public BusMessageDTO(){
}
/**
* 构造 带业务参数的消息
* @param fromUser
* @param toUser
* @param title
* @param msgContent
* @param msgCategory
* @param busType
* @param busId
*/
public BusMessageDTO(String fromUser, String toUser, String title, String msgContent, String msgCategory, String busType, String busId){
super(fromUser, toUser, title, msgContent, msgCategory);
this.busId = busId;
this.busType = busType;
}
}
@@ -0,0 +1,45 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* 带业务参数的模板消息
*/
@Data
public class BusTemplateMessageDTO extends TemplateMessageDTO implements Serializable {
private static final long serialVersionUID = -4277810906346929459L;
/**
* 业务类型
*/
private String busType;
/**
* 业务id
*/
private String busId;
public BusTemplateMessageDTO(){
}
/**
* 构造 带业务参数的模板消息
* @param fromUser
* @param toUser
* @param title
* @param templateParam
* @param templateCode
* @param busType
* @param busId
*/
public BusTemplateMessageDTO(String fromUser, String toUser, String title, Map<String, String> templateParam, String templateCode, String busType, String busId){
super(fromUser, toUser, title, templateParam, templateCode);
this.busId = busId;
this.busType = busType;
}
}
@@ -0,0 +1,29 @@
package com.jero.common.api.dto.message;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Author: liao
* @Date: 2023/10/13 14:22
* @Description: 待办
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="统一待办集成", description="统一待办集成")
public class HiworkTodoAdd {
@ApiModelProperty(value = "审批记录表id")
private String recordId;
@ApiModelProperty(value = "流程定义id")
private String processDefinitionId;
@ApiModelProperty(value = "1待办,2已办,3结束,6删除,其他是待办已办")
private String type;
@ApiModelProperty(value = "转办时用")
private String toUserId;
}
@@ -0,0 +1,69 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import com.jero.common.constant.CommonConstant;
import java.io.Serializable;
/**
* 普通消息
*/
@Data
public class MessageDTO implements Serializable {
private static final long serialVersionUID = -5690444483968058442L;
/**
* 发送人(用户登录账户)
*/
protected String fromUser;
/**
* 发送给(用户登录账户)
*/
protected String toUser;
/**
* 消息主题
*/
protected String title;
/**
* 消息内容
*/
protected String content;
/**
* 消息类型 1:消息 2:系统消息
*/
protected String category;
public MessageDTO(){
}
/**
* 构造器1 系统消息
*/
public MessageDTO(String fromUser,String toUser,String title, String content){
this.fromUser = fromUser;
this.toUser = toUser;
this.title = title;
this.content = content;
//默认 都是2系统消息
this.category = CommonConstant.MSG_CATEGORY_2;
}
/**
* 构造器2 支持设置category 1:消息 2:系统消息
*/
public MessageDTO(String fromUser,String toUser,String title, String content, String category){
this.fromUser = fromUser;
this.toUser = toUser;
this.title = title;
this.content = content;
this.category = category;
}
}
@@ -0,0 +1,26 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import java.util.Map;
/**
* @Author: liao
* @Date: 2023/10/17 11:19
* @Description: 发送消息
*/
@Data
public class SendMessageDTO {
/**
* 模板code
*/
private String templateCode;
/**
* 接收人id,多个以逗号分隔
*/
private String toUserId;
/**
* 对象例如 用户名:${username} map{"username":"张三"} 转换成 用户名:张三
*/
private Map<String, String> map;
}
@@ -0,0 +1,37 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* 消息模板dto
*/
@Data
public class TemplateDTO implements Serializable {
private static final long serialVersionUID = 5848247133907528650L;
/**
* 模板编码
*/
protected String templateCode;
/**
* 模板参数
*/
protected transient Map<String, String> templateParam;
/**
* 构造器 通过设置模板参数和模板编码 作为参数获取消息内容
*/
public TemplateDTO(String templateCode, Map<String, String> templateParam){
this.templateCode = templateCode;
this.templateParam = templateParam;
}
public TemplateDTO(){
}
}
@@ -0,0 +1,48 @@
package com.jero.common.api.dto.message;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* 模板消息
*/
@Data
public class TemplateMessageDTO extends TemplateDTO implements Serializable {
private static final long serialVersionUID = 411137565170647585L;
/**
* 发送人(用户登录账户)
*/
protected String fromUser;
/**
* 发送给(用户登录账户)
*/
protected String toUser;
/**
* 消息主题
*/
protected String title;
public TemplateMessageDTO(){
}
/**
* 构造器1 发模板消息用
*/
public TemplateMessageDTO(String fromUser, String toUser,String title, Map<String, String> templateParam, String templateCode){
super(templateCode, templateParam);
this.fromUser = fromUser;
this.toUser = toUser;
this.title = title;
}
}
@@ -0,0 +1,107 @@
package com.jero.common.api.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 文档
* @Author: jero-boot
* @Date: 2020-06-09
* @Version: V1.0
*/
@Data
@TableName("oa_wps_file")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "oa_wps_file对象", description = "文档")
public class OaWpsModel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private String id;
/**
* name
*/
@Excel(name = "name", width = 15)
@ApiModelProperty(value = "name")
private String name;
/**
* version
*/
@Excel(name = "version", width = 15)
@ApiModelProperty(value = "version")
private Integer version;
/**
* size
*/
@Excel(name = "size", width = 15)
@ApiModelProperty(value = "size")
private Integer size;
/**
* downloadUrl
*/
@Excel(name = "downloadUrl", width = 15)
@ApiModelProperty(value = "downloadUrl")
private String downloadUrl;
/**
* deleted
*/
@Excel(name = "deleted", width = 15)
@ApiModelProperty(value = "deleted")
private String deleted;
/**
* canDelete
*/
@Excel(name = "canDelete", width = 15)
@ApiModelProperty(value = "canDelete")
private String canDelete;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 组织机构编码
*/
@ApiModelProperty(value = "组织机构编码")
private String sysOrgCode;
@TableField(exist = false)
private String userId;
}
@@ -0,0 +1,147 @@
package com.jero.common.api.vo;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jero.common.util.MessageUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.jero.common.constant.CommonConstant;
import lombok.Data;
/**
* 接口返回数据格式
* @author scott
* @date 2019年1月19日
*/
@Data
@ApiModel(value="接口返回对象", description="接口返回对象")
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 成功标志
*/
@ApiModelProperty(value = "成功标志")
private boolean success = true;
/**
* 返回处理消息
*/
@ApiModelProperty(value = "返回处理消息")
private String message = "操作成功!";
/**
* 返回代码
*/
@ApiModelProperty(value = "返回代码")
private Integer code = 200;
/**
* 返回数据对象 data
*/
@ApiModelProperty(value = "返回数据对象")
private transient T result;
/**
* 时间戳
*/
@ApiModelProperty(value = "时间戳")
private long timestamp = System.currentTimeMillis();
public Result() {
// do other
}
public Result<T> success(String message) {
this.message = message;
this.code = CommonConstant.SC_OK_200;
this.success = true;
return this;
}
public static<T> Result<T> OK() {
Result<T> r = new Result<>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(MessageUtils.getMessage(ResultCommon.OK));
return r;
}
public static<T> Result<T> OK(String msg) {
Result<T> r = new Result<>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
msg = MessageUtils.getMessage(msg);
r.setMessage(msg);
return r;
}
public static<T> Result<T> OK(String msg, Object... args) {
Result<T> r = new Result<>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
msg = MessageUtils.getMessage(msg,args);
r.setMessage(msg);
return r;
}
public static<T> Result<T> OK(T data) {
Result<T> r = new Result<>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setResult(data);
return r;
}
public static<T> Result<T> OK(String msg, T data) {
Result<T> r = new Result<>();
r.setSuccess(true);
r.setCode(CommonConstant.SC_OK_200);
r.setMessage(msg);
r.setResult(data);
return r;
}
public static<T> Result<T> error(String msg, T data) {
Result<T> r = new Result<>();
r.setSuccess(false);
r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
r.setMessage(msg);
r.setResult(data);
return r;
}
public static<T> Result<T> error(String msg) {
msg = MessageUtils.getMessage(msg);
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
}
public static<T> Result<T> error(String msg, Object... args) {
msg = MessageUtils.getMessage(msg,args);
return error(CommonConstant.SC_INTERNAL_SERVER_ERROR_500, msg);
}
public static<T> Result<T> error(int code, String msg) {
Result<T> r = new Result<>();
r.setCode(code);
r.setMessage(msg);
r.setSuccess(false);
return r;
}
public Result<T> error500(String message) {
this.message = message;
this.code = CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
this.success = false;
return this;
}
/**
* 无权限访问返回结果
*/
public static Result<Object> noauth(String msg) {
return error(CommonConstant.SC_JERO_NO_AUTHZ, msg);
}
@JsonIgnore
private String onlTable;
}
@@ -0,0 +1,170 @@
package com.jero.common.api.vo;
/**
* @Author: liao
* @Date: 2023/8/24 14:01
* @Description: 返回常量
*/
public class ResultCommon {
private ResultCommon() {}
/**操作成功*/
public static final String OK = "message.ok";
/**操作失败*/
public static final String ERROR = "message.error";
/**编辑成功*/
public static final String EDIT_OK = "edit.ok";
/**编辑失败*/
public static final String EDIT_ERROR = "edit.error";
/**请选择数据*/
public static final String PLEASE_SELECT_DATA = "please.select.data";
/**删除成功*/
public static final String SUCCESSFULLY_DELETED = "successfully.deleted";
/**批量删除成功*/
public static final String SUCCESSFULLY_DELETED_IN_BULK = "successfully.deleted.in.bulk";
/**未找到对应数据*/
public static final String NO_CORRESPONDING_DATA_FOUND = "no.corresponding.data.found";
/**已过期*/
public static final String OVER_DUE = "over.due";
/**参数不识别*/
public static final String PARAMETER_NOT_RECOGNIZED = "parameter.not.recognized";
public static final String EMPTY_SOURCE = "message.empty.source"; // 来源不能为空
public static final String EMPTY_STANDARD_NUMBER = "message.empty.standard.number"; // 标准编号不能为空
public static final String EMPTY_STANDARD_NAME = "message.empty.standard.name"; // 标准名称不能为空
public static final String EMPTY_COMMON = "message.empty.common"; // {0}不能为空
public static final String EXIST_STANDARD_NUMBER = "message.exists.standard.number"; // 标准编号已经存在
public static final String NOT_EXIST_PARAM = "message.no.exists.param"; // 参数{0}不存在
public static final String NO_PERMISSION = "message.no.permission"; // 没有数据操作权限
public static final String SELECT_DATA = "message.select.data"; // 请选择数据
public static final String EXIST_SUB_FOLDERS = "message.exist.sub.folders"; // 文件夹下有子文件夹 ,该文件夹不允许删除
public static final String EXIST_SUB_FILES = "message.exist.sub.files"; // 文件夹下有文件不能删除
public static final String RMR_SET_QUALITY_OVER_TEN = "es.rmr.setQuality.overTen"; // 请最多选择10条
public static final String SUCCESSFULLY_CLEARED = "successfully.cleared"; // 清除成功
public static final String CANNOT_DUPLICATE_FAVORITES = "cannot.duplicate.favorites"; // 不能重复收藏
public static final String THE_TOPLEVEL_GROUP_CANNOT_BE_DELETED = "the.toplevel.group.cannot.be.deleted"; // 最高级组别不能删除
public static final String PLEASE_SELECT_PERSONNEL_AND_WORKGROUP = "please.select.personnel.and.workgroup"; // 请选择人员和工作组
public static final String NUMBER_WORK_NO_ALREADY_EXISTS = "number.work.no.already.exists"; // 工号已存在
public static final String NO_FILES_IMPORTED = "no.files.imported"; // 没有导入文件
public static final String PLEASE_SELECT_A_WORKGROUP_TO_IMPORT = "Please.select.a.workgroup.to.import"; // 请选择工作组进行导入
public static final String PLEASE_USE_A_FILE_WITH_THE_SUFFIX_XLS = "please.use.a.file.with.the.suffix.xls"; // 文件名格式不正确, 请使用后缀名为.xls的文件
public static final String IMPORT_DATA_CANNOT_BE_EMPTY = "import.data.cannot.be.empty"; // 导入数据不能为空
public static final String HEADER_INCONSISTENT_WITH_TEMPLATE = "header.inconsistent.with.template"; // 表头与模板不一致
public static final String PLEASE_SELECT_A_WORKGROUP_TO_EXPORT = "please.select.a.workgroup.for.export"; // 请选择工作组进行导出
public static final String THE_JOB_NUMBER_CANNOT_BE_EMPTY_EXPORT = "the.job.number.cannot.be.empty.export"; // 第{0}行,工号不能为空
public static final String THE_REAL_NAME_CANNOT_BE_EMPTY_EXPORT = "the.real.name.cannot.be.empty.export"; // 第{0}行,姓名不能为空
public static final String THE_REAL_NAME_AND_JOB_NUMBER_MISMATCH_EXPORT = "the.real.name.and.job.number.mismatch.export"; // 第{0}行,姓名与工号不匹配
public static final String JOB_NUMBER_DOES_NOT_EXIST_EXPORT = "job.number.does.not.exist.export"; // 第{0}行,工号不存在
public static final String DUPLICATE_JOB_NUMBER_EXPORT = "duplicate.job.number.export"; // 第{0}行,工号重复
public static final String CANNOT_CLOSE = "cannot.close"; // 不是待整改已过期的数据不能关闭
public static final String NO_CORRESPONDING_RECORD_FOUND = "no.corresponding.record.found"; // 没有找到对应的记录
public static final String PARAMETERS_CANNOT_BE_NULL = "parameters.cannot.be.null"; // 参数不能为空
public static final String ROOT_NODE_CANNOT_BE_EDITED = "root.node.cannot.be.edited"; // 根节点不能编辑
public static final String HORIZONTAL_TRANSGRESSION = "horizontal.transgression"; // 水平越权
public static final String NO_PERMISSIONS_PLEASE_SELECT = "horizontal.transgression.select"; // 暂无权限,请重新选择
public static final String SELECT_LEVEL_TWO_TREE_NODE = "select.level.two.tree.node"; // 请先选择二级及以下体系
public static final String EXPORT_ERROR = "export.error"; // 导出ZIP压缩包失败
public static final String IMPORT_ERROR = "import.error"; // 导入ZIP压缩包失败
public static final String PLEASE_UPLOAD_ZIP = "please.upload.zip.archive"; // 请上传Zip压缩包
public static final String TASK_HANDLER_ERROR = "task.handler.error"; // 只有处理人可以操作
public static final String NO_AUTH = "no.auth"; // 只有处理人可以操作
public static final String IMPORT_TEMPLATE_ERROR = "import.template.error"; // 导入模板错误
public static final String ZIP_CHARSET_ERROR = "zip.charset.error"; // zip压缩包编码错误
/**字段名称太长*/
public static final String TAG_ADD_ERROR_1 = "tag.add.error.1";
/**每张表最多有50个字段*/
public static final String TAG_ADD_ERROR_2 = "tag.add.error.2";
/**同一所属模块下,展示区域名称不能重复!*/
public static final String TAG_ERROR_1 = "tag.error.1";
/**该展示区域有关联数据,无法删除!*/
public static final String TAG_DELETE_ERROR_2 = "tag.delete.error.2";
/**包含固定字段,不可删除*/
public static final String TAG_DELETE_ERROR_3 = "tag.delete.error.3";
/**包含固定字段,不可编辑*/
public static final String TAG_EDIT_ERROR_1 = "tag.edit.error.1";
/**属性已存在,请检查*/
public static final String TAG_EDIT_ERROR_2 = "tag.edit.error.2";
/**标签已被引用,无法删除*/
public static final String DICT_DELETE_ERROR = "dict.delete.error";
public static final String FOLDER_ONLY_ONE = "folder.only.one";
public static final String YOU_HAVE_NOT_DATA_AUTH = "you.have.not.data.auth";
/**请输入检索内容*/
public static final String PLEASE_SEARCH_TO_IMPORT = "please.search.to.import";
/**
* 任务不存在
*/
public static final String TASK_NOT_EXISTS = "task.not.exists";
/**
* 只能催办待办任务
*/
public static final String TASK_URGING_ERROR = "task.urging.error";
/**
* 暂无该流程催办权限
*/
public static final String TASK_URGING_ERROR_2 = "task.urging.error.2";
/**
* 草稿不存在
*/
public static final String DRAFT_NOT_EXISTS = "draft.not.exists";
/**
* 企标编号已存在,需等待重新生成顺序号
*/
public static final String EN_STANDARD_NUMBER_CONFLICT = "en.standard.number.conflict";
/**
* 该新企标编号与已存在的企标编号重复,请重新修改提交
*/
public static final String NEW_EN_STANDARD_NUMBER_CONFLICT = "new.en.standard.number.conflict";
/**
* 无效的企标计划
*/
public static final String INVALID_ESP = "invalid.esp";
/**
* 不可以编辑废止或封存状态的企标
*/
public static final String CAN_NOT_EDIT_ABOLISH_OR_ARCHIVE_ES = "can.not.edit.abolish.or.archive.es";
// ---------项目合规评估流程---------
/**
* 模块负责人不能为空
*/
public static final String ProjectAssess = "en.standard.number.conflict";
// ---------项目合规评估流程---------
//未符合项中有整改中、审批中的数据时,不允许删除
public static final String ASSESS_DELETE_ERROR = "assess.delete.error";
//项目中有评估中的数据时,不允许删除
public static final String ASSESS_DELETE_ERROR2 = "assess.delete.error2";
}
@@ -0,0 +1,25 @@
package com.jero.common.api.vo;
/**
* @author LQT
* @date 2023/3/9 9:11
*/
public class ResultConstant {
private ResultConstant(){
}
public static final String OP_OK = "操作成功!";
public static final String DEL_OK = "删除成功!";
public static final String DEL_ERR = "删除失败!";
public static final String BATCH_DEL_OK = "批量删除成功!";
public static final String EN_WAS_NOT_FOUND = "未找到对应实体!";
}
@@ -0,0 +1,19 @@
package com.jero.common.api.vo;
import com.jero.common.api.dto.message.SendMessageDTO;
/**
* @Author: liao
* @Date: 2023/10/27 15:15
* @Description: 发送消息
*/
public interface SendMessageAPI {
/**
* @Author: liao
* @Date: 2023/10/27 15:13
* @Description: 根据模板发送消息
**/
void sendMessage(SendMessageDTO sendMessageDTO);
}
@@ -0,0 +1,219 @@
package com.jero.common.aspect;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.jero.common.api.dto.LogDTO;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.AutoLog;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.enums.ModuleType;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.IPUtils;
import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.base.service.BaseCommonService;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.JoinPoint;
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.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* 系统日志,切面处理类
*
* @Author scott
* @Date 2018年1月14日
*/
@Aspect
@Component
public class AutoLogAspect {
@Resource
private BaseCommonService baseCommonService;
@Pointcut("@annotation(com.jero.common.aspect.annotation.AutoLog)")
public void logPointCut() {
// do other
}
@Around("logPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
long beginTime = System.currentTimeMillis();
//执行方法
Object result = point.proceed();
//执行时长(毫秒)
long time = System.currentTimeMillis() - beginTime;
//保存日志
saveSysLog(point, time, result);
return result;
}
private void saveSysLog(ProceedingJoinPoint joinPoint, long time, Object obj) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
LogDTO dto = new LogDTO();
AutoLog syslog = method.getAnnotation(AutoLog.class);
if(syslog != null){
//update-begin-author:taoyan date:
String content = syslog.value();
if(syslog.module()== ModuleType.ONLINE){
content = getOnlineLogContent(obj, content);
}
//注解上的描述,操作日志内容
dto.setLogType(syslog.logType());
dto.setLogContent(content);
}
//请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
dto.setMethod(className + "." + methodName + "()");
//设置操作类型
if (dto.getLogType() == CommonConstant.LOG_TYPE_2) {
assert syslog != null;
dto.setOperateType(getOperateType(methodName, syslog.operateType()));
}
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//请求的参数
dto.setRequestParam(getReqestParams(request,joinPoint));
//设置IP地址
dto.setIp(IPUtils.getIpAddr(request));
//获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(sysUser!=null){
if ("admin".equals(sysUser.getUsername())){
return;
}
dto.setUserid(sysUser.getUsername());
dto.setUsername(sysUser.getRealname());
}
//耗时
dto.setCostTime(time);
dto.setCreateTime(new Date());
//保存系统日志
baseCommonService.addLog(dto);
}
/**
* 获取操作类型
*/
private int getOperateType(String methodName,int operateType) {
if (operateType > 0) {
return operateType;
}
if (methodName.startsWith("list") || methodName.startsWith("query")) {
return CommonConstant.OPERATE_TYPE_1;
}
if (methodName.startsWith("add") || methodName.startsWith("create")) {
return CommonConstant.OPERATE_TYPE_2;
}
if (methodName.startsWith("edit") || methodName.startsWith("update")) {
return CommonConstant.OPERATE_TYPE_3;
}
if (methodName.startsWith("delete") || methodName.startsWith("remove")) {
return CommonConstant.OPERATE_TYPE_4;
}
if (methodName.startsWith("import")) {
return CommonConstant.OPERATE_TYPE_5;
}
if (methodName.startsWith("export")) {
return CommonConstant.OPERATE_TYPE_6;
}
return CommonConstant.OPERATE_TYPE_1;
}
/**
* @Description: 获取请求参数
* @author: scott
* @date: 2020/4/16 0:10
* @param request: request
* @param joinPoint: joinPoint
* @Return: java.lang.String
*/
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
String httpMethod = request.getMethod();
StringBuilder params = new StringBuilder();
List<String> list = Arrays.asList("POST","PUT","PATCH");
if (list.contains(httpMethod)) {
Object[] paramsArray = joinPoint.getArgs();
// java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
// https://my.oschina.net/mengzhang6/blog/2395893
Object[] arguments = new Object[paramsArray.length];
for (int i = 0; i < paramsArray.length; i++) {
if (paramsArray[i] instanceof BindingResult || paramsArray[i] instanceof ServletRequest || paramsArray[i] instanceof ServletResponse || paramsArray[i] instanceof MultipartFile) {
//ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
//ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
continue;
}
arguments[i] = paramsArray[i];
}
//update-begin-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
PropertyFilter profilter = (o, name, value) -> value == null || value.toString().length() <= 500;
params = new StringBuilder(JSON.toJSONString(arguments, profilter));
//update-end-author:taoyan date:20200724 for:日志数据太长的直接过滤掉
} else {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
// 请求的方法参数值
Object[] args = joinPoint.getArgs();
// 请求的方法参数名称
LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
String[] paramNames = u.getParameterNames(method);
if (args != null && paramNames != null) {
for (int i = 0; i < args.length; i++) {
params.append(" ").append(paramNames[i]).append(": ").append(args[i]);
}
}
}
return params.toString();
}
/**
* online日志内容拼接
* @param obj
* @param content
* @return
*/
private String getOnlineLogContent(Object obj, String content){
if (obj instanceof Result){
Result<T> res = (Result)obj;
String msg = res.getMessage();
String tableName = res.getOnlTable();
if(oConvertUtils.isNotEmpty(tableName)){
content+=",表名:"+tableName;
}
if(res.isSuccess()){
content+= ","+(oConvertUtils.isEmpty(msg)?"操作成功":msg);
}else{
content+= ","+(oConvertUtils.isEmpty(msg)?"操作失败":msg);
}
}
return content;
}
}
@@ -0,0 +1,507 @@
package com.jero.common.aspect;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jero.common.api.CommonAPI;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.Dict;
import com.jero.common.constant.CacheConstant;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.vo.DictModel;
import com.jero.common.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @Description: 字典aop类
* @Author: dangzhenghui
* @Date: 2019-3-17 21:50
* @Version: 1.0
*/
@Aspect
@Component
@Slf4j
public class DictAspect {
@Autowired
private CommonAPI commonAPI;
@Autowired
public RedisTemplate<String,Object> redisTemplate;
private static final String SYS_CACHE_DICT_S_S = "sys:cache:dict::%s:%s";
// 定义切点Pointcut
@Pointcut("execution(public * com.jero.modules..*.*Controller.*(..))")
public void excudeService() {
// do other
}
@Pointcut("@annotation(com.jero.common.aspect.annotation.DictPoint)")
public void dictPointCut() {
}
@Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time1=System.currentTimeMillis();
Object result = pjp.proceed();
long time2=System.currentTimeMillis();
log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
long start=System.currentTimeMillis();
this.parseDictText(result);
long end=System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms");
return result;
}
@Around("dictPointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable {
long time1 = System.currentTimeMillis();
Object result = point.proceed();
long time2 = System.currentTimeMillis();
log.debug("获取JSON数据 耗时:" + (time2 - time1) + "ms");
long start = System.currentTimeMillis();
this.parseMethodDictText(result);
long end = System.currentTimeMillis();
log.debug("解析注入JSON数据 耗时" + (end - start) + "ms");
return result;
}
/**
* 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
* 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 table字典 code table text配合使用与原来jero的用法相同
* 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text,已字段名称加_dictText形式返回到前端
* 例输入当前返回值的就会多出一个sex_dictText字段
* {
* sex:1,
* sex_dictText:"男"
* }
* 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
* customRender:function (text) {
* if(text==1){
* return "男";
* }else if(text==2){
* return "女";
* }else{
* return text;
* }
* }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
* @param result
*/
private void parseDictText(Object result) {
if (result instanceof Result && ((Result) result).getResult() instanceof IPage) {
List<JSONObject> items = new ArrayList<>();
//step.1 筛选出加了 Dict 注解的字段列表
List<Field> dictFieldList = new ArrayList<>();
// 字典数据列表, key = 字典code,value=数据列表
Map<String, List<String>> dataListMap = new HashMap<>();
addItems((Result) result, items, dictFieldList, dataListMap);
//step.2 调用翻译方法,一次性翻译
Map<String, List<DictModel>> translText = this.translateAllDict(dataListMap);
//step.3 将翻译结果填充到返回结果里
putItems(items, dictFieldList, translText);
((IPage) ((Result) result).getResult()).setRecords(items);
}
}
private void putItems(List<JSONObject> items, List<Field> dictFieldList, Map<String, List<DictModel>> translText) {
for (JSONObject obj : items) {
for (Field field : dictFieldList) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String fieldDictCode = code;
if (!StringUtils.isEmpty(table)) {
fieldDictCode = String.format("%s,%s,%s", table, text, code);
}
String value = obj.getString(field.getName());
if (oConvertUtils.isNotEmpty(value)) {
List<DictModel> dictModels = translText.get(fieldDictCode);
if(dictModels==null || dictModels.isEmpty()){
continue;
}
String textValue = this.translDictText(dictModels, value);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + " " + textValue);
// TODO-sun 测试输出,待删
log.debug(" ---- dictCode: " + fieldDictCode);
log.debug(" ---- value: " + value);
log.debug(" ----- text: " + textValue);
log.debug(" ---- dictModels: " + JSON.toJSONString(dictModels));
obj.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
}
}
}
private void addItems(Result<IPage<T>> result, List<JSONObject> items, List<Field> dictFieldList, Map<String, List<String>> dataListMap) {
for (Object obj : result.getResult().getRecords()) {
ObjectMapper mapper = new ObjectMapper();
String json="{}";
try {
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
log.error("json解析失败"+e.getMessage(),e);
}
JSONObject item = JSON.parseObject(json,Feature.OrderedField);
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
// 遍历所有字段,把字典Code取出来,放到 map 里
putItem(dictFieldList, dataListMap, obj, item);
items.add(item);
}
}
private void putItem(List<Field> dictFieldList, Map<String, List<String>> dataListMap, Object obj, JSONObject item) {
for (Field field : oConvertUtils.getAllFields(obj)) {
String value = item.getString(field.getName());
if (oConvertUtils.isEmpty(value)) {
continue;
}
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
if (!dictFieldList.contains(field)) {
dictFieldList.add(field);
}
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
List<String> dataList;
String dictCode = code;
if (!StringUtils.isEmpty(table)) {
dictCode = String.format("%s,%s,%s", table, text, code);
}
dataList = dataListMap.computeIfAbsent(dictCode, k -> new ArrayList<>());
this.listAddAllDeduplicate(dataList, Arrays.asList(value.split(",")));
}
//date类型默认转换string格式化日期
if (Date.class.isAssignableFrom(field.getType()) && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null){
SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
}
/**
* list 去重添加
*/
private void listAddAllDeduplicate(List<String> dataList, List<String> addList) {
// 筛选出dataList中没有的数据
List<String> filterList = addList.stream().filter(i -> !dataList.contains(i)).collect(Collectors.toList());
dataList.addAll(filterList);
}
/**
* 一次性把所有的字典都翻译了
* 1. 所有的普通数据字典的所有数据只执行一次SQL
* 2. 表字典相同的所有数据只执行一次SQL
* @param dataListMap
* @return
*/
private Map<String, List<DictModel>> translateAllDict(Map<String, List<String>> dataListMap) {
// 翻译后的字典文本,key=dictCode
Map<String, List<DictModel>> translText = new HashMap<>();
// 需要翻译的数据(有些可以从redis缓存中获取,就不走数据库查询)
List<String> needTranslData = new ArrayList<>();
//step.1 先通过redis中获取缓存字典数据
for (Map.Entry<String, List<String>> entry : dataListMap.entrySet()) {
String dictCode = entry.getKey();
List<String> dataList = entry.getValue();
if (dataList.isEmpty()) {
continue;
}
// 表字典需要翻译的数据
List<String> needTranslDataTable = new ArrayList<>();
addNeedTranslData(translText, needTranslData, dictCode, dataList, needTranslDataTable);
//step.2 调用数据库翻译表字典
if (!needTranslDataTable.isEmpty()) {
String[] arr = dictCode.split(",");
String table = arr[0];
String text = arr[1];
String code = arr[2];
String values = String.join(",", needTranslDataTable);
log.info("translateDictFromTableByKeys.dictCode:" + dictCode);
log.info("translateDictFromTableByKeys.values:" + values);
List<DictModel> texts;
if ("sys_user".equals(table)&&"realname".equals(text)&&"id".equals(code)){
texts = commonAPI.translateUserRealNameFromTableByKeys(values);
}else {
texts = commonAPI.translateDictFromTableByKeys(table, text, code, values);
}
log.info("translateDictFromTableByKeys.result:" + texts);
List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
list.addAll(texts);
setRedis(dictCode, texts);
}
}
//step.3 调用数据库进行翻译普通字典
if (!needTranslData.isEmpty()) {
List<String> dictCodeList = Arrays.asList(dataListMap.keySet().toArray(new String[]{}));
// 将不包含逗号的字典code筛选出来,因为带逗号的是表字典,而不是普通的数据字典
List<String> filterDictCodes = dictCodeList.stream().filter(key -> !key.contains(",")).collect(Collectors.toList());
String dictCodes = String.join(",", filterDictCodes);
String values = String.join(",", needTranslData);
log.info("translateManyDict.dictCodes:" + dictCodes);
log.info("translateManyDict.values:" + values);
Map<String, List<DictModel>> manyDict = commonAPI.translateManyDict(dictCodes, values);
log.info("translateManyDict.result:" + manyDict);
for (Map.Entry<String, List<DictModel>> entry : manyDict.entrySet()) {
String dictCode = entry.getKey();
List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
List<DictModel> newList = entry.getValue();
list.addAll(newList);
// 做 redis 缓存
for (DictModel dict : newList) {
String redisKey = String.format(SYS_CACHE_DICT_S_S, dictCode, dict.getValue());
try {
redisTemplate.opsForValue().set(redisKey, dict.getText());
} catch (Exception e) {
log.warn(e.getMessage(), e);
}
}
}
}
return translText;
}
private void setRedis(String dictCode, List<DictModel> texts) {
// 做 redis 缓存
for (DictModel dict : texts) {
String redisKey = String.format(CacheConstant.SYS_DICT_TABLE_CACHE_SIMPLE_KEY, dictCode, dict.getValue());
try {
// 保留10分钟
redisTemplate.opsForValue().set(redisKey, dict.getText(), 600, TimeUnit.SECONDS);
} catch (Exception e) {
log.warn(e.getMessage(), e);
}
}
}
private void addNeedTranslData(Map<String, List<DictModel>> translText, List<String> needTranslData, String dictCode, List<String> dataList, List<String> needTranslDataTable) {
for (String s : dataList) {
String data = s.trim();
if (data.length() == 0) {
continue; //跳过循环
}
if (dictCode.contains(",")) {
String keyString = String.format(CacheConstant.SYS_DICT_TABLE_CACHE_SIMPLE_KEY, dictCode, data);
if (Boolean.TRUE.equals(redisTemplate.hasKey(keyString))) {
addList(translText, dictCode, data, keyString);
} else if (!needTranslDataTable.contains(data)) {
// 去重添加
needTranslDataTable.add(data);
}
} else {
String keyString = String.format(SYS_CACHE_DICT_S_S, dictCode, data);
if (Boolean.TRUE.equals(redisTemplate.hasKey(keyString))) {
addList(translText, dictCode, data, keyString);
} else if (!needTranslData.contains(data)) {
// 去重添加
needTranslData.add(data);
}
}
}
}
private void addList(Map<String, List<DictModel>> translText, String dictCode, String data, String keyString) {
try {
String text = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
List<DictModel> list = translText.computeIfAbsent(dictCode, k -> new ArrayList<>());
list.add(new DictModel(data, text));
} catch (Exception e) {
log.warn(e.getMessage());
}
}
/**
* 字典值替换文本
*
* @param dictModels
* @param values
* @return
*/
private String translDictText(List<DictModel> dictModels, String values) {
List<String> result = new ArrayList<>();
// 允许多个逗号分隔,允许传数组对象
String[] splitVal = values.split(",");
for (String val : splitVal) {
String dictText = "";
for (DictModel dict : dictModels) {
if (val.equals(dict.getValue())) {
dictText = dict.getText();
break;
}
}
result.add(dictText);
}
return String.join(",", result);
}
/**
* 翻译字典文本
* @param code
* @param text
* @param table
* @param key
* @deprecated 不推荐
* @return
*/
@Deprecated
private String translateDictValue(String code, String text, String table, String key) {
if(oConvertUtils.isEmpty(key)) {
return null;
}
StringBuilder textValue = new StringBuilder();
String[] keys = key.split(",");
for (String k : keys) {
String tmpValue = null;
log.debug(" 字典 key : "+ k);
if (k.trim().length() == 0) {
continue; //跳过循环
}
//update-begin--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
tmpValue = getTmpValue(code, text, table, k, tmpValue);
//update-end--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
if (tmpValue != null) {
if (!"".equals(textValue.toString())) {
textValue.append(",");
}
textValue.append(tmpValue);
}
}
return textValue.toString();
}
private String getTmpValue(String code, String text, String table, String k, String tmpValue) {
if (!StringUtils.isEmpty(table)){
log.info("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim());
if (Boolean.TRUE.equals(redisTemplate.hasKey(keyString))){
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
//处理用户要翻译为姓名加工号
if ("sys_user".equals(table)&&"realname".equals(text)&&"id".equals(code)){
tmpValue= commonAPI.translateUserRealNameFromTable(k.trim());
}else {
tmpValue= commonAPI.translateDictFromTable(table,text,code,k.trim());
}
}
}else {
String keyString = String.format(SYS_CACHE_DICT_S_S,code,k.trim());
if (Boolean.TRUE.equals(redisTemplate.hasKey(keyString))){
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
tmpValue = commonAPI.translateDict(code, k.trim());
}
}
return tmpValue;
}
/**
* @param result
*/
private void parseMethodDictText(Object result) {
if (result instanceof Result) {
Object result1 = ((Result<Object>) result).getResult();
String jsonStr = JSONUtil.toJsonStr(result1);
if (JSONUtil.isTypeJSONObject(jsonStr)) {
JSONObject translate = translate(result1);
((Result<Object>) result).setResult(translate);
} else {
List<JSONObject> items = new ArrayList<>();
for (Object o : (List<Object>) result1) {
JSONObject translate = translate(o);
items.add(translate);
}
((Result<Object>) result).setResult(items);
}
}
}
/**
* @param record
* @return
*/
private JSONObject translate(Object record) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
//for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
//翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + " " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
//date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
return item;
}
}
@@ -0,0 +1,57 @@
package com.jero.common.aspect;
import com.jero.common.aspect.annotation.RedisLock;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.RedisLockHelper;
import com.jero.common.util.RedisUtil;
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.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.UUID;
/**
* 分布式部署定时任务
* @Author lqt
*/
@Slf4j
@Aspect
@Component
public class LockMethodAspect {
@Resource
private RedisLockHelper redisLockHelper;
@Resource
private RedisUtil redisUtis;
@Around("@annotation(com.jero.common.aspect.annotation.RedisLock)")
public Object around(ProceedingJoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
RedisLock redisLock = method.getAnnotation(RedisLock.class);
String value = UUID.randomUUID().toString();
log.info("====value=====" + value + "===========");
String key = redisLock.key();
log.info("====key======" + key + "===========");
try {
final boolean islock = redisLockHelper.lock(redisUtis, key, value, redisLock.expire(), redisLock.timeUnit());
log.info("isLock : {}", islock);
if (!islock) {
log.error("获取锁失败");
throw new JeroBootException("获取锁失败");
}
try {
return joinPoint.proceed();
} catch (Throwable throwable) {
throw new JeroBootException("系统异常");
}
} finally {
log.info("释放锁");
redisLockHelper.unlock(redisUtis, key, value);
}
}
}
@@ -0,0 +1,122 @@
package com.jero.common.aspect;
import com.jero.common.api.CommonAPI;
import com.jero.common.aspect.annotation.PermissionData;
import com.jero.common.system.util.JeroDataAutorUtils;
import com.jero.common.system.util.JwtUtil;
import com.jero.common.system.vo.SysPermissionDataRuleModel;
import com.jero.common.system.vo.SysUserCacheInfo;
import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.List;
/**
* 数据权限切面处理类
* 当被请求的方法有注解PermissionData时,会在往当前request中写入数据权限信息
* @Date 2019年4月10日
* @Version: 1.0
*/
@Aspect
@Component
@Slf4j
public class PermissionDataAspect {
@Autowired
private CommonAPI commonAPI;
@Pointcut("@annotation(com.jero.common.aspect.annotation.PermissionData)")
public void pointCut() {
// do other
}
@Around("pointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable{
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
PermissionData pd = method.getAnnotation(PermissionData.class);
String component = pd.pageComponent();
String requestMethod = request.getMethod();
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
requestPath = filterUrl(requestPath);
log.debug("拦截请求 >> "+requestPath+";请求类型 >> "+requestMethod);
String username = JwtUtil.getUserNameByToken(request);
//查询数据权限信息
// TODO 微服务情况下也得支持缓存机制
List<SysPermissionDataRuleModel> dataRules = commonAPI.queryPermissionDataRule(component, requestPath, username);
if(dataRules!=null && !dataRules.isEmpty()) {
//临时存储
JeroDataAutorUtils.installDataSearchConditon(request, dataRules);
// TODO 微服务情况下也得支持缓存机制
SysUserCacheInfo userinfo = commonAPI.getCacheUser(username);
JeroDataAutorUtils.installUserInfo(request, userinfo);
}
return point.proceed();
}
private String filterUrl(String requestPath){
String url = "";
if(oConvertUtils.isNotEmpty(requestPath)){
url = requestPath.replace("\\", "/");
url = url.replace("//", "/");
if(url.contains("//")){
url = filterUrl(url);
}
}
return url;
}
/**
* 获取请求地址
* @param request
* @return
* @deprecated 未调用
*/
@Deprecated
private String getJgAuthRequsetPath(HttpServletRequest request) {
String queryString = request.getQueryString();
String requestPath = request.getRequestURI();
if(oConvertUtils.isNotEmpty(queryString)){
requestPath += "?" + queryString;
}
if (requestPath.indexOf("&") > -1) {// 去掉其他参数(保留一个参数) 例如:loginController.do?login
requestPath = requestPath.substring(0, requestPath.indexOf("&"));
}
if(requestPath.indexOf("=")!=-1){
if(requestPath.indexOf(".do")!=-1){
requestPath = requestPath.substring(0,requestPath.indexOf(".do")+3);
}else{
requestPath = requestPath.substring(0,requestPath.indexOf("?"));
}
}
requestPath = requestPath.substring(request.getContextPath().length() + 1);// 去掉项目路径
return filterUrl(requestPath);
}
/**
*
* @deprecated 未调用
*/
@Deprecated
private boolean moHuContain(List<String> list,String key){
for(String str : list){
if(key.contains(str)){
return true;
}
}
return false;
}
}
@@ -0,0 +1,266 @@
package com.jero.common.aspect;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jero.common.api.CommonAPI;
import com.jero.common.api.vo.Result;
import com.jero.common.aspect.annotation.Dict;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.vo.SysDictItemCore;
import com.jero.common.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description 对controller接口返回值翻译,不支持多层嵌套翻译
* @Author lqt
* @Date 2022/6/7 17:08
* @Version 1.0
*/
@Slf4j
@Aspect
@Component
@SuppressWarnings({"unused"})
public class TranslationAspect {
@Resource
private CommonAPI commonAPI;
@Pointcut("@annotation(com.jero.common.aspect.annotation.Translation)")
public void annotationPointcut() {
// do other
}
@Before("annotationPointcut()")
public void beforePointcut(JoinPoint joinPoint) {
// 此处进入到方法前 可以实现一些业务逻辑
}
@Around("annotationPointcut()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object result = joinPoint.proceed();
this.parseDictText(result);
return result;
}
/**
* 在切入点return内容之后切入内容(可以用来对处理返回值做一些加工处理)
*
* @param joinPoint
*/
@AfterReturning(returning = "rvt", pointcut = "annotationPointcut()")
public void doAfterReturning(JoinPoint joinPoint, Object rvt) {
}
private void parseDictText(Object result) {
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
if (CollectionUtils.isEmpty(listDict)) {
return;
}
if (result instanceof Result) {
if (((Result) result).getResult() instanceof IPage) {
List<Object> items = new ArrayList<>();
for (Object record : ((IPage) ((Result) result).getResult()).getRecords()) {
Object item = translateObject(record, listDict);
items.add(item);
}
((IPage) ((Result) result).getResult()).setRecords(items);
} else if (((Result) result).getResult() instanceof List) {
List<Object> items = new ArrayList<>();
for (Object record : ((List) ((Result) result).getResult())) {
Object item = translateObject(record, listDict);
items.add(item);
}
((Result) result).setResult(items);
} else {
Object record = (Object) ((Result) result).getResult();
Object item = translateObject(record, listDict);
((Result) result).setResult(item);
}
}
}
/**
* 手动发起流程
* 流程发起将数据翻译后保存为json以供强制撤回后使用
* @param data
* @param user
* @return
*/
public String manualParseDictText(Object data, Object user) {
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
if (CollectionUtils.isEmpty(listDict)) {
return "";
}
JSONObject dataJsonObject = (JSONObject) translateObject(data, listDict);
dataJsonObject.put("personnelObj", user);
return dataJsonObject.toJSONString();
}
/**
* 自动发起流程的
* 流程发起将数据翻译后保存为json以供强制撤回后使用
* @param data
* @param user
* @return
*/
public String autoParseDictText(Object data, Map<String, Object> user) {
List<SysDictItemCore> listDict = commonAPI.getDictItemAll();
if (CollectionUtils.isEmpty(listDict)) {
return "";
}
JSONObject dataJsonObject = (JSONObject) translateObject(data, listDict);
// 对人员进行翻译
dataJsonObject.put("personnelObj", this.translateUser(user, listDict));
return dataJsonObject.toJSONString();
}
private Object translateUser(Map<String, Object> user, List<SysDictItemCore> listDict) {
Map<String, Object> result = new HashMap<>();
for (Map.Entry<String, Object> entry : user.entrySet()) {
String value = (String) entry.getValue();
if (StrUtil.isBlank(value)) {
continue;
}
String code = "id";
String text = "CONCAT(realname, '(', username, ')')";
String table = "sys_user";
String textValue = translateDictValue(code, text, table, value, listDict);
result.put(entry.getKey(), value);
result.put(entry.getKey() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
return result;
}
private Object translateObject(Object record, List<SysDictItemCore> listDict) {
ObjectMapper mapper = new ObjectMapper();
String json;
try {
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
return record;
}
JSONObject item;
try {
item = JSONObject.parseObject(json);
} catch (Exception e) {
log.error("json解析失败" + e.getMessage(), e);
return record;
}
for (Field field : oConvertUtils.getAllFields(record)) {
field.setAccessible(true);
// 如果字段是复杂对象类型或者是List,进行递归翻译
if (isComplexObject(field.getType()) || List.class.isAssignableFrom(field.getType())) {
Object nestedRecord;
try {
nestedRecord = field.get(record);
} catch (IllegalAccessException e) {
continue;
}
if (nestedRecord != null) {
JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
String jsonFieldName = (jsonProperty != null) ? jsonProperty.value() : field.getName();
if (List.class.isAssignableFrom(field.getType())) {
List<?> objList = (List<?>) nestedRecord;
List<Object> translatedList = new ArrayList<>();
for (Object obj : objList) {
translatedList.add(translateObject(obj, listDict));
}
item.put(jsonFieldName, translatedList);
} else {
Object translatedNestedRecord = translateObject(nestedRecord, listDict);
item.put(jsonFieldName, translatedNestedRecord);
}
}
}
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
String textValue = translateDictValue(code, text, table, key, listDict);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
if (Objects.equals(field.getType().getName(), "java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
return item;
}
private boolean isComplexObject(Class<?> type) {
return !(
type.isPrimitive() ||
type.equals(String.class) ||
Number.class.isAssignableFrom(type) ||
Date.class.isAssignableFrom(type)
);
}
/**
* 翻译字典文本
*
* @param code 编码
* @param text 值
* @param table 表名
* @param key 键
* @param listDict 字典集合
*/
private String translateDictValue(String code, String text, String table, String key, List<SysDictItemCore> listDict) {
if (oConvertUtils.isEmpty(key)) {
return null;
}
StringBuilder textValue = new StringBuilder();
String[] keys = key.split(",");
for (String k : keys) {
String tmpValue = null;
if (k.trim().length() == 0) {
continue; //跳过循环
}
if (!StringUtils.isEmpty(table)) {
tmpValue = commonAPI.queryTableDictTextByKey(table, text, code, k.trim());
} else {
List<SysDictItemCore> listNew = listDict.stream().filter(o -> Objects.equals(o.getDictCode(), code) && Objects.equals(o.getItemValue(), k.trim())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(listNew)) {
tmpValue = listNew.get(0).getItemText();
}
}
if (tmpValue != null) {
if (!"".equals(textValue.toString())) {
textValue.append(",");
}
textValue.append(tmpValue);
}
}
return textValue.toString();
}
}
@@ -0,0 +1,57 @@
package com.jero.common.aspect;
/**
* @Author scott
* @Date 2020/1/14 13:36
* @Description: 请求URL与菜单路由URL转换规则(方便于采用菜单路由URL来配置数据权限规则)
*/
public enum UrlMatchEnum {
CGFORM_DATA("/online/cgform/api/getData/", UrlMatch.ONLINE_CGFORMLIST),
CGFORM_EXCEL_DATA("/online/cgform/api/exportXls/", UrlMatch.ONLINE_CGFORMLIST),
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", UrlMatch.ONLINE_CGFORMLIST),
CGREPORT_DATA("/online/cgreport/api/getColumnsAndData/", "/online/cgreport/"),
CGREPORT_EXCEL_DATA("/online/cgreport/api/exportXls/", "/online/cgreport/");
UrlMatchEnum(String url, String matchUrl) {
this.url = url;
this.matchUrl = matchUrl;
}
/**
* Request 请求 URL前缀
*/
private String url;
/**
* 菜单路由 URL前缀 (对应菜单路径)
*/
private String matchUrl;
/**
* 根据req url 获取到菜单配置路径(前端页面路由URL)
*
* @param url
* @return
*/
public static String getMatchResultByUrl(String url) {
//获取到枚举
UrlMatchEnum[] values = UrlMatchEnum.values();
//加强for循环进行遍历操作
for (UrlMatchEnum lr : values) {
//如果遍历获取的type和参数type一致
if (url.indexOf(lr.url) != -1) {
//返回type对象的desc
return url.replace(lr.url, lr.matchUrl);
}
}
return null;
}
public class UrlMatch{
private UrlMatch(){
}
public static final String ONLINE_CGFORMLIST = "/online/cgformList/";
}
}
@@ -0,0 +1,45 @@
package com.jero.common.aspect.annotation;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.enums.ModuleType;
import java.lang.annotation.*;
/**
* 系统日志注解
*
* @Author scott
* @Date 2019年1月14日
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AutoLog {
/**
* 日志内容
*
* @return
*/
String value() default "";
/**
* 日志类型
*
* @return 0:操作日志;1:登录日志;2:定时任务;
*/
int logType() default CommonConstant.LOG_TYPE_2;
/**
* 操作日志类型
*
* @return 1查询,2添加,3修改,4删除)
*/
int operateType() default 0;
/**
* 模块类型 默认为common
* @return
*/
ModuleType module() default ModuleType.COMMON;
}
@@ -0,0 +1,42 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 类描述: 字典注解
* 作 者: dangzhenghui
* 日 期: 2019年03月17日-下午9:37:16
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Dict {
/**
* 方法描述: 数据code
* 作 者: dangzhenghui
* 日 期: 2019年03月17日-下午9:37:16
*
* @return 返回类型: String
*/
String dicCode();
/**
* 方法描述: 数据Text
* 作 者: dangzhenghui
* 日 期: 2019年03月17日-下午9:37:16
*
* @return 返回类型: String
*/
String dicText() default "";
/**
* 方法描述: 数据字典表
* 作 者: dangzhenghui
* 日 期: 2019年03月17日-下午9:37:16
*
* @return 返回类型: String
*/
String dictTable() default "";
}
@@ -0,0 +1,17 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 字典转换点注解
* 加到方法上,返回值会返回字典数据
* @author liJiaRao
* @date 2021-08-02 9:44
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface DictPoint {
}
@@ -0,0 +1,18 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.*;
/**
* online请求拦截专用注解
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
@Documented
public @interface OnlineAuth {
/**
* 请求关键字,在xxx/code之前的字符串
* @return
*/
String value();
}
@@ -0,0 +1,29 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 数据权限注解
* @Author taoyan
* @Date 2019年4月11日
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
@Documented
public @interface PermissionData {
/**
* 暂时没用
* @return
*/
String value() default "";
/**
* 配置菜单的组件路径,用于数据权限
*/
String pageComponent() default "";
}
@@ -0,0 +1,24 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;
/**
* @author LQT
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface RedisLock {
/*** 业务键** @return*/
String key();
/*** 锁的过期秒数,默认是5秒** @return*/
int expire() default 5;
/*** 尝试加锁,最多等待时间** @return*/
long waitTime() default Long.MIN_VALUE;
/*** 锁的超时时间单位** @return*/
TimeUnit timeUnit() default TimeUnit.SECONDS;
}
@@ -0,0 +1,14 @@
package com.jero.common.aspect.annotation;
import java.lang.annotation.*;
/**
* 只适用controller层,在controller上添加此注解,该注解对返回结果进行翻译,不支持多层嵌套
* @author LQT
*/
@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Translation {
}
@@ -0,0 +1,343 @@
package com.jero.common.constant;
public class CommonConstant {
private CommonConstant(){
}
/**
* 用户默认密码
*/
public static final String DEFAULT_PASSWORD = "srms1q2w3e";
/**
* 正常状态
*/
public static final Integer STATUS_NORMAL = 0;
/**
* 禁用状态
*/
public static final Integer STATUS_DISABLE = -1;
/**
* 删除标志
*/
public static final Integer DEL_FLAG_1 = 1;
/**
* 未删除
*/
public static final Integer DEL_FLAG_0 = 0;
/**
* 系统日志类型: 登录
*/
public static final int LOG_TYPE_1 = 1;
/**
* 系统日志类型: 操作
*/
public static final int LOG_TYPE_2 = 2;
/**
* 操作日志类型: 查询
*/
public static final int OPERATE_TYPE_1 = 1;
/**
* 操作日志类型: 添加
*/
public static final int OPERATE_TYPE_2 = 2;
/**
* 操作日志类型: 更新
*/
public static final int OPERATE_TYPE_3 = 3;
/**
* 操作日志类型: 删除
*/
public static final int OPERATE_TYPE_4 = 4;
/**
* 操作日志类型: 倒入
*/
public static final int OPERATE_TYPE_5 = 5;
/**
* 操作日志类型: 导出
*/
public static final int OPERATE_TYPE_6 = 6;
/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
public static final Integer SC_OK_200 = 200;
/** {@code 600 OK} (自编,RSA过期) */
public static final Integer SC_RSA_TIMEOUT_600 = 600;
/**访问权限认证未通过 510*/
public static final Integer SC_JERO_NO_AUTHZ=510;
/** 登录用户Shiro权限缓存KEY前缀 */
public static final String PREFIX_USER_SHIRO_CACHE = "shiro:cache:com.jero.config.shiro.ShiroRealm.authorizationCache:";
/** 登录用户Token令牌缓存KEY前缀 */
public static final String PREFIX_USER_TOKEN = "prefix_user_token_";
/** Token缓存时间:3600秒即一小时 */
public static final int TOKEN_EXPIRE_TIME = 3600;
/**
* 0:一级菜单
*/
public static final Integer MENU_TYPE_0 = 0;
/**
* 1:子菜单
*/
public static final Integer MENU_TYPE_1 = 1;
/**
* 2:按钮权限
*/
public static final Integer MENU_TYPE_2 = 2;
/**通告对象类型(USER:指定用户,ALL:全体用户)*/
public static final String MSG_TYPE_UESR = "USER";
public static final String MSG_TYPE_ALL = "ALL";
/**发布状态(0未发布,1已发布,2已撤销)*/
public static final String NO_SEND = "0";
public static final String HAS_SEND = "1";
public static final String HAS_CANCLE = "2";
/**阅读状态(0未读,1已读)*/
public static final String HAS_READ_FLAG = "1";
public static final String NO_READ_FLAG = "0";
/**优先级(L低,M中,H高)*/
public static final String PRIORITY_L = "L";
public static final String PRIORITY_M = "M";
public static final String PRIORITY_H = "H";
/**
* 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板
*/
public static final String SMS_TPL_TYPE_0 = "0";
public static final String SMS_TPL_TYPE_1 = "1";
public static final String SMS_TPL_TYPE_2 = "2";
/**
* 状态(0无效1有效)
*/
public static final String STATUS_0 = "0";
public static final String STATUS_1 = "1";
/**
* 同步工作流引擎1同步0不同步
*/
public static final Integer ACT_SYNC_1 = 1;
public static final Integer ACT_SYNC_0 = 0;
/**
* 消息类型1:通知公告2:系统消息
*/
public static final String MSG_CATEGORY_1 = "1";
public static final String MSG_CATEGORY_2 = "2";
/**
* 是否配置菜单的数据权限 1是0否
*/
public static final Integer RULE_FLAG_0 = 0;
public static final Integer RULE_FLAG_1 = 1;
/**
* 是否用户已被冻结 1正常(解冻) 2冻结
*/
public static final Integer USER_UNFREEZE = 1;
public static final Integer USER_FREEZE = 2;
/**字典翻译文本后缀*/
public static final String DICT_TEXT_SUFFIX = "_dictText";
/**
* 表单设计器主表类型
*/
public static final Integer DESIGN_FORM_TYPE_MAIN = 1;
/**
* 表单设计器子表表类型
*/
public static final Integer DESIGN_FORM_TYPE_SUB = 2;
/**
* 表单设计器URL授权通过
*/
public static final Integer DESIGN_FORM_URL_STATUS_PASSED = 1;
/**
* 表单设计器URL授权未通过
*/
public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2;
/**
* 表单设计器新增 Flag
*/
public static final String DESIGN_FORM_URL_TYPE_ADD = "add";
/**
* 表单设计器修改 Flag
*/
public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit";
/**
* 表单设计器详情 Flag
*/
public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail";
/**
* 表单设计器复用数据 Flag
*/
public static final String DESIGN_FORM_URL_TYPE_REUSE = "reuse";
/**
* 表单设计器编辑 Flag (已弃用)
*/
public static final String DESIGN_FORM_URL_TYPE_VIEW = "view";
/**
* online参数值设置(是:Y, 否:N)
*/
public static final String ONLINE_PARAM_VAL_IS_TURE = "Y";
public static final String ONLINE_PARAM_VAL_IS_FALSE = "N";
/**
* 文件上传类型(本地:localMiniominio,阿里云:alioss
*/
public static final String UPLOAD_TYPE_LOCAL = "local";
public static final String UPLOAD_TYPE_MINIO = "minio";
public static final String UPLOAD_TYPE_OSS = "alioss";
/**
* 文档上传自定义桶名称
*/
public static final String UPLOAD_CUSTOM_BUCKET = "eoafile";
/**
* 文档上传自定义路径
*/
public static final String UPLOAD_CUSTOM_PATH = "eoafile";
/**
* 文件外链接有效天数
*/
public static final Integer UPLOAD_EFFECTIVE_DAYS = 1;
/**
* 员工身份 (1:普通员工 2:上级)
*/
public static final Integer USER_IDENTITY_1 = 1;
public static final Integer USER_IDENTITY_2 = 2;
/** sys_user 表 username 唯一键索引 */
public static final String SQL_INDEX_INDEX_USER_NAME = "index_user_name";
/** sys_user 表 username 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username";
/** sys_user 表 phone 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
/** sys_user 表 email 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email";
/** sys_quartz_job 表 job_class_name 唯一键索引 */
public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name";
/** sys_position 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_CODE = "uniq_code";
/** sys_role 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
/** sys_depart 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
/**
* 在线聊天 是否为默认分组
*/
public static final String IM_DEFAULT_GROUP = "1";
/**
* 在线聊天 图片文件保存路径
*/
public static final String IM_UPLOAD_CUSTOM_PATH = "imfile";
/**
* 在线聊天 用户状态
*/
public static final String IM_STATUS_ONLINE = "online";
/**
* 在线聊天 SOCKET消息类型
*/
public static final String IM_SOCKET_TYPE = "chatMessage";
/**
* 在线聊天 是否开启默认添加好友 1是 0否
*/
public static final String IM_DEFAULT_ADD_FRIEND = "1";
/**
* 在线聊天 用户好友缓存前缀
*/
public static final String IM_PREFIX_USER_FRIEND_CACHE = "sys:cache:im:im_prefix_user_friend_";
/**
* 考勤补卡业务状态 (1:同意 2:不同意)
*/
public static final String SIGN_PATCH_BIZ_STATUS_1 = "1";
public static final String SIGN_PATCH_BIZ_STATUS_2 = "2";
/**
* 公文文档上传自定义路径
*/
public static final String UPLOAD_CUSTOM_PATH_OFFICIAL = "officialdoc";
/**
* 公文文档下载自定义路径
*/
public static final String DOWNLOAD_CUSTOM_PATH_OFFICIAL = "officaldown";
/**
* WPS存储值类别(1 code文号 2 text(WPS模板还是公文发文模板))
*/
public static final String WPS_TYPE_1="1";
public static final String WPS_TYPE_2="2";
public static final String X_ACCESS_TOKEN = "X-Access-Token";
// common/view 预览接口用的token
public static final String AT = "at";
public static final String X_SIGN = "X-Sign";
public static final String X_TIMESTAMP = "X-TIMESTAMP";
/**
* 多租户 请求头
*/
public static final String TENANT_ID = "tenant-id";
/**
* 微服务读取配置文件属性 服务地址
*/
public static final String CLOUD_SERVER_KEY = "spring.cloud.nacos.discovery.server-addr";
/**
* 第三方登录 验证密码/创建用户 都需要设置一个操作码 防止被恶意调用
*/
public static final String THIRD_LOGIN_CODE = "third_login_code";
public static final String ANNOUNCEMENT_SEND_STATUS_0 = "0";
/** 系统通告消息状态:1=已发布 */
public static final String ANNOUNCEMENT_SEND_STATUS_1 = "1";
/** 系统通告消息状态:2=已撤销 */
public static final String ANNOUNCEMENT_SEND_STATUS_2 = "2";
/**
* 标准来源(1国内、2海外、3企业)
*/
public static final String STANDARD_SOURCE_1 = "1";
public static final String STANDARD_SOURCE_2 = "2";
public static final String STANDARD_SOURCE_3 = "3";
public static final String STANDARD_SOURCE_4 = "4";
/**
* 阅读状态(1未读、2已读)
*/
public static final String READING_STATUS_1 = "1";
public static final String READING_STATUS_2 = "2";
}
@@ -0,0 +1,28 @@
package com.jero.common.constant;
/**
* 系统通告 - 发布状态
* @Author LeeShaoQing
*
*/
public class CommonSendStatus {
private CommonSendStatus(){
}
public static final String UNPUBLISHED_STATUS_0 = "0"; //未发布
public static final String PUBLISHED_STATUS_1 = "1"; //已发布
public static final String REVOKE_STATUS_2 = "2"; //撤销
//app端推送会话标识后缀
public static final String APP_SESSION_SUFFIX = "_app"; //app端推送会话标识后缀
/**流程催办——系统通知消息模板*/
public static final String TZMB_BPM_CUIBAN = "bpm_cuiban";
/**标准模板—系统消息通知*/
public static final String TZMB_SYS_TS_NOTE = "sys_ts_note";
/**流程超时提醒——系统通知消息模板*/
public static final String TZMB_BPM_CHAOSHI_TIP = "bpm_chaoshi_tip";
}
@@ -0,0 +1,127 @@
package com.jero.common.constant;
/**
* 数据库上下文常量
*/
public class DataBaseConstant {
private DataBaseConstant(){
}
//*********数据库类型****************************************
public static final String DB_TYPE_MYSQL = "MYSQL";
public static final String DB_TYPE_ORACLE = "ORACLE";
public static final String DB_TYPE_DM = "DM";//达梦数据库
public static final String DB_TYPE_POSTGRESQL = "POSTGRESQL";
public static final String DB_TYPE_SQLSERVER = "SQLSERVER";
// 数据库类型,对应 database_type 字典
public static final String DB_TYPE_MYSQL_NUM = "1";
public static final String DB_TYPE_ORACLE_NUM = "2";
public static final String DB_TYPE_SQLSERVER_NUM = "3";
public static final String DB_TYPE_POSTGRESQL_NUM = "4";
//*********系统上下文变量****************************************
/**
* 数据-所属机构编码
*/
public static final String SYS_ORG_CODE = "sysOrgCode";
/**
* 数据-所属机构编码
*/
public static final String SYS_ORG_CODE_TABLE = "sys_org_code";
/**
* 数据-所属机构编码
*/
public static final String SYS_MULTI_ORG_CODE = "sysMultiOrgCode";
/**
* 数据-所属机构编码
*/
public static final String SYS_MULTI_ORG_CODE_TABLE = "sys_multi_org_code";
/**
* 数据-系统用户编码(对应登录用户账号)
*/
public static final String SYS_USER_CODE = "sysUserCode";
/**
* 数据-系统用户编码(对应登录用户账号)
*/
public static final String SYS_USER_CODE_TABLE = "sys_user_code";
/**
* 登录用户真实姓名
*/
public static final String SYS_USER_NAME = "sysUserName";
/**
* 登录用户真实姓名
*/
public static final String SYS_USER_NAME_TABLE = "sys_user_name";
/**
* 系统日期"yyyy-MM-dd"
*/
public static final String SYS_DATE = "sysDate";
/**
* 系统日期"yyyy-MM-dd"
*/
public static final String SYS_DATE_TABLE = "sys_date";
/**
* 系统时间"yyyy-MM-dd HH:mm"
*/
public static final String SYS_TIME = "sysTime";
/**
* 系统时间"yyyy-MM-dd HH:mm"
*/
public static final String SYS_TIME_TABLE = "sys_time";
//*********系统上下文变量****************************************
//*********系统建表标准字段****************************************
/**
* 创建者登录名称
*/
public static final String CREATE_BY_TABLE = "create_by";
/**
* 创建者登录名称
*/
public static final String CREATE_BY = "createBy";
/**
* 创建日期时间
*/
public static final String CREATE_TIME_TABLE = "create_time";
/**
* 创建日期时间
*/
public static final String CREATE_TIME = "createTime";
/**
* 更新用户登录名称
*/
public static final String UPDATE_BY_TABLE = "update_by";
/**
* 更新用户登录名称
*/
public static final String UPDATE_BY = "updateBy";
/**
* 更新日期时间
*/
public static final String UPDATE_TIME = "updateTime";
/**
* 更新日期时间
*/
public static final String UPDATE_TIME_TABLE = "update_time";
/**
* 业务流程状态
*/
public static final String BPM_STATUS = "bpmStatus";
/**
* 业务流程状态
*/
public static final String BPM_STATUS_TABLE = "bpm_status";
//*********系统建表标准字段****************************************
/**
* 租户ID 实体字段名
*/
public static final String TENANT_ID = "tenantId";
/**
* 租户ID 数据库字段名
*/
public static final String TENANT_ID_TABLE = "tenant_id";
}
@@ -0,0 +1,39 @@
package com.jero.common.constant;
/**
* 规则值生成 编码常量类
* @author: taoyan
* @date: 2020年04月02日
*/
public class FillRuleConstant {
private FillRuleConstant(){
}
/**
* 公文发文编码
*/
public static final String DOC_SEND = "doc_send_code";
/**
* 部门编码
*/
public static final String DEPART = "org_num_role";
/**
* 分类字典编码
*/
public static final String CATEGORY = "category_code_rule";
/**
* 体系字典编码
*/
public static final String SYSTEM = "system_tree_node";
/**
* 标签树编码
*/
public static final String LABEL = "label_tree_node";
}
@@ -0,0 +1,127 @@
package com.jero.common.constant;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.util.oConvertUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
@Component("pca")
public class ProvinceCityArea {
List<Area> areaList;
public String getText(String code){
this.initAreaList();
if(!CollectionUtils.isEmpty(this.areaList)){
List<String> ls = new ArrayList<>();
getAreaByCode(code,ls);
return String.join("/",ls);
}
return "";
}
public String getCode(String text){
this.initAreaList();
if(!CollectionUtils.isEmpty(areaList)){
for(int i=areaList.size()-1;i>=0;i--){
if(text.indexOf(areaList.get(i).getText())>=0){
return areaList.get(i).getId();
}
}
}
return null;
}
public void getAreaByCode(String code,List<String> ls){
for(Area area: areaList){
if(area.getId().equals(code)){
String pid = area.getPid();
ls.add(0,area.getText());
getAreaByCode(pid,ls);
}
}
}
private void initAreaList(){
if(CollectionUtils.isEmpty(this.areaList)){
this.areaList = new ArrayList<>();
try {
String jsonData = oConvertUtils.readStatic("classpath:static/pca.json");
JSONObject baseJson = JSON.parseObject(jsonData);
//第一层 省
JSONObject provinceJson = baseJson.getJSONObject("86");
for(String provinceKey: provinceJson.keySet()){
Area province = new Area(provinceKey,provinceJson.getString(provinceKey),"86");
this.areaList.add(province);
//第二层 市
JSONObject cityJson = baseJson.getJSONObject(provinceKey);
for(String cityKey:cityJson.keySet()){
Area city = new Area(cityKey,cityJson.getString(cityKey),provinceKey);
this.areaList.add(city);
//第三层 区
JSONObject areaJson = baseJson.getJSONObject(cityKey);
if(areaJson!=null){
addArea(cityKey, areaJson);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void addArea(String cityKey, JSONObject areaJson) {
for(String areaKey:areaJson.keySet()){
Area area = new Area(areaKey,areaJson.getString(areaKey),cityKey);
this.areaList.add(area);
}
}
/**
*
* @deprecated 未调用
*/
@Deprecated
private String jsonRead(File file){
StringBuilder buffer = new StringBuilder();
try(Scanner scanner = new Scanner(file, "utf-8");) {
while (scanner.hasNextLine()) {
buffer.append(scanner.nextLine());
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}
class Area{
String id;
String text;
String pid;
public Area(String id,String text,String pid){
this.id = id;
this.text = text;
this.pid = pid;
}
public String getId() {
return id;
}
public String getText() {
return text;
}
public String getPid() {
return pid;
}
}
}
@@ -0,0 +1,42 @@
/*
*
* * Copyright (c) 2019-2020, 冷冷 (wangiegie@gmail.com).
* * <p>
* * Licensed under the GNU Lesser General Public License 3.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* * <p>
* * https://www.gnu.org/licenses/lgpl.html
* * <p>
* * 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.jero.common.constant;
/**
* @author scott
* @date 2019年05月18日
* 服务名称
*/
public class ServiceNameConstants {
private ServiceNameConstants(){
}
/**
* 系统管理 admin
*/
public static final String SYSTEM_SERVICE = "jero-system";
/**
* gateway通过header传递根路径 basePath
*/
public static final String X_GATEWAY_BASE_PATH = "X_GATEWAY_BASE_PATH";
}
@@ -0,0 +1,34 @@
package com.jero.common.constant;
/**
* VXESocket 常量
*/
public class VXESocketConst {
private VXESocketConst(){
}
/**
* 消息类型
*/
public static final String TYPE = "type";
/**
* 消息数据
*/
public static final String DATA = "data";
/**
* 消息类型:心跳检测
*/
public static final String TYPE_HB = "heart_beat";
/**
* 消息类型:通用数据传递
*/
public static final String TYPE_CSD = "common_send_date";
/**
* 消息类型:更新vxe table数据
*/
public static final String TYPE_UVT = "update_vxe_table";
}
@@ -0,0 +1,64 @@
package com.jero.common.constant;
/**
* @Description: Websocket常量类
* @author: taoyan
* @date: 2020年03月23日
*/
public class WebsocketConst {
private WebsocketConst(){
}
/**
* 消息json key:cmd
*/
public static final String MSG_CMD = "cmd";
/**
* 消息json key:msgId
*/
public static final String MSG_ID = "msgId";
/**
* 消息json key:msgTxt
*/
public static final String MSG_TXT = "msgTxt";
/**
* 消息json key:userId
*/
public static final String MSG_USER_ID = "userId";
/**
* 消息类型 heartcheck
*/
public static final String CMD_CHECK = "heartcheck";
/**
* 消息类型 user 用户消息
*/
public static final String CMD_USER = "user";
/**
* 消息类型 topic 系统通知
*/
public static final String CMD_TOPIC = "topic";
/**
* 消息类型 email
*/
public static final String CMD_EMAIL = "email";
/**
* 消息类型 meetingsign 会议签到
*/
public static final String CMD_SIGN = "sign";
/**
* 消息类型 新闻发布/取消
*/
public static final String NEWS_PUBLISH = "publish";
}
@@ -0,0 +1,152 @@
package com.jero.common.constant.enums;
import java.util.*;
/**
* online表单枚举 代码生成器用到
*/
public enum CgformEnum {
/**
* 单表
*/
ONE(1, "one", Cgform.CODE_TEMPLATE_ONLINE, "default.one", "经典风格"),
/**
* 多表
*/
MANY(2, "many", Cgform.CODE_TEMPLATE_ONLINE, "default.onetomany", "经典风格"),
/**
* 多表
*/
ERP(2, "erp", Cgform.CODE_TEMPLATE_ONLINE, "erp.onetomany", "ERP风格"),
/**
* 多表(jvxe风格)
* */
JVXE_TABLE(2, "jvxe", Cgform.CODE_TEMPLATE_ONLINE, "jvxe.onetomany", "JVXE风格"),
/**
* 多表(内嵌子表风格)
*/
INNER_TABLE(2, "innerTable", Cgform.CODE_TEMPLATE_ONLINE, "inner-table.onetomany", "内嵌子表风格"),
/**
* 多表(tab风格)
* */
TAB(2, "tab", Cgform.CODE_TEMPLATE_ONLINE, "tab.onetomany", "Tab风格"),
/**
* 树形列表
*/
TREE(3, "tree", Cgform.CODE_TEMPLATE_ONLINE, "default.tree", "树形列表");
/**
* 类型 1/单表 2/一对多 3/树
*/
int type;
/**
* 编码标识
*/
String code;
/**
* 代码生成器模板路径
*/
String templatePath;
/**
* 代码生成器模板路径
*/
String stylePath;
/**
* 模板风格名称
*/
String note;
/**
* 构造器
*
* @param type 类型 1/单表 2/一对多 3/树
* @param code 模板编码
* @param templatePath 模板路径
* @param stylePath 模板子路径
* @param note
*/
CgformEnum(int type, String code, String templatePath, String stylePath, String note) {
this.type = type;
this.code = code;
this.templatePath = templatePath;
this.stylePath = stylePath;
this.note = note;
}
/**
* 根据code获取模板路径
*
* @param code
* @return
*/
public static String getTemplatePathByConfig(String code) {
return Objects.requireNonNull(getCgformEnumByConfig(code)).templatePath;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getTemplatePath() {
return templatePath;
}
public void setTemplatePath(String templatePath) {
this.templatePath = templatePath;
}
public String getStylePath() {
return stylePath;
}
public void setStylePath(String stylePath) {
this.stylePath = stylePath;
}
/**
* 根据code找枚举
*
* @param code
* @return
*/
public static CgformEnum getCgformEnumByConfig(String code) {
for (CgformEnum e : CgformEnum.values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
/**
* 根据类型找所有
*
* @param type
* @return
*/
public static List<Map<String, Object>> getJspModelList(int type) {
List<Map<String, Object>> ls = new ArrayList<>();
for (CgformEnum e : CgformEnum.values()) {
if (e.type == type) {
Map<String, Object> map = new HashMap<>();
map.put("code", e.code);
map.put("note", e.note);
ls.add(map);
}
}
return ls;
}
public class Cgform{
private Cgform(){
}
public static final String CODE_TEMPLATE_ONLINE = "/jero/code-template-online";
}
}
@@ -0,0 +1,37 @@
package com.jero.common.constant.enums;
/**
* 中英文切换标识
* @description
* @date 2022/1/21 15:22
* @auth zhn
*/
public enum IsMustEnum {
YES("","1"),
NO("","0");
String name;
String value;
private IsMustEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,22 @@
package com.jero.common.constant.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 中英文切换标识
* @description
* @date 2022/1/21 15:22
* @auth zhn
*/
@Getter
@AllArgsConstructor
public enum LanguageEnum {
/**
* 中文,英文
*/
CN("cn"), EN("en");
String value;
}
@@ -0,0 +1,42 @@
package com.jero.common.constant.enums;
public enum MessageType2Enum {
SUBSCRIPTION_NOTIFICATION("Subscription Notification","订阅通知"),
SHARE_FORWARD("Share Forward","转发推送"),
REGULATION_EARLY_WARNING("Regulation Early Warning","法规预警"),
REGULATION_LIST_CONFIRMATION("Regulation List Confirmation","法规清单确认"),
REGULATION_TASK_CONFIRMATION("Regulation Task Confirmation","法规任务确认"),
DESIGN_COMPLIANCE_CONFIRMATION("Design Compliance Confirmation","设计符合性确认"),
PRE_HOMO_CONFIRMATION("Pre-Homo Confirmation","Pre-Homo确认"),
VALIDATION_COMPLIANCE_CONFIRMATION("Validation Compliance Confirmation","验证符合性确认"),
REGULATION_OPINION_COLLECTION("Regulation Opinion Collection","法规意见收集"),
REGULATION_TECHNICAL_ASSESSMENT("Regulation Technical Assessment","法规技术评估"),
HOMO_PARAMETER_COLLECTION("Homo Parameter Collection","认证参数收集"),
CERTIFICATION_LIST_CONFIRMATION("Certification List Confirmation","认证清单确认");
String en;
String cn;
MessageType2Enum(String en, String cn) {
this.en = en;
this.cn = cn;
}
public String getEn() {
return en;
}
public void setEn(String en) {
this.en = en;
}
public String getCn() {
return cn;
}
public void setCn(String cn) {
this.cn = cn;
}
}
@@ -0,0 +1,65 @@
package com.jero.common.constant.enums;
/**
* @description
* @date 2022/1/21 15:22
* @auth zhn
*/
public enum MessageTypeEnum {
READ("Subscription Notification","订阅通知","1"),
WARN("Regulation Early Warning","法规预警","2"),
PUSH("Share / Forward","转发推送","3"),
HOMO_TASK("Homo Parameter Task","","4"),
TASK("Regulation Compliance Task","", "5"),
//REGULATION_LIST_CONFIRMATION_TASK("Regulation List Confirmation Task", "6"), // 清单确认任务
//REGULATION_LIST_CONFIRMATION_NOTIFICATION("Regulation List Confirmation Notification", "7"), // 清单确认通知
//REGULATION_TASK_CONFIRMATION_TASK("Regulation Task Confirmation", "8"), // 任务确认任务
//REGULATION_TASK_CONFIRMATION_NOTIFICATION("Regulation Task Confirmation Notification", "15"), // 任务确认通知
//DESIGN_COMPLIANCE_TASK("Design Compliance Task", "9"), // 设计符合性任务
//PRE_HOMO_TASK("Pre-Homo Task", "10"), // Pre-Homo任务
//VALIDATION_TASK("Validation Compliance Task", "11"), // 验证符合性任务
//DESIGN_COMPLIANCE_NOTIFICATION("Design Compliance Notification", "12"), // 设计符合性通知
//PRE_HOMO_NOTIFICATION("Pre-Homo Notification", "13"), // Pre-Homo通知
//VALIDATION_COMPLIANCE_NOTIFICATION("Validation Compliance Notification", "14"), // 验证符合性通知
SYSTEMATIC_NOTIFICATION("Systematic Notification","系统通知", "15"), // 系统通知
LIST_CONFIRMATION("List Confirmation", "","17"), // 清单确认
TASK_CONFIRMATION("Task Confirmation", "","18"), // 任务确认
COMPLIANCE_CONFIRMATION("Compliance Confirmation","", "19"), // 符合性确认
COLLECTION_OF_LEGISLATIVE_COMMENTS("Collection of Legislative Comments","", "20"), // 法规意见收集
REGULATORY_AND_TECHNICAL_ASSESSMENT("Regulatory and technical assessment", "","21"), // 法规技术评估
;
String name;
String nameCn;
String value;
private MessageTypeEnum(String name,String nameCn, String value) {
this.name = name;
this.nameCn = nameCn;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getNameCn() {
return nameCn;
}
public void setNameCn(String nameCn) {
this.nameCn = nameCn;
}
}
@@ -0,0 +1,42 @@
package com.jero.common.constant.enums;
/**
* @description
* @date 2022/1/21 16:42
* @auth zhn
*/
public enum ModuleEnum {
DOCUMENT_LIBRARY("文档管理","1"),
OCR_RECORD("OCR识别转换记录表","2"),
FILE_SPLIT("文档拆分","3"),
FILE_SPLIT_ITEMS("文档拆分条款","4"),
ONL_CGFORM_COLLECTION("我的收藏","5"),
ONL_CGFORM_SUBSCRIBE("我的订阅","6"),
PARAMS_COLLECT_MANIFEST("参数收集清单","7"),
PARAMS_REPORT_DETAIL("上报库参数项","8");
String name;
String value;
private ModuleEnum(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@@ -0,0 +1,17 @@
package com.jero.common.constant.enums;
/**
* 日志按模块分类
*/
public enum ModuleType {
/**
* 普通
*/
COMMON,
/**
* online
*/
ONLINE;
}
@@ -0,0 +1,32 @@
package com.jero.common.constant.enums;
public enum MsgColorEnum {
GREEN("其他","green"),
RED("任务被拒绝","red"),
YELLOW("任务逾期","yellow");
String label;
String value;
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
MsgColorEnum(String label, String value) {
this.label = label;
this.value = value;
}
}
@@ -0,0 +1,33 @@
package com.jero.common.constant.enums;
/**
* @description
* @date 2022/1/21 15:02
* @auth zhn
*/
public enum TableEnum {
BUSS_DOCUMENT_LIBRARY("buss_document_library"),
OCR_RECORD("ocr_record"),
FILE_SPLIT("sar_file_split_info"),
FILE_SPLIT_ITEMS("laws_document_split"),
TAG("onl_cgform_tag"),
TAG_AREA("onl_cgform_area"),
ONL_CGFORM_COLLECTION("onl_cgform_collection"),
ONL_CGFORM_SUBSCRIBE("onl_cgform_subscribe"),
PARAMS_COLLECT_MANIFEST("params_collect_manifest"),
PARAMS_REPORT_DETAIL("params_report_detail");
String table;
private TableEnum(String table) {
this.table = table;
}
public String getTable() {
return table;
}
public void setTable(String table) {
this.table = table;
}
}
@@ -0,0 +1,35 @@
package com.jero.common.constant.enums;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.web.bind.annotation.GetMapping;
/**
* @description
* @date 2022/1/21 15:22
* @auth zhn
*/
@Getter
@AllArgsConstructor
public enum YesOrNoEnum {
/**
*
*/
NO("","0",0),
YES("","1",1);
String name;
String value;
Integer integer;
public static String getNameByValue(String value) {
for (YesOrNoEnum enumObject : values()) {
if (enumObject.getValue().equals(value)) {
return enumObject.getName();
}
}
return null;
}
}
@@ -0,0 +1,589 @@
package com.jero.common.es;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import com.jero.common.util.RestUtil;
import com.jero.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
*
* @author sunjianlei
*/
@Slf4j
@Component
public class JeroElasticsearchTemplate {
/** es服务地址 */
private String baseUrl;
private static final String FORMAT_JSON = "format=json";
/** Elasticsearch 的版本号 */
private String version = null;
// ElasticSearch 最大可返回条目数
public static final int ES_MAX_SIZE = 10000;
@Value("${jero.elasticsearch.username}")
private String username;
@Value("${jero.elasticsearch.password}")
private String password;
public JeroElasticsearchTemplate(@Value("${jero.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jero.elasticsearch.check-enabled}") boolean checkEnabled) {
log.debug("JeroElasticsearchTemplate BaseURL" + baseUrl);
if (StringUtils.isNotEmpty(baseUrl)) {
this.baseUrl = baseUrl;
// 验证配置的ES地址是否有效
if (checkEnabled) {
try {
this.getElasticsearchVersion();
String basicAuth = this.getBasicAuth();
HttpRequest.get(this.getBaseUrl().toString())
.header("Authorization", basicAuth)
.execute()
.body();
log.info("ElasticSearch 服务连接成功");
log.info("ElasticSearch version: " + this.version);
} catch (Exception e) {
this.version = "";
log.warn("ElasticSearch 服务连接失败,原因:配置未通过。可能是BaseURL未配置或配置有误,也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法!");
}
}
}
}
/**
* 获取 Elasticsearch 的版本号信息,失败返回null
*/
private void getElasticsearchVersion() {
if (this.version == null) {
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(this.getBaseUrl().toString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject result = JSONObject.parseObject(response);
if (result != null) {
JSONObject v = result.getJSONObject("version");
this.version = v.getString("number");
}
}
}
public String getBasicAuth(){
String authString = username + ":" + password;
String encode = Base64.getEncoder().encodeToString(authString.getBytes());
String authHeader = "Basic " + encode;
return authHeader;
}
public StringBuilder getBaseUrl(String indexName, String typeName) {
typeName = typeName.trim().toLowerCase();
return this.getBaseUrl(indexName).append("/").append(typeName);
}
public StringBuilder getBaseUrl(String indexName) {
indexName = indexName.trim().toLowerCase();
return this.getBaseUrl().append("/").append(indexName);
}
public StringBuilder getBaseUrl() {
return new StringBuilder("http://").append(this.baseUrl);
}
/**
* cat 查询ElasticSearch系统数据,返回json
*/
public JSONArray _cat(String urlAfter) {
String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString();
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(url)
.header("Authorization", basicAuth)
.execute()
.body();
JSONArray jsonArray = JSONArray.parseArray(response);
return jsonArray;
}
public JSONObject put(String url){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.put(url)
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject put(String url, String params){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.put(url)
.body(params)
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject get(String url, JSONObject params){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(url)
.body(params.toJSONString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject post(String url, JSONObject params){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.post(url)
.body(params.toJSONString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
public JSONObject delete(String url){
String basicAuth = this.getBasicAuth();
String response = HttpRequest.delete(url)
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject jsonObject = JSONObject.parseObject(response);
return jsonObject;
}
/**
* cat 查询ElasticSearch系统数据,返回json
*/
public <T> ResponseEntity<T> _cat(String urlAfter, Class<T> responseType) {
String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString();
return RestUtil.request(url, HttpMethod.GET, null, null, null, responseType);
}
/**
* 查询所有索引
* <p>
* 查询地址:GET http://{baseUrl}/_cat/indices
*/
public JSONArray getIndices() {
return getIndices(null);
}
/**
* 查询单个索引
* <p>
* 查询地址:GET http://{baseUrl}/_cat/indices/{indexName}
*/
public JSONArray getIndices(String indexName) {
StringBuilder urlAfter = new StringBuilder("/indices");
if (!StringUtils.isEmpty(indexName)) {
urlAfter.append("/").append(indexName.trim().toLowerCase());
}
return _cat(urlAfter.toString());
}
/**
* 索引是否存在
*/
public boolean indexExists(String indexName) {
try {
JSONArray array = getIndices(indexName);
return array != null;
} catch (org.springframework.web.client.HttpClientErrorException ex) {
if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
return false;
} else {
throw ex;
}
}
}
/**
* 根据ID获取索引数据,未查询到返回null
* <p>
* 查询地址:GET http://{baseUrl}/{indexName}/{typeName}/{dataId}
*
* @param indexName 索引名称
* @param typeName type,一个任意字符串,用于分类
* @param dataId 数据id
* @return
*/
public JSONObject getDataById(String indexName, String typeName, String dataId) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
log.info("url:" + url);
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(this.getBaseUrl().toString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject result = JSONObject.parseObject(response);
boolean found = result.getBoolean("found");
if (found) {
return result.getJSONObject("_source");
} else {
return new JSONObject();
}
}
/**
* 创建索引
* <p>
* 查询地址:PUT http://{baseUrl}/{indexName}
*/
public boolean createIndex(String indexName) {
String url = this.getBaseUrl(indexName).toString();
try {
return this.put(url).getBoolean("acknowledged");
} catch (org.springframework.web.client.HttpClientErrorException ex) {
if (HttpStatus.BAD_REQUEST == ex.getStatusCode()) {
log.warn("索引创建失败:" + indexName + " 已存在,无需再创建");
} else {
ex.printStackTrace();
}
}
return false;
}
/**
* 删除索引
* <p>
* 查询地址:DELETE http://{baseUrl}/{indexName}
*/
public boolean removeIndex(String indexName) {
String url = this.getBaseUrl(indexName).toString();
try {
return this.delete(url).getBoolean("acknowledged");
} catch (org.springframework.web.client.HttpClientErrorException ex) {
if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
log.warn("索引删除失败:" + indexName + " 不存在,无需删除");
} else {
ex.printStackTrace();
}
}
return false;
}
/**
* 获取索引字段映射(可获取字段类型)
* <p>
*
* @param indexName 索引名称
* @param typeName 分类名称
* @return
*/
public JSONObject getIndexMapping(String indexName, String typeName) {
String url = this.getBaseUrl(indexName, typeName).append("/_mapping?").append(FORMAT_JSON).toString();
// 针对 es 7.x 版本做兼容
this.getElasticsearchVersion();
if (oConvertUtils.isNotEmpty(this.version) && this.version.startsWith("7")) {
url += "&include_type_name=true";
}
log.info("getIndexMapping-url:" + url);
try {
String basicAuth = this.getBasicAuth();
String response = HttpRequest.get(this.getBaseUrl().toString())
.header("Authorization", basicAuth)
.execute()
.body();
JSONObject result = JSONObject.parseObject(response);
return result;
} catch (org.springframework.web.client.HttpClientErrorException e) {
String message = e.getMessage();
if (message != null && message.contains("404 Not Found")) {
return new JSONObject();
}
throw e;
}
}
/**
* 获取索引字段映射,返回Java实体类
*
* @param indexName
* @param typeName
* @return
*/
public <T> Map<String, T> getIndexMappingFormat(String indexName, String typeName, Class<T> clazz) {
JSONObject mapping = this.getIndexMapping(indexName, typeName);
Map<String, T> map = new HashMap<>();
if (mapping == null) {
return map;
}
// 获取字段属性
JSONObject properties = mapping.getJSONObject(indexName)
.getJSONObject("mappings")
.getJSONObject(typeName)
.getJSONObject("properties");
// 封装成 java类型
for (String key : properties.keySet()) {
T entity = properties.getJSONObject(key).toJavaObject(clazz);
map.put(key, entity);
}
return map;
}
/**
* 保存数据,详见:saveOrUpdate
*/
public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
/**
* 更新数据,详见:saveOrUpdate
*/
public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
/**
* 保存或修改索引数据
* <p>
* 查询地址:PUT http://{baseUrl}/{indexName}/{typeName}/{dataId}
*
* @param indexName 索引名称
* @param typeName type,一个任意字符串,用于分类
* @param dataId 数据id
* @param data 要存储的数据
* @return
*/
public boolean saveOrUpdate(String indexName, String typeName, String dataId, JSONObject data) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).append("?refresh=wait_for").toString();
try {
// 去掉 data 中为空的值
Set<String> keys = data.keySet();
List<String> emptyKeys = new ArrayList<>(keys.size());
for (String key : keys) {
String value = data.getString(key);
//1、剔除空值
if (oConvertUtils.isEmpty(value) || "[]".equals(value)) {
emptyKeys.add(key);
}
//2、剔除上传控件值(会导致ES同步失败,报异常failed to parse field [ge_pic] of type [text] )
if (oConvertUtils.isNotEmpty(value) && value.indexOf("[{")!=-1) {
emptyKeys.add(key);
log.info("-------剔除上传控件字段------------key: "+ key);
}
}
for (String key : emptyKeys) {
data.remove(key);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
String result = this.put(url, data.toJSONString()).getString("result");
return "created".equals(result) || "updated".equals(result);
} catch (Exception e) {
log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString());
//TODO 打印接口返回异常json
return false;
}
}
/**
* 批量保存数据
*
* @param indexName 索引名称
* @param typeName type,一个任意字符串,用于分类
* @param dataList 要存储的数据数组,每行数据必须包含id
* @return
*/
public boolean saveBatch(String indexName, String typeName, JSONArray dataList) {
String url = this.getBaseUrl().append("/_bulk").append("?refresh=wait_for").toString();
StringBuilder bodySB = new StringBuilder();
for (int i = 0; i < dataList.size(); i++) {
JSONObject data = dataList.getJSONObject(i);
String id = data.getString("id");
// 该行的操作
JSONObject action = new JSONObject();
JSONObject actionInfo = new JSONObject();
actionInfo.put("_id", id);
actionInfo.put("_index", indexName);
actionInfo.put("_type", typeName);
action.put("create", actionInfo);
bodySB.append(action.toJSONString()).append("\n");
// 该行的数据
data.remove("id");
bodySB.append(data.toJSONString()).append("\n");
}
log.info("+-+-+-: bodySB.toString(): " + bodySB.toString());
this.put(url,bodySB.toString());
return true;
}
/**
* 删除索引数据
* <p>
* 请求地址:DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
*/
public boolean delete(String indexName, String typeName, String dataId) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
try {
return "deleted".equals(this.delete(url).getString("result"));
} catch (org.springframework.web.client.HttpClientErrorException ex) {
if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
return false;
} else {
throw ex;
}
}
}
/* = = = 以下关于查询和查询条件的方法 = = =*/
/**
* 查询数据
* <p>
* 请求地址:POST http://{baseUrl}/{indexName}/{typeName}/_search
*/
public JSONObject search(String indexName, String typeName, JSONObject queryObject) {
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
log.info("url:" + url + " ,search: " + queryObject.toJSONString());
JSONObject res = this.get(url, queryObject);
log.info("url:" + url + " ,return res: \n" + res.toJSONString());
return res;
}
/**
* @param _source (源滤波器)指定返回的字段,传null返回所有字段
* @param query
* @param from 从第几条数据开始
* @param size 返回条目数
* @return { "query": query }
*/
public JSONObject buildQuery(List<String> _source, JSONObject query, int from, int size) {
JSONObject json = new JSONObject();
if (_source != null) {
json.put("_source", _source);
}
json.put("query", query);
json.put("from", from);
json.put("size", size);
return json;
}
public JSONObject buildQuery(List<String> _source, JSONObject query,Map<String, Object> highlight,JSONArray sort, int from, int size) {
JSONObject json = new JSONObject();
if (_source != null) {
json.put("_source", _source);
}
json.put("highlight", highlight);
json.put("query", query);
json.put("sort", sort);
json.put("from", from * size);
json.put("size", size);
return json;
}
/**
* @return { "bool" : { "must": must, "must_not": mustNot, "should": should } }
*/
public JSONObject buildBoolQuery(JSONArray must, JSONArray mustNot, JSONArray should) {
JSONObject bool = new JSONObject();
if (must != null) {
bool.put("must", must);
}
if (mustNot != null) {
bool.put("must_not", mustNot);
}
if (should != null) {
bool.put("should", should);
}
JSONObject json = new JSONObject();
json.put("bool", bool);
return json;
}
/**
* @param field 要查询的字段
* @param args 查询参数,参考: *哈哈* OR *哒* NOT *呵* OR *啊*
* @return
*/
public JSONObject buildQueryString(String field, String... args) {
if (field == null) {
return new JSONObject();
}
StringBuilder sb = new StringBuilder(field).append(":(");
if (args != null) {
for (String arg : args) {
sb.append(arg).append(" ");
}
}
sb.append(")");
return this.buildQueryString(sb.toString());
}
/**
* @return { "query_string": { "query": query } }
*/
public JSONObject buildQueryString(String query) {
JSONObject queryString = new JSONObject();
queryString.put("query", query);
JSONObject json = new JSONObject();
json.put("query_string", queryString);
return json;
}
/**
* @param field 查询字段
* @param min 最小值
* @param max 最大值
* @param containMin 范围内是否包含最小值
* @param containMax 范围内是否包含最大值
* @return { "range" : { field : { 『 "gt『e』?containMin" : min 』?min!=null , 『 "lt『e』?containMax" : max 』}} }
*/
public JSONObject buildRangeQuery(String field, Object min, Object max, boolean containMin, boolean containMax) {
JSONObject inner = new JSONObject();
if (min != null) {
if (containMin) {
inner.put("gte", min);
} else {
inner.put("gt", min);
}
}
if (max != null) {
if (containMax) {
inner.put("lte", max);
} else {
inner.put("lt", max);
}
}
JSONObject range = new JSONObject();
range.put(field, inner);
JSONObject json = new JSONObject();
json.put("range", range);
return json;
}
/**
* 按条件删除数据
* <p>
* 请求地址:POST http://{baseUrl}/{indexName}/{typeName}/_delete_by_query
*/
public JSONObject delete(String indexName, String typeName, JSONObject queryObject) {
String url = this.getBaseUrl(indexName, typeName).append("/_delete_by_query").toString();
log.info("url:" + url + " ,delete: " + queryObject.toJSONString());
JSONObject res = this.post(url, queryObject);
log.info("url:" + url + " ,return res: \n" + res.toJSONString());
return res;
}
}
@@ -0,0 +1,98 @@
package com.jero.common.es;
/**
* 用于创建 ElasticSearch 的 queryString
*
* @author sunjianlei
*/
public class QueryStringBuilder {
StringBuilder builder;
public QueryStringBuilder(String field, String str, boolean not, boolean addQuot) {
builder = this.createBuilder(field, str, not, addQuot);
}
public QueryStringBuilder(String field, String str, boolean not) {
builder = this.createBuilder(field, str, not, true);
}
/**
* 创建 StringBuilder
*
* @param field
* @param str
* @param not 是否是不匹配
* @param addQuot 是否添加双引号
* @return
*/
public StringBuilder createBuilder(String field, String str, boolean not, boolean addQuot) {
StringBuilder sb = new StringBuilder(field).append(":(");
if (not) {
sb.append(" NOT ");
}
this.addQuotEffect(sb, str, addQuot);
return sb;
}
public QueryStringBuilder and(String str) {
return this.and(str, true);
}
public QueryStringBuilder and(String str, boolean addQuot) {
builder.append(" AND ");
this.addQuot(str, addQuot);
return this;
}
public QueryStringBuilder or(String str) {
return this.or(str, true);
}
public QueryStringBuilder or(String str, boolean addQuot) {
builder.append(" OR ");
this.addQuot(str, addQuot);
return this;
}
public QueryStringBuilder not(String str) {
return this.not(str, true);
}
public QueryStringBuilder not(String str, boolean addQuot) {
builder.append(" NOT ");
this.addQuot(str, addQuot);
return this;
}
/**
* 添加双引号(模糊查询,不能加双引号)
*/
private QueryStringBuilder addQuot(String str, boolean addQuot) {
return this.addQuotEffect(this.builder, str, addQuot);
}
/**
* 是否在两边加上双引号
* @param builder
* @param str
* @param addQuot
* @return
*/
private QueryStringBuilder addQuotEffect(StringBuilder builder, String str, boolean addQuot) {
if (addQuot) {
builder.append('"');
}
builder.append(str);
if (addQuot) {
builder.append('"');
}
return this;
}
@Override
public String toString() {
return builder.append(")").toString();
}
}
@@ -0,0 +1,24 @@
package com.jero.common.exception;
import com.jero.common.util.MessageUtils;
public class JeroBootException extends RuntimeException {
private static final long serialVersionUID = 1L;
public JeroBootException(String message){
super(MessageUtils.getMessage(message));
}
public JeroBootException(String message, Object... args) {
super(MessageUtils.getMessage(message,args));
}
public JeroBootException(Throwable cause)
{
super(cause);
}
public JeroBootException(String message,Throwable cause)
{
super(message,cause);
}
}
@@ -0,0 +1,104 @@
package com.jero.common.exception;
import com.jero.common.api.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.redis.connection.PoolException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.NoHandlerFoundException;
/**
* 异常处理器
*
* @Author scott
* @Date 2019
*/
@RestControllerAdvice
@Slf4j
public class JeroBootExceptionHandler {
/**
* 处理自定义异常
*/
@ExceptionHandler(JeroBootException.class)
public Result<T> handleJeroBootException(JeroBootException e){
log.error(e.getMessage(), e);
return Result.error(e.getMessage());
}
@ExceptionHandler(NoHandlerFoundException.class)
public Result<T> handlerNoFoundException(Exception e) {
log.error(e.getMessage(), e);
return Result.error(404, "路径不存在,请检查路径是否正确");
}
@ExceptionHandler(DuplicateKeyException.class)
public Result<T> handleDuplicateKeyException(DuplicateKeyException e){
log.error(e.getMessage(), e);
return Result.error("数据库中已存在该记录");
}
@ExceptionHandler({UnauthorizedException.class, AuthorizationException.class})
public Result<Object> handleAuthorizationException(AuthorizationException e){
log.error(e.getMessage(), e);
return Result.noauth("没有权限,请联系管理员授权");
}
@ExceptionHandler(Exception.class)
public Result<T> handleException(Exception e){
log.error(e.getMessage(), e);
return Result.error("操作失败");
}
/**
* @Author 政辉
* @param e
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result<T> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
StringBuilder sb = new StringBuilder();
sb.append("不支持");
sb.append(e.getMethod());
sb.append("请求方法,");
sb.append("支持以下");
String [] methods = e.getSupportedMethods();
if(methods!=null){
for(String str:methods){
sb.append(str);
sb.append("");
}
}
log.error(sb.toString(), e);
return Result.error(405,sb.toString());
}
/**
* spring默认上传大小100MB 超出大小捕获异常MaxUploadSizeExceededException
*/
@ExceptionHandler(MaxUploadSizeExceededException.class)
public Result<T> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) {
log.error(e.getMessage(), e);
return Result.error("文件大小超出500MB限制, 请压缩或降低文件质量! ");
}
@ExceptionHandler(DataIntegrityViolationException.class)
public Result<T> handleDataIntegrityViolationException(DataIntegrityViolationException e) {
log.error(e.getMessage(), e);
return Result.error("字段太长,请重新选择");
}
@ExceptionHandler(PoolException.class)
public Result<T> handlePoolException(PoolException e) {
log.error(e.getMessage(), e);
return Result.error("Redis 连接异常!");
}
}
@@ -0,0 +1,21 @@
package com.jero.common.handler;
import com.alibaba.fastjson.JSONObject;
/**
* 填值规则接口
*
* @author Yan_东
* 如需使用填值规则功能,规则实现类必须实现此接口
*/
public interface IFillRuleHandler {
/**
* @param params 页面配置固定参数
* @param formData 动态表单参数
* @return
*/
public Object execute(JSONObject params, JSONObject formData);
}
@@ -0,0 +1,227 @@
package com.jero.common.system.base.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: Controller基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
@Slf4j
public class JeroController<T, S extends IService<T>> {
public static final String CLASS = "entity";
public static final String PARAMS = "params";
public static final String FILE_NAME = "fileName";
@Autowired
S service;
@Value("${jero.path.upload}")
private String upLoadPath;
/**
* 导出excel
*
* @param request
*/
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title) {
// Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 获取导出数据
List<T> pageList = service.list(queryWrapper);
List<T> exportList = null;
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = pageList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
} else {
exportList = pageList;
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
try {
mv.addObject(FILE_NAME, URLEncoder.encode(title, "UTF-8")); //此处设置的filename无效 ,前端会重更新设置一下
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
mv.addObject(CLASS, clazz);
//update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
ExportParams exportParams=new ExportParams(title, "导出人:" + sysUser.getRealname(), title);
exportParams.setImageBasePath(upLoadPath);
//update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
mv.addObject(PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
/**
* 导出excel
*
* @param
*/
protected ModelAndView exportListXls(List<?> object, Class<?> clazz, String title) {
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.CLASS, clazz);
ExportParams exportParams=new ExportParams(title, title);
// 导出xlsx
exportParams.setType(ExcelType.XSSF);
exportParams.setImageBasePath(upLoadPath);
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, object);
return mv;
}
/**
* 根据每页sheet数量导出多sheet
*
* @param request
* @param object 实体类
* @param clazz 实体类class
* @param title 标题
* @param exportFields 导出字段自定义
* @param pageNum 每个sheet的数据条数
* @param request
*/
protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields,Integer pageNum) {
// Step.1 组装查询条件
QueryWrapper<T> queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap());
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// Step.2 计算分页sheet数据
double total = service.count();
int count = (int)Math.ceil(total/pageNum);
// Step.3 多sheet处理
List<Map<String, Object>> listMap = new ArrayList<>();
for (int i = 1; i <=count ; i++) {
Page<T> page = new Page<>(i, pageNum);
IPage<T> pageList = service.page(page, queryWrapper);
List<T> records = pageList.getRecords();
List<T> exportList = null;
// 过滤选中数据
String selections = request.getParameter("selections");
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = records.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
} else {
exportList = records;
}
Map<String, Object> map = new HashMap<>();
ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,upLoadPath);
exportParams.setType(ExcelType.XSSF);
//map.put("title",exportParams);//表格Title
map.put(PARAMS,exportParams);//表格Title
map.put(CLASS,clazz);//表格对应实体
map.put(NormalExcelConstants.DATA_LIST, exportList);//数据集合
listMap.add(map);
}
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.MAP_LIST, listMap);
return mv;
}
/**
* 根据权限导出excel,传入导出字段参数
*
* @param request
*/
protected ModelAndView exportXls(HttpServletRequest request, T object, Class<T> clazz, String title,String exportFields) {
ModelAndView mv = this.exportXls(request,object,clazz,title);
mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields);
return mv;
}
/**
* 获取对象ID
*
* @return
*/
private String getId(T item) {
try {
return PropertyUtils.getProperty(item, "id").toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 通过excel导入数据
*
* @param request
* @return
*/
protected Result<T> importExcel(HttpServletRequest request, HttpServletResponse response, Class<T> clazz) {
if(Objects.isNull(response)){
log.info("打印未使用参数");
}
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
// 获取上传文件对象
MultipartFile file = entity.getValue();
ImportParams params = new ImportParams();
/*params.setTitleRows(2);
params.setHeadRows(1);*/
params.setNeedSave(true);
try {
List<T> list = ExcelImportUtil.importExcel(file.getInputStream(), clazz, params);
//update-begin-author:taoyan date:20190528 for:批量插入数据
long start = System.currentTimeMillis();
service.saveBatch(list);
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
//update-end-author:taoyan date:20190528 for:批量插入数据
return Result.OK("文件导入成功!数据行数:" + list.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return Result.error("文件导入失败!");
}
}
@@ -0,0 +1,52 @@
package com.jero.common.system.base.entity;
import java.io.Serializable;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: Entity基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-28
* @Version: 1.1
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class JeroEntity implements Serializable {
private static final long serialVersionUID = 1L;
/** ID */
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "ID")
private java.lang.String id;
/** 创建人 */
@ApiModelProperty(value = "创建人")
@Excel(name = "创建人", width = 15)
private java.lang.String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date createTime;
/** 更新人 */
@ApiModelProperty(value = "更新人")
@Excel(name = "更新人", width = 15)
private java.lang.String updateBy;
/** 更新时间 */
@ApiModelProperty(value = "更新时间")
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date updateTime;
}
@@ -0,0 +1,12 @@
package com.jero.common.system.base.service;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: Service基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
public interface JeroService<T> extends IService<T> {
}
@@ -0,0 +1,19 @@
package com.jero.common.system.base.service.impl;
import com.jero.common.system.base.entity.JeroEntity;
import com.jero.common.system.base.service.JeroService;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
/**
* @Description: ServiceImpl基类
* @Author: dangzhenghui@163.com
* @Date: 2019-4-21 8:13
* @Version: 1.0
*/
@Slf4j
public class JeroServiceImpl<M extends BaseMapper<T>, T extends JeroEntity> extends ServiceImpl<M, T> implements JeroService<T> {
}
@@ -0,0 +1,43 @@
package com.jero.common.system.query;
import com.jero.common.util.oConvertUtils;
/**
* 查询链接规则
*
* @Author Sunjianlei
*/
public enum MatchTypeEnum {
AND("AND"),
OR("OR");
private String value;
MatchTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static MatchTypeEnum getByValue(Object value) {
if (oConvertUtils.isEmpty(value)) {
return null;
}
return getByValue(value.toString());
}
public static MatchTypeEnum getByValue(String value) {
if (oConvertUtils.isEmpty(value)) {
return null;
}
for (MatchTypeEnum val : values()) {
if (val.getValue().equalsIgnoreCase(value)) {
return val;
}
}
return null;
}
}
@@ -0,0 +1,69 @@
package com.jero.common.system.query;
import java.io.Serializable;
public class QueryCondition implements Serializable {
private static final long serialVersionUID = 4740166316629191651L;
private String field;
/** 组件的类型(例如:input、select、radio */
private String type;
/**
* 对应的数据库字段的类型
* 支持:int、bigDecimal、short、long、float、double、boolean
*/
private String dbType;
private String rule;
private String val;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
@Override
public String toString(){
StringBuilder sb =new StringBuilder();
if(field == null || "".equals(field)){
return "";
}
sb.append(this.field).append(" ").append(this.rule).append(" ").append(this.type).append(" ").append(this.dbType).append(" ").append(this.val);
return sb.toString();
}
}
@@ -0,0 +1,73 @@
package com.jero.common.system.query;
import com.jero.common.util.oConvertUtils;
/**
* Query 规则 常量
* @Author Scott
* @Date 2019年02月14日
*/
public enum QueryRuleEnum {
GT(">","gt","大于"),
GE(">=","ge","大于等于"),
LT("<","lt","小于"),
LE("<=","le","小于等于"),
EQ("=","eq","等于"),
NE("!=","ne","不等于"),
IN("IN","in","包含"),
LIKE("LIKE","like","全模糊"),
LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),
EQ_WITH_ADD("EQWITHADD","eq_with_add","带加号等于"),
LIKE_WITH_AND("LIKEWITHAND","like_with_and","多词模糊匹配————暂时未用上"),
SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段");
private String value;
private String condition;
private String msg;
QueryRuleEnum(String value, String condition, String msg){
this.value = value;
this.condition = condition;
this.msg = msg;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public static QueryRuleEnum getByValue(String value){
if(oConvertUtils.isEmpty(value)) {
return null;
}
for(QueryRuleEnum val :values()){
if (val.getValue().equals(value) || val.getCondition().equals(value)){
return val;
}
}
return null;
}
}
@@ -0,0 +1,108 @@
package com.jero.common.system.util;
import com.jero.common.system.vo.SysPermissionDataRuleModel;
import com.jero.common.system.vo.SysUserCacheInfo;
import com.jero.common.util.SpringContextUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: JeroDataAutorUtils
* @Description: 数据权限查询规则容器工具类
* @Author: 张代浩
* @Date: 2012-12-15 下午11:27:39
*
*/
public class JeroDataAutorUtils {
private JeroDataAutorUtils(){
}
public static final String MENU_DATA_AUTHOR_RULES = "MENU_DATA_AUTHOR_RULES";
public static final String MENU_DATA_AUTHOR_RULE_SQL = "MENU_DATA_AUTHOR_RULE_SQL";
public static final String SYS_USER_INFO = "SYS_USER_INFO";
/**
* 往链接请求里面,传入数据查询条件
*
* @param request
* @param dataRules
*/
public static synchronized void installDataSearchConditon(HttpServletRequest request, List<SysPermissionDataRuleModel> dataRules) {
@SuppressWarnings("unchecked")
List<SysPermissionDataRuleModel> list = loadDataSearchConditon();// 1.先从request获取MENU_DATA_AUTHOR_RULES,如果存则获取到LIST
if (list==null) {
// 2.如果不存在,则new一个list
list = new ArrayList<>();
}
for (SysPermissionDataRuleModel tsDataRule : dataRules) {
list.add(tsDataRule);
}
request.setAttribute(MENU_DATA_AUTHOR_RULES, list); // 3.往list里面增量存指
}
/**
* 获取请求对应的数据权限规则
*
* @return
*/
@SuppressWarnings("unchecked")
public static synchronized List<SysPermissionDataRuleModel> loadDataSearchConditon() {
return (List<SysPermissionDataRuleModel>) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULES);
}
/**
* 获取请求对应的数据权限SQL
*
* @return
*/
public static synchronized String loadDataSearchConditonSQLString() {
return (String) SpringContextUtils.getHttpServletRequest().getAttribute(MENU_DATA_AUTHOR_RULE_SQL);
}
/**
* 往链接请求里面,传入数据查询条件
*
* @param request
* @param sql
*/
public static synchronized void installDataSearchConditon(HttpServletRequest request, String sql) {
String ruleSql = loadDataSearchConditonSQLString();
if (!StringUtils.hasText(ruleSql)) {
request.setAttribute(MENU_DATA_AUTHOR_RULE_SQL,sql);
}
}
/**
* 将用户信息存到request
* @param request
* @param userinfo
*/
public static synchronized void installUserInfo(HttpServletRequest request, SysUserCacheInfo userinfo) {
request.setAttribute(SYS_USER_INFO, userinfo);
}
/**
* 将用户信息存到request
* @param userinfo
*/
public static synchronized void installUserInfo(SysUserCacheInfo userinfo) {
SpringContextUtils.getHttpServletRequest().setAttribute(SYS_USER_INFO, userinfo);
}
/**
* 从request获取用户信息
* @return
*/
public static synchronized SysUserCacheInfo loadUserInfo() {
return (SysUserCacheInfo) SpringContextUtils.getHttpServletRequest().getAttribute(SYS_USER_INFO);
}
}
@@ -0,0 +1,257 @@
package com.jero.common.system.util;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.google.common.base.Joiner;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.jero.common.constant.CommonConstant;
import org.apache.shiro.SecurityUtils;
import com.jero.common.constant.DataBaseConstant;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.system.vo.SysUserCacheInfo;
import com.jero.common.util.DateUtils;
import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils;
/**
* @Author Scott
* @Date 2018-07-12 14:23
* @Desc JWT工具类
**/
public class JwtUtil {
private JwtUtil(){
}
// Token过期时间30分钟(用户登录过期时间也是30分钟,以token在reids缓存时间为准)
//public static final long EXPIRE_TIME = 180 * 60 * 1000L;
public static final long EXPIRE_TIME = 24 * 60 * 60 * 1000L; // 设置成1天(开发用)
private static final String USERNAME_FIELD = "username";
/**
* 校验token是否正确
*
* @param token 密钥
* @param secret 用户的密码
* @return 是否正确
*/
public static boolean verify(String token, String username, String secret) {
try {
// 根据密码生成JWT效验器
Algorithm algorithm = Algorithm.HMAC256(secret);
JWTVerifier verifier = JWT.require(algorithm).withClaim(USERNAME_FIELD, username).build();
// 效验TOKEN
verifier.verify(token);
return true;
} catch (Exception exception) {
return false;
}
}
/**
* 获得token中的信息无需secret解密也能获得
*
* @return token中包含的用户名
*/
public static String getUsername(String token) {
try {
DecodedJWT jwt = JWT.decode(token);
return jwt.getClaim(USERNAME_FIELD).asString();
} catch (JWTDecodeException e) {
return null;
}
}
/**
* 生成签名,5min后过期
*
* @param username 用户名
* @param secret 用户的密码
* @return 加密的token
*/
public static String sign(String username, String secret) {
// 24小时后过期
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
Algorithm algorithm = Algorithm.HMAC256(secret);
// 附带username信息
return JWT.create().withClaim(USERNAME_FIELD, username).withExpiresAt(date).sign(algorithm);
}
/**
* 根据request中的token获取用户账号
*
* @param request
* @return
* @throws JeroBootException
*/
public static String getUserNameByToken(HttpServletRequest request) throws JeroBootException {
String accessToken = request.getHeader("X-Access-Token");
String username = getUsername(accessToken);
if (oConvertUtils.isEmpty(username)) {
throw new JeroBootException("未获取到用户");
}
return username;
}
/**
* 从session中获取变量
* @param key
* @return
*/
public static String getSessionData(String key) {
//${myVar}%
//得到${} 后面的值
String moshi = "";
if(key.indexOf("}")!=-1){
moshi = key.substring(key.indexOf("}")+1);
}
String returnValue = null;
if (key.contains("#{")) {
key = key.substring(2,key.indexOf("}"));
}
if (oConvertUtils.isNotEmpty(key)) {
HttpSession session = SpringContextUtils.getHttpServletRequest().getSession();
returnValue = (String) session.getAttribute(key);
}
//结果加上${} 后面的值
if(returnValue!=null){returnValue = returnValue + moshi;}
return returnValue;
}
/**
* 从当前用户中获取变量
* @param key
* @param user
* @return
*/
// TODO 急待改造 sckjkdsjsfjdk
public static String getUserSystemData(String key,SysUserCacheInfo user) {
if(user==null) {
user = JeroDataAutorUtils.loadUserInfo();
}
//#{sys_user_code}%
// 获取登录用户信息
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String moshi = "";
if(key.contains("}")){
moshi = key.substring(key.indexOf("}")+1);
}
String returnValue = null;
//针对特殊标示处理#{sysOrgCode},判断替换
if (key.contains("#{")) {
key = key.substring(2,key.indexOf("}"));
}
returnValue = setReturnValue(key, user, sysUser, returnValue);
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if(returnValue!=null){returnValue = returnValue + moshi;}
return returnValue;
}
private static String setReturnValue(String key, SysUserCacheInfo user, LoginUser sysUser, String returnValue) {
//替换为系统登录用户帐号
if (isaBoolean(key, DataBaseConstant.SYS_USER_CODE, DataBaseConstant.SYS_USER_CODE_TABLE)) {
returnValue = setReturnValueUsername(user, sysUser);
}
//替换为系统登录用户真实名字
else if (isaBoolean(key, DataBaseConstant.SYS_USER_NAME, DataBaseConstant.SYS_USER_NAME_TABLE)) {
returnValue = setReturnValueRealName(user, sysUser);
}
//替换为系统用户登录所使用的机构编码
else if (isaBoolean(key, DataBaseConstant.SYS_ORG_CODE, DataBaseConstant.SYS_ORG_CODE_TABLE)) {
returnValue = setReturnValueOrgCode(user, sysUser);
}
//替换为系统用户所拥有的所有机构编码
else if (isaBoolean(key, DataBaseConstant.SYS_MULTI_ORG_CODE, DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
returnValue = setReturnValueOrgCodeNew(user, sysUser);
}
//替换为当前系统时间(年月日)
else if (isaBoolean(key, DataBaseConstant.SYS_DATE, DataBaseConstant.SYS_DATE_TABLE)) {
returnValue = DateUtils.formatDate();
}
//替换为当前系统时间(年月日时分秒)
else if (isaBoolean(key, DataBaseConstant.SYS_TIME, DataBaseConstant.SYS_TIME_TABLE)) {
returnValue = DateUtils.now();
}
//流程状态默认值(默认未发起)
else if (isaBoolean(key, DataBaseConstant.BPM_STATUS, DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1";
}
//update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量
else if (isaBoolean(key, DataBaseConstant.TENANT_ID, DataBaseConstant.TENANT_ID_TABLE)){
returnValue = sysUser.getRelTenantIds();
returnValue = setReturnValueTenantId(returnValue);
}
return returnValue;
}
private static boolean isaBoolean(String key, String sysUserCode, String sysUserCodeTable) {
return key.equals(sysUserCode) || key.equalsIgnoreCase(sysUserCodeTable);
}
private static String setReturnValueTenantId(String returnValue) {
if(oConvertUtils.isEmpty(returnValue) || returnValue.contains(",")){
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID);
}
return returnValue;
}
private static String setReturnValueOrgCodeNew(SysUserCacheInfo user, LoginUser sysUser) {
String returnValue;
if(user==null){
// TODO 暂时使用用户登录部门,存在逻辑缺陷,不是用户所拥有的部门
returnValue = sysUser.getOrgCode();
}else{
if(user.isOneDepart()) {
returnValue = user.getSysMultiOrgCode().get(0);
}else {
returnValue = Joiner.on(",").join(user.getSysMultiOrgCode());
}
}
return returnValue;
}
private static String setReturnValueOrgCode(SysUserCacheInfo user, LoginUser sysUser) {
String returnValue;
if(user==null) {
returnValue = sysUser.getOrgCode();
}else {
returnValue = user.getSysOrgCode();
}
return returnValue;
}
private static String setReturnValueRealName(SysUserCacheInfo user, LoginUser sysUser) {
String returnValue;
if(user==null) {
returnValue = sysUser.getRealname();
}else {
returnValue = user.getSysUserName();
}
return returnValue;
}
private static String setReturnValueUsername(SysUserCacheInfo user, LoginUser sysUser) {
String returnValue;
if(user==null) {
returnValue = sysUser.getUsername();
}else {
returnValue = user.getSysUserCode();
}
return returnValue;
}
}
@@ -0,0 +1,36 @@
package com.jero.common.system.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ComboModel implements Serializable {
private String id;
private String title;
/**文档管理 表单table默认选中*/
private boolean checked;
/**文档管理 表单table 用户账号*/
private String username;
/**文档管理 表单table 用户邮箱*/
private String email;
/**文档管理 表单table 角色编码*/
private String roleCode;
public ComboModel(){
}
public ComboModel(String id,String title,boolean checked,String username){
this.id = id;
this.title = title;
this.checked = checked;
this.username = username;
}
}
@@ -0,0 +1,43 @@
package com.jero.common.system.vo;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class DictModel implements Serializable{
private static final long serialVersionUID = 1L;
public DictModel() {
}
public DictModel(String value, String text) {
this.value = value;
this.text = text;
}
/**
* 字典value
*/
private String value;
/**
* 字典文本
*/
private String text;
/**
* 特殊用途: JgEditableTable
* @return
*/
public String getTitle() {
return this.text;
}
}
@@ -0,0 +1,18 @@
package com.jero.common.system.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 查询多个字典时用到
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class DictModelMany extends DictModel {
/**
* 字典code,根据多个字段code查询时才用到,用于区分不同的字典选项
*/
private String dictCode;
}
@@ -0,0 +1,34 @@
package com.jero.common.system.vo;
import lombok.Data;
/**
* 字典查询参数实体
*/
@Data
public class DictQuery {
/**
* 表名
*/
private String table;
/**
* 存储列
*/
private String code;
/**
* 显示列
*/
private String text;
/**
* 关键字查询
*/
private String keyword;
/**
* 存储列的值 用于回显查询
*/
private String codeValue;
}
@@ -0,0 +1,48 @@
package com.jero.common.system.vo;
import lombok.Data;
import org.springframework.beans.BeanUtils;
@Data
public class DynamicDataSourceModel {
public DynamicDataSourceModel() {
}
public DynamicDataSourceModel(Object dbSource) {
if (dbSource != null) {
BeanUtils.copyProperties(dbSource, this);
}
}
/**
* id
*/
private java.lang.String id;
/**
* 数据源编码
*/
private java.lang.String code;
/**
* 数据库类型
*/
private java.lang.String dbType;
/**
* 驱动类
*/
private java.lang.String dbDriver;
/**
* 数据源地址
*/
private java.lang.String dbUrl;
/**
* 用户名
*/
private java.lang.String dbUsername;
/**
* 密码
*/
private java.lang.String dbPassword;
}
@@ -0,0 +1,130 @@
package com.jero.common.system.vo;
import java.util.Date;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 在线用户信息
* </p>
*
* @Author scott
* @since 2018-12-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class LoginUser {
/**
* 登录人id
*/
private String id;
/**
* 登录人账号
*/
private String username;
/**
* 登录人名字
*/
private String realname;
/**
* 登录人密码
*/
private String password;
/**
* 当前登录部门code
*/
private String orgCode;
/**
* 头像
*/
private String avatar;
/**
* 生日
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday;
/**
* 性别(1:男 2:女)
*/
private Integer sex;
/**
* 电子邮件
*/
private String email;
/**
* 电话
*/
private String phone;
/**
* 状态(1:正常 2:冻结
*/
private Integer status;
private Integer delFlag;
/**
* 同步工作流引擎1同步0不同步
*/
private Integer activitiSync;
/**
* 创建时间
*/
private Date createTime;
/**
* 身份(1 普通员工 2 上级)
*/
private Integer userIdentity;
/**
* 管理部门ids
*/
private String departIds;
/**
* 职务,关联职务表
*/
private String post;
/**
* 座机号
*/
private String telephone;
/**多租户id配置,编辑用户的时候设置*/
private String relTenantIds;
/**设备id uniapp推送用*/
private String clientId;
private String roleIds;
public String calcNameWorkNo(){
return this.realname + "(" + this.username + ")";
}
/**
* 根据配置文件中的adminRoleCode判断
*/
private Boolean isAdmin;
}
@@ -0,0 +1,50 @@
package com.jero.common.system.vo;
/**
* @Author qinfeng
* @Date 2020/2/19 12:01
* @Description:
* @Version 1.0
*/
public class SysCategoryModel {
/**主键*/
private java.lang.String id;
/**父级节点*/
private java.lang.String pid;
/**类型名称*/
private java.lang.String name;
/**类型编码*/
private java.lang.String code;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
@@ -0,0 +1,147 @@
package com.jero.common.system.vo;
/**
* lvdandan 部门机构model
*/
public class SysDepartModel {
/**ID*/
private String id;
/**父机构ID*/
private String parentId;
/**机构/部门名称*/
private String departName;
/**英文名*/
private String departNameEn;
/**缩写*/
private String departNameAbbr;
/**排序*/
private Integer departOrder;
/**描述*/
private String description;
/**机构类别 1组织机构,2岗位*/
private String orgCategory;
/**机构类型*/
private String orgType;
/**机构编码*/
private String orgCode;
/**手机号*/
private String mobile;
/**传真*/
private String fax;
/**地址*/
private String address;
/**备注*/
private String memo;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public String getDepartNameEn() {
return departNameEn;
}
public void setDepartNameEn(String departNameEn) {
this.departNameEn = departNameEn;
}
public String getDepartNameAbbr() {
return departNameAbbr;
}
public void setDepartNameAbbr(String departNameAbbr) {
this.departNameAbbr = departNameAbbr;
}
public Integer getDepartOrder() {
return departOrder;
}
public void setDepartOrder(Integer departOrder) {
this.departOrder = departOrder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getOrgCategory() {
return orgCategory;
}
public void setOrgCategory(String orgCategory) {
this.orgCategory = orgCategory;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
}
@@ -0,0 +1,388 @@
package com.jero.common.system.vo;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* <p>
* 部门表 存储树结构数据的实体类
* <p>
*
* @Author Steve
* @Since 2019-01-22
*/
public class SysDepartTreeModel implements Serializable{
private static final long serialVersionUID = 1L;
/** 对应SysDepart中的id字段,前端数据树中的key*/
private String key;
/** 对应SysDepart中的id字段,前端数据树中的value*/
private String value;
/** 对应depart_name字段,前端数据树中的title*/
private String title;
private boolean isLeaf;
// 以下所有字段均与SysDepart相同
private String id;
private String parentId;
private String departName;
private String departNameEn;
private String departNameAbbr;
private Integer departOrder;
private String description;
private String orgCategory;
private String orgType;
private String orgCode;
private String mobile;
private String fax;
private String address;
private String memo;
private String status;
private String delFlag;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String company;
private String headOfDepartment;
private String leadersInCharge;
private String deputyLeader;
private List<SysDepartTreeModel> children = new ArrayList<>();
public boolean getIsLeaf() {
return isLeaf;
}
public void setIsLeaf(boolean isleaf) {
this.isLeaf = isleaf;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<SysDepartTreeModel> getChildren() {
return children;
}
public void setChildren(List<SysDepartTreeModel> children) {
if (children==null){
this.isLeaf=true;
}
this.children = children;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public String getOrgCategory() {
return orgCategory;
}
public void setOrgCategory(String orgCategory) {
this.orgCategory = orgCategory;
}
public String getOrgType() {
return orgType;
}
public void setOrgType(String orgType) {
this.orgType = orgType;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getDepartNameEn() {
return departNameEn;
}
public void setDepartNameEn(String departNameEn) {
this.departNameEn = departNameEn;
}
public String getDepartNameAbbr() {
return departNameAbbr;
}
public void setDepartNameAbbr(String departNameAbbr) {
this.departNameAbbr = departNameAbbr;
}
public Integer getDepartOrder() {
return departOrder;
}
public void setDepartOrder(Integer departOrder) {
this.departOrder = departOrder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDelFlag() {
return delFlag;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getHeadOfDepartment() {
return headOfDepartment;
}
public void setHeadOfDepartment(String headOfDepartment) {
this.headOfDepartment = headOfDepartment;
}
public String getLeadersInCharge() {
return leadersInCharge;
}
public void setLeadersInCharge(String leadersInCharge) {
this.leadersInCharge = leadersInCharge;
}
public String getDeputyLeader() {
return deputyLeader;
}
public void setDeputyLeader(String deputyLeader) {
this.deputyLeader = deputyLeader;
}
public SysDepartTreeModel() {
// do other
}
/**
* 重写equals方法
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SysDepartTreeModel model = (SysDepartTreeModel) o;
return Objects.equals(id, model.id) &&
Objects.equals(parentId, model.parentId) &&
Objects.equals(departName, model.departName) &&
Objects.equals(departNameEn, model.departNameEn) &&
Objects.equals(departNameAbbr, model.departNameAbbr) &&
Objects.equals(departOrder, model.departOrder) &&
Objects.equals(description, model.description) &&
Objects.equals(orgCategory, model.orgCategory) &&
Objects.equals(orgType, model.orgType) &&
Objects.equals(orgCode, model.orgCode) &&
Objects.equals(mobile, model.mobile) &&
Objects.equals(fax, model.fax) &&
Objects.equals(address, model.address) &&
Objects.equals(memo, model.memo) &&
Objects.equals(status, model.status) &&
Objects.equals(delFlag, model.delFlag) &&
Objects.equals(createBy, model.createBy) &&
Objects.equals(createTime, model.createTime) &&
Objects.equals(updateBy, model.updateBy) &&
Objects.equals(updateTime, model.updateTime) &&
Objects.equals(company, model.company)&&
Objects.equals(headOfDepartment, model.headOfDepartment)&&
Objects.equals(leadersInCharge, model.leadersInCharge)&&
Objects.equals(deputyLeader, model.deputyLeader)&&
Objects.equals(children, model.children);
}
/**
* 重写hashCode方法
*/
@Override
public int hashCode() {
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
departOrder, description, orgCategory, orgType, orgCode, mobile, fax, address,
memo, status, delFlag, createBy, createTime, updateBy, updateTime,
headOfDepartment, leadersInCharge, deputyLeader, children);
}
}
@@ -0,0 +1,80 @@
package com.jero.common.system.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.jero.common.aspect.annotation.Dict;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysDictItemCore implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 字典id
*/
private String dictId;
/**
* 字典编码
*/
@TableField(exist = false)
private String dictCode;
/**
* 字典项文本
*/
@Excel(name = "字典项文本", width = 20)
private String itemText;
/**
* 字典项值
*/
@Excel(name = "字典项值", width = 30)
private String itemValue;
/**
* 描述
*/
@Excel(name = "描述", width = 40)
private String description;
/**
* 排序
*/
@Excel(name = "排序", width = 15,type=4)
private Integer sortOrder;
/**
* 状态(1启用 0不启用)
*/
@Dict(dicCode = "dict_item_status")
private Integer status;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
}
@@ -0,0 +1,144 @@
package com.jero.common.system.vo;
import java.util.Date;
/**
* <p>
* 菜单权限规则表
* </p>
*
* @Author huangzhilin
* @since 2019-03-29
*/
public class SysPermissionDataRuleModel {
/**
* id
*/
private String id;
/**
* 对应的菜单id
*/
private String permissionId;
/**
* 规则名称
*/
private String ruleName;
/**
* 字段
*/
private String ruleColumn;
/**
* 条件
*/
private String ruleConditions;
/**
* 规则值
*/
private String ruleValue;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 修改时间
*/
private Date updateTime;
/**
* 修改人
*/
private String updateBy;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPermissionId() {
return permissionId;
}
public void setPermissionId(String permissionId) {
this.permissionId = permissionId;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleColumn() {
return ruleColumn;
}
public void setRuleColumn(String ruleColumn) {
this.ruleColumn = ruleColumn;
}
public String getRuleConditions() {
return ruleConditions;
}
public void setRuleConditions(String ruleConditions) {
this.ruleConditions = ruleConditions;
}
public String getRuleValue() {
return ruleValue;
}
public void setRuleValue(String ruleValue) {
this.ruleValue = ruleValue;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
}

Some files were not shown because too many files have changed in this diff Show More