mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 16:26:41 +08:00
Jeecg-Boot 2.1.4 版本发布 | 重构较大,较多新功能
This commit is contained in:
@ -50,7 +50,7 @@ RUN cd /etc/yum.repos.d/ \
|
||||
# 前端迁移到系统文件中 默认是80端口 同级目录下的html地址
|
||||
ADD ant-design-vue-jeecg/dist/ /var/www/html/
|
||||
# 拷贝相关的jar包
|
||||
ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.1.1.jar jeecgboot.jar
|
||||
ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.1.4.jar jeecgboot.jar
|
||||
EXPOSE 80 8080 81
|
||||
ENTRYPOINT /bin/sh -c /etc/init.d/start.sh
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Jeecg-Boot 快速开发平台
|
||||
===============
|
||||
|
||||
当前最新版本: 2.1.3(发布日期:20191226)
|
||||
当前最新版本: 2.1.4(发布日期:20200224)
|
||||
|
||||
|
||||
## 后端技术架构
|
||||
@ -37,11 +37,11 @@ Jeecg-Boot 快速开发平台
|
||||
## 技术文档
|
||||
|
||||
|
||||
- 在线演示 : [http://boot.jeecg.org](http://boot.jeecg.org)
|
||||
- 在线演示 : [http://boot.jeecg.com](http://boot.jeecg.com)
|
||||
|
||||
- 在线文档: [http://doc.jeecg.com/1273753](http://doc.jeecg.com/1273753)
|
||||
|
||||
- 常见问题: [入门常见问题大全](http://www.jeecg.org/forum.php?mod=viewthread&tid=7816&extra=page%3D1)
|
||||
- 常见问题: [入门常见问题大全](http://bbs.jeecg.com/forum.php?mod=viewthread&tid=7816&extra=page%3D1)
|
||||
|
||||
- QQ交流群 : ①284271917、②769925425
|
||||
|
||||
|
||||
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
141
jeecg-boot/db/增量升级SQL/2.1.3升级到2.1.4mysq.sql
Normal file
141
jeecg-boot/db/增量升级SQL/2.1.3升级到2.1.4mysq.sql
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
|
||||
-- 多数据源表
|
||||
DROP TABLE IF EXISTS `sys_data_source`;
|
||||
CREATE TABLE `sys_data_source` (
|
||||
`id` varchar(36) NOT NULL,
|
||||
`name` varchar(100) DEFAULT NULL COMMENT '数据源名称',
|
||||
`remark` varchar(200) DEFAULT NULL COMMENT '备注',
|
||||
`db_type` varchar(10) DEFAULT NULL COMMENT '数据库类型',
|
||||
`db_driver` varchar(100) DEFAULT NULL COMMENT '驱动类',
|
||||
`db_url` varchar(500) DEFAULT NULL COMMENT '数据源地址',
|
||||
`db_name` varchar(100) DEFAULT NULL COMMENT '数据库名称',
|
||||
`db_username` varchar(100) DEFAULT NULL COMMENT '用户名',
|
||||
`db_password` varchar(100) DEFAULT NULL COMMENT '密码',
|
||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建日期',
|
||||
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新日期',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
INSERT INTO `sys_data_source` VALUES ('1209779538310004737', 'MySQL5.7', '本地数据库MySQL5.7', '1', 'com.mysql.jdbc.Driver', 'jdbcmysql127.0.0.13306jeecg-bootcharacterEncoding=UTF-8&useUnicode=true&useSSL=false', 'jeecg-boot', 'root', 'root', 'admin', '2019-12-25 181453', null, null, 'A01');
|
||||
|
||||
-- 数据库类型字典
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1209733563293962241', '数据库类型', 'database_type', '', '0', 'admin', '2019-12-25 151212', NULL, NULL, '0');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1209733775114702850', '1209733563293962241', 'MySQL', '1', '', '1', '1', 'admin', '2019-12-25 151302', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1209733839933476865', '1209733563293962241', 'Oracle', '2', '', '1', '1', 'admin', '2019-12-25 151318', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1209733903020003330', '1209733563293962241', 'SQLServer', '3', '', '1', '1', 'admin', '2019-12-25 151333', NULL, NULL);
|
||||
|
||||
|
||||
-- 生产销售监控 --
|
||||
update sys_permission set url='{{ window._CONFIG['domianURL'] }}bigscreentemplatindex1' where id='1205098241075453953';
|
||||
-- 智慧物流监控 --
|
||||
update sys_permission set url='{{ window._CONFIG['domianURL'] }}bigscreentemplatindex2' where id='1205306106780364802';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `sys_user`
|
||||
ADD COLUMN `identity` tinyint(1) DEFAULT NULL COMMENT '身份(1普通成员 2上级)' AFTER `update_time`;
|
||||
|
||||
ALTER TABLE `sys_user`
|
||||
ADD COLUMN `depart_id` longtext DEFAULT NULL COMMENT '负责部门' AFTER `identity`;
|
||||
|
||||
|
||||
ALTER TABLE `sys_user`
|
||||
CHANGE COLUMN `depart_id` `depart_ids` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '负责部门' AFTER `identity`;
|
||||
|
||||
ALTER TABLE `sys_announcement`
|
||||
ADD COLUMN `bus_type` varchar(20) COMMENT '业务类型(email邮件 bpm流程)' AFTER `del_flag`,
|
||||
ADD COLUMN `bus_id` varchar(50) COMMENT '业务id' AFTER `bus_type`,
|
||||
ADD COLUMN `open_type` varchar(20) COMMENT '打开方式(组件:component 路由:url)' AFTER `bus_id`,
|
||||
ADD COLUMN `open_page` varchar(255) COMMENT '组件路由 地址' AFTER `open_type`;
|
||||
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1209731624921534465', 'd7d6e2e4e2934f2c9385a623fd98c6f3', '多数据源管理', 'isystemdataSource', 'systemSysDataSourceList', '1', NULL, NULL, '1', NULL, '1', '3', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-12-25 150430', NULL, NULL, '0', '0', '1', '0');
|
||||
|
||||
|
||||
ALTER TABLE `sys_data_source`
|
||||
ADD COLUMN `code` varchar(100) NULL COMMENT '数据源编码' AFTER `id`;
|
||||
|
||||
ALTER TABLE `sys_data_source`
|
||||
ADD UNIQUE INDEX `sys_data_source_code_uni` (`code`) USING BTREE ;
|
||||
|
||||
-- 编码校验规则表
|
||||
DROP TABLE IF EXISTS `sys_check_rule`;
|
||||
CREATE TABLE `sys_check_rule` (
|
||||
`id` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '主键id',
|
||||
`rule_name` varchar(100) DEFAULT NULL COMMENT '规则名称',
|
||||
`rule_code` varchar(100) DEFAULT NULL COMMENT '规则Code',
|
||||
`rule_json` varchar(1024) DEFAULT NULL COMMENT '规则JSON',
|
||||
`rule_description` varchar(200) DEFAULT NULL COMMENT '规则描述',
|
||||
`update_by` varchar(32) CHARACTER SET utf8 DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`create_by` varchar(32) CHARACTER SET utf8 DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uni_sys_check_rule_code` (`rule_code`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 编码校验规则测试数据
|
||||
INSERT INTO `sys_check_rule` VALUES ('1224980593992388610', '通用编码规则', 'common', '[{digits1,pattern^[a-zA-Z]$,message第一位只能是字母},{digits,pattern^[0-9a-zA-Z_]{0,}$,message只能填写数字、大小写字母、下划线},{digits,pattern^.{3,}$,message最少输入3位数},{digits,pattern^.{3,12}$,message最多输入12位数}]', '规则:1、首位只能是字母;2、只能填写数字、大小写字母、下划线;3、最少3位数,最多12位数。', 'admin', '2020-02-07 112548', 'admin', '2020-02-05 165827');
|
||||
INSERT INTO `sys_check_rule` VALUES ('1225001845524004866', '负责的功能测试', 'test', '[{digits,pattern^.{3,12}$,message只能输入3-12位字符},{digits3,pattern^d{3}$,message前3位必须是数字},{digits,pattern^[^pP]$,message不能输入P},{digits4,pattern^@{4}$,message第4-7位必须都为 @},{digits2,pattern^#=$,message第8-9位必须是 #=},{digits1,pattern^O$,message第10位必须为大写的O},{digits,pattern^.。$,message必须以。结尾}]', '包含长度校验、特殊字符校验等', 'admin', '2020-02-07 115731', 'admin', '2020-02-05 182254');
|
||||
|
||||
-- 编码校验规则菜单
|
||||
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1224641973866467330', 'd7d6e2e4e2934f2c9385a623fd98c6f3', '编码校验规则', 'isystemcheckRule', 'systemSysCheckRuleList', '1', NULL, NULL, '1', NULL, '1', '2', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-11-07 135253', NULL, NULL, '0', '0', '1', '0');
|
||||
|
||||
DROP TABLE IF EXISTS `sys_depart_permission`;
|
||||
CREATE TABLE `sys_depart_permission` (
|
||||
`id` varchar(32) NOT NULL,
|
||||
`depart_id` varchar(32) DEFAULT NULL COMMENT '部门id',
|
||||
`permission_id` varchar(32) DEFAULT NULL COMMENT '权限id',
|
||||
`data_rule_ids` varchar(1000) DEFAULT NULL COMMENT '数据规则id',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部门权限表';
|
||||
|
||||
DROP TABLE IF EXISTS `sys_depart_role`;
|
||||
CREATE TABLE `sys_depart_role` (
|
||||
`id` varchar(32) NOT NULL,
|
||||
`depart_id` varchar(32) DEFAULT NULL COMMENT '部门id',
|
||||
`role_name` varchar(200) DEFAULT NULL COMMENT '部门角色名称',
|
||||
`role_code` varchar(100) DEFAULT NULL COMMENT '部门角色编码',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT '描述',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部门角色表';
|
||||
|
||||
DROP TABLE IF EXISTS `sys_depart_role_permission`;
|
||||
CREATE TABLE `sys_depart_role_permission` (
|
||||
`id` varchar(32) NOT NULL,
|
||||
`depart_id` varchar(32) DEFAULT NULL COMMENT '部门id',
|
||||
`role_id` varchar(32) DEFAULT NULL COMMENT '角色id',
|
||||
`permission_id` varchar(32) DEFAULT NULL COMMENT '权限id',
|
||||
`data_rule_ids` varchar(1000) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `index_group_role_per_id` (`role_id`,`permission_id`) USING BTREE,
|
||||
KEY `index_group_role_id` (`role_id`) USING BTREE,
|
||||
KEY `index_group_per_id` (`permission_id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='部门角色权限表';
|
||||
|
||||
DROP TABLE IF EXISTS `sys_depart_role_user`;
|
||||
CREATE TABLE `sys_depart_role_user` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键id',
|
||||
`user_id` varchar(32) DEFAULT NULL COMMENT '用户id',
|
||||
`drole_id` varchar(32) DEFAULT NULL COMMENT '角色id',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='部门角色用户表';
|
||||
|
||||
|
||||
ALTER TABLE `onl_cgform_head`
|
||||
ADD COLUMN `theme_template` varchar(50) NULL COMMENT '主题模板' AFTER `create_time`;
|
||||
update onl_cgform_head SET theme_template = 'normal';
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1229674163694841857', 'e41b69c57a941a3bbcce45032fe57605', 'AUTO在线表单ERP', 'onlinecgformErpListcode', 'modulesonlinecgformautoerpOnlCgformErpList', NULL, NULL, 1, NULL, '1', 5.00, 0, NULL, 1, 1, 0, 1, NULL, 'admin', '2020-02-18 154900', 'admin', '2020-02-18 155225', 0, 0, '1', 0);
|
||||
|
||||
ALTER TABLE `onl_cgform_field`
|
||||
ADD COLUMN `is_read_only` tinyint(1) NULL DEFAULT 0 COMMENT '是否是只读(1是 0否)' AFTER `is_show_list`;
|
||||
|
||||
@ -1,187 +0,0 @@
|
||||
|
||||
|
||||
-- 字典:日程计划状态
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1199525215290306561', '日程计划状态', 'eoa_plan_status', '', '0', 'admin', '2019-11-27 11:07:52', 'admin', '2019-11-27 11:10:11', '0');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199525468672405505', '1199525215290306561', '未开始', '0', '', '1.00', '1', 'admin', '2019-11-27 11:08:52', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199525490575060993', '1199525215290306561', '进行中', '1', '', '1.00', '1', 'admin', '2019-11-27 11:08:58', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199525506429530114', '1199525215290306561', '已完成', '2', '', '1.00', '1', 'admin', '2019-11-27 11:09:02', 'admin', '2019-11-27 11:10:02');
|
||||
|
||||
-- 字典:分类栏目类型
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1199520177767587841', '分类栏目类型', 'eoa_cms_menu_type', '', '0', 'admin', '2019-11-27 10:47:51', 'admin', '2019-11-27 10:49:35', '0');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199520817285701634', '1199520177767587841', '列表', '1', '', '1.00', '1', 'admin', '2019-11-27 10:50:24', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199520835035996161', '1199520177767587841', '链接', '2', '', '1.00', '1', 'admin', '2019-11-27 10:50:28', NULL, NULL);
|
||||
|
||||
-- 字典:日程计划类型
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1199518099888414722', '日程计划类型', 'eoa_plan_type', '', '0', 'admin', '2019-11-27 10:39:36', NULL, NULL, '0');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199518186144276482', '1199518099888414722', '日常记录', '1', '', '1.00', '1', 'admin', '2019-11-27 10:39:56', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199518214858481666', '1199518099888414722', '本周工作', '2', '', '1.00', '1', 'admin', '2019-11-27 10:40:03', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199518235943247874', '1199518099888414722', '下周计划', '3', '', '1.00', '1', 'admin', '2019-11-27 10:40:08', NULL, NULL);
|
||||
|
||||
-- 字典:紧急程度
|
||||
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1199517671259906049', '紧急程度', 'urgent_level', '日程计划紧急程度', '0', 'admin', '2019-11-27 10:37:53', NULL, NULL, '0');
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199517884758368257', '1199517671259906049', '一般', '1', '', '1.00', '1', 'admin', '2019-11-27 10:38:44', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199517914017832962', '1199517671259906049', '重要', '2', '', '1.00', '1', 'admin', '2019-11-27 10:38:51', NULL, NULL);
|
||||
INSERT INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `description`, `sort_order`, `status`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1199517941339529217', '1199517671259906049', '紧急', '3', '', '1.00', '1', 'admin', '2019-11-27 10:38:58', NULL, NULL);
|
||||
|
||||
|
||||
INSERT INTO `sys_fill_rule` VALUES ('1202551334738382850', '机构编码生成', 'org_num_role', 'org.jeecg.modules.system.rule.OrgCodeRule', '{\"parentId\":\"c6d7cb4deeac411cb3384b1b31278596\"}', 'admin', '2019-12-9 10:37:06', 'admin', '2019-12-5 19:32:35');
|
||||
INSERT INTO `sys_fill_rule` VALUES ('1202787623203065858', '分类字典编码生成', 'category_code_rule', 'org.jeecg.modules.system.rule.CategoryCodeRule', '{\"pid\":\"\"}', 'admin', '2019-12-9 10:36:54', 'admin', '2019-12-6 11:11:31');
|
||||
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1205097455226462210', '', '大屏设计', '/big/screen', 'layouts/RouteView', NULL, NULL, 0, NULL, '1', 10.00, 0, 'area-chart', 1, 0, 0, 0, NULL, 'admin', '2019-12-12 20:09:58', 'admin', '2019-12-12 20:36:56', 0, 0, '1', 0);
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1205098241075453953', '1205097455226462210', '生产销售监控', '{{ window._CONFIG[\'domianURL\'] }}/big/screen/index1', 'layouts/IframePageView', NULL, NULL, 1, NULL, '1', 1.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2019-12-12 20:13:05', 'admin', '2019-12-12 20:15:27', 0, 0, '1', 1);
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('1205306106780364802', '1205097455226462210', '智慧物流监控', '{{ window._CONFIG[\'domianURL\'] }}/big/screen/index2', 'layouts/IframePageView', NULL, NULL, 1, NULL, '1', 2.00, 0, NULL, 1, 1, 0, 0, NULL, 'admin', '2019-12-13 09:59:04', NULL, NULL, 0, 0, '1', 1);
|
||||
|
||||
|
||||
/*
|
||||
online报表增量sql
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('109c78a583d4693ce2f16551b7786786', 'e41b69c57a941a3bbcce45032fe57605', 'Online报表配置', '/online/cgreport', 'modules/online/cgreport/OnlCgreportHeadList', NULL, NULL, 1, NULL, NULL, 2.00, 0, NULL, 1, 1, NULL, 0, NULL, 'admin', '2019-03-08 10:51:07', 'admin', '2019-03-30 19:04:28', 0, 0, NULL, NULL);
|
||||
INSERT INTO `sys_permission`(`id`, `parent_id`, `name`, `url`, `component`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_route`, `is_leaf`, `keep_alive`, `hidden`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`) VALUES ('9fe26464838de2ea5e90f2367e35efa0', 'e41b69c57a941a3bbcce45032fe57605', 'AUTO在线报表', '/online/cgreport/:code', 'modules/online/cgreport/auto/OnlCgreportAutoList', 'onlineAutoList', NULL, 1, NULL, NULL, 9.00, 0, NULL, 1, 1, NULL, 1, NULL, 'admin', '2019-03-12 11:06:48', 'admin', '2019-04-30 18:19:10', 0, 0, NULL, NULL);
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for onl_cgreport_head
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `onl_cgreport_head`;
|
||||
CREATE TABLE `onl_cgreport_head` (
|
||||
`id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报表编码',
|
||||
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报表名字',
|
||||
`cgr_sql` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报表SQL',
|
||||
`return_val_field` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '返回值字段',
|
||||
`return_txt_field` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '返回文本字段',
|
||||
`return_type` varchar(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '1' COMMENT '返回类型,单选或多选',
|
||||
`db_source` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '动态数据源',
|
||||
`content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||
`update_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人id',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`create_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人id',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `index_onlinereport_code`(`code`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of onl_cgreport_head
|
||||
-- ----------------------------
|
||||
INSERT INTO `onl_cgreport_head` VALUES ('6c7f59741c814347905a938f06ee003c', 'report_user', '统计在线用户', 'select * from sys_user', NULL, NULL, '1', NULL, NULL, '2019-11-22 16:34:31', 'admin', '2019-03-25 11:20:45', 'admin');
|
||||
INSERT INTO `onl_cgreport_head` VALUES ('87b55a515d3441b6b98e48e5b35474a6', 'demo', 'Report Demo', 'select * from demo', NULL, NULL, '1', NULL, NULL, '2019-03-15 18:18:17', 'admin', '2019-03-12 11:25:16', 'admin');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for onl_cgreport_item
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `onl_cgreport_item`;
|
||||
CREATE TABLE `onl_cgreport_item` (
|
||||
`id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`cgrhead_id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '报表ID',
|
||||
`field_name` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字段名字',
|
||||
`field_txt` varchar(300) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字段文本',
|
||||
`field_width` int(3) NULL DEFAULT NULL,
|
||||
`field_type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字段类型',
|
||||
`search_mode` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '查询模式',
|
||||
`is_order` int(2) NULL DEFAULT 0 COMMENT '是否排序 0否,1是',
|
||||
`is_search` int(2) NULL DEFAULT 0 COMMENT '是否查询 0否,1是',
|
||||
`dict_code` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典CODE',
|
||||
`field_href` varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字段跳转URL',
|
||||
`is_show` int(2) NULL DEFAULT 1 COMMENT '是否显示 0否,1显示',
|
||||
`order_num` int(11) NULL DEFAULT NULL COMMENT '排序',
|
||||
`replace_val` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '取值表达式',
|
||||
`create_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `index_CGRHEAD_ID`(`cgrhead_id`) USING BTREE,
|
||||
INDEX `index_isshow`(`is_show`) USING BTREE,
|
||||
INDEX `index_order_num`(`order_num`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of onl_cgreport_item
|
||||
-- ----------------------------
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('0ba0dc69589a85a96be30f59451c81df', 'b32a3fdd008f4506b2bac4ac00f0bd4f', '222', '222', NULL, 'String', NULL, 0, 0, '', '', 1, 0, '', 'admin', '2019-05-31 14:37:25', 'admin', '2019-05-31 14:37:30');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('1740bb02519db90c44cb2cba8b755136', '6c7f59741c814347905a938f06ee003c', 'realname', '用户名称', NULL, 'String', NULL, 0, 0, '', '', 1, 3, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('1b181e6d2813bcb263adc39737f9df46', '87b55a515d3441b6b98e48e5b35474a6', 'name', '用户名', NULL, 'String', 'single', 0, 1, '', '', 1, 4, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('1fb45af29af4e792bdc5a4a2c06a4d4d', '402880ec5d872157015d87f2dd940010', 'data_table', '表名', NULL, 'String', NULL, 0, 0, NULL, NULL, 1, 0, NULL, 'admin', '2019-03-20 13:24:21', 'admin', '2019-03-20 13:25:08');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ec0003', '402880e64e1ef94d014e1efefc2a0001', 'id', 'id', 0, 'String', '', NULL, 0, '', '', 0, 0, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0004', '402880e64e1ef94d014e1efefc2a0001', 'accountname', 'accountname', 0, 'String', '', NULL, 0, '', '', 0, 1, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0005', '402880e64e1ef94d014e1efefc2a0001', 'accounttoken', 'accounttoken', 0, 'String', '', NULL, 0, '', '', 0, 2, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0006', '402880e64e1ef94d014e1efefc2a0001', 'accountnumber', 'accountnumber', 0, 'String', '', NULL, 0, '', '', 0, 3, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0007', '402880e64e1ef94d014e1efefc2a0001', 'accounttype', 'accounttype', 0, 'String', '', NULL, 0, '', '', 0, 4, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0008', '402880e64e1ef94d014e1efefc2a0001', 'accountemail', 'accountemail', 0, 'String', '', NULL, 0, '', '', 0, 5, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ed0009', '402880e64e1ef94d014e1efefc2a0001', 'accountdesc', 'accountdesc', 0, 'String', '', NULL, 0, '', '', 0, 6, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee000b', '402880e64e1ef94d014e1efefc2a0001', 'accountappid', 'accountappid', 0, 'String', '', NULL, 0, '', '', 0, 8, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee000c', '402880e64e1ef94d014e1efefc2a0001', 'accountappsecret', 'accountappsecret', 0, 'String', '', NULL, 0, '', '', 0, 9, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee000d', '402880e64e1ef94d014e1efefc2a0001', 'ADDTOEKNTIME', 'ADDTOEKNTIME', 0, 'String', '', NULL, 0, '', '', 0, 10, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee000e', '402880e64e1ef94d014e1efefc2a0001', 'USERNAME', 'USERNAME', 0, 'String', '', NULL, 0, '', '', 0, 11, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee0010', '402880e64e1ef94d014e1efefc2a0001', 'jsapiticket', 'jsapiticket', 0, 'String', '', NULL, 0, '', '', 0, 13, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ee0011', '402880e64e1ef94d014e1efefc2a0001', 'jsapitickettime', 'jsapitickettime', 0, 'String', '', NULL, 0, '', '', 0, 14, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f167cf82600167cfa154ef0012', '402880e64e1ef94d014e1efefc2a0001', 'init_data_flag', 'init_data_flag', 0, 'String', '', NULL, 0, '', '', 0, 15, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490002', '402881f363aa9a380163aa9ebe480001', 'id', 'id', 0, 'String', '', NULL, 0, '', '', 0, 0, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490003', '402881f363aa9a380163aa9ebe480001', 'name', 'name', 0, 'String', 'single', NULL, 0, '', '', 0, 10, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490004', '402881f363aa9a380163aa9ebe480001', 'sex', 'sex', 0, 'String', 'single', NULL, 0, 'sex', '', 0, 11, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490005', '402881f363aa9a380163aa9ebe480001', 'age', 'age', 0, 'String', '', NULL, 0, '', '', 0, 12, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490006', '402881f363aa9a380163aa9ebe480001', 'address', 'address', 0, 'String', '', NULL, 0, '', '', 0, 13, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe490007', '402881f363aa9a380163aa9ebe480001', 'phone', 'phone', 0, 'String', '', NULL, 0, '', '', 0, 14, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f363aa9a380163aa9ebe4a0008', '402881f363aa9a380163aa9ebe480001', 'memo', 'memo', 0, 'String', '', NULL, 0, '', '', 0, 15, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2c0004', '402880e64eb9a22c014eb9a4d5890001', 'ID', 'ID', 0, 'String', '', NULL, 0, '', '', 0, 0, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2c0005', '402880e64eb9a22c014eb9a4d5890001', 'activitiSync', 'activitiSync', 0, 'String', '', NULL, 0, '', '', 0, 1, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2d0006', '402880e64eb9a22c014eb9a4d5890001', 'browser', 'browser', 0, 'String', '', NULL, 0, '', '', 0, 2, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2d0007', '402880e64eb9a22c014eb9a4d5890001', 'password', 'password', 0, 'String', '', NULL, 0, '', '', 0, 3, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2e0008', '402880e64eb9a22c014eb9a4d5890001', 'realname', 'realname', 0, 'String', '', NULL, 0, '', '', 0, 4, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2e0009', '402880e64eb9a22c014eb9a4d5890001', 'signature', 'signature', 0, 'String', '', NULL, 0, '', '', 0, 5, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d2f000a', '402880e64eb9a22c014eb9a4d5890001', 'status', 'status', 0, 'String', '', NULL, 0, '', '', 0, 6, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d30000b', '402880e64eb9a22c014eb9a4d5890001', 'userkey', 'userkey', 0, 'String', '', NULL, 0, '', '', 0, 7, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d30000c', '402880e64eb9a22c014eb9a4d5890001', 'username', 'username', 0, 'String', '', NULL, 0, '', '', 0, 8, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d31000d', '402880e64eb9a22c014eb9a4d5890001', 'departid', 'departid', 0, 'String', '', NULL, 0, '', '', 0, 9, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d31000e', '402880e64eb9a22c014eb9a4d5890001', 'user_name_en', 'user_name_en', 0, 'String', '', NULL, 0, '', '', 0, 10, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f36402f3de016403035d32000f', '402880e64eb9a22c014eb9a4d5890001', 'delete_flag', 'delete_flag', 0, 'String', '', NULL, 0, '', '', 0, 11, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f3647e95be01647eb88c400003', '402880e74d76e784014d76f9e783001e', 'account', 'account', 0, 'String', 'single', NULL, 0, '', '', 0, 0, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('402881f3647e95be01647eb88c410004', '402880e74d76e784014d76f9e783001e', 'realname', 'realname', 0, 'String', '', NULL, 0, '', '', 0, 1, '', NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('61ef5b323134938fdd07ad5e3ea16cd3', '87b55a515d3441b6b98e48e5b35474a6', 'key_word', '关键词', NULL, 'String', 'single', 0, 1, '', '', 1, 5, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('627768efd9ba2c41e905579048f21000', '6c7f59741c814347905a938f06ee003c', 'username', '用户账号', NULL, 'String', 'single', 0, 1, '', '', 1, 2, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('8a2dfe672f3c0d391ace4a9f9bf564ff', '402880ec5d872157015d87f2dd940010', 'data_id', '数据ID', NULL, 'String', NULL, 0, 0, NULL, NULL, 1, 0, NULL, 'admin', '2019-03-20 13:24:21', 'admin', '2019-03-20 13:25:08');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('8bb087a9aa2000bcae17a1b3f5768435', '6c7f59741c814347905a938f06ee003c', 'sex', '性别', NULL, 'Integer', 'single', 0, 1, 'sex', '', 1, 5, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('90d4fa57d301801abb26a9b86b6b94c4', '6c7f59741c814347905a938f06ee003c', 'birthday', '生日', NULL, 'Date', 'single', 0, 0, '', '', 1, 4, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('9a0a7375479b7657e16c6a228354b495', '402880ec5d872157015d87f2dd940010', 'data_version', '数据版本', NULL, 'String', NULL, 0, 0, NULL, NULL, 1, 0, NULL, 'admin', '2019-03-20 13:24:21', 'admin', '2019-03-20 13:25:08');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('a4ac355f07a05218854e5f23e2930163', '6c7f59741c814347905a938f06ee003c', 'avatar', '头像', NULL, 'String', NULL, 0, 0, '', '', 0, 6, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('ae4d621e391a1392779175cf5a65134c', '87b55a515d3441b6b98e48e5b35474a6', 'update_by', '修改人', NULL, 'String', NULL, 0, 0, '', '', 1, 7, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('b27bea35b1264003c79d38cb86d6929e', '6c7f59741c814347905a938f06ee003c', 'id', 'id', NULL, 'String', NULL, 0, 0, '', '', 0, 1, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('ce5168755a734ea09dd190e28bf8d9f4', '87b55a515d3441b6b98e48e5b35474a6', 'update_time', '修改时间', NULL, 'String', NULL, 0, 0, '', '', 1, 2, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('d6e86b5ffd096ddcc445c0f320a45004', '6c7f59741c814347905a938f06ee003c', 'phone', '手机号', NULL, 'String', NULL, 0, 0, '', '', 1, 11, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('df365cd357699eea96c29763d1dd7f9d', '6c7f59741c814347905a938f06ee003c', 'email', '邮箱', NULL, 'String', NULL, 0, 0, '', '', 1, 14, '', 'admin', '2019-11-22 16:34:31', NULL, NULL);
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('edf9932912b81ad01dd557d3d593a559', '87b55a515d3441b6b98e48e5b35474a6', 'age', '年龄', NULL, 'String', NULL, 0, 0, '', '', 1, 8, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('f985883e509a6faaaf62ca07fd24a73c', '87b55a515d3441b6b98e48e5b35474a6', 'birthday', '生日', NULL, 'Date', 'single', 0, 1, '', '', 1, 1, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
INSERT INTO `onl_cgreport_item` VALUES ('fce83e4258de3e2f114ab3116397670c', '87b55a515d3441b6b98e48e5b35474a6', 'punch_time', '发布时间', NULL, 'String', NULL, 0, 0, '', '', 1, 3, '', 'admin', '2019-03-20 19:26:39', 'admin', '2019-03-27 18:05:04');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for onl_cgreport_param
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `onl_cgreport_param`;
|
||||
CREATE TABLE `onl_cgreport_param` (
|
||||
`id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||
`cgrhead_id` varchar(36) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '动态报表ID',
|
||||
`param_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '参数字段',
|
||||
`param_txt` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数文本',
|
||||
`param_value` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '参数默认值',
|
||||
`order_num` int(11) NULL DEFAULT NULL COMMENT '排序',
|
||||
`create_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人登录名称',
|
||||
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建日期',
|
||||
`update_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人登录名称',
|
||||
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新日期',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `idx_cgrheadid`(`cgrhead_id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of onl_cgreport_param
|
||||
-- ----------------------------
|
||||
INSERT INTO `onl_cgreport_param` VALUES ('402881f36402f3de016403035d350010', '402880e64eb9a22c014eb9a4d5890001', 'usekey', 'usekey', '', 0, 'admin', '2018-06-15 18:35:09', NULL, NULL);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@ -1,9 +0,0 @@
|
||||
<EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
JeecgBoot<6F><74><EFBFBD><EFBFBD>ƽ̨<C6BD><CCA8><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>ݽ϶࣬Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>
|
||||
1.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> => <20><><EFBFBD>ذ汾ͨ<E6B1BE><CDA8>svn<76><6E><EFBFBD><EFBFBD>git<69><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>ڷ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><F1BFAAB7><EFBFBD>jeecgÿ<67>ΰ汾<CEB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵĴ<C9B5><C4B4>룬<EFBFBD>Աȴ<D4B1><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB>
|
||||
2.<2E><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD> => <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>η<EFBFBD><CEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQL<51><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SQLʵ<4C><CAB5><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
ע<>⣺ <20><><EFBFBD><EFBFBD>sqlĿǰֻ<C7B0>ṩmysql<71>汾<EFBFBD><E6B1BE>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>²˵<C2B2><CBB5><EFBFBD>Ҫ<EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB>Ȩ<EFBFBD><C8A8>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD>ҳ<EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>֡<EFBFBD>
|
||||
1
jeecg-boot/jeecg-boot-base-common/.gitignore
vendored
1
jeecg-boot/jeecg-boot-base-common/.gitignore
vendored
@ -1 +0,0 @@
|
||||
/target/
|
||||
@ -3,12 +3,12 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jeecg-boot-base-common</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
|
||||
@ -171,20 +171,42 @@ public interface CommonConstant {
|
||||
public static final Integer DESIGN_FORM_URL_STATUS_NOT_PASSED = 2;
|
||||
|
||||
/**
|
||||
* 表单设计器URL授权未通过
|
||||
* 表单设计器新增 Flag
|
||||
*/
|
||||
public static final String DESIGN_FORM_URL_TYPE_ADD = "add";
|
||||
/**
|
||||
* 表单设计器URL授权未通过
|
||||
* 表单设计器修改 Flag
|
||||
*/
|
||||
public static final String DESIGN_FORM_URL_TYPE_EDIT = "edit";
|
||||
/**
|
||||
* 表单设计器URL授权未通过
|
||||
* 表单设计器详情 Flag
|
||||
*/
|
||||
public static final String DESIGN_FORM_URL_TYPE_DETAIL = "detail";
|
||||
/**
|
||||
* 表单设计器URL授权未通过
|
||||
* 表单设计器复用数据 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";
|
||||
|
||||
/**
|
||||
* 文件上传类型(本地:local,Minio:minio,阿里云: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";
|
||||
|
||||
/**
|
||||
* 员工身份 (1:普通员工 2:上级)
|
||||
*/
|
||||
public static final Integer USER_IDENTITY_1 = 1;
|
||||
public static final Integer USER_IDENTITY_2 = 2;
|
||||
}
|
||||
|
||||
@ -8,7 +8,12 @@ public interface DataBaseConstant {
|
||||
public static final String DB_TYPE_ORACLE = "ORACLE";
|
||||
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";
|
||||
//*********系统上下文变量****************************************
|
||||
/**
|
||||
* 数据-所属机构编码
|
||||
|
||||
@ -1,398 +1,398 @@
|
||||
package org.jeecg.common.es;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
|
||||
*
|
||||
* @author sunjianlei
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JeecgElasticsearchTemplate {
|
||||
|
||||
/**
|
||||
* 用户配置是否通过,未通过就不走任何方法
|
||||
*/
|
||||
private static boolean configIsPassed = true;
|
||||
/**
|
||||
* 是否已检测过配置
|
||||
*/
|
||||
private static boolean configIsChecked = false;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
private final String FORMAT_JSON = "format=json";
|
||||
|
||||
public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl) {
|
||||
log.debug("JeecgElasticsearchTemplate BaseURL:" + baseUrl);
|
||||
|
||||
// 未检测过配置,进行检测操作
|
||||
if (!configIsChecked) {
|
||||
configIsChecked = true;
|
||||
// 为空则代表未配置 baseUrl
|
||||
if (StringUtils.isEmpty(baseUrl)) {
|
||||
configIsPassed = false;
|
||||
} else {
|
||||
this.baseUrl = baseUrl;
|
||||
// 判断配置的地址是否有效
|
||||
try {
|
||||
RestUtil.get(this.getBaseUrl().toString());
|
||||
} catch (Exception e) {
|
||||
configIsPassed = false;
|
||||
}
|
||||
}
|
||||
if (configIsPassed) {
|
||||
log.info("ElasticSearch服务连接成功");
|
||||
} else {
|
||||
log.warn("ElasticSearch 服务连接失败,原因:配置未通过。可能是BaseURL未配置或配置有误,也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置是否通过,未通过就抛出异常,中断执行
|
||||
*/
|
||||
private void checkConfig() {
|
||||
if (!configIsPassed) {
|
||||
throw new RuntimeException("配置未通过,拒绝执行该方法");
|
||||
}
|
||||
}
|
||||
|
||||
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 <T> ResponseEntity<T> _cat(String urlAfter, Class<T> responseType) {
|
||||
this.checkConfig();
|
||||
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() {
|
||||
this.checkConfig();
|
||||
return getIndices(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询单个索引
|
||||
* <p>
|
||||
* 查询地址:GET http://{baseUrl}/_cat/indices/{indexName}
|
||||
*/
|
||||
public JSONArray getIndices(String indexName) {
|
||||
this.checkConfig();
|
||||
StringBuilder urlAfter = new StringBuilder("/indices");
|
||||
if (!StringUtils.isEmpty(indexName)) {
|
||||
urlAfter.append("/").append(indexName.trim().toLowerCase());
|
||||
}
|
||||
return _cat(urlAfter.toString(), JSONArray.class).getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* 索引是否存在
|
||||
*/
|
||||
public boolean indexExists(String indexName) {
|
||||
this.checkConfig();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建索引
|
||||
* <p>
|
||||
* 查询地址:PUT http://{baseUrl}/{indexName}
|
||||
*/
|
||||
public boolean createIndex(String indexName) {
|
||||
this.checkConfig();
|
||||
String url = this.getBaseUrl(indexName).toString();
|
||||
|
||||
/* 返回结果 (仅供参考)
|
||||
"createIndex": {
|
||||
"shards_acknowledged": true,
|
||||
"acknowledged": true,
|
||||
"index": "hello_world"
|
||||
}
|
||||
*/
|
||||
try {
|
||||
return RestUtil.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) {
|
||||
this.checkConfig();
|
||||
String url = this.getBaseUrl(indexName).toString();
|
||||
try {
|
||||
return RestUtil.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据,详见:saveOrUpdate
|
||||
*/
|
||||
public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
|
||||
this.checkConfig();
|
||||
return this.saveOrUpdate(indexName, typeName, dataId, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据,详见:saveOrUpdate
|
||||
*/
|
||||
public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
|
||||
this.checkConfig();
|
||||
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) {
|
||||
this.checkConfig();
|
||||
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
|
||||
/* 返回结果(仅供参考)
|
||||
"createIndexA2": {
|
||||
"result": "created",
|
||||
"_shards": {
|
||||
"total": 2,
|
||||
"successful": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"_seq_no": 0,
|
||||
"_index": "test_index_1",
|
||||
"_type": "test_type_1",
|
||||
"_id": "a2",
|
||||
"_version": 1,
|
||||
"_primary_term": 1
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
// 去掉 data 中为空的值
|
||||
Set<String> keys = data.keySet();
|
||||
List<String> emptyKeys = new ArrayList<>(keys.size());
|
||||
for (String key : keys) {
|
||||
String value = data.getString(key);
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
emptyKeys.add(key);
|
||||
}
|
||||
}
|
||||
for (String key : emptyKeys) {
|
||||
data.remove(key);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String result = RestUtil.put(url, data).getString("result");
|
||||
return "created".equals(result) || "updated".equals(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除索引数据
|
||||
* <p>
|
||||
* 请求地址:DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
|
||||
*/
|
||||
public boolean delete(String indexName, String typeName, String dataId) {
|
||||
this.checkConfig();
|
||||
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
|
||||
/* 返回结果(仅供参考)
|
||||
{
|
||||
"_index": "es_demo",
|
||||
"_type": "docs",
|
||||
"_id": "001",
|
||||
"_version": 3,
|
||||
"result": "deleted",
|
||||
"_shards": {
|
||||
"total": 1,
|
||||
"successful": 1,
|
||||
"failed": 0
|
||||
},
|
||||
"_seq_no": 28,
|
||||
"_primary_term": 18
|
||||
}
|
||||
*/
|
||||
try {
|
||||
return "deleted".equals(RestUtil.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) {
|
||||
this.checkConfig();
|
||||
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
|
||||
|
||||
log.info("search: " + queryObject.toJSONString());
|
||||
|
||||
return RestUtil.post(url, queryObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return { "query": query }
|
||||
*/
|
||||
public JSONObject buildQuery(JSONObject query) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("query", query);
|
||||
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 null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//package org.jeecg.common.es;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.apache.commons.lang.StringUtils;
|
||||
//import org.jeecg.common.util.RestUtil;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.http.HttpMethod;
|
||||
//import org.springframework.http.HttpStatus;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.Set;
|
||||
//
|
||||
///**
|
||||
// * 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
|
||||
// *
|
||||
// * @author sunjianlei
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class JeecgElasticsearchTemplate {
|
||||
//
|
||||
// /**
|
||||
// * 用户配置是否通过,未通过就不走任何方法
|
||||
// */
|
||||
// private static boolean configIsPassed = true;
|
||||
// /**
|
||||
// * 是否已检测过配置
|
||||
// */
|
||||
// private static boolean configIsChecked = false;
|
||||
//
|
||||
// private String baseUrl;
|
||||
//
|
||||
// private final String FORMAT_JSON = "format=json";
|
||||
//
|
||||
// public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl) {
|
||||
// log.debug("JeecgElasticsearchTemplate BaseURL:" + baseUrl);
|
||||
//
|
||||
// // 未检测过配置,进行检测操作
|
||||
// if (!configIsChecked) {
|
||||
// configIsChecked = true;
|
||||
// // 为空则代表未配置 baseUrl
|
||||
// if (StringUtils.isEmpty(baseUrl)) {
|
||||
// configIsPassed = false;
|
||||
// } else {
|
||||
// this.baseUrl = baseUrl;
|
||||
// // 判断配置的地址是否有效
|
||||
// try {
|
||||
// RestUtil.get(this.getBaseUrl().toString());
|
||||
// } catch (Exception e) {
|
||||
// configIsPassed = false;
|
||||
// }
|
||||
// }
|
||||
// if (configIsPassed) {
|
||||
// log.info("ElasticSearch服务连接成功");
|
||||
// } else {
|
||||
// log.warn("ElasticSearch 服务连接失败,原因:配置未通过。可能是BaseURL未配置或配置有误,也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法!");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 检查配置是否通过,未通过就抛出异常,中断执行
|
||||
// */
|
||||
// private void checkConfig() {
|
||||
// if (!configIsPassed) {
|
||||
// throw new RuntimeException("配置未通过,拒绝执行该方法");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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 <T> ResponseEntity<T> _cat(String urlAfter, Class<T> responseType) {
|
||||
// this.checkConfig();
|
||||
// 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() {
|
||||
// this.checkConfig();
|
||||
// return getIndices(null);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 查询单个索引
|
||||
// * <p>
|
||||
// * 查询地址:GET http://{baseUrl}/_cat/indices/{indexName}
|
||||
// */
|
||||
// public JSONArray getIndices(String indexName) {
|
||||
// this.checkConfig();
|
||||
// StringBuilder urlAfter = new StringBuilder("/indices");
|
||||
// if (!StringUtils.isEmpty(indexName)) {
|
||||
// urlAfter.append("/").append(indexName.trim().toLowerCase());
|
||||
// }
|
||||
// return _cat(urlAfter.toString(), JSONArray.class).getBody();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 索引是否存在
|
||||
// */
|
||||
// public boolean indexExists(String indexName) {
|
||||
// this.checkConfig();
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 创建索引
|
||||
// * <p>
|
||||
// * 查询地址:PUT http://{baseUrl}/{indexName}
|
||||
// */
|
||||
// public boolean createIndex(String indexName) {
|
||||
// this.checkConfig();
|
||||
// String url = this.getBaseUrl(indexName).toString();
|
||||
//
|
||||
// /* 返回结果 (仅供参考)
|
||||
// "createIndex": {
|
||||
// "shards_acknowledged": true,
|
||||
// "acknowledged": true,
|
||||
// "index": "hello_world"
|
||||
// }
|
||||
// */
|
||||
// try {
|
||||
// return RestUtil.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) {
|
||||
// this.checkConfig();
|
||||
// String url = this.getBaseUrl(indexName).toString();
|
||||
// try {
|
||||
// return RestUtil.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;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 保存数据,详见:saveOrUpdate
|
||||
// */
|
||||
// public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
|
||||
// this.checkConfig();
|
||||
// return this.saveOrUpdate(indexName, typeName, dataId, data);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 更新数据,详见:saveOrUpdate
|
||||
// */
|
||||
// public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
|
||||
// this.checkConfig();
|
||||
// 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) {
|
||||
// this.checkConfig();
|
||||
// String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
|
||||
// /* 返回结果(仅供参考)
|
||||
// "createIndexA2": {
|
||||
// "result": "created",
|
||||
// "_shards": {
|
||||
// "total": 2,
|
||||
// "successful": 1,
|
||||
// "failed": 0
|
||||
// },
|
||||
// "_seq_no": 0,
|
||||
// "_index": "test_index_1",
|
||||
// "_type": "test_type_1",
|
||||
// "_id": "a2",
|
||||
// "_version": 1,
|
||||
// "_primary_term": 1
|
||||
// }
|
||||
// */
|
||||
//
|
||||
// try {
|
||||
// // 去掉 data 中为空的值
|
||||
// Set<String> keys = data.keySet();
|
||||
// List<String> emptyKeys = new ArrayList<>(keys.size());
|
||||
// for (String key : keys) {
|
||||
// String value = data.getString(key);
|
||||
// if (StringUtils.isEmpty(value)) {
|
||||
// emptyKeys.add(key);
|
||||
// }
|
||||
// }
|
||||
// for (String key : emptyKeys) {
|
||||
// data.remove(key);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// String result = RestUtil.put(url, data).getString("result");
|
||||
// return "created".equals(result) || "updated".equals(result);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除索引数据
|
||||
// * <p>
|
||||
// * 请求地址:DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
|
||||
// */
|
||||
// public boolean delete(String indexName, String typeName, String dataId) {
|
||||
// this.checkConfig();
|
||||
// String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
|
||||
// /* 返回结果(仅供参考)
|
||||
// {
|
||||
// "_index": "es_demo",
|
||||
// "_type": "docs",
|
||||
// "_id": "001",
|
||||
// "_version": 3,
|
||||
// "result": "deleted",
|
||||
// "_shards": {
|
||||
// "total": 1,
|
||||
// "successful": 1,
|
||||
// "failed": 0
|
||||
// },
|
||||
// "_seq_no": 28,
|
||||
// "_primary_term": 18
|
||||
// }
|
||||
// */
|
||||
// try {
|
||||
// return "deleted".equals(RestUtil.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) {
|
||||
// this.checkConfig();
|
||||
// String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
|
||||
//
|
||||
// log.info("search: " + queryObject.toJSONString());
|
||||
//
|
||||
// return RestUtil.post(url, queryObject);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return { "query": query }
|
||||
// */
|
||||
// public JSONObject buildQuery(JSONObject query) {
|
||||
// JSONObject json = new JSONObject();
|
||||
// json.put("query", query);
|
||||
// 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 null;
|
||||
// }
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
||||
|
||||
@ -4,10 +4,9 @@ import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jeecg.common.system.vo.ComboModel;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysDepartModel;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.system.vo.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @Description: 底层共通业务API,提供其他独立模块调用
|
||||
@ -77,6 +76,12 @@ public interface ISysBaseAPI {
|
||||
/** 查询所有的父级字典,按照create_time排序 */
|
||||
public List<DictModel> queryAllDict();
|
||||
|
||||
/**
|
||||
* 查询所有分类字典
|
||||
* @return
|
||||
*/
|
||||
public List<SysCategoryModel> queryAllDSysCategory();
|
||||
|
||||
/**
|
||||
* 获取表数据字典
|
||||
* @param table
|
||||
@ -111,6 +116,18 @@ public interface ISysBaseAPI {
|
||||
*/
|
||||
public void sendSysAnnouncement(String fromUser, String toUser,String title, Map<String, String> map, String templateCode);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fromUser 发送人(用户登录账户)
|
||||
* @param toUser 发送给(用户登录账户)
|
||||
* @param title 通知标题
|
||||
* @param map 模板参数
|
||||
* @param templateCode 模板编码
|
||||
* @param busType 业务类型
|
||||
* @param busId 业务id
|
||||
*/
|
||||
public void sendSysAnnouncement(String fromUser, String toUser,String title, Map<String, String> map, String templateCode,String busType,String busId);
|
||||
|
||||
/**
|
||||
* 通过消息中心模板,生成推送内容
|
||||
*
|
||||
@ -131,6 +148,24 @@ public interface ISysBaseAPI {
|
||||
*/
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory);
|
||||
|
||||
/**queryTableDictByKeys
|
||||
* 发送系统消息
|
||||
* @param fromUser 发送人(用户登录账户)
|
||||
* @param toUser 发送给(用户登录账户)
|
||||
* @param title 消息主题
|
||||
* @param msgContent 消息内容
|
||||
* @param setMsgCategory 消息类型 1:消息2:系统消息
|
||||
* @param busType 业务类型
|
||||
* @param busId 业务id
|
||||
*/
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory,String busType,String busId);
|
||||
|
||||
/**
|
||||
* 根据业务类型及业务id修改消息已读
|
||||
* @param busType
|
||||
* @param busId
|
||||
*/
|
||||
public void updateSysAnnounReadFlag(String busType,String busId);
|
||||
/**
|
||||
* 查询表字典 支持过滤数据
|
||||
* @param table
|
||||
@ -141,6 +176,16 @@ public interface ISysBaseAPI {
|
||||
*/
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql);
|
||||
|
||||
/**
|
||||
* 查询指定table的 text code 获取字典,包含text和value
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray);
|
||||
|
||||
/**
|
||||
* 获取所有有效用户
|
||||
* @return
|
||||
@ -152,7 +197,7 @@ public interface ISysBaseAPI {
|
||||
* userIds 默认选中用户
|
||||
* @return
|
||||
*/
|
||||
public List<ComboModel> queryAllUser(String[] userIds);
|
||||
public JSONObject queryAllUser(String[] userIds, int pageNo, int pageSize);
|
||||
|
||||
/**
|
||||
* 获取所有角色
|
||||
@ -193,5 +238,37 @@ public interface ISysBaseAPI {
|
||||
* @return
|
||||
*/
|
||||
public List<SysDepartModel> getAllSysDepart();
|
||||
|
||||
|
||||
/**
|
||||
* 根据 id 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceId
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId);
|
||||
|
||||
/**
|
||||
* 根据 code 查询数据库中存储的 DynamicDataSourceModel
|
||||
*
|
||||
* @param dbSourceCode
|
||||
* @return
|
||||
*/
|
||||
DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode);
|
||||
|
||||
/**
|
||||
* 根据部门Id获取部门负责人
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getDeptHeadByDepId(String deptId);
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param file 文件
|
||||
* @param bizPath 自定义路径
|
||||
* @param uploadType 上传方式
|
||||
* @return
|
||||
*/
|
||||
public String upload(MultipartFile file,String bizPath,String uploadType);
|
||||
|
||||
}
|
||||
|
||||
@ -13,6 +13,10 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
@ -40,9 +44,18 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequestMapping("/sys/common")
|
||||
public class CommonController {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@Value(value = "${jeecg.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
/**
|
||||
* 本地:local minio:minio 阿里:alioss
|
||||
*/
|
||||
@Value(value="${jeecg.uploadType}")
|
||||
private String uploadType;
|
||||
|
||||
/**
|
||||
* @Author 政辉
|
||||
* @return
|
||||
@ -51,48 +64,124 @@ public class CommonController {
|
||||
public Result<?> noauth() {
|
||||
return Result.error("没有权限,请联系管理员授权");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件上传统一方法
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/upload")
|
||||
public Result<?> upload(HttpServletRequest request, HttpServletResponse response) {
|
||||
Result<?> result = new Result<>();
|
||||
try {
|
||||
String ctxPath = uploadpath;
|
||||
String fileName = null;
|
||||
String bizPath = "files";
|
||||
String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
File file = new File(ctxPath + File.separator + bizPath + File.separator + nowday);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();// 创建文件根目录
|
||||
String savePath = "";
|
||||
String bizPath = request.getParameter("biz");
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
|
||||
if(oConvertUtils.isEmpty(bizPath)){
|
||||
if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
|
||||
result.setMessage("使用阿里云文件上传时,必须添加目录!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}else{
|
||||
bizPath = "";
|
||||
}
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile mf = multipartRequest.getFile("file");// 获取上传文件对象
|
||||
String orgName = mf.getOriginalFilename();// 获取文件名
|
||||
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
|
||||
String savePath = file.getPath() + File.separator + fileName;
|
||||
File savefile = new File(savePath);
|
||||
FileCopyUtils.copy(mf.getBytes(), savefile);
|
||||
String dbpath = bizPath + File.separator + nowday + File.separator + fileName;
|
||||
if (dbpath.contains("\\")) {
|
||||
dbpath = dbpath.replace("\\", "/");
|
||||
}
|
||||
result.setMessage(dbpath);
|
||||
}
|
||||
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
|
||||
savePath = this.uploadLocal(file,bizPath);
|
||||
}else{
|
||||
savePath = sysBaseAPI.upload(file,bizPath,uploadType);
|
||||
}
|
||||
if(oConvertUtils.isNotEmpty(savePath)){
|
||||
result.setMessage(savePath);
|
||||
result.setSuccess(true);
|
||||
} catch (IOException e) {
|
||||
}else {
|
||||
result.setMessage("上传失败!");
|
||||
result.setSuccess(false);
|
||||
result.setMessage(e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览图片
|
||||
* 请求地址:http://localhost:8080/common/view/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
*
|
||||
* 本地文件上传
|
||||
* @param mf 文件
|
||||
* @param bizPath 自定义路径
|
||||
* @return
|
||||
*/
|
||||
private String uploadLocal(MultipartFile mf,String bizPath){
|
||||
try {
|
||||
String ctxPath = uploadpath;
|
||||
String fileName = null;
|
||||
File file = new File(ctxPath + File.separator + bizPath + File.separator );
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();// 创建文件根目录
|
||||
}
|
||||
String orgName = mf.getOriginalFilename();// 获取文件名
|
||||
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
|
||||
String savePath = file.getPath() + File.separator + fileName;
|
||||
File savefile = new File(savePath);
|
||||
FileCopyUtils.copy(mf.getBytes(), savefile);
|
||||
String dbpath = null;
|
||||
if(oConvertUtils.isNotEmpty(bizPath)){
|
||||
dbpath = bizPath + File.separator + fileName;
|
||||
}else{
|
||||
dbpath = fileName;
|
||||
}
|
||||
if (dbpath.contains("\\")) {
|
||||
dbpath = dbpath.replace("\\", "/");
|
||||
}
|
||||
return dbpath;
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// @PostMapping(value = "/upload2")
|
||||
// public Result<?> upload2(HttpServletRequest request, HttpServletResponse response) {
|
||||
// Result<?> result = new Result<>();
|
||||
// try {
|
||||
// String ctxPath = uploadpath;
|
||||
// String fileName = null;
|
||||
// String bizPath = "files";
|
||||
// String tempBizPath = request.getParameter("biz");
|
||||
// if(oConvertUtils.isNotEmpty(tempBizPath)){
|
||||
// bizPath = tempBizPath;
|
||||
// }
|
||||
// String nowday = new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
// File file = new File(ctxPath + File.separator + bizPath + File.separator + nowday);
|
||||
// if (!file.exists()) {
|
||||
// file.mkdirs();// 创建文件根目录
|
||||
// }
|
||||
// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
// MultipartFile mf = multipartRequest.getFile("file");// 获取上传文件对象
|
||||
// String orgName = mf.getOriginalFilename();// 获取文件名
|
||||
// fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
|
||||
// String savePath = file.getPath() + File.separator + fileName;
|
||||
// File savefile = new File(savePath);
|
||||
// FileCopyUtils.copy(mf.getBytes(), savefile);
|
||||
// String dbpath = bizPath + File.separator + nowday + File.separator + fileName;
|
||||
// if (dbpath.contains("\\")) {
|
||||
// dbpath = dbpath.replace("\\", "/");
|
||||
// }
|
||||
// result.setMessage(dbpath);
|
||||
// result.setSuccess(true);
|
||||
// } catch (IOException e) {
|
||||
// result.setSuccess(false);
|
||||
// result.setMessage(e.getMessage());
|
||||
// log.error(e.getMessage(), e);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 预览图片&下载文件
|
||||
* 请求地址:http://localhost:8080/common/static/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/view/**")
|
||||
@GetMapping(value = "/static/**")
|
||||
public void view(HttpServletRequest request, HttpServletResponse response) {
|
||||
// ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
String imgPath = extractPathFromPattern(request);
|
||||
@ -104,10 +193,12 @@ public class CommonController {
|
||||
if (imgPath.endsWith(",")) {
|
||||
imgPath = imgPath.substring(0, imgPath.length() - 1);
|
||||
}
|
||||
response.setContentType("image/jpeg;charset=utf-8");
|
||||
String localPath = uploadpath;
|
||||
String imgurl = localPath + File.separator + imgPath;
|
||||
inputStream = new BufferedInputStream(new FileInputStream(imgurl));
|
||||
String filePath = uploadpath + File.separator + imgPath;
|
||||
String downloadFilePath = uploadpath + File.separator + filePath;
|
||||
File file = new File(downloadFilePath);
|
||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(filePath));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
@ -116,7 +207,7 @@ public class CommonController {
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
log.error("预览图片失败" + e.getMessage());
|
||||
log.error("预览文件失败" + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
@ -136,64 +227,65 @@ public class CommonController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* 请求地址:http://localhost:8080/common/download/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/download/**")
|
||||
public void download(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
// ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
String filePath = extractPathFromPattern(request);
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
filePath = filePath.replace("..", "");
|
||||
if (filePath.endsWith(",")) {
|
||||
filePath = filePath.substring(0, filePath.length() - 1);
|
||||
}
|
||||
String localPath = uploadpath;
|
||||
String downloadFilePath = localPath + File.separator + filePath;
|
||||
File file = new File(downloadFilePath);
|
||||
if (file.exists()) {
|
||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(file));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info("文件下载失败" + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// /**
|
||||
// * 下载文件
|
||||
// * 请求地址:http://localhost:8080/common/download/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
// *
|
||||
// * @param request
|
||||
// * @param response
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @GetMapping(value = "/download/**")
|
||||
// public void download(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
// // ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
// String filePath = extractPathFromPattern(request);
|
||||
// // 其余处理略
|
||||
// InputStream inputStream = null;
|
||||
// OutputStream outputStream = null;
|
||||
// try {
|
||||
// filePath = filePath.replace("..", "");
|
||||
// if (filePath.endsWith(",")) {
|
||||
// filePath = filePath.substring(0, filePath.length() - 1);
|
||||
// }
|
||||
// String localPath = uploadpath;
|
||||
// String downloadFilePath = localPath + File.separator + filePath;
|
||||
// File file = new File(downloadFilePath);
|
||||
// if (file.exists()) {
|
||||
// response.setContentType("application/force-download");// 设置强制下载不打开
|
||||
// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
// inputStream = new BufferedInputStream(new FileInputStream(file));
|
||||
// outputStream = response.getOutputStream();
|
||||
// byte[] buf = new byte[1024];
|
||||
// int len;
|
||||
// while ((len = inputStream.read(buf)) > 0) {
|
||||
// outputStream.write(buf, 0, len);
|
||||
// }
|
||||
// response.flushBuffer();
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// log.info("文件下载失败" + e.getMessage());
|
||||
// // e.printStackTrace();
|
||||
// } finally {
|
||||
// if (inputStream != null) {
|
||||
// try {
|
||||
// inputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// if (outputStream != null) {
|
||||
// try {
|
||||
// outputStream.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* @功能:pdf预览Iframe
|
||||
* @param modelAndView
|
||||
@ -206,7 +298,7 @@ public class CommonController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定URL后的字符串全部截断当成参数
|
||||
* 把指定URL后的字符串全部截断当成参数
|
||||
* 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题
|
||||
* @param request
|
||||
* @return
|
||||
@ -216,5 +308,5 @@ public class CommonController {
|
||||
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
|
||||
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ public class QueryGenerator {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取请求对应的数据权限规则
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, SysPermissionDataRuleModel> getRuleMap() {
|
||||
|
||||
@ -18,6 +18,10 @@ public class ComboModel implements Serializable {
|
||||
private boolean checked;
|
||||
/**文档管理 表单table 用户账号*/
|
||||
private String username;
|
||||
/**文档管理 表单table 用户邮箱*/
|
||||
private String email;
|
||||
/**文档管理 表单table 角色编码*/
|
||||
private String roleCode;
|
||||
|
||||
public ComboModel(){
|
||||
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.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 dbName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private java.lang.String dbUsername;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private java.lang.String dbPassword;
|
||||
|
||||
}
|
||||
@ -90,4 +90,14 @@ public class LoginUser {
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 身份(1 普通员工 2 上级)
|
||||
*/
|
||||
private Integer identity;
|
||||
|
||||
/**
|
||||
* 管理部门ids
|
||||
*/
|
||||
private String departIds;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.common.system.vo;
|
||||
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.handler.IFillRuleHandler;
|
||||
|
||||
@ -14,6 +15,7 @@ import org.jeecg.common.handler.IFillRuleHandler;
|
||||
* @author qinfeng
|
||||
* @举例: 自动生成订单号;自动生成当前日期
|
||||
*/
|
||||
@Slf4j
|
||||
public class FillRuleUtil {
|
||||
|
||||
/**
|
||||
@ -30,6 +32,10 @@ public class FillRuleUtil {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("rule_code", ruleCode);
|
||||
JSONObject entity = JSON.parseObject(JSON.toJSONString(impl.getOne(queryWrapper)));
|
||||
if (entity == null) {
|
||||
log.warn("填值规则:" + ruleCode + " 不存在");
|
||||
return null;
|
||||
}
|
||||
// 获取必要的参数
|
||||
String ruleClass = entity.getString("ruleClass");
|
||||
JSONObject params = entity.getJSONObject("ruleParams");
|
||||
|
||||
@ -24,14 +24,14 @@ public class PmsUtil {
|
||||
|
||||
public static String saveErrorTxtByList(List<String> msg, String name) {
|
||||
Date d = new Date();
|
||||
String saveDir = "logs" + File.separator + DateUtils.yyyyMMdd.format(d) + File.separator;
|
||||
String saveDir = "logs" + File.separator + DateUtils.yyyyMMdd.get().format(d) + File.separator;
|
||||
String saveFullDir = uploadPath + File.separator + saveDir;
|
||||
|
||||
File saveFile = new File(saveFullDir);
|
||||
if (!saveFile.exists()) {
|
||||
saveFile.mkdirs();
|
||||
}
|
||||
name += DateUtils.yyyymmddhhmmss.format(d) + Math.round(Math.random() * 10000);
|
||||
name += DateUtils.yyyymmddhhmmss.get().format(d) + Math.round(Math.random() * 10000);
|
||||
String saveFilePath = saveFullDir + name + ".txt";
|
||||
|
||||
try {
|
||||
|
||||
@ -0,0 +1,238 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author 张代浩
|
||||
* @desc 通过反射来动态调用get 和 set 方法
|
||||
*/
|
||||
@Slf4j
|
||||
public class ReflectHelper {
|
||||
|
||||
private Class cls;
|
||||
|
||||
/**
|
||||
* 传过来的对象
|
||||
*/
|
||||
private Object obj;
|
||||
|
||||
/**
|
||||
* 存放get方法
|
||||
*/
|
||||
private Hashtable<String, Method> getMethods = null;
|
||||
/**
|
||||
* 存放set方法
|
||||
*/
|
||||
private Hashtable<String, Method> setMethods = null;
|
||||
|
||||
/**
|
||||
* 定义构造方法 -- 一般来说是个pojo
|
||||
*
|
||||
* @param o 目标对象
|
||||
*/
|
||||
public ReflectHelper(Object o) {
|
||||
obj = o;
|
||||
initMethods();
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 初始化
|
||||
*/
|
||||
public void initMethods() {
|
||||
getMethods = new Hashtable<String, Method>();
|
||||
setMethods = new Hashtable<String, Method>();
|
||||
cls = obj.getClass();
|
||||
Method[] methods = cls.getMethods();
|
||||
// 定义正则表达式,从方法中过滤出getter / setter 函数.
|
||||
String gs = "get(\\w+)";
|
||||
Pattern getM = Pattern.compile(gs);
|
||||
String ss = "set(\\w+)";
|
||||
Pattern setM = Pattern.compile(ss);
|
||||
// 把方法中的"set" 或者 "get" 去掉
|
||||
String rapl = "$1";
|
||||
String param;
|
||||
for (int i = 0; i < methods.length; ++i) {
|
||||
Method m = methods[i];
|
||||
String methodName = m.getName();
|
||||
if (Pattern.matches(gs, methodName)) {
|
||||
param = getM.matcher(methodName).replaceAll(rapl).toLowerCase();
|
||||
getMethods.put(param, m);
|
||||
} else if (Pattern.matches(ss, methodName)) {
|
||||
param = setM.matcher(methodName).replaceAll(rapl).toLowerCase();
|
||||
setMethods.put(param, m);
|
||||
} else {
|
||||
// logger.info(methodName + " 不是getter,setter方法!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 调用set方法
|
||||
*/
|
||||
public boolean setMethodValue(String property, Object object) {
|
||||
Method m = setMethods.get(property.toLowerCase());
|
||||
if (m != null) {
|
||||
try {
|
||||
// 调用目标类的setter函数
|
||||
m.invoke(obj, object);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
log.info("invoke getter on " + property + " error: " + ex.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 调用set方法
|
||||
*/
|
||||
public Object getMethodValue(String property) {
|
||||
Object value = null;
|
||||
Method m = getMethods.get(property.toLowerCase());
|
||||
if (m != null) {
|
||||
try {
|
||||
/*
|
||||
* 调用obj类的setter函数
|
||||
*/
|
||||
value = m.invoke(obj, new Object[]{});
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.info("invoke getter on " + property + " error: " + ex.toString());
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把map中的内容全部注入到obj中
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public Object setAll(Map<String, Object> data) {
|
||||
if (data == null || data.keySet().size() <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (Entry<String, Object> entry : data.entrySet()) {
|
||||
this.setMethodValue(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把map中的内容全部注入到obj中
|
||||
*
|
||||
* @param o
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static Object setAll(Object o, Map<String, Object> data) {
|
||||
ReflectHelper reflectHelper = new ReflectHelper(o);
|
||||
reflectHelper.setAll(data);
|
||||
return o;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把map中的内容全部注入到新实例中
|
||||
*
|
||||
* @param clazz
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T setAll(Class<T> clazz, Map<String, Object> data) {
|
||||
T o = null;
|
||||
try {
|
||||
o = clazz.newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
o = null;
|
||||
return o;
|
||||
}
|
||||
return (T) setAll(o, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入的class将mapList转换为实体类list
|
||||
*
|
||||
* @param mapist
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> transList2Entrys(List<Map<String, Object>> mapist, Class<T> clazz) {
|
||||
List<T> list = new ArrayList<T>();
|
||||
if (mapist != null && mapist.size() > 0) {
|
||||
for (Map<String, Object> data : mapist) {
|
||||
list.add(ReflectHelper.setAll(clazz, data));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据属性名获取属性值
|
||||
*/
|
||||
public static Object getFieldValueByName(String fieldName, Object o) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
||||
Method method = o.getClass().getMethod(getter, new Class[]{});
|
||||
Object value = method.invoke(o, new Object[]{});
|
||||
return value;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性名数组
|
||||
*/
|
||||
public static String[] getFiledName(Object o) {
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
String[] fieldNames = new String[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
//System.out.println(fields[i].getType());
|
||||
fieldNames[i] = fields[i].getName();
|
||||
}
|
||||
return fieldNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取属性类型(type),属性名(name),属性值(value)的map组成的list
|
||||
*/
|
||||
public static List<Map> getFiledsInfo(Object o) {
|
||||
Field[] fields = o.getClass().getDeclaredFields();
|
||||
String[] fieldNames = new String[fields.length];
|
||||
List<Map> list = new ArrayList<Map>();
|
||||
Map<String, Object> infoMap = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
infoMap = new HashMap<String, Object>();
|
||||
infoMap.put("type", fields[i].getType().toString());
|
||||
infoMap.put("name", fields[i].getName());
|
||||
infoMap.put("value", getFieldValueByName(fields[i].getName(), o));
|
||||
list.add(infoMap);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象的所有属性值,返回一个对象数组
|
||||
*/
|
||||
public static Object[] getFiledValues(Object o) {
|
||||
String[] fieldNames = getFiledName(o);
|
||||
Object[] value = new Object[fieldNames.length];
|
||||
for (int i = 0; i < fieldNames.length; i++) {
|
||||
value[i] = getFieldValueByName(fieldNames[i], o);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
@ -15,6 +15,28 @@ import java.util.Map;
|
||||
*/
|
||||
public class RestUtil {
|
||||
|
||||
private static String domain = null;
|
||||
|
||||
public static String getDomain() {
|
||||
if (domain == null) {
|
||||
domain = SpringContextUtils.getDomain();
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
public static String path = null;
|
||||
|
||||
public static String getPath() {
|
||||
if (path == null) {
|
||||
path = SpringContextUtils.getApplicationContext().getEnvironment().getProperty("server.servlet.context-path");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String getBaseUrl() {
|
||||
return getDomain() + getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* RestAPI 调用器
|
||||
*/
|
||||
|
||||
@ -21,10 +21,12 @@ public class SqlInjectionUtil {
|
||||
if (value == null || "".equals(value)) {
|
||||
return;
|
||||
}
|
||||
value = value.toLowerCase();// 统一转为小写
|
||||
// 统一转为小写
|
||||
value = value.toLowerCase();
|
||||
String[] xssArr = xssStr.split("\\|");
|
||||
for (int i = 0; i < xssArr.length; i++) {
|
||||
if (value.indexOf(xssArr[i]) > -1) {
|
||||
log.error("请注意,存在SQL注入关键词---> {}", xssArr[i]);
|
||||
log.error("请注意,值可能存在SQL注入风险!---> {}", value);
|
||||
throw new RuntimeException("请注意,值可能存在SQL注入风险!--->" + value);
|
||||
}
|
||||
@ -35,7 +37,7 @@ public class SqlInjectionUtil {
|
||||
/**
|
||||
* sql注入过滤处理,遇到注入关键字抛异常
|
||||
*
|
||||
* @param value
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public static void filterContent(String[] values) {
|
||||
@ -44,9 +46,11 @@ public class SqlInjectionUtil {
|
||||
if (value == null || "".equals(value)) {
|
||||
return;
|
||||
}
|
||||
value = value.toLowerCase();// 统一转为小写
|
||||
// 统一转为小写
|
||||
value = value.toLowerCase();
|
||||
for (int i = 0; i < xssArr.length; i++) {
|
||||
if (value.indexOf(xssArr[i]) > -1) {
|
||||
log.error("请注意,存在SQL注入关键词---> {}", xssArr[i]);
|
||||
log.error("请注意,值可能存在SQL注入风险!---> {}", value);
|
||||
throw new RuntimeException("请注意,值可能存在SQL注入风险!--->" + value);
|
||||
}
|
||||
@ -62,14 +66,16 @@ public class SqlInjectionUtil {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void specialFilterContent(String value) {
|
||||
String specialXssStr = "exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|+|";
|
||||
String specialXssStr = " exec | insert | select | delete | update | drop | count | chr | mid | master | truncate | char | declare |;|+|";
|
||||
String[] xssArr = specialXssStr.split("\\|");
|
||||
if (value == null || "".equals(value)) {
|
||||
return;
|
||||
}
|
||||
value = value.toLowerCase();// 统一转为小写
|
||||
// 统一转为小写
|
||||
value = value.toLowerCase();
|
||||
for (int i = 0; i < xssArr.length; i++) {
|
||||
if (value.indexOf(xssArr[i]) > -1) {
|
||||
if (value.indexOf(xssArr[i]) > -1 || value.startsWith(xssArr[i].trim())) {
|
||||
log.error("请注意,存在SQL注入关键词---> {}", xssArr[i]);
|
||||
log.error("请注意,值可能存在SQL注入风险!---> {}", value);
|
||||
throw new RuntimeException("请注意,值可能存在SQL注入风险!--->" + value);
|
||||
}
|
||||
@ -85,14 +91,16 @@ public class SqlInjectionUtil {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void specialFilterContentForOnlineReport(String value) {
|
||||
String specialXssStr = "exec |insert |delete |update |drop |chr |mid |master |truncate |char |declare |";
|
||||
String specialXssStr = " exec | insert | delete | update | drop | chr | mid | master | truncate | char | declare |";
|
||||
String[] xssArr = specialXssStr.split("\\|");
|
||||
if (value == null || "".equals(value)) {
|
||||
return;
|
||||
}
|
||||
value = value.toLowerCase();// 统一转为小写
|
||||
// 统一转为小写
|
||||
value = value.toLowerCase();
|
||||
for (int i = 0; i < xssArr.length; i++) {
|
||||
if (value.indexOf(xssArr[i]) > -1) {
|
||||
if (value.indexOf(xssArr[i]) > -1 || value.startsWith(xssArr[i].trim())) {
|
||||
log.error("请注意,存在SQL注入关键词---> {}", xssArr[i]);
|
||||
log.error("请注意,值可能存在SQL注入风险!---> {}", value);
|
||||
throw new RuntimeException("请注意,值可能存在SQL注入风险!--->" + value);
|
||||
}
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
/**
|
||||
* 系统公告自定义跳转方式
|
||||
*/
|
||||
public enum SysAnnmentTypeEnum {
|
||||
/**
|
||||
* 邮件跳转组件
|
||||
*/
|
||||
EMAIL("email", "component", "modules/eoa/email/modals/EoaEmailInForm"),
|
||||
/**
|
||||
* 工作流跳转链接我的办公
|
||||
*/
|
||||
BPM("bpm", "url", "/bpm/task/MyTaskList");
|
||||
|
||||
/**
|
||||
* 业务类型(email:邮件 bpm:流程)
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private String openPage;
|
||||
|
||||
SysAnnmentTypeEnum(String type, String openType, String openPage) {
|
||||
this.type = type;
|
||||
this.openType = openType;
|
||||
this.openPage = openPage;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getOpenType() {
|
||||
return openType;
|
||||
}
|
||||
|
||||
public void setOpenType(String openType) {
|
||||
this.openType = openType;
|
||||
}
|
||||
|
||||
public String getOpenPage() {
|
||||
return openPage;
|
||||
}
|
||||
|
||||
public void setOpenPage(String openPage) {
|
||||
this.openPage = openPage;
|
||||
}
|
||||
|
||||
public static SysAnnmentTypeEnum getByType(String type) {
|
||||
if (oConvertUtils.isEmpty(type)) {
|
||||
return null;
|
||||
}
|
||||
for (SysAnnmentTypeEnum val : values()) {
|
||||
if (val.getType().equals(type)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package org.jeecg.common.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
@ -38,6 +39,10 @@ public class TokenUtils {
|
||||
log.info(" -- url --" + request.getRequestURL());
|
||||
String token = getTokenByRequest(request);
|
||||
|
||||
if (StringUtils.isBlank(token)) {
|
||||
throw new AuthenticationException("token不能为空!");
|
||||
}
|
||||
|
||||
// 解密获得username,用于和数据库进行对比
|
||||
String username = JwtUtil.getUsername(token);
|
||||
if (username == null) {
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
package org.jeecg.common.util.dynamic.db;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.DynamicDataSourceModel;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 数据源缓存池
|
||||
*/
|
||||
public class DataSourceCachePool {
|
||||
|
||||
/**
|
||||
* DynamicDataSourceModel的 code 和 id 的对应关系。key为id,value为code
|
||||
*/
|
||||
private static Map<String, String> dynamicDbSourcesIdToCode = new HashMap<>();
|
||||
/**
|
||||
* DynamicDataSourceModel的缓存。key为code,value为数据源
|
||||
*/
|
||||
private static Map<String, DynamicDataSourceModel> dynamicDbSourcesCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 动态数据源参数配置【缓存】
|
||||
*/
|
||||
public static Map<String, DynamicDataSourceModel> getCacheAllDynamicDataSourceModel() {
|
||||
return dynamicDbSourcesCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多数据源缓存
|
||||
*
|
||||
* @param dbKey
|
||||
* @return
|
||||
*/
|
||||
public static DynamicDataSourceModel getCacheDynamicDataSourceModel(String dbKey) {
|
||||
DynamicDataSourceModel dbSource = dynamicDbSourcesCache.get(dbKey);
|
||||
if (dbSource == null) {
|
||||
ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
|
||||
dbSource = sysBaseAPI.getDynamicDbSourceByCode(dbKey);
|
||||
dynamicDbSourcesCache.put(dbKey, dbSource);
|
||||
dynamicDbSourcesIdToCode.put(dbSource.getId(), dbKey);
|
||||
}
|
||||
return dbSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态数据源连接池【本地class缓存 - 不支持分布式】
|
||||
*/
|
||||
private static Map<String, BasicDataSource> dbSources = new HashMap<>();
|
||||
|
||||
public static BasicDataSource getCacheBasicDataSource(String dbKey) {
|
||||
return dbSources.get(dbKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* put 数据源缓存
|
||||
*
|
||||
* @param dbKey
|
||||
* @param db
|
||||
*/
|
||||
public static void putCacheBasicDataSource(String dbKey, BasicDataSource db) {
|
||||
dbSources.put(dbKey, db);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空数据源缓存
|
||||
*/
|
||||
public static void cleanCacheBasicDataSource() {
|
||||
dbSources.clear();
|
||||
}
|
||||
|
||||
public static void removeCache(String dbKey) {
|
||||
dbSources.remove(dbKey);
|
||||
dynamicDbSourcesCache.remove(dbKey);
|
||||
}
|
||||
|
||||
public static void removeCacheById(String dbId) {
|
||||
String dbKey = dynamicDbSourcesIdToCode.get(dbId);
|
||||
dbSources.remove(dbKey);
|
||||
dynamicDbSourcesCache.remove(dbKey);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,283 @@
|
||||
package org.jeecg.common.util.dynamic.db;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.jeecg.common.system.vo.DynamicDataSourceModel;
|
||||
import org.jeecg.common.util.ReflectHelper;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Spring JDBC 实时数据库访问
|
||||
*
|
||||
* @author chenguobin
|
||||
* @version 1.0
|
||||
* @date 2014-09-05
|
||||
*/
|
||||
@Slf4j
|
||||
public class DynamicDBUtil {
|
||||
|
||||
/**
|
||||
* 获取数据源【最底层方法,不要随便调用】
|
||||
*
|
||||
* @param dbSource
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
private static BasicDataSource getJdbcDataSource(final DynamicDataSourceModel dbSource) {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
|
||||
String driverClassName = dbSource.getDbDriver();
|
||||
String url = dbSource.getDbUrl();
|
||||
String dbUser = dbSource.getDbUsername();
|
||||
String dbPassword = dbSource.getDbPassword();
|
||||
//设置数据源的时候,要重新解密
|
||||
// String dbPassword = PasswordUtil.decrypt(dbSource.getDbPassword(), dbSource.getDbUsername(), PasswordUtil.getStaticSalt());//解密字符串;
|
||||
dataSource.setDriverClassName(driverClassName);
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername(dbUser);
|
||||
dataSource.setPassword(dbPassword);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 dbKey ,获取数据源
|
||||
*
|
||||
* @param dbKey
|
||||
* @return
|
||||
*/
|
||||
public static BasicDataSource getDbSourceByDbKey(final String dbKey) {
|
||||
//获取多数据源配置
|
||||
DynamicDataSourceModel dbSource = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
|
||||
//先判断缓存中是否存在数据库链接
|
||||
BasicDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
|
||||
if (cacheDbSource != null && !cacheDbSource.isClosed()) {
|
||||
log.debug("--------getDbSourceBydbKey------------------从缓存中获取DB连接-------------------");
|
||||
return cacheDbSource;
|
||||
} else {
|
||||
BasicDataSource dataSource = getJdbcDataSource(dbSource);
|
||||
DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
|
||||
log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭数据库连接池
|
||||
*
|
||||
* @param dbKey
|
||||
* @return
|
||||
*/
|
||||
public static void closeDbKey(final String dbKey) {
|
||||
BasicDataSource dataSource = getDbSourceByDbKey(dbKey);
|
||||
try {
|
||||
if (dataSource != null && !dataSource.isClosed()) {
|
||||
dataSource.getConnection().commit();
|
||||
dataSource.getConnection().close();
|
||||
dataSource.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static JdbcTemplate getJdbcTemplate(String dbKey) {
|
||||
BasicDataSource dataSource = getDbSourceByDbKey(dbKey);
|
||||
return new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement in this <code>PreparedStatement</code> object,
|
||||
* which must be an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or
|
||||
* <code>DELETE</code>; or an SQL statement that returns nothing,
|
||||
* such as a DDL statement.
|
||||
*/
|
||||
public static int update(final String dbKey, String sql, Object... param) {
|
||||
int effectCount;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
if (ArrayUtils.isEmpty(param)) {
|
||||
effectCount = jdbcTemplate.update(sql);
|
||||
} else {
|
||||
effectCount = jdbcTemplate.update(sql, param);
|
||||
}
|
||||
return effectCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的Update
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static int updateByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
int effectCount;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
//根据模板获取sql
|
||||
sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
effectCount = namedParameterJdbcTemplate.update(sql, data);
|
||||
return effectCount;
|
||||
}
|
||||
|
||||
public static Object findOne(final String dbKey, String sql, Object... param) {
|
||||
List<Map<String, Object>> list;
|
||||
list = findList(dbKey, sql, param);
|
||||
if (oConvertUtils.listIsEmpty(list)) {
|
||||
log.error("Except one, but not find actually");
|
||||
}
|
||||
if (list.size() > 1) {
|
||||
log.error("Except one, but more than one actually");
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的查询 返回HashMap
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static Object findOneByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
List<Map<String, Object>> list;
|
||||
list = findListByHash(dbKey, sql, data);
|
||||
if (oConvertUtils.listIsEmpty(list)) {
|
||||
log.error("Except one, but not find actually");
|
||||
}
|
||||
if (list.size() > 1) {
|
||||
log.error("Except one, but more than one actually");
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接sql查询 根据clazz返回单个实例
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句
|
||||
* @param clazz 返回实例的Class
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Object findOne(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
Map<String, Object> map = (Map<String, Object>) findOne(dbKey, sql, param);
|
||||
return ReflectHelper.setAll(clazz, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的查询 返回单个实例
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param clazz 返回实例的Class
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Object findOneByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
Map<String, Object> map = (Map<String, Object>) findOneByHash(dbKey, sql, data);
|
||||
return ReflectHelper.setAll(clazz, map);
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> findList(final String dbKey, String sql, Object... param) {
|
||||
List<Map<String, Object>> list;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
|
||||
if (ArrayUtils.isEmpty(param)) {
|
||||
list = jdbcTemplate.queryForList(sql);
|
||||
} else {
|
||||
list = jdbcTemplate.queryForList(sql, param);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的查询
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static List<Map<String, Object>> findListByHash(final String dbKey, String sql, HashMap<String, Object> data) {
|
||||
List<Map<String, Object>> list;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
//根据模板获取sql
|
||||
sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
list = namedParameterJdbcTemplate.queryForList(sql, data);
|
||||
return list;
|
||||
}
|
||||
|
||||
//此方法只能返回单列,不能返回实体类
|
||||
public static <T> List<T> findList(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
List<T> list;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
|
||||
if (ArrayUtils.isEmpty(param)) {
|
||||
list = jdbcTemplate.queryForList(sql, clazz);
|
||||
} else {
|
||||
list = jdbcTemplate.queryForList(sql, clazz, param);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的查询 返回单列数据list
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param clazz 类型Long、String等
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> findListByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
List<T> list;
|
||||
JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey);
|
||||
//根据模板获取sql
|
||||
sql = FreemarkerParseFactory.parseTemplateContent(sql, data);
|
||||
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate.getDataSource());
|
||||
list = namedParameterJdbcTemplate.queryForList(sql, data, clazz);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接sql查询 返回实体类列表
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持 minidao 语法逻辑
|
||||
* @param clazz 返回实体类列表的class
|
||||
* @param param sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> findListEntities(final String dbKey, String sql, Class<T> clazz, Object... param) {
|
||||
List<Map<String, Object>> queryList = findList(dbKey, sql, param);
|
||||
return ReflectHelper.transList2Entrys(queryList, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持miniDao语法操作的查询 返回实体类列表
|
||||
*
|
||||
* @param dbKey 数据源标识
|
||||
* @param sql 执行sql语句,sql支持minidao语法逻辑
|
||||
* @param clazz 返回实体类列表的class
|
||||
* @param data sql语法中需要判断的数据及sql拼接注入中需要的数据
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> findListEntitiesByHash(final String dbKey, String sql, Class<T> clazz, HashMap<String, Object> data) {
|
||||
List<Map<String, Object>> queryList = findListByHash(dbKey, sql, data);
|
||||
return ReflectHelper.transList2Entrys(queryList, clazz);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,173 @@
|
||||
package org.jeecg.common.util.dynamic.db;
|
||||
|
||||
import freemarker.cache.StringTemplateLoader;
|
||||
import freemarker.core.ParseException;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jeecgframework.codegenerate.generate.util.SimpleFormat;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author 赵俊夫
|
||||
* @version V1.0
|
||||
* @Title:FreemarkerHelper
|
||||
* @description:Freemarker引擎协助类
|
||||
* @date Jul 5, 2013 2:58:29 PM
|
||||
*/
|
||||
@Slf4j
|
||||
public class FreemarkerParseFactory {
|
||||
|
||||
private static final String ENCODE = "utf-8";
|
||||
/**
|
||||
* 参数格式化工具类
|
||||
*/
|
||||
private static final String MINI_DAO_FORMAT = "DaoFormat";
|
||||
|
||||
/**
|
||||
* 文件缓存
|
||||
*/
|
||||
private static final Configuration _tplConfig = new Configuration();
|
||||
/**
|
||||
* SQL 缓存
|
||||
*/
|
||||
private static final Configuration _sqlConfig = new Configuration();
|
||||
|
||||
private static StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
|
||||
|
||||
// 使用内嵌的(?ms)打开单行和多行模式
|
||||
private final static Pattern p = Pattern
|
||||
.compile("(?ms)/\\*.*?\\*/|^\\s*//.*?$");
|
||||
|
||||
static {
|
||||
_tplConfig.setClassForTemplateLoading(
|
||||
new FreemarkerParseFactory().getClass(), "/");
|
||||
_tplConfig.setNumberFormat("0.#####################");
|
||||
_sqlConfig.setTemplateLoader(stringTemplateLoader);
|
||||
_sqlConfig.setNumberFormat("0.#####################");
|
||||
//classic_compatible设置,解决报空指针错误
|
||||
_sqlConfig.setClassicCompatible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断模板是否存在
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static boolean isExistTemplate(String tplName) throws Exception {
|
||||
try {
|
||||
Template mytpl = _tplConfig.getTemplate(tplName, "UTF-8");
|
||||
if (mytpl == null) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//update-begin--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误-----
|
||||
if (e instanceof ParseException) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
throw new Exception(e);
|
||||
}
|
||||
log.debug("----isExistTemplate----" + e.toString());
|
||||
//update-end--Author:scott Date:20180320 for:解决问题 - 错误提示sql文件不存在,实际问题是sql freemarker用法错误------
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析ftl模板
|
||||
*
|
||||
* @param tplName 模板名
|
||||
* @param paras 参数
|
||||
* @return
|
||||
*/
|
||||
public static String parseTemplate(String tplName, Map<String, Object> paras) {
|
||||
try {
|
||||
log.debug(" minidao sql templdate : " + tplName);
|
||||
StringWriter swriter = new StringWriter();
|
||||
Template mytpl = _tplConfig.getTemplate(tplName, ENCODE);
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString());
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
return sql;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
log.error("发送一次的模板key:{ " + tplName + " }");
|
||||
//System.err.println(e.getMessage());
|
||||
//System.err.println("模板名:{ "+ tplName +" }");
|
||||
throw new RuntimeException("解析SQL模板异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析ftl
|
||||
*
|
||||
* @param tplContent 模板内容
|
||||
* @param paras 参数
|
||||
* @return String 模板解析后内容
|
||||
*/
|
||||
public static String parseTemplateContent(String tplContent,
|
||||
Map<String, Object> paras) {
|
||||
try {
|
||||
StringWriter swriter = new StringWriter();
|
||||
if (stringTemplateLoader.findTemplateSource("sql_" + tplContent.hashCode()) == null) {
|
||||
stringTemplateLoader.putTemplate("sql_" + tplContent.hashCode(), tplContent);
|
||||
}
|
||||
Template mytpl = _sqlConfig.getTemplate("sql_" + tplContent.hashCode(), ENCODE);
|
||||
if (paras.containsKey(MINI_DAO_FORMAT)) {
|
||||
throw new RuntimeException("DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!");
|
||||
}
|
||||
paras.put(MINI_DAO_FORMAT, new SimpleFormat());
|
||||
mytpl.process(paras, swriter);
|
||||
String sql = getSqlText(swriter.toString());
|
||||
paras.remove(MINI_DAO_FORMAT);
|
||||
return sql;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e.fillInStackTrace());
|
||||
log.error("发送一次的模板key:{ " + tplContent + " }");
|
||||
//System.err.println(e.getMessage());
|
||||
//System.err.println("模板内容:{ "+ tplContent +" }");
|
||||
throw new RuntimeException("解析SQL模板异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 除去无效字段,去掉注释 不然批量处理可能报错 去除无效的等于
|
||||
*/
|
||||
private static String getSqlText(String sql) {
|
||||
// 将注释替换成""
|
||||
sql = p.matcher(sql).replaceAll("");
|
||||
sql = sql.replaceAll("\\n", " ").replaceAll("\\t", " ")
|
||||
.replaceAll("\\s{1,}", " ").trim();
|
||||
// 去掉 最后是 where这样的问题
|
||||
if (sql.endsWith("where") || sql.endsWith("where ")) {
|
||||
sql = sql.substring(0, sql.lastIndexOf("where"));
|
||||
}
|
||||
// 去掉where and 这样的问题
|
||||
int index = 0;
|
||||
while ((index = StringUtils.indexOfIgnoreCase(sql, "where and", index)) != -1) {
|
||||
sql = sql.substring(0, index + 5)
|
||||
+ sql.substring(index + 9, sql.length());
|
||||
}
|
||||
// 去掉 , where 这样的问题
|
||||
index = 0;
|
||||
while ((index = StringUtils.indexOfIgnoreCase(sql, ", where", index)) != -1) {
|
||||
sql = sql.substring(0, index)
|
||||
+ sql.substring(index + 1, sql.length());
|
||||
}
|
||||
// 去掉 最后是 ,这样的问题
|
||||
if (sql.endsWith(",") || sql.endsWith(", ")) {
|
||||
sql = sql.substring(0, sql.lastIndexOf(","));
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,212 @@
|
||||
package org.jeecg.common.util.dynamic.db;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.system.vo.DynamicDataSourceModel;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 根据不同的数据库,动态生成SQL,例如分页
|
||||
*/
|
||||
public class SqlUtils {
|
||||
|
||||
public static final String DATABSE_TYPE_MYSQL = "mysql";
|
||||
public static final String DATABSE_TYPE_POSTGRE = "postgresql";
|
||||
public static final String DATABSE_TYPE_ORACLE = "oracle";
|
||||
public static final String DATABSE_TYPE_SQLSERVER = "sqlserver";
|
||||
|
||||
|
||||
/**
|
||||
* 分页SQL
|
||||
*/
|
||||
public static final String MYSQL_SQL = "select * from ( {0}) sel_tab00 limit {1},{2}";
|
||||
public static final String POSTGRE_SQL = "select * from ( {0}) sel_tab00 limit {2} offset {1}";
|
||||
public static final String ORACLE_SQL = "select * from (select row_.*,rownum rownum_ from ({0}) row_ where rownum <= {1}) where rownum_>{2}";
|
||||
public static final String SQLSERVER_SQL = "select * from ( select row_number() over(order by tempColumn) tempRowNumber, * from (select top {1} tempColumn = 0, {0}) t ) tt where tempRowNumber > {2}";
|
||||
|
||||
/**
|
||||
* 获取所有表的SQL
|
||||
*/
|
||||
public static final String MYSQL_ALLTABLES_SQL = "select distinct table_name from information_schema.columns where table_schema = {0}";
|
||||
public static final String POSTGRE__ALLTABLES_SQL = "SELECT distinct c.relname AS table_name FROM pg_class c";
|
||||
public static final String ORACLE__ALLTABLES_SQL = "select distinct colstable.table_name as table_name from user_tab_cols colstable";
|
||||
public static final String SQLSERVER__ALLTABLES_SQL = "select distinct c.name as table_name from sys.objects c";
|
||||
|
||||
/**
|
||||
* 获取指定表的所有列名
|
||||
*/
|
||||
public static final String MYSQL_ALLCOLUMNS_SQL = "select column_name from information_schema.columns where table_name = {0} and table_schema = {1}";
|
||||
public static final String POSTGRE_ALLCOLUMNS_SQL = "select table_name from information_schema.columns where table_name = {0}";
|
||||
public static final String ORACLE_ALLCOLUMNS_SQL = "select column_name from all_tab_columns where table_name ={0}";
|
||||
public static final String SQLSERVER_ALLCOLUMNS_SQL = "select name from syscolumns where id={0}";
|
||||
|
||||
/*
|
||||
* 判断数据库类型
|
||||
*/
|
||||
|
||||
public static boolean dbTypeIsMySQL(String dbType) {
|
||||
return dbTypeIf(dbType, DATABSE_TYPE_MYSQL, DataBaseConstant.DB_TYPE_MYSQL_NUM);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsOracle(String dbType) {
|
||||
return dbTypeIf(dbType, DATABSE_TYPE_ORACLE, DataBaseConstant.DB_TYPE_ORACLE_NUM);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsSQLServer(String dbType) {
|
||||
return dbTypeIf(dbType, DATABSE_TYPE_SQLSERVER, DataBaseConstant.DB_TYPE_SQLSERVER_NUM);
|
||||
}
|
||||
|
||||
public static boolean dbTypeIsPostgre(String dbType) {
|
||||
return dbTypeIf(dbType, DATABSE_TYPE_POSTGRE, DataBaseConstant.DB_TYPE_POSTGRESQL_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据库类型
|
||||
*/
|
||||
public static boolean dbTypeIf(String dbType, String... correctTypes) {
|
||||
for (String type : correctTypes) {
|
||||
if (type.equalsIgnoreCase(dbType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全 SQL
|
||||
* 拼接 where 条件
|
||||
*
|
||||
* @param sql
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String getFullSql(String sql, Map params) {
|
||||
return getFullSql(sql, params, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全 SQL
|
||||
* 拼接 where 条件
|
||||
* 拼接 order 排序
|
||||
*
|
||||
* @param sql
|
||||
* @param params
|
||||
* @param orderColumn 排序字段
|
||||
* @param orderBy 排序方式,只能是 DESC 或 ASC
|
||||
* @return
|
||||
*/
|
||||
public static String getFullSql(String sql, Map params, String orderColumn, String orderBy) {
|
||||
StringBuilder sqlBuilder = new StringBuilder();
|
||||
sqlBuilder.append("SELECT t.* FROM ( ").append(sql).append(" ) t ");
|
||||
if (params != null && params.size() >= 1) {
|
||||
sqlBuilder.append("WHERE 1=1 ");
|
||||
for (Object key : params.keySet()) {
|
||||
String value = String.valueOf(params.get(key));
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
sqlBuilder.append(" AND (").append(key).append(" = N'").append(value).append("')");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(orderColumn) && StringUtils.isNotBlank(orderBy)) {
|
||||
sqlBuilder.append("ORDER BY ").append(orderColumn).append(" ").append("DESC".equalsIgnoreCase(orderBy) ? "DESC" : "ASC");
|
||||
}
|
||||
}
|
||||
return sqlBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取求数量 SQL
|
||||
*
|
||||
* @param sql
|
||||
* @return
|
||||
*/
|
||||
public static String getCountSql(String sql) {
|
||||
return String.format("SELECT COUNT(1) \"total\" FROM ( %s ) temp_count", sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成分页查询 SQL
|
||||
*
|
||||
* @param dbType 数据库类型
|
||||
* @param sql
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
public static String createPageSqlByDBType(String dbType, String sql, int page, int rows) {
|
||||
int beginNum = (page - 1) * rows;
|
||||
Object[] sqlParam = new Object[3];
|
||||
sqlParam[0] = sql;
|
||||
sqlParam[1] = String.valueOf(beginNum);
|
||||
sqlParam[2] = String.valueOf(rows);
|
||||
if (dbTypeIsMySQL(dbType)) {
|
||||
sql = MessageFormat.format(MYSQL_SQL, sqlParam);
|
||||
} else if (dbTypeIsPostgre(dbType)) {
|
||||
sql = MessageFormat.format(POSTGRE_SQL, sqlParam);
|
||||
} else {
|
||||
int beginIndex = (page - 1) * rows;
|
||||
int endIndex = beginIndex + rows;
|
||||
sqlParam[2] = Integer.toString(beginIndex);
|
||||
sqlParam[1] = Integer.toString(endIndex);
|
||||
if (dbTypeIsOracle(dbType)) {
|
||||
sql = MessageFormat.format(ORACLE_SQL, sqlParam);
|
||||
} else if (dbTypeIsSQLServer(dbType)) {
|
||||
sqlParam[0] = sql.substring(getAfterSelectInsertPoint(sql));
|
||||
sql = MessageFormat.format(SQLSERVER_SQL, sqlParam);
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成分页查询 SQL
|
||||
*
|
||||
* @param sql
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
public static String createPageSqlByDBKey(String dbKey, String sql, int page, int rows) {
|
||||
DynamicDataSourceModel dynamicSourceEntity = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
|
||||
String dbType = dynamicSourceEntity.getDbType();
|
||||
return createPageSqlByDBType(dbType, sql, page, rows);
|
||||
}
|
||||
|
||||
private static int getAfterSelectInsertPoint(String sql) {
|
||||
int selectIndex = sql.toLowerCase().indexOf("select");
|
||||
int selectDistinctIndex = sql.toLowerCase().indexOf("select distinct");
|
||||
return selectIndex + (selectDistinctIndex == selectIndex ? 15 : 6);
|
||||
}
|
||||
|
||||
public static String getAllTableSql(String dbType, Object... params) {
|
||||
if (StringUtils.isNotEmpty(dbType)) {
|
||||
if (dbTypeIsMySQL(dbType)) {
|
||||
return MessageFormat.format(MYSQL_ALLTABLES_SQL, params);
|
||||
} else if (dbTypeIsOracle(dbType)) {
|
||||
return ORACLE__ALLTABLES_SQL;
|
||||
} else if (dbTypeIsPostgre(dbType)) {
|
||||
return POSTGRE__ALLTABLES_SQL;
|
||||
} else if (dbTypeIsSQLServer(dbType)) {
|
||||
return SQLSERVER__ALLTABLES_SQL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getAllColumnSQL(String dbType, Object... params) {
|
||||
if (StringUtils.isNotEmpty(dbType)) {
|
||||
if (dbTypeIsMySQL(dbType)) {
|
||||
return MessageFormat.format(MYSQL_ALLCOLUMNS_SQL, params);
|
||||
} else if (dbTypeIsOracle(dbType)) {
|
||||
return MessageFormat.format(ORACLE_ALLCOLUMNS_SQL, params);
|
||||
} else if (dbTypeIsPostgre(dbType)) {
|
||||
return MessageFormat.format(POSTGRE_ALLCOLUMNS_SQL, params);
|
||||
} else if (dbTypeIsSQLServer(dbType)) {
|
||||
return MessageFormat.format(SQLSERVER_ALLCOLUMNS_SQL, params);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package org.jeecg.common.util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
@ -12,20 +13,10 @@ import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author 张代浩
|
||||
@ -631,4 +622,28 @@ public class oConvertUtils {
|
||||
return (T)model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 list 是否为空
|
||||
*
|
||||
* @param list
|
||||
* @return true or false
|
||||
* list == null : true
|
||||
* list.size() == 0 : true
|
||||
*/
|
||||
public static boolean listIsEmpty(Collection list) {
|
||||
return (list == null || list.size() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 list 是否不为空
|
||||
*
|
||||
* @param list
|
||||
* @return true or false
|
||||
* list == null : false
|
||||
* list.size() == 0 : false
|
||||
*/
|
||||
public static boolean listIsNotEmpty(Collection list) {
|
||||
return !listIsEmpty(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.aliyun.oss.common.auth.DefaultCredentialProvider;
|
||||
import com.aliyun.oss.model.CannedAccessControlList;
|
||||
import com.aliyun.oss.model.PutObjectResult;
|
||||
import org.apache.tomcat.util.http.fileupload.FileItemStream;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -69,8 +70,11 @@ public class OssBootUtil {
|
||||
}
|
||||
fileUrl = fileUrl.append(fileDir + fileName);
|
||||
|
||||
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
|
||||
//FILE_URL = staticDomain + "/" + fileUrl;
|
||||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) {
|
||||
FILE_URL = staticDomain + "/" + fileUrl;
|
||||
} else {
|
||||
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
|
||||
}
|
||||
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(), file.getInputStream());
|
||||
// 设置权限(公开读)
|
||||
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
|
||||
@ -105,8 +109,11 @@ public class OssBootUtil {
|
||||
}
|
||||
fileUrl = fileUrl.append(fileDir + fileName);
|
||||
|
||||
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
|
||||
//FILE_URL = staticDomain + "/" + fileUrl;
|
||||
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) {
|
||||
FILE_URL = staticDomain + "/" + fileUrl;
|
||||
} else {
|
||||
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
|
||||
}
|
||||
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(), file.openStream());
|
||||
// 设置权限(公开读)
|
||||
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
|
||||
|
||||
4
jeecg-boot/jeecg-boot-module-system/.gitattributes
vendored
Normal file
4
jeecg-boot/jeecg-boot-module-system/.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.js linguist-language=Java
|
||||
*.css linguist-language=Java
|
||||
*.html linguist-language=Java
|
||||
*.vue linguist-language=Java
|
||||
@ -1 +0,0 @@
|
||||
/target/
|
||||
@ -3,12 +3,12 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jeecg-boot-module-system</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
|
||||
@ -25,17 +25,18 @@ public class JeecgApplication {
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
//System.setProperty("spring.devtools.restart.enabled", "true");
|
||||
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"swagger-ui: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
|
||||
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class JeecgOneToMainUtil {
|
||||
|
||||
//第三步:一对多(父子表)数据模型,代码生成
|
||||
try {
|
||||
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile();
|
||||
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package org.jeecg.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Minio文件上传配置文件
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class MinioConfig {
|
||||
@Value(value = "${jeecg.minio.minio_url}")
|
||||
private String minioUrl;
|
||||
@Value(value = "${jeecg.minio.minio_name}")
|
||||
private String minioName;
|
||||
@Value(value = "${jeecg.minio.minio_pass}")
|
||||
private String minioPass;
|
||||
@Value(value = "${jeecg.minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Bean
|
||||
public void initMinio(){
|
||||
if(!minioUrl.startsWith("http")){
|
||||
minioUrl = "http://" + minioUrl;
|
||||
}
|
||||
if(!minioUrl.endsWith("/")){
|
||||
minioUrl = minioUrl.concat("/");
|
||||
}
|
||||
MinioUtil.setMinioUrl(minioUrl);
|
||||
MinioUtil.setMinioName(minioName);
|
||||
MinioUtil.setMinioPass(minioPass);
|
||||
MinioUtil.setBucketName(bucketName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package org.jeecg.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(5000);//ms
|
||||
factory.setConnectTimeout(15000);//ms
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@ -66,14 +66,12 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put(url,"anon");
|
||||
}
|
||||
}
|
||||
//大屏请求排除
|
||||
filterChainDefinitionMap.put("/big/screen/**", "anon");
|
||||
filterChainDefinitionMap.put("/bigscreen/**", "anon");
|
||||
|
||||
//cas验证登录
|
||||
filterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
filterChainDefinitionMap.put("/sys/getCheckCode", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
|
||||
@ -86,8 +84,9 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
|
||||
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
|
||||
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
|
||||
filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
|
||||
//filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
|
||||
//filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
|
||||
filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
|
||||
filterChainDefinitionMap.put("/", "anon");
|
||||
@ -104,6 +103,7 @@ public class ShiroConfig {
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
filterChainDefinitionMap.put("/**/*.ttf", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
|
||||
filterChainDefinitionMap.put("/druid/**", "anon");
|
||||
@ -123,10 +123,13 @@ public class ShiroConfig {
|
||||
|
||||
//排除Online请求
|
||||
filterChainDefinitionMap.put("/auto/cgform/**", "anon");
|
||||
|
||||
|
||||
//websocket排除
|
||||
filterChainDefinitionMap.put("/websocket/**", "anon");
|
||||
|
||||
|
||||
//大屏设计器排除
|
||||
filterChainDefinitionMap.put("/big/screen/**", "anon");
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
||||
filterMap.put("jwt", new JwtFilter());
|
||||
|
||||
@ -19,8 +19,8 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/big/screen")
|
||||
public class BigScreenController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
@RequestMapping("/big/screen/templat")
|
||||
public class BigScreenTemplatController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
|
||||
/**
|
||||
* @param modelAndView
|
||||
@ -128,7 +128,6 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request,SysMessageTemplate sysMessageTemplate) {
|
||||
|
||||
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.oss.entity.OSSFile;
|
||||
@ -44,6 +45,7 @@ public class OSSFileController {
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/upload")
|
||||
@RequiresRoles("admin")
|
||||
public Result upload(@RequestParam("file") MultipartFile multipartFile) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
@ -83,6 +84,7 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<?> add(@RequestBody QuartzJob quartzJob) {
|
||||
List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
|
||||
@ -99,6 +101,7 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
|
||||
try {
|
||||
@ -116,6 +119,7 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||
@ -133,6 +137,7 @@ public class QuartzJobController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
@ -148,9 +153,10 @@ public class QuartzJobController {
|
||||
/**
|
||||
* 暂停定时任务
|
||||
*
|
||||
* @param job
|
||||
* @param jobClassName
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@GetMapping(value = "/pause")
|
||||
@ApiOperation(value = "暂停定时任务")
|
||||
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
|
||||
@ -172,9 +178,10 @@ public class QuartzJobController {
|
||||
/**
|
||||
* 启动定时任务
|
||||
*
|
||||
* @param job
|
||||
* @param jobClassName
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@GetMapping(value = "/resume")
|
||||
@ApiOperation(value = "恢复定时任务")
|
||||
public Result<Object> resumeJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
|
||||
@ -203,7 +210,7 @@ public class QuartzJobController {
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param quartzJob
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
|
||||
|
||||
@ -75,15 +75,26 @@ public class PermissionDataAspect {
|
||||
String requestMethod = request.getMethod();
|
||||
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
|
||||
requestPath = filterUrl(requestPath);
|
||||
log.info("拦截请求>>"+requestPath+";请求类型>>"+requestMethod);
|
||||
log.info("拦截请求 >> "+requestPath+";请求类型 >> "+requestMethod);
|
||||
//1.直接通过前端请求地址查询菜单
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getMenuType,2);
|
||||
query.eq(SysPermission::getDelFlag,0);
|
||||
query.eq(SysPermission::getUrl, requestPath);
|
||||
currentSyspermission = sysPermissionService.list(query);
|
||||
//2.未找到 再通过正则匹配获取菜单
|
||||
//2.未找到 再通过自定义匹配URL 获取菜单
|
||||
if(currentSyspermission==null || currentSyspermission.size()==0) {
|
||||
//通过自定义URL匹配规则 获取菜单(实现通过菜单配置数据权限规则,实际上针对获取数据接口进行数据规则控制)
|
||||
String userMatchUrl = UrlMatchEnum.getMatchResultByUrl(requestPath);
|
||||
LambdaQueryWrapper<SysPermission> queryQserMatch = new LambdaQueryWrapper<SysPermission>();
|
||||
queryQserMatch.eq(SysPermission::getMenuType, 1);
|
||||
queryQserMatch.eq(SysPermission::getDelFlag, 0);
|
||||
queryQserMatch.eq(SysPermission::getUrl, userMatchUrl);
|
||||
currentSyspermission = sysPermissionService.list(queryQserMatch);
|
||||
}
|
||||
//3.未找到 再通过正则匹配获取菜单
|
||||
if(currentSyspermission==null || currentSyspermission.size()==0) {
|
||||
//通过正则匹配权限配置
|
||||
String regUrl = getRegexpUrl(requestPath);
|
||||
if(regUrl!=null) {
|
||||
currentSyspermission = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getMenuType,2).eq(SysPermission::getUrl, regUrl).eq(SysPermission::getDelFlag,0));
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package org.jeecg.modules.system.aspect;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2020/1/14 13:36
|
||||
* @Description: 请求URL与菜单路由URL转换规则(方便于采用菜单路由URL来配置数据权限规则)
|
||||
*/
|
||||
public enum UrlMatchEnum {
|
||||
CGFORM_DATA("/online/cgform/api/getData/", "/online/cgformList/"),
|
||||
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/");
|
||||
|
||||
UrlMatchEnum(String url, String match_url) {
|
||||
this.url = url;
|
||||
this.match_url = match_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request 请求 URL前缀
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 菜单路由 URL前缀 (对应菜单路径)
|
||||
*/
|
||||
private String match_url;
|
||||
|
||||
/**
|
||||
* 根据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.match_url);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* 比如request真实请求URL: /online/cgform/api/getData/81fcf7d8922d45069b0d5ba983612d3a
|
||||
* 转换匹配路由URL后(对应配置的菜单路径):/online/cgformList/81fcf7d8922d45069b0d5ba983612d3a
|
||||
*/
|
||||
System.out.println(UrlMatchEnum.getMatchResultByUrl("/online/cgform/api/getData/81fcf7d8922d45069b0d5ba983612d3a"));
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ import org.jeecg.modules.system.model.SysLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysLogService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.util.RandImageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -64,12 +65,15 @@ public class LoginController {
|
||||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
|
||||
//update-begin-author:taoyan date:20190828 for:校验验证码
|
||||
Object checkCode = redisUtil.get(sysLoginModel.getCheckKey());
|
||||
if(checkCode==null) {
|
||||
result.error500("验证码失效");
|
||||
return result;
|
||||
}
|
||||
if(!checkCode.equals(sysLoginModel.getCaptcha())) {
|
||||
String captcha = sysLoginModel.getCaptcha();
|
||||
if(captcha==null){
|
||||
result.error500("验证码无效");
|
||||
return result;
|
||||
}
|
||||
String lowerCaseCaptcha = captcha.toLowerCase();
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+sysLoginModel.getCheckKey(), "utf-8");
|
||||
Object checkCode = redisUtil.get(realKey);
|
||||
if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
|
||||
result.error500("验证码错误");
|
||||
return result;
|
||||
}
|
||||
@ -214,8 +218,14 @@ public class LoginController {
|
||||
public Result<String> sms(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String mobile = jsonObject.get("mobile").toString();
|
||||
//手机号模式 登录模式: "2" 注册模式: "1"
|
||||
String smsmode=jsonObject.get("smsmode").toString();
|
||||
log.info(mobile);
|
||||
log.info(mobile);
|
||||
if(oConvertUtils.isEmpty(mobile)){
|
||||
result.setMessage("手机号不允许为空!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
Object object = redisUtil.get(mobile);
|
||||
if (object != null) {
|
||||
result.setMessage("验证码10分钟内,仍然有效!");
|
||||
@ -375,7 +385,10 @@ public class LoginController {
|
||||
String key = MD5Util.MD5Encode(code+System.currentTimeMillis(), "utf-8");
|
||||
redisUtil.set(key, code, 60);
|
||||
map.put("key", key);
|
||||
map.put("code",code);
|
||||
//update-begin-author:taoyan date:20200210 for:TASK #3391 【bug】安全问题,返回验证码不安全
|
||||
String encode = java.util.Base64.getEncoder().encodeToString(code.getBytes("UTF-8"));
|
||||
map.put("code",encode);
|
||||
//update-end-author:taoyan date:20200210 for:TASK #3391 【bug】安全问题,返回验证码不安全
|
||||
result.setResult(map);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
@ -384,6 +397,30 @@ public class LoginController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台生成图形验证码
|
||||
* @param response
|
||||
* @param key
|
||||
*/
|
||||
@ApiOperation("获取验证码2")
|
||||
@GetMapping(value = "/randomImage/{key}")
|
||||
public Result<String> randomImage(HttpServletResponse response,@PathVariable String key){
|
||||
Result<String> res = new Result<String>();
|
||||
try {
|
||||
String code = RandomUtil.randomString(BASE_CHECK_CODES,4);
|
||||
String lowerCaseCode = code.toLowerCase();
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCode+key, "utf-8");
|
||||
redisUtil.set(realKey, lowerCaseCode, 60);
|
||||
String base64 = RandImageUtil.generate(code);
|
||||
res.setSuccess(true);
|
||||
res.setResult(base64);
|
||||
} catch (Exception e) {
|
||||
res.error500("获取验证码出错"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* app登录
|
||||
|
||||
@ -237,10 +237,10 @@ public class SysCategoryController {
|
||||
for (SysCategory sysCategoryExcel : listSysCategorys) {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSysCategorys.size());
|
||||
return Result.ok("文件导入成功!数据行数:" + listSysCategorys.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
@ -249,7 +249,7 @@ public class SysCategoryController {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,186 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
import org.jeecg.modules.system.service.ISysCheckRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "编码校验规则")
|
||||
@RestController
|
||||
@RequestMapping("/sys/checkRule")
|
||||
public class SysCheckRuleController extends JeecgController<SysCheckRule, ISysCheckRuleService> {
|
||||
|
||||
@Autowired
|
||||
private ISysCheckRuleService sysCheckRuleService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-分页列表查询")
|
||||
@ApiOperation(value = "编码校验规则-分页列表查询", notes = "编码校验规则-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result queryPageList(
|
||||
SysCheckRule sysCheckRule,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest request
|
||||
) {
|
||||
QueryWrapper<SysCheckRule> queryWrapper = QueryGenerator.initQueryWrapper(sysCheckRule, request.getParameterMap());
|
||||
Page<SysCheckRule> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysCheckRule> pageList = sysCheckRuleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过Code校验传入的值")
|
||||
@ApiOperation(value = "编码校验规则-通过Code校验传入的值", notes = "编码校验规则-通过Code校验传入的值")
|
||||
@GetMapping(value = "/checkByCode")
|
||||
public Result checkByCode(
|
||||
@RequestParam(name = "ruleCode") String ruleCode,
|
||||
@RequestParam(name = "value") String value
|
||||
) throws UnsupportedEncodingException {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getByCode(ruleCode);
|
||||
if (sysCheckRule == null) {
|
||||
return Result.error("该编码不存在");
|
||||
}
|
||||
JSONObject errorResult = sysCheckRuleService.checkValue(sysCheckRule, URLDecoder.decode(value, "UTF-8"));
|
||||
if (errorResult == null) {
|
||||
return Result.ok();
|
||||
} else {
|
||||
Result<Object> r = Result.error(errorResult.getString("message"));
|
||||
r.setResult(errorResult);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-添加")
|
||||
@ApiOperation(value = "编码校验规则-添加", notes = "编码校验规则-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result add(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.save(sysCheckRule);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-编辑")
|
||||
@ApiOperation(value = "编码校验规则-编辑", notes = "编码校验规则-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result edit(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.updateById(sysCheckRule);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id删除")
|
||||
@ApiOperation(value = "编码校验规则-通过id删除", notes = "编码校验规则-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysCheckRuleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-批量删除")
|
||||
@ApiOperation(value = "编码校验规则-批量删除", notes = "编码校验规则-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.sysCheckRuleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id查询")
|
||||
@ApiOperation(value = "编码校验规则-通过id查询", notes = "编码校验规则-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getById(id);
|
||||
return Result.ok(sysCheckRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysCheckRule
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCheckRule sysCheckRule) {
|
||||
return super.exportXls(request, sysCheckRule, SysCheckRule.class, "编码校验规则");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysCheckRule.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,178 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.dynamic.db.DataSourceCachePool;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "多数据源管理")
|
||||
@RestController
|
||||
@RequestMapping("/sys/dataSource")
|
||||
public class SysDataSourceController extends JeecgController<SysDataSource, ISysDataSourceService> {
|
||||
|
||||
@Autowired
|
||||
private ISysDataSourceService sysDataSourceService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-分页列表查询")
|
||||
@ApiOperation(value = "多数据源管理-分页列表查询", notes = "多数据源管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(
|
||||
SysDataSource sysDataSource,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req
|
||||
) {
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
Page<SysDataSource> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDataSource> pageList = sysDataSourceService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/options")
|
||||
public Result<?> queryOptions(SysDataSource sysDataSource, HttpServletRequest req) {
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
List<SysDataSource> pageList = sysDataSourceService.list(queryWrapper);
|
||||
JSONArray array = new JSONArray(pageList.size());
|
||||
for (SysDataSource item : pageList) {
|
||||
JSONObject option = new JSONObject(3);
|
||||
option.put("value", item.getCode());
|
||||
option.put("label", item.getName());
|
||||
option.put("text", item.getName());
|
||||
array.add(option);
|
||||
}
|
||||
return Result.ok(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-添加")
|
||||
@ApiOperation(value = "多数据源管理-添加", notes = "多数据源管理-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDataSource sysDataSource) {
|
||||
sysDataSourceService.save(sysDataSource);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-编辑")
|
||||
@ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
|
||||
sysDataSourceService.updateById(sysDataSource);
|
||||
DataSourceCachePool.removeCacheById(sysDataSource.getId());
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-通过id删除")
|
||||
@ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id") String id) {
|
||||
sysDataSourceService.removeById(id);
|
||||
DataSourceCachePool.removeCacheById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-批量删除")
|
||||
@ApiOperation(value = "多数据源管理-批量删除", notes = "多数据源管理-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
this.sysDataSourceService.removeByIds(idList);
|
||||
idList.forEach(DataSourceCachePool::removeCacheById);
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-通过id查询")
|
||||
@ApiOperation(value = "多数据源管理-通过id查询", notes = "多数据源管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id") String id) {
|
||||
SysDataSource sysDataSource = sysDataSourceService.getById(id);
|
||||
return Result.ok(sysDataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDataSource
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDataSource sysDataSource) {
|
||||
return super.exportXls(request, sysDataSource, SysDataSource.class, "多数据源管理");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDataSource.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,9 +14,11 @@ import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
@ -58,6 +60,31 @@ public class SysDepartController {
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
/**
|
||||
* 查询数据 查出我的部门,并以树结构数据格式响应给前端
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
try {
|
||||
if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
|
||||
result.setResult(list);
|
||||
result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
|
||||
result.setSuccess(true);
|
||||
}else{
|
||||
result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
|
||||
result.setSuccess(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据 查出所有部门,并以树结构数据格式响应给前端
|
||||
*
|
||||
@ -228,20 +255,14 @@ public class SysDepartController {
|
||||
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
|
||||
try {
|
||||
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
|
||||
if (treeList.size() == 0 || treeList == null) {
|
||||
throw new Exception();
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(treeList);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
|
||||
if (treeList == null || treeList.size() == 0) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("查询失败或没有您想要的任何数据!");
|
||||
result.setMessage("未查询匹配数据!");
|
||||
return result;
|
||||
}
|
||||
result.setResult(treeList);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,321 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartPermissionService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.system.service.ISysDepartRolePermissionService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="部门权限表")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysDepartPermission")
|
||||
public class SysDepartPermissionController extends JeecgController<SysDepartPermission, ISysDepartPermissionService> {
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionService sysPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRolePermissionService sysDepartRolePermissionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-分页列表查询")
|
||||
@ApiOperation(value="部门权限表-分页列表查询", notes="部门权限表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysDepartPermission sysDepartPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDepartPermission> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartPermission, req.getParameterMap());
|
||||
Page<SysDepartPermission> page = new Page<SysDepartPermission>(pageNo, pageSize);
|
||||
IPage<SysDepartPermission> pageList = sysDepartPermissionService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-添加")
|
||||
@ApiOperation(value="部门权限表-添加", notes="部门权限表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.save(sysDepartPermission);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-编辑")
|
||||
@ApiOperation(value="部门权限表-编辑", notes="部门权限表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.updateById(sysDepartPermission);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-通过id删除")
|
||||
@ApiOperation(value="部门权限表-通过id删除", notes="部门权限表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartPermissionService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-批量删除")
|
||||
@ApiOperation(value="部门权限表-批量删除", notes="部门权限表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-通过id查询")
|
||||
@ApiOperation(value="部门权限表-通过id查询", notes="部门权限表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getById(id);
|
||||
return Result.ok(sysDepartPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDepartPermission
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDepartPermission sysDepartPermission) {
|
||||
return super.exportXls(request, sysDepartPermission, SysDepartPermission.class, "部门权限表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDepartPermission.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门管理授权查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{departId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
|
||||
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
|
||||
if(list==null || list.size()==0) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
}else {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
|
||||
.eq(SysDepartPermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartPermission::getDepartId,departId);
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
|
||||
if(sysDepartPermission==null) {
|
||||
//return Result.error("未找到角色菜单配置信息");
|
||||
}else {
|
||||
String drChecked = sysDepartPermission.getDataRuleIds();
|
||||
if(oConvertUtils.isNotEmpty(drChecked)) {
|
||||
map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
|
||||
}
|
||||
}
|
||||
return Result.ok(map);
|
||||
//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据规则至部门菜单关联表
|
||||
*/
|
||||
@PostMapping(value = "/datarule")
|
||||
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
String permissionId = jsonObject.getString("permissionId");
|
||||
String departId = jsonObject.getString("departId");
|
||||
String dataRuleIds = jsonObject.getString("dataRuleIds");
|
||||
log.info("保存数据规则>>"+"菜单ID:"+permissionId+"部门ID:"+ departId+"数据权限ID:"+dataRuleIds);
|
||||
LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
|
||||
.eq(SysDepartPermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartPermission::getDepartId,departId);
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
|
||||
if(sysDepartPermission==null) {
|
||||
return Result.error("请先保存部门菜单权限!");
|
||||
}else {
|
||||
sysDepartPermission.setDataRuleIds(dataRuleIds);
|
||||
this.sysDepartPermissionService.updateById(sysDepartPermission);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SysDepartPermissionController.saveDatarule()发生异常:" + e.getMessage(),e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDeptRolePermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryDeptRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<SysDepartRolePermission> list = sysDepartRolePermissionService.list(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId));
|
||||
result.setResult(list.stream().map(SysDepartRolePermission -> String.valueOf(SysDepartRolePermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveDeptRolePermission", method = RequestMethod.POST)
|
||||
public Result<String> saveDeptRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String roleId = json.getString("roleId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.sysDepartRolePermissionService.saveDeptRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
result.success("保存成功!");
|
||||
log.info("======部门角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
|
||||
public Result<Map<String,Object>> queryTreeListForDeptRole(@RequestParam(name="departId",required=true) String departId,HttpServletRequest request) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
query.inSql(SysPermission::getId,"select permission_id from sys_depart_permission where depart_id='"+departId+"'");
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
for(SysPermission sysPer : list) {
|
||||
ids.add(sysPer.getId());
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String,Object> resMap = new HashMap<String,Object>();
|
||||
resMap.put("treeList", treeList); //全部树节点数据
|
||||
resMap.put("ids", ids);//全部树ids
|
||||
result.setResult(resMap);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
|
||||
for (SysPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(),permission.getRuleFlag(), permission.isLeaf());
|
||||
if(temp==null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
|
||||
temp.getChildren().add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,285 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="部门角色")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysDepartRole")
|
||||
public class SysDepartRoleController extends JeecgController<SysDepartRole, ISysDepartRoleService> {
|
||||
@Autowired
|
||||
private ISysDepartRoleService sysDepartRoleService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRoleUserService departRoleUserService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRolePermissionService sysDepartRolePermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-分页列表查询")
|
||||
@ApiOperation(value="部门角色-分页列表查询", notes="部门角色-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysDepartRole sysDepartRole,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name="deptId",required=false) String deptId,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDepartRole> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartRole, req.getParameterMap());
|
||||
Page<SysDepartRole> page = new Page<SysDepartRole>(pageNo, pageSize);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> deptIds = null;
|
||||
if(oConvertUtils.isEmpty(deptId)){
|
||||
if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
|
||||
deptIds = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
|
||||
}else{
|
||||
return Result.ok(null);
|
||||
}
|
||||
}else{
|
||||
deptIds = sysDepartService.getSubDepIdsByDepId(deptId);
|
||||
}
|
||||
queryWrapper.in("depart_id",deptIds);
|
||||
IPage<SysDepartRole> pageList = sysDepartRoleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-添加")
|
||||
@ApiOperation(value="部门角色-添加", notes="部门角色-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartRole sysDepartRole) {
|
||||
sysDepartRoleService.save(sysDepartRole);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-编辑")
|
||||
@ApiOperation(value="部门角色-编辑", notes="部门角色-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDepartRole sysDepartRole) {
|
||||
sysDepartRoleService.updateById(sysDepartRole);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-通过id删除")
|
||||
@ApiOperation(value="部门角色-通过id删除", notes="部门角色-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartRoleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-批量删除")
|
||||
@ApiOperation(value="部门角色-批量删除", notes="部门角色-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartRoleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-通过id查询")
|
||||
@ApiOperation(value="部门角色-通过id查询", notes="部门角色-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepartRole sysDepartRole = sysDepartRoleService.getById(id);
|
||||
return Result.ok(sysDepartRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下角色
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDeptRoleList", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartRole>> getDeptRoleList(@RequestParam(value = "departId") String departId){
|
||||
Result<List<SysDepartRole>> result = new Result<>();
|
||||
List<SysDepartRole> deptRoleList = sysDepartRoleService.list(new QueryWrapper<SysDepartRole>().eq("depart_id",departId));
|
||||
result.setSuccess(true);
|
||||
result.setResult(deptRoleList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/deptRoleUserAdd", method = RequestMethod.POST)
|
||||
public Result<?> deptRoleAdd(@RequestBody JSONObject json) {
|
||||
String newRoleId = json.getString("newRoleId");
|
||||
String oldRoleId = json.getString("oldRoleId");
|
||||
String userId = json.getString("userId");
|
||||
departRoleUserService.deptRoleUserAdd(userId,newRoleId,oldRoleId);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取已设置部门角色
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDeptRoleByUserId", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartRoleUser>> getDeptRoleByUserId(@RequestParam(value = "userId") String userId){
|
||||
Result<List<SysDepartRoleUser>> result = new Result<>();
|
||||
List<SysDepartRoleUser> roleUserList = departRoleUserService.list(new QueryWrapper<SysDepartRoleUser>().eq("user_id",userId));
|
||||
result.setSuccess(true);
|
||||
result.setResult(roleUserList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{departId}/{roleId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId,@PathVariable("roleId") String roleId) {
|
||||
//查询已授权的部门规则
|
||||
List<SysPermissionDataRule> list = sysDepartPermissionService.getPermRuleListByDeptIdAndPermId(departId,permissionId);
|
||||
if(list==null || list.size()==0) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
}else {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
|
||||
.eq(SysDepartRolePermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartRolePermission::getRoleId,roleId);
|
||||
SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
//return Result.error("未找到角色菜单配置信息");
|
||||
}else {
|
||||
String drChecked = sysRolePermission.getDataRuleIds();
|
||||
if(oConvertUtils.isNotEmpty(drChecked)) {
|
||||
map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
|
||||
}
|
||||
}
|
||||
return Result.ok(map);
|
||||
//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据规则至角色菜单关联表
|
||||
*/
|
||||
@PostMapping(value = "/datarule")
|
||||
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
String permissionId = jsonObject.getString("permissionId");
|
||||
String roleId = jsonObject.getString("roleId");
|
||||
String dataRuleIds = jsonObject.getString("dataRuleIds");
|
||||
log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
|
||||
LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
|
||||
.eq(SysDepartRolePermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartRolePermission::getRoleId,roleId);
|
||||
SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
return Result.error("请先保存角色菜单权限!");
|
||||
}else {
|
||||
sysRolePermission.setDataRuleIds(dataRuleIds);
|
||||
this.sysDepartRolePermissionService.updateById(sysRolePermission);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDepartRole
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDepartRole sysDepartRole) {
|
||||
return super.exportXls(request, sysDepartRole, SysDepartRole.class, "部门角色");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDepartRole.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -18,6 +14,7 @@ import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
@ -35,6 +32,7 @@ import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -69,9 +67,10 @@ public class SysDictController {
|
||||
|
||||
@Autowired
|
||||
private ISysDictService sysDictService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
public RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -226,7 +225,6 @@ public class SysDictController {
|
||||
}else {
|
||||
sysDict.setUpdateTime(new Date());
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
//TODO 返回false说明什么?
|
||||
if(ok) {
|
||||
result.success("编辑成功!");
|
||||
}
|
||||
@ -270,11 +268,29 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:刷新缓存
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/refleshCache")
|
||||
public Result<?> refleshCache() {
|
||||
Result<?> result = new Result<SysDict>();
|
||||
//清空字典缓存
|
||||
Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
|
||||
Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
|
||||
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
|
||||
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
|
||||
redisTemplate.delete(keys);
|
||||
redisTemplate.delete(keys2);
|
||||
redisTemplate.delete(keys3);
|
||||
redisTemplate.delete(keys4);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
|
||||
|
||||
@ -1,43 +1,32 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.MD5Util;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.modules.system.model.SysPermissionTree;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionService;
|
||||
import org.jeecg.modules.system.service.ISysRolePermissionService;
|
||||
import org.jeecg.modules.system.util.PermissionDataUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.MD5Util;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.modules.system.model.SysPermissionTree;
|
||||
import org.jeecg.modules.system.model.SysRoleDeisgnModel;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.util.PermissionDataUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -61,6 +50,9 @@ public class SysPermissionController {
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
/**
|
||||
* 加载数据节点
|
||||
*
|
||||
@ -116,7 +108,6 @@ public class SysPermissionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询子菜单
|
||||
* @param parentId
|
||||
@ -145,6 +136,42 @@ public class SysPermissionController {
|
||||
}
|
||||
/*update_end author:wuxianquan date:20190908 for:先查询一级菜单,当用户点击展开菜单时加载子菜单 */
|
||||
|
||||
// update_begin author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
/**
|
||||
* 查询子菜单
|
||||
*
|
||||
* @param parentIds 父ID(多个采用半角逗号分割)
|
||||
* @return 返回 key-value 的 Map
|
||||
*/
|
||||
@GetMapping("/getSystemSubmenuBatch")
|
||||
public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
query.in(SysPermission::getParentId, parentIdList);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
Map<String, List<SysPermissionTree>> listMap = new HashMap<>();
|
||||
for (SysPermission item : list) {
|
||||
String pid = item.getParentId();
|
||||
if (parentIdList.contains(pid)) {
|
||||
List<SysPermissionTree> mapList = listMap.get(pid);
|
||||
if (mapList == null) {
|
||||
mapList = new ArrayList<>();
|
||||
}
|
||||
mapList.add(new SysPermissionTree(item));
|
||||
listMap.put(pid, mapList);
|
||||
}
|
||||
}
|
||||
return Result.ok(listMap);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("批量查询子菜单失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
// update_end author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
|
||||
// /**
|
||||
// * 查询用户拥有的菜单权限和按钮权限(根据用户账号)
|
||||
// *
|
||||
@ -183,7 +210,12 @@ public class SysPermissionController {
|
||||
String username = JwtUtil.getUsername(token);
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
//添加首页路由
|
||||
PermissionDataUtil.addIndexPage(metaList);
|
||||
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
if(!PermissionDataUtil.hasIndexPage(metaList)){
|
||||
SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0);
|
||||
metaList.add(0,indexMenu);
|
||||
}
|
||||
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray menujsonArray = new JSONArray();
|
||||
this.getPermissionJsonArray(menujsonArray, metaList, null);
|
||||
@ -217,6 +249,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysPermission> add(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<SysPermission>();
|
||||
@ -236,6 +269,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -255,6 +289,7 @@ public class SysPermissionController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -274,6 +309,7 @@ public class SysPermissionController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -371,6 +407,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
@RequiresRoles({ "admin" })
|
||||
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
@ -429,8 +466,7 @@ public class SysPermissionController {
|
||||
/**
|
||||
* 获取权限JSON数组
|
||||
* @param jsonArray
|
||||
* @param metaList
|
||||
* @param parentJson
|
||||
* @param allList
|
||||
*/
|
||||
private void getAllAuthJsonArray(JSONArray jsonArray,List<SysPermission> allList) {
|
||||
JSONObject json = null;
|
||||
@ -448,7 +484,6 @@ public class SysPermissionController {
|
||||
* 获取权限JSON数组
|
||||
* @param jsonArray
|
||||
* @param metaList
|
||||
* @param parentJson
|
||||
*/
|
||||
private void getAuthJsonArray(JSONArray jsonArray,List<SysPermission> metaList) {
|
||||
for (SysPermission permission : metaList) {
|
||||
@ -718,4 +753,45 @@ public class SysPermissionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门权限表
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDepartPermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryDepartPermission(@RequestParam(name = "departId", required = true) String departId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<SysDepartPermission> list = sysDepartPermissionService.list(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId));
|
||||
result.setResult(list.stream().map(SysDepartPermission -> String.valueOf(SysDepartPermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存部门授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveDepartPermission", method = RequestMethod.POST)
|
||||
@RequiresRoles({ "admin" })
|
||||
public Result<String> saveDepartPermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String departId = json.getString("departId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.sysDepartPermissionService.saveDepartPermission(departId, permissionIds, lastPermissionIds);
|
||||
result.success("保存成功!");
|
||||
log.info("======部门授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,6 @@ public class SysRoleController {
|
||||
/**
|
||||
* 导出excel
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
|
||||
@ -308,6 +307,7 @@ public class SysRoleController {
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
|
||||
.eq(SysRolePermission::getPermissionId, permissionId)
|
||||
.isNotNull(SysRolePermission::getDataRuleIds)
|
||||
.eq(SysRolePermission::getRoleId,roleId);
|
||||
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.oss.entity.OSSFile;
|
||||
import org.jeecg.modules.oss.service.IOSSFileService;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* minio文件上传示例
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/upload")
|
||||
public class SysUploadController {
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param request
|
||||
*/
|
||||
@PostMapping(value = "/uploadMinio")
|
||||
public Result<?> uploadMinio(HttpServletRequest request) {
|
||||
Result<?> result = new Result<>();
|
||||
String bizPath = request.getParameter("biz");
|
||||
if(oConvertUtils.isEmpty(bizPath)){
|
||||
bizPath = "";
|
||||
}
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
|
||||
String orgName = file.getOriginalFilename();// 获取文件名
|
||||
String file_url = MinioUtil.upload(file,bizPath);
|
||||
//保存文件信息
|
||||
OSSFile minioFile = new OSSFile();
|
||||
minioFile.setFileName(orgName);
|
||||
minioFile.setUrl(file_url);
|
||||
ossFileService.save(minioFile);
|
||||
result.setMessage(file_url);
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1,26 +1,21 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
@ -29,7 +24,10 @@ import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserDepart;
|
||||
import org.jeecg.modules.system.entity.SysUserRole;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
@ -44,27 +42,16 @@ import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -106,12 +93,26 @@ public class SysUserController {
|
||||
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
|
||||
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
pageList.getRecords().forEach(item->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
log.info(pageList.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@RequiresPermissions("user:add")
|
||||
public Result<SysUser> add(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
String selectedRoles = jsonObject.getString("selectedroles");
|
||||
@ -136,6 +137,7 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
//@RequiresPermissions("user:edit")
|
||||
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
try {
|
||||
@ -272,8 +274,9 @@ public class SysUserController {
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@RequestMapping(value = "/changPassword", method = RequestMethod.PUT)
|
||||
public Result<?> changPassword(@RequestBody SysUser sysUser) {
|
||||
@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/changePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changePassword(@RequestBody SysUser sysUser) {
|
||||
SysUser u = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, sysUser.getUsername()));
|
||||
if (u == null) {
|
||||
return Result.error("用户不存在!");
|
||||
@ -335,7 +338,22 @@ public class SysUserController {
|
||||
@RequestMapping(value = "/queryUserByDepId", method = RequestMethod.GET)
|
||||
public Result<List<SysUser>> queryUserByDepId(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<List<SysUser>> result = new Result<>();
|
||||
List<SysUser> userList = sysUserDepartService.queryUserByDepId(id);
|
||||
//List<SysUser> userList = sysUserDepartService.queryUserByDepId(id);
|
||||
SysDepart sysDepart = sysDepartService.getById(id);
|
||||
List<SysUser> userList = sysUserDepartService.queryUserByDepCode(sysDepart.getOrgCode());
|
||||
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
userList.forEach(item->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
result.setSuccess(true);
|
||||
result.setResult(userList);
|
||||
@ -397,6 +415,7 @@ public class SysUserController {
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("user:import")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@ -562,9 +581,37 @@ public class SysUserController {
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
String depId = req.getParameter("depId");
|
||||
String username = req.getParameter("username");
|
||||
IPage<SysUser> pageList = sysUserService.getUserByDepId(page,depId,username);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
//根据部门ID查询,当前和下级所有的部门IDS
|
||||
List<String> subDepids = new ArrayList<>();
|
||||
//部门id为空时,查询我的部门下所有用户
|
||||
if(oConvertUtils.isEmpty(depId)){
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
int userIdentity = user.getIdentity() != null?user.getIdentity():CommonConstant.USER_IDENTITY_1;
|
||||
if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
|
||||
subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
|
||||
}
|
||||
}else{
|
||||
subDepids = sysDepartService.getSubDepIdsByDepId(depId);
|
||||
}
|
||||
if(subDepids != null && subDepids.size()>0){
|
||||
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
pageList.getRecords().forEach(item -> {
|
||||
//批量查询用户的所属部门
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
}else{
|
||||
result.setSuccess(true);
|
||||
result.setResult(null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -592,7 +639,7 @@ public class SysUserController {
|
||||
public Result<?> queryByOrgCodeForAddressList(
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(name = "orgCode") String orgCode,
|
||||
@RequestParam(name = "orgCode",required = false) String orgCode,
|
||||
SysUser userParams
|
||||
) {
|
||||
IPage page = new Page(pageNo, pageSize);
|
||||
@ -669,8 +716,12 @@ public class SysUserController {
|
||||
try {
|
||||
QueryWrapper<SysUserDepart> queryWrapper = new QueryWrapper<SysUserDepart>();
|
||||
queryWrapper.eq("dep_id", depId).eq("user_id",userId);
|
||||
sysUserDepartService.remove(queryWrapper);
|
||||
result.success("删除成功!");
|
||||
boolean b = sysUserDepartService.remove(queryWrapper);
|
||||
if(b){
|
||||
result.success("删除成功!");
|
||||
}else{
|
||||
result.error500("当前选中部门与用户无关联关系!");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("删除失败!");
|
||||
@ -737,7 +788,15 @@ public class SysUserController {
|
||||
String smscode = jsonObject.getString("smscode");
|
||||
Object code = redisUtil.get(phone);
|
||||
String username = jsonObject.getString("username");
|
||||
//未设置用户名,则用手机号作为用户名
|
||||
if(oConvertUtils.isEmpty(username)){
|
||||
username = phone;
|
||||
}
|
||||
//未设置密码,则随机生成一个密码
|
||||
String password = jsonObject.getString("password");
|
||||
if(oConvertUtils.isEmpty(password)){
|
||||
password = RandomUtil.randomString(8);
|
||||
}
|
||||
String email = jsonObject.getString("email");
|
||||
SysUser sysUser1 = sysUserService.getUserByName(username);
|
||||
if (sysUser1 != null) {
|
||||
@ -746,18 +805,20 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
SysUser sysUser2 = sysUserService.getUserByPhone(phone);
|
||||
|
||||
if (sysUser2 != null) {
|
||||
result.setMessage("该手机号已注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
SysUser sysUser3 = sysUserService.getUserByEmail(email);
|
||||
if (sysUser3 != null) {
|
||||
result.setMessage("邮箱已被注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(oConvertUtils.isNotEmpty(email)){
|
||||
SysUser sysUser3 = sysUserService.getUserByEmail(email);
|
||||
if (sysUser3 != null) {
|
||||
result.setMessage("邮箱已被注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!smscode.equals(code)) {
|
||||
result.setMessage("手机验证码错误");
|
||||
@ -851,19 +912,27 @@ public class SysUserController {
|
||||
@RequestParam(name="smscode")String smscode,
|
||||
@RequestParam(name="phone") String phone) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
if(oConvertUtils.isEmpty(username) || oConvertUtils.isEmpty(password) || oConvertUtils.isEmpty(smscode) || oConvertUtils.isEmpty(phone) ) {
|
||||
result.setMessage("重置密码失败!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
SysUser sysUser=new SysUser();
|
||||
Object object= redisUtil.get(phone);
|
||||
if(null==object) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setMessage("短信验证码失效!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
if(!smscode.equals(object)) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setMessage("短信验证码不匹配!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username));
|
||||
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username).eq(SysUser::getPhone,phone));
|
||||
if (sysUser == null) {
|
||||
result.setMessage("未找到对应实体");
|
||||
result.setMessage("未找到用户!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
} else {
|
||||
@ -873,7 +942,7 @@ public class SysUserController {
|
||||
sysUser.setPassword(passwordEncode);
|
||||
this.sysUserService.updateById(sysUser);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("密码修改完成!");
|
||||
result.setMessage("密码重置完成!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -941,5 +1010,55 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取被逻辑删除的用户列表,无分页
|
||||
*
|
||||
* @return logicDeletedUserList
|
||||
*/
|
||||
@GetMapping("/recycleBin")
|
||||
public Result getRecycleBin() {
|
||||
List<SysUser> logicDeletedUserList = sysUserService.queryLogicDeleted();
|
||||
if (logicDeletedUserList.size() > 0) {
|
||||
// 批量查询用户的所属部门
|
||||
// step.1 先拿到全部的 userIds
|
||||
List<String> userIds = logicDeletedUserList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
// step.2 通过 userIds,一次性查询用户的所属部门名字
|
||||
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
logicDeletedUserList.forEach(item -> item.setOrgCode(useDepNames.get(item.getId())));
|
||||
}
|
||||
return Result.ok(logicDeletedUserList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*
|
||||
* @param userIds 被还原的用户ID,是个 list 集合
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/recycleBin")
|
||||
public Result putRecycleBin(@RequestBody List<String> userIds, HttpServletRequest request) {
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
SysUser updateUser = new SysUser();
|
||||
updateUser.setUpdateBy(JwtUtil.getUserNameByToken(request));
|
||||
updateUser.setUpdateTime(new Date());
|
||||
sysUserService.revertLogicDeleted(userIds, updateUser);
|
||||
}
|
||||
return Result.ok("还原成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 彻底删除用户
|
||||
*
|
||||
* @param userIds 被删除的用户ID,多个id用半角逗号分割
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/recycleBin")
|
||||
public Result deleteRecycleBin(@RequestParam("userIds") String userIds) {
|
||||
if (StringUtils.isNotBlank(userIds)) {
|
||||
sysUserService.removeLogicDeleted(Arrays.asList(userIds.split(",")));
|
||||
}
|
||||
return Result.ok("删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -124,4 +124,20 @@ public class SysAnnouncement implements Serializable {
|
||||
* 指定用户
|
||||
**/
|
||||
private java.lang.String userIds;
|
||||
/**
|
||||
* 业务类型(email:邮件 bpm:流程)
|
||||
*/
|
||||
private java.lang.String busType;
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private java.lang.String busId;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private java.lang.String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private java.lang.String openPage;
|
||||
}
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_check_rule")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "sys_check_rule对象", description = "编码校验规则")
|
||||
public class SysCheckRule {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Excel(name = "规则名称", width = 15)
|
||||
@ApiModelProperty(value = "规则名称")
|
||||
private String ruleName;
|
||||
/**
|
||||
* 规则Code
|
||||
*/
|
||||
@Excel(name = "规则Code", width = 15)
|
||||
@ApiModelProperty(value = "规则Code")
|
||||
private String ruleCode;
|
||||
/**
|
||||
* 规则JSON
|
||||
*/
|
||||
@Excel(name = "规则JSON", width = 15)
|
||||
@ApiModelProperty(value = "规则JSON")
|
||||
private String ruleJson;
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Excel(name = "规则描述", width = 15)
|
||||
@ApiModelProperty(value = "规则描述")
|
||||
private String ruleDescription;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
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.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_data_source")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "sys_data_source对象", description = "多数据源管理")
|
||||
public class SysDataSource {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 数据源编码
|
||||
*/
|
||||
@Excel(name = "数据源编码", width = 15)
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
private java.lang.String code;
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@Excel(name = "数据源名称", width = 15)
|
||||
@ApiModelProperty(value = "数据源名称")
|
||||
private java.lang.String name;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String remark;
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
@Dict(dicCode = "database_type")
|
||||
@Excel(name = "数据库类型", width = 15, dicCode = "database_type")
|
||||
@ApiModelProperty(value = "数据库类型")
|
||||
private java.lang.String dbType;
|
||||
/**
|
||||
* 驱动类
|
||||
*/
|
||||
@Excel(name = "驱动类", width = 15)
|
||||
@ApiModelProperty(value = "驱动类")
|
||||
private java.lang.String dbDriver;
|
||||
/**
|
||||
* 数据源地址
|
||||
*/
|
||||
@Excel(name = "数据源地址", width = 15)
|
||||
@ApiModelProperty(value = "数据源地址")
|
||||
private java.lang.String dbUrl;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@Excel(name = "数据库名称", width = 15)
|
||||
@ApiModelProperty(value = "数据库名称")
|
||||
private java.lang.String dbName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Excel(name = "用户名", width = 15)
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private java.lang.String dbUsername;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Excel(name = "密码", width = 15)
|
||||
@ApiModelProperty(value = "密码")
|
||||
private java.lang.String dbPassword;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Excel(name = "所属部门", width = 15)
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_permission")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_permission对象", description="部门权限表")
|
||||
public class SysDepartPermission {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
private java.lang.String departId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**数据规则id*/
|
||||
@ApiModelProperty(value = "数据规则id")
|
||||
private java.lang.String dataRuleIds;
|
||||
|
||||
public SysDepartPermission() {
|
||||
|
||||
}
|
||||
|
||||
public SysDepartPermission(String departId, String permissionId) {
|
||||
this.departId = departId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role对象", description="部门角色")
|
||||
public class SysDepartRole {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
private java.lang.String departId;
|
||||
/**部门角色名称*/
|
||||
@Excel(name = "部门角色名称", width = 15)
|
||||
@ApiModelProperty(value = "部门角色名称")
|
||||
private java.lang.String roleName;
|
||||
/**部门角色编码*/
|
||||
@Excel(name = "部门角色编码", width = 15)
|
||||
@ApiModelProperty(value = "部门角色编码")
|
||||
private java.lang.String roleCode;
|
||||
/**描述*/
|
||||
@Excel(name = "描述", width = 15)
|
||||
@ApiModelProperty(value = "描述")
|
||||
private java.lang.String description;
|
||||
/**创建人*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建时间*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新时间*/
|
||||
@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")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role_permission")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role_permission对象", description="部门角色权限")
|
||||
public class SysDepartRolePermission {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
private java.lang.String departId;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private java.lang.String roleId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**dataRuleIds*/
|
||||
@Excel(name = "dataRuleIds", width = 15)
|
||||
@ApiModelProperty(value = "dataRuleIds")
|
||||
private java.lang.String dataRuleIds;
|
||||
|
||||
public SysDepartRolePermission() {
|
||||
}
|
||||
|
||||
public SysDepartRolePermission(String roleId, String permissionId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role_user")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role_user对象", description="部门角色人员信息")
|
||||
public class SysDepartRoleUser {
|
||||
|
||||
/**主键id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private java.lang.String id;
|
||||
/**用户id*/
|
||||
@Excel(name = "用户id", width = 15)
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private java.lang.String userId;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private java.lang.String droleId;
|
||||
|
||||
public SysDepartRoleUser() {
|
||||
|
||||
}
|
||||
|
||||
public SysDepartRoleUser(String userId, String droleId) {
|
||||
this.userId = userId;
|
||||
this.droleId = droleId;
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class SysUser implements Serializable {
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 部门code
|
||||
* 部门code(当前选择登录部门)
|
||||
*/
|
||||
private String orgCode;
|
||||
|
||||
@ -158,5 +158,16 @@ public class SysUser implements Serializable {
|
||||
*/
|
||||
private String activitiSync;
|
||||
|
||||
/**
|
||||
* 身份(0 普通成员 1 上级)
|
||||
*/
|
||||
@Excel(name="(1普通成员 2上级)",width = 15)
|
||||
private Integer identity;
|
||||
|
||||
/**
|
||||
* 负责部门
|
||||
*/
|
||||
@Excel(name="负责部门",width = 15,dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
private String departIds;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysCheckRuleMapper extends BaseMapper<SysCheckRule> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDataSourceMapper extends BaseMapper<SysDataSource> {
|
||||
|
||||
}
|
||||
@ -38,4 +38,18 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
|
||||
@Select("select id,parent_id from sys_depart where id=#{departId}")
|
||||
public SysDepart getParentDepartId(@Param("departId") String departId);
|
||||
|
||||
/**
|
||||
* 根据部门Id查询,当前和下级所有部门IDS
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByDepId(@Param("departId") String departId);
|
||||
|
||||
/**
|
||||
* 根据部门编码获取部门下所有IDS
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByOrgCodes(@org.apache.ibatis.annotations.Param("orgCodes") String[] orgCodes);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartPermissionMapper extends BaseMapper<SysDepartPermission> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRoleMapper extends BaseMapper<SysDepartRole> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRolePermissionMapper extends BaseMapper<SysDepartRolePermission> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRoleUserMapper extends BaseMapper<SysDepartRoleUser> {
|
||||
|
||||
}
|
||||
@ -1,11 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.vo.SysUserDepVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -33,6 +36,21 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
*/
|
||||
IPage<SysUser> getUserByDepId(Page page, @Param("departId") String departId, @Param("username") String username);
|
||||
|
||||
/**
|
||||
* 根据用户Ids,查询用户所属部门名称信息
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
List<SysUserDepVo> getDepNamesByUserIds(@Param("userIds")List<String> userIds);
|
||||
|
||||
/**
|
||||
* 根据部门Ids,查询部门下用户信息
|
||||
* @param page
|
||||
* @param departIds
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserByDepIds(Page page, @Param("departIds") List<String> departIds, @Param("username") String username);
|
||||
|
||||
/**
|
||||
* 根据角色Id查询用户信息
|
||||
* @param page
|
||||
@ -96,4 +114,20 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @Description: 批量删除角色与权限关系
|
||||
*/
|
||||
void deleteBathRolePermissionRelation(@Param("roleIdArray") String[] roleIdArray);
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户
|
||||
*/
|
||||
List<SysUser> selectLogicDeleted(@Param(Constants.WRAPPER) Wrapper<SysUser> wrapper);
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*/
|
||||
int revertLogicDeleted(@Param("userIds") String userIds, @Param("entity") SysUser entity);
|
||||
|
||||
/**
|
||||
* 彻底删除被逻辑删除的用户
|
||||
*/
|
||||
int deleteLogicDeleted(@Param("userIds") String userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -21,6 +21,10 @@
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="user_ids" property="userIds" jdbcType="VARCHAR"/>
|
||||
<result column="bus_type" property="busType" jdbcType="VARCHAR"/>
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@
|
||||
<result column="priority" property="priority" jdbcType="VARCHAR"/>
|
||||
<result column="msg_category" property="msgCategory" jdbcType="VARCHAR"/>
|
||||
<result column="send_time" property="sendTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryByUserId" parameterType="String" resultType="String">
|
||||
@ -30,7 +33,10 @@
|
||||
sa.sender as sender,
|
||||
sa.priority as priority,
|
||||
sa.msg_category,
|
||||
sa.send_time as send_time
|
||||
sa.send_time as send_time,
|
||||
sa.bus_id as bus_id,
|
||||
sa.open_type as open_type,
|
||||
sa.open_page as open_page
|
||||
from sys_announcement_send sas
|
||||
left join sys_announcement sa ON sas.annt_id = sa.id
|
||||
where sa.send_status = '1'
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysCheckRuleMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysDataSourceMapper">
|
||||
|
||||
</mapper>
|
||||
@ -21,4 +21,17 @@
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 根据部门Id查询,当前和下级所有部门IDS -->
|
||||
<select id="getSubDepIdsByDepId" resultType="java.lang.String">
|
||||
select id from sys_depart where del_flag = '0' and org_code like concat((select org_code from sys_depart where id=#{departId}),'%')
|
||||
</select>
|
||||
|
||||
<!--根据部门编码获取我的部门下所有部门ids -->
|
||||
<select id="getSubDepIdsByOrgCodes" resultType="java.lang.String">
|
||||
select id from sys_depart where del_flag = '0' and
|
||||
<foreach collection="orgCodes" item="item" index="index" open="(" separator="or" close=")">
|
||||
org_code LIKE CONCAT(#{item},'%')
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysDepartPermissionMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysDepartRoleMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysDepartRolePermissionMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysDepartRoleUserMapper">
|
||||
|
||||
</mapper>
|
||||
@ -11,6 +11,16 @@
|
||||
join sys_user_role d on d.role_id = c.id
|
||||
join sys_user e on d.user_id = e.id
|
||||
where e.username = #{username} and b.id = #{permissionId}
|
||||
<!--update begin Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
union
|
||||
select data_rule_ids
|
||||
from sys_depart_role_permission a
|
||||
join sys_permission b on a.permission_id = b.id
|
||||
join sys_depart_role c on a.role_id = c.id
|
||||
join sys_depart_role_user d on d.drole_id = c.id
|
||||
join sys_user e on d.user_id = e.id
|
||||
where e.username = #{username} and b.id = #{permissionId}
|
||||
<!--update end Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -41,17 +41,31 @@
|
||||
|
||||
<!-- 获取登录用户拥有的权限 -->
|
||||
<select id="queryByUser" parameterType="Object" resultMap="SysPermission">
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_role_permission a
|
||||
join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
order by p.sort_no ASC
|
||||
SELECT * FROM (
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_role_permission a
|
||||
join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
<!--update begin Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
UNION
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_depart_role_permission a
|
||||
join sys_depart_role b on a.role_id = b.id
|
||||
join sys_depart_role_user c on c.drole_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
<!--update end Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
) h order by h.sort_no ASC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,29 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 查询用户的所属部门名称信息 -->
|
||||
<select id="getDepNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserDepVo">
|
||||
select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in
|
||||
<foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 通过多个部门IDS,查询部门下的用户信息 -->
|
||||
<select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = '0'
|
||||
<if test="departIds!=null and departIds.size()>0">
|
||||
and id in (select user_id from sys_user_depart where dep_id in
|
||||
<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="username!=null and username!=''">
|
||||
and username = #{username}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据角色Id查询 -->
|
||||
<select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_role where role_id=#{roleId})
|
||||
@ -47,7 +70,7 @@
|
||||
-- 关联查询出该用户的详细信息
|
||||
INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id
|
||||
WHERE
|
||||
sys_depart.org_code LIKE '${orgCode}%'
|
||||
sys_user.del_flag = "0" AND sys_depart.org_code LIKE '${orgCode}%'
|
||||
|
||||
<if test="userParams != null">
|
||||
<if test="userParams.realname != null and userParams.realname != ''">
|
||||
@ -97,4 +120,28 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 查询被逻辑删除的用户 -->
|
||||
<select id="selectLogicDeleted" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
SELECT * FROM sys_user ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<!-- 更新被逻辑删除的用户 -->
|
||||
<update id="revertLogicDeleted">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
del_flag = "0",
|
||||
update_by = #{entity.updateBy},
|
||||
update_time = #{entity.updateTime}
|
||||
WHERE
|
||||
del_flag = "1"
|
||||
AND id IN (${userIds})
|
||||
</update>
|
||||
|
||||
<!-- 彻底删除被逻辑删除的用户 -->
|
||||
<delete id="deleteLogicDeleted">
|
||||
DELETE FROM sys_user WHERE del_flag = "1" AND id IN (${userIds})
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@ -51,4 +51,16 @@ public class AnnouncementSendModel implements Serializable {
|
||||
* 消息类型1:通知公告2:系统消息
|
||||
*/
|
||||
private java.lang.String msgCategory;
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private java.lang.String busId;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private java.lang.String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private java.lang.String openPage;
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package org.jeecg.modules.system.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2019/12/12.
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleDeisgnModel {
|
||||
/**主键*/
|
||||
private java.lang.String id;
|
||||
/**变单设计器code*/
|
||||
private java.lang.String desformCode;
|
||||
/**变单设计器名称*/
|
||||
private java.lang.String desformName;
|
||||
/**变单设计器图标*/
|
||||
private java.lang.String desformIcon;
|
||||
/**流程类型*/
|
||||
private java.lang.String procType;
|
||||
/**流程名称*/
|
||||
private java.lang.String procName;
|
||||
/**标题表达式*/
|
||||
private java.lang.String titleExp;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysCheckRuleService extends IService<SysCheckRule> {
|
||||
|
||||
/**
|
||||
* 通过 code 获取规则
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
SysCheckRule getByCode(String ruleCode);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户设定的自定义校验规则校验传入的值
|
||||
*
|
||||
* @param checkRule
|
||||
* @param value
|
||||
* @return 返回 null代表通过校验,否则就是返回的错误提示文本
|
||||
*/
|
||||
JSONObject checkValue(SysCheckRule checkRule, String value);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDataSourceService extends IService<SysDataSource> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartPermissionService extends IService<SysDepartPermission> {
|
||||
/**
|
||||
* 保存授权 将上次的权限和这次作比较 差异处理提高效率
|
||||
* @param departId
|
||||
* @param permissionIds
|
||||
* @param lastPermissionIds
|
||||
*/
|
||||
public void saveDepartPermission(String departId,String permissionIds,String lastPermissionIds);
|
||||
|
||||
/**
|
||||
* 根据部门id,菜单id获取数据规则
|
||||
* @param permissionId
|
||||
* @return
|
||||
*/
|
||||
List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId,String permissionId);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRolePermissionService extends IService<SysDepartRolePermission> {
|
||||
/**
|
||||
* 保存授权 将上次的权限和这次作比较 差异处理提高效率
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @param lastPermissionIds
|
||||
*/
|
||||
public void saveDeptRolePermission(String roleId,String permissionIds,String lastPermissionIds);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRoleService extends IService<SysDepartRole> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRoleUserService extends IService<SysDepartRoleUser> {
|
||||
|
||||
void deptRoleUserAdd(String userId,String newRoleId,String oldRoleId);
|
||||
}
|
||||
@ -16,6 +16,11 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysDepartService extends IService<SysDepart>{
|
||||
|
||||
/**
|
||||
* 查询我的部门信息,并分节点进行显示
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryMyDeptTreeList(String departIds);
|
||||
|
||||
/**
|
||||
* 查询所有部门信息,并分节点进行显示
|
||||
@ -84,5 +89,18 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
void deleteBatchWithChildren(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据部门Id查询,当前和下级所有部门IDS
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByDepId(String departId);
|
||||
|
||||
/**
|
||||
* 获取我的部门下级所有部门IDS
|
||||
* @return
|
||||
*/
|
||||
List<String> getMySubDepIdsByDepId(String departIds);
|
||||
|
||||
}
|
||||
|
||||
@ -34,4 +34,8 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryUserByDepId(String depId);
|
||||
/**
|
||||
* 根据部门code,查询当前部门和下级部门的用户信息
|
||||
*/
|
||||
public List<SysUser> queryUserByDepCode(String depCode);
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -95,6 +97,20 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
|
||||
|
||||
/**
|
||||
* 根据部门Ids查询
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
|
||||
|
||||
/**
|
||||
* 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getDepNamesByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 根据部门 Id 和 QueryWrapper 查询
|
||||
*
|
||||
@ -178,4 +194,24 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
Result checkUserIsEffective(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户
|
||||
*/
|
||||
List<SysUser> queryLogicDeleted();
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户(可拼装查询条件)
|
||||
*/
|
||||
List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper);
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*/
|
||||
boolean revertLogicDeleted(List<String> userIds, SysUser updateEntity);
|
||||
|
||||
/**
|
||||
* 彻底删除被逻辑删除的用户
|
||||
*/
|
||||
boolean removeLogicDeleted(List<String> userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -13,26 +13,31 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.ComboModel;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysDepartModel;
|
||||
import org.jeecg.common.system.vo.*;
|
||||
import org.jeecg.common.util.IPUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.SysAnnmentTypeEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.oss.OssBootUtil;
|
||||
import org.jeecg.modules.message.entity.SysMessageTemplate;
|
||||
import org.jeecg.modules.message.service.ISysMessageTemplateService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -42,6 +47,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @Description: 底层共通业务API,提供其他独立模块调用
|
||||
@ -76,7 +82,12 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
private SysRoleMapper roleMapper;
|
||||
@Resource
|
||||
private SysDepartMapper departMapper;
|
||||
|
||||
@Resource
|
||||
private SysCategoryMapper categoryMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysDataSourceService dataSourceService;
|
||||
|
||||
@Override
|
||||
public void addLog(String LogContent, Integer logType, Integer operatetype) {
|
||||
SysLog sysLog = new SysLog();
|
||||
@ -228,7 +239,64 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory, String busType, String busId) {
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(msgContent);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(setMsgCategory);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
announcement.setBusId(busId);
|
||||
announcement.setBusType(busType);
|
||||
announcement.setOpenType(SysAnnmentTypeEnum.getByType(busType).getOpenType());
|
||||
announcement.setOpenPage(SysAnnmentTypeEnum.getByType(busType).getOpenPage());
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = toUser;
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = announcement.getId();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
if(oConvertUtils.isNotEmpty(userIds[i])) {
|
||||
SysUser sysUser = userMapper.getUserByName(userIds[i]);
|
||||
if(sysUser==null) {
|
||||
continue;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "user");
|
||||
obj.put("userId", sysUser.getId());
|
||||
obj.put("msgId", announcement.getId());
|
||||
obj.put("msgTxt", announcement.getTitile());
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysAnnounReadFlag(String busType, String busId) {
|
||||
SysAnnouncement announcement = sysAnnouncementMapper.selectOne(new QueryWrapper<SysAnnouncement>().eq("bus_type",busType).eq("bus_id",busId));
|
||||
if(announcement != null){
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = sysUser.getId();
|
||||
LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
|
||||
updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
|
||||
updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
|
||||
updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'");
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
sysAnnouncementSendMapper.update(announcementSend, updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
@ -301,6 +369,64 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, Map<String, String> map, String templateCode, String busType, String busId) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
|
||||
}
|
||||
SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
|
||||
//模板标题
|
||||
title = title==null?sysSmsTemplate.getTemplateName():title;
|
||||
//模板内容
|
||||
String content = sysSmsTemplate.getTemplateContent();
|
||||
if(map!=null) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String str = "${" + entry.getKey() + "}";
|
||||
title = title.replace(str, entry.getValue());
|
||||
content = content.replace(str, entry.getValue());
|
||||
}
|
||||
}
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(content);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
announcement.setBusId(busId);
|
||||
announcement.setBusType(busType);
|
||||
announcement.setOpenType(SysAnnmentTypeEnum.getByType(busType).getOpenType());
|
||||
announcement.setOpenPage(SysAnnmentTypeEnum.getByType(busType).getOpenPage());
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = toUser;
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = announcement.getId();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
if(oConvertUtils.isNotEmpty(userIds[i])) {
|
||||
SysUser sysUser = userMapper.getUserByName(userIds[i]);
|
||||
if(sysUser==null) {
|
||||
continue;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "user");
|
||||
obj.put("userId", sysUser.getId());
|
||||
obj.put("msgId", announcement.getId());
|
||||
obj.put("msgTxt", announcement.getTitile());
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型
|
||||
* @param dataSource
|
||||
@ -349,11 +475,23 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysCategoryModel> queryAllDSysCategory() {
|
||||
List<SysCategory> ls = categoryMapper.selectList(null);
|
||||
List<SysCategoryModel> res = oConvertUtils.entityListToModelList(ls,SysCategoryModel.class);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
|
||||
return sysDictService.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) {
|
||||
return sysDictService.queryTableDictByKeys(table,text,code,keyArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUser() {
|
||||
List<ComboModel> list = new ArrayList<ComboModel>();
|
||||
@ -362,20 +500,25 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
ComboModel model = new ComboModel();
|
||||
model.setTitle(user.getRealname());
|
||||
model.setId(user.getId());
|
||||
model.setUsername(user.getUsername());
|
||||
list.add(model);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUser(String[] userIds) {
|
||||
public JSONObject queryAllUser(String[] userIds,int pageNo,int pageSize) {
|
||||
JSONObject json = new JSONObject();
|
||||
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status","1").eq("del_flag","0");
|
||||
List<ComboModel> list = new ArrayList<ComboModel>();
|
||||
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().eq("status","1").eq("del_flag","0"));
|
||||
for(SysUser user : userList){
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
IPage<SysUser> pageList = userMapper.selectPage(page, queryWrapper);
|
||||
for(SysUser user : pageList.getRecords()){
|
||||
ComboModel model = new ComboModel();
|
||||
model.setUsername(user.getUsername());
|
||||
model.setTitle(user.getRealname());
|
||||
model.setId(user.getId());
|
||||
model.setEmail(user.getEmail());
|
||||
if(oConvertUtils.isNotEmpty(userIds)){
|
||||
for(int i = 0; i<userIds.length;i++){
|
||||
if(userIds[i].equals(user.getId())){
|
||||
@ -385,7 +528,9 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
list.add(model);
|
||||
}
|
||||
return list;
|
||||
json.put("list",list);
|
||||
json.put("total",pageList.getTotal());
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -409,6 +554,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
ComboModel model = new ComboModel();
|
||||
model.setTitle(role.getRoleName());
|
||||
model.setId(role.getId());
|
||||
model.setRoleCode(role.getRoleCode());
|
||||
if(oConvertUtils.isNotEmpty(roleIds)) {
|
||||
for (int i = 0; i < roleIds.length; i++) {
|
||||
if (roleIds[i].equals(role.getId())) {
|
||||
@ -449,4 +595,38 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
return departModelList;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId) {
|
||||
SysDataSource dbSource = dataSourceService.getById(dbSourceId);
|
||||
return new DynamicDataSourceModel(dbSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode) {
|
||||
SysDataSource dbSource = dataSourceService.getOne(new LambdaQueryWrapper<SysDataSource>().eq(SysDataSource::getCode, dbSourceCode));
|
||||
return new DynamicDataSourceModel(dbSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDeptHeadByDepId(String deptId) {
|
||||
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().like("depart_ids",deptId).eq("status","1").eq("del_flag","0"));
|
||||
List<String> list = new ArrayList<>();
|
||||
for(SysUser user : userList){
|
||||
list.add(user.getUsername());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(MultipartFile file,String bizPath,String uploadType) {
|
||||
String url = "";
|
||||
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
|
||||
url = MinioUtil.upload(file,bizPath);
|
||||
}else{
|
||||
url = OssBootUtil.upload(file,bizPath);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user