Jeecg-Boot 2.2.0 版本发布 | 重磅升级

This commit is contained in:
zhangdaiscott
2020-05-03 12:43:53 +08:00
parent 046831e700
commit 9e046a07d4
335 changed files with 12894 additions and 27387 deletions

View File

@ -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.4.jar jeecgboot.jar
ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.2.0.jar jeecgboot.jar
EXPOSE 80 8080 81
ENTRYPOINT /bin/sh -c /etc/init.d/start.sh

View File

@ -1,7 +1,7 @@
Jeecg-Boot 快速开发平台
===============
当前最新版本: 2.1.4发布日期20200224
当前最新版本: 2.2.0发布日期20200506
## 后端技术架构

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,138 +0,0 @@
-- 多数据源表
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', 'jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false', 'jeecg-boot', 'root', 'root', 'admin', '2019-12-25 18:14:53', 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 15:12:12', 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 15:13:02', 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 15:13:18', 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 15:13:33', NULL, NULL);
-- 生产销售监控 --
update sys_permission set url='{{ window._CONFIG[\'domianURL\'] }}/big/screen/templat/index1' where id='1205098241075453953';
-- 智慧物流监控 --
update sys_permission set url='{{ window._CONFIG[\'domianURL\'] }}/big/screen/templat/index2' 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', '多数据源管理', '/isystem/dataSource', 'system/SysDataSourceList', '1', NULL, NULL, '1', NULL, '1', '3', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-12-25 15:04:30', 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', '[{\"digits\":\"1\",\"pattern\":\"^[a-z|A-Z]$\",\"message\":\"第一位只能是字母\"},{\"digits\":\"*\",\"pattern\":\"^[0-9|a-z|A-Z|_]{0,}$\",\"message\":\"只能填写数字、大小写字母、下划线\"},{\"digits\":\"*\",\"pattern\":\"^.{3,}$\",\"message\":\"最少输入3位数\"},{\"digits\":\"*\",\"pattern\":\"^.{3,12}$\",\"message\":\"最多输入12位数\"}]', '规则1、首位只能是字母2、只能填写数字、大小写字母、下划线3、最少3位数最多12位数。', 'admin', '2020-02-07 11:25:48', 'admin', '2020-02-05 16:58:27');
INSERT INTO `sys_check_rule` VALUES ('1225001845524004866', '负责的功能测试', 'test', '[{\"digits\":\"*\",\"pattern\":\"^.{3,12}$\",\"message\":\"只能输入3-12位字符\"},{\"digits\":\"3\",\"pattern\":\"^\\\\d{3}$\",\"message\":\"前3位必须是数字\"},{\"digits\":\"*\",\"pattern\":\"^[^pP]*$\",\"message\":\"不能输入P\"},{\"digits\":\"4\",\"pattern\":\"^@{4}$\",\"message\":\"第4-7位必须都为 @\"},{\"digits\":\"2\",\"pattern\":\"^#=$\",\"message\":\"第8-9位必须是 #=\"},{\"digits\":\"1\",\"pattern\":\"^O$\",\"message\":\"第10位必须为大写的O\"},{\"digits\":\"*\",\"pattern\":\"^.*。$\",\"message\":\"必须以。结尾\"}]', '包含长度校验、特殊字符校验等', 'admin', '2020-02-07 11:57:31', 'admin', '2020-02-05 18:22:54');
-- 编码校验规则菜单
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', '编码校验规则', '/isystem/checkRule', 'system/SysCheckRuleList', '1', NULL, NULL, '1', NULL, '1', '2', '0', NULL, '1', '0', '0', NULL, 'admin', '2019-11-07 13:52:53', 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', '/online/cgformErpList/:code', 'modules/online/cgform/auto/erp/OnlCgformErpList', NULL, NULL, 1, NULL, '1', 5.00, 0, NULL, 1, 1, 0, 1, NULL, 'admin', '2020-02-18 15:49:00', 'admin', '2020-02-18 15:52:25', 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`;

View File

@ -0,0 +1,145 @@
ALTER TABLE `onl_cgform_field`
MODIFY COLUMN `dict_table` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典表' AFTER `dict_field`;
ALTER TABLE `onl_cgform_field`
ADD COLUMN `converter` varchar(255) NULL COMMENT '自定义值转换器' AFTER `create_by`;
INSERT INTO `onl_cgform_head`(`id`, `table_name`, `table_type`, `table_version`, `table_txt`, `is_checkbox`, `is_db_synch`, `is_page`, `is_tree`, `id_sequence`, `id_type`, `query_mode`, `relation_type`, `sub_table_str`, `tab_order_num`, `tree_parent_id_field`, `tree_id_field`, `tree_fieldname`, `form_category`, `form_template`, `form_template_mobile`, `scroll`, `copy_version`, `copy_type`, `physic_id`, `update_by`, `update_time`, `create_by`, `create_time`, `theme_template`) VALUES ('3d447fa919b64f6883a834036c14aa67', 'test_enhance_select', 1, 5, 'js增强实现下拉联动效果', 'N', 'Y', 'Y', 'N', NULL, 'UUID', 'single', NULL, NULL, NULL, NULL, NULL, NULL, 'bdfl_include', '1', NULL, 0, NULL, 0, NULL, 'admin', '2020-02-21 17:58:46', 'admin', '2020-02-20 16:19:00', 'normal');
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('209ddb923d8dab9f454d56d82c0cc725', '3d447fa919b64f6883a834036c14aa67', 'create_by', '创建人', NULL, 0, 1, 'string', 50, 0, '', '', '', '', 'text', '', 120, NULL, '0', '', '', 0, 0, 0, 0, 'single', '', '', 6, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('37462a4d78968d0e432d746423603b81', '3d447fa919b64f6883a834036c14aa67', 'province', '省份', NULL, 0, 1, 'String', 100, 0, '', '', '{table:\'sys_category\',txt:\'name\',key:\'id\',linkField:\'city,area\',idField:\'id\',pidField:\'pid\', condition:\" pid = \'1230769196661510146\' \" }', '', 'link_down', '', 120, NULL, '0', '', '', 0, 1, 1, 0, 'single', '', '', 2, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('7cdbe0d563e15f3fb1fb32d996fe4ba7', '3d447fa919b64f6883a834036c14aa67', 'area', '', NULL, 0, 1, 'String', 100, 0, '', '', '', '', 'text', '', 120, NULL, '0', '', '', 0, 1, 1, 0, 'single', '', '', 4, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('91f7cd9b59c0da033363f8a09b02ec96', '3d447fa919b64f6883a834036c14aa67', 'create_time', '创建日期', NULL, 0, 1, 'Date', 20, 0, '', '', '', '', 'datetime', '', 120, NULL, '0', '', '', 0, 0, 0, 0, 'single', '', '', 5, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('9bd056786694d67666f6924cc225b1a0', '3d447fa919b64f6883a834036c14aa67', 'id', '主键', NULL, 1, 0, 'string', 36, 0, '', '', '', '', 'text', '', 120, NULL, '0', '', '', 0, 0, 0, 0, 'single', '', '', 1, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `onl_cgform_field`(`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_value_rule_code`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`) VALUES ('c988bd2b6125c01ceb3579a207dd8784', '3d447fa919b64f6883a834036c14aa67', 'city', '', NULL, 0, 1, 'String', 100, 0, '', '', '', '', 'text', '', 120, NULL, '0', '', '', 0, 1, 1, 0, 'single', '', '', 3, 'admin', '2020-02-21 17:58:46', '2020-02-20 16:19:00', 'admin', NULL);
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769855347593217', '1230769769930592257', 'C区', NULL, 'admin', '2020-02-21 16:22:54', NULL, NULL, 'A01A03', NULL);
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769769930592257', '1230769253267836929', '淮南市', NULL, 'admin', '2020-02-21 16:22:34', 'admin', '2020-02-21 16:22:54', 'A01A03', '1');
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769620021972993', '1230769470889299970', 'B区', NULL, 'admin', '2020-02-21 16:21:58', NULL, NULL, 'A01A03', NULL);
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769547519234050', '1230769470889299970', 'A区', NULL, 'admin', '2020-02-21 16:21:41', NULL, NULL, 'A01A03', NULL);
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769470889299970', '1230769290609725441', '济南市', NULL, 'admin', '2020-02-21 16:21:23', 'admin', '2020-02-21 16:21:41', 'A01A03', '1');
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769407907631106', '1230769347157331969', '包河区', NULL, 'admin', '2020-02-21 16:21:08', NULL, NULL, 'A01A03', NULL);
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769347157331969', '1230769253267836929', '合肥市', NULL, 'admin', '2020-02-21 16:20:53', 'admin', '2020-02-21 16:21:08', 'A01A03', '1');
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769290609725441', '1230769196661510146', '山东省', NULL, 'admin', '2020-02-21 16:20:40', 'admin', '2020-02-21 16:21:23', 'A01A03', '1');
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769253267836929', '1230769196661510146', '安徽省', NULL, 'admin', '2020-02-21 16:20:31', 'admin', '2020-02-21 16:20:53', 'A01A03', '1');
INSERT INTO `sys_category`(`id`, `pid`, `name`, `code`, `create_by`, `create_time`, `update_by`, `update_time`, `sys_org_code`, `has_child`) VALUES ('1230769196661510146', '0', '', NULL, 'admin', '2020-02-21 16:20:16', 'admin', '2020-02-21 16:20:31', 'A01A03', '1');
INSERT INTO `sys_dict`(`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1232913193820581889', 'Online表单业务分类', 'ol_form_biz_type', '', 0, 'admin', '2020-02-27 14:19:46', 'admin', '2020-02-27 14:20:23', 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 ('1232913424813486081', '1232913193820581889', '官方示例', 'demo', '', 1, 1, 'admin', '2020-02-27 14:20:42', 'admin', '2020-02-27 14:21:37');
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 ('1232913493717512194', '1232913193820581889', '流程表单', 'bpm', '', 2, 1, 'admin', '2020-02-27 14:20:58', 'admin', '2020-02-27 14:22:20');
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 ('1232913605382467585', '1232913193820581889', '测试表单', 'temp', '', 4, 1, 'admin', '2020-02-27 14:21:25', 'admin', '2020-02-27 14:22:16');
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 ('1232914232372195330', '1232913193820581889', '导入表单', 'bdfl_include', '', 5, 1, 'admin', '2020-02-27 14:23:54', NULL, NULL);
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 ('1235823781053313025', 'e41b69c57a941a3bbcce45032fe57605', 'AUTO在线内嵌子表', '/online/cgformInnerTableList/:code', 'modules/online/cgform/auto/innerTable/OnlCgformInnerTableList', '1', NULL, NULL, '1', NULL, '1', '999', '0', NULL, '1', '0', '1', NULL, 'admin', '2020-03-06 15:05:24', 'admin', '2020-03-06 15:07:42', '0', '0', '1', '0');
DELETE from onl_cgreport_item where cgrhead_id not in (select id from onl_cgreport_head);
DELETE from onl_cgreport_param where cgrhead_id not in (select id from onl_cgreport_head);
ALTER TABLE `onl_cgform_field`
ADD COLUMN `query_def_val` varchar(50) NULL COMMENT '查询默认值' AFTER `converter`,
ADD COLUMN `query_dict_text` varchar(100) NULL COMMENT '查询配置字典text' AFTER `query_def_val`,
ADD COLUMN `query_dict_field` varchar(100) NULL COMMENT '查询配置字典code' AFTER `query_dict_text`,
ADD COLUMN `query_dict_table` varchar(500) NULL COMMENT '查询配置字典table' AFTER `query_dict_field`,
ADD COLUMN `query_show_type` varchar(50) NULL COMMENT '查询显示控件' AFTER `query_dict_table`,
ADD COLUMN `query_config_flag` varchar(3) NULL COMMENT '是否启用查询配置1是0否' AFTER `query_show_type`,
ADD COLUMN `query_valid_type` varchar(50) NULL COMMENT '查询字段校验类型' AFTER `query_config_flag`,
ADD COLUMN `query_must_input` varchar(3) NULL COMMENT '查询字段是否必填1是0否' AFTER `query_valid_type`,
ADD COLUMN `sort_flag` varchar(3) NULL COMMENT '是否支持排序1是0否' AFTER `query_must_input`;
UPDATE `onl_cgform_field` SET `field_value_rule_code` = CONCAT('${', field_value_rule_code, '}') WHERE field_value_rule_code IS NOT NULL AND field_value_rule_code != '';
ALTER TABLE `onl_cgform_field`
CHANGE COLUMN `field_value_rule_code` `field_default_value` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '控件默认值,不同的表达式展示不同的结果。\r\n1. 纯字符串直接赋给默认值;\r\n2. #{普通变量}\r\n3. {{ 动态JS表达式 }}\r\n4. ${填值规则编码}\r\n填值规则表达式只允许存在一个且不能和其他规则混用。' AFTER `field_extend_json`;
INSERT INTO `onl_cgform_head` (`id`, `table_name`, `table_type`, `table_version`, `table_txt`, `is_checkbox`, `is_db_synch`, `is_page`, `is_tree`, `id_sequence`, `id_type`, `query_mode`, `relation_type`, `sub_table_str`, `tab_order_num`, `tree_parent_id_field`, `tree_id_field`, `tree_fieldname`, `form_category`, `form_template`, `form_template_mobile`, `scroll`, `copy_version`, `copy_type`, `physic_id`, `update_by`, `update_time`, `create_by`, `create_time`, `theme_template`) VALUES ('4adec929a6594108bef5b35ee9966e9f', 'demo_field_def_val_main', '2', '1', '示例:控件默认值(主表)', 'Y', 'N', 'Y', 'N', NULL, 'UUID', 'single', NULL, 'demo_field_def_val_sub', NULL, NULL, NULL, NULL, 'demo', '1', NULL, '1', NULL, '0', NULL, 'admin', '2020-04-10 19:51:27', 'admin', '2020-04-10 19:35:57', 'normal');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('101a73df0aa5199ac05c4ce92a4f0e3e', '4adec929a6594108bef5b35ee9966e9f', 'name', '姓名', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '#{sysUserCode}', '0', '1', '1', '0', 'single', '', '', '3', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('4c4f4067fa31737f3ff9e088130ef793', '4adec929a6594108bef5b35ee9966e9f', 'sex', '性别', NULL, '0', '1', 'String', '200', '0', '', 'sex', '', '', 'list', '', '120', NULL, '0', '', '{{ 2 }}', '0', '1', '1', '0', 'single', '', '', '4', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('5f5ac4d37fd1a3a09e2b19f0d4d99c0f', '4adec929a6594108bef5b35ee9966e9f', 'code', '编码', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '${order_num_rule_param}', '0', '1', '1', '0', 'single', '', '', '2', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('7b4c181e4ebd76022f75535ed6fd9de3', '4adec929a6594108bef5b35ee9966e9f', 'update_time', '更新日期', NULL, '0', '1', 'Date', '20', '0', '', '', '', '', 'datetime', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '10', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('8e080f4ded1e3b2a1daa5b11eca4a0ff', '4adec929a6594108bef5b35ee9966e9f', 'create_by', '创建人', NULL, '0', '1', 'string', '50', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '7', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('951c51699d728072d88196d30f7aad10', '4adec929a6594108bef5b35ee9966e9f', 'address', '地址', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '{{ demoFieldDefVal_getAddress() }}', '0', '1', '1', '0', 'single', '', '', '5', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('9ceff249ef81ca6fa145456667c89051', '4adec929a6594108bef5b35ee9966e9f', 'create_time', '创建日期', NULL, '0', '1', 'Date', '20', '0', '', '', '', '', 'datetime', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '8', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('c0c80f370e1d400fe670d8702c3b84da', '4adec929a6594108bef5b35ee9966e9f', 'address_param', '地址(传参)', NULL, '0', '1', 'String', '32', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '{{ demoFieldDefVal_getAddress(\"昌平区\") }}', '0', '1', '1', '0', 'single', '', '', '6', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:40:53', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('c2b9eae184afe56d59ea7940d77cfced', '4adec929a6594108bef5b35ee9966e9f', 'id', '主键', NULL, '1', '0', 'string', '36', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '1', 'single', '', '', '1', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:57', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('df58a7b1c3ed8f58a1994c0c0855db16', '4adec929a6594108bef5b35ee9966e9f', 'sys_org_code', '所属部门', NULL, '0', '1', 'string', '64', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '11', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('fed133a00f57245d4cfb02dd3c3ce7c1', '4adec929a6594108bef5b35ee9966e9f', 'update_by', '更新人', NULL, '0', '1', 'string', '50', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '9', 'admin', '2020-04-10 19:43:38', '2020-04-10 19:35:58', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
-- 主表JS增强
INSERT INTO `onl_cgform_enhance_js` (`ID`, `CG_JS`, `CG_JS_TYPE`, `CONTENT`, `CGFORM_HEAD_ID`) VALUES ('44cad4eec436328ed3cc134855f8d1d5', ' onlChange(){\n   return {\n   name(that, event) {\n that.executeMainFillRule()\n }\n }\n }', 'form', NULL, '4adec929a6594108bef5b35ee9966e9f');
-- 控件默认值示例:子表
INSERT INTO `onl_cgform_head` (`id`, `table_name`, `table_type`, `table_version`, `table_txt`, `is_checkbox`, `is_db_synch`, `is_page`, `is_tree`, `id_sequence`, `id_type`, `query_mode`, `relation_type`, `sub_table_str`, `tab_order_num`, `tree_parent_id_field`, `tree_id_field`, `tree_fieldname`, `form_category`, `form_template`, `form_template_mobile`, `scroll`, `copy_version`, `copy_type`, `physic_id`, `update_by`, `update_time`, `create_by`, `create_time`, `theme_template`) VALUES ('4fb8e12a697f4d5bbe9b9fb1e9009486', 'demo_field_def_val_sub', '3', '1', '示例:控件默认值(子表)', 'Y', 'N', 'Y', 'N', NULL, 'UUID', 'single', '0', NULL, '1', NULL, NULL, NULL, 'demo', '1', NULL, '1', NULL, '0', NULL, 'admin', '2020-04-10 19:51:31', 'admin', '2020-04-10 19:47:01', 'normal');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('0a453a63e33654aa1b9ee2affa854a6d', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'create_by', '创建人', NULL, '0', '1', 'string', '50', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '6', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('1d95bdf1120c5a1776df022d0a571f21', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'create_time', '创建日期', NULL, '0', '1', 'Date', '20', '0', '', '', '', '', 'datetime', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '7', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('2e6f741fa96a49a0adccc7b4682c1cef', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'name', '名称', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '#{sysUserName}', '0', '1', '1', '0', 'single', '', '', '3', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('6a0082c8ffbae092e99689520f1c83f7', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'update_time', '更新日期', NULL, '0', '1', 'Date', '20', '0', '', '', '', '', 'datetime', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '9', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('6e5c9d8e8b7eb6980ec246cb813b180b', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'sys_org_code', '所属部门', NULL, '0', '1', 'string', '64', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '10', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('9341a3b2a734d8c73455c136e1cac8ad', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'update_by', '更新人', NULL, '0', '1', 'string', '50', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', '', '', '8', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', 'text', '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('bef85fd2846dd7ffc42d747095557d14', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'date', '日期', NULL, '0', '1', 'string', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '#{date}', '0', '1', '1', '0', 'single', '', '', '4', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('c382877700a9987f4bcc2deea9ee9daf', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'id', '主键', NULL, '1', '0', 'string', '36', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '1', 'single', '', '', '1', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('d44b89cc5f1828f7ceb9be196d549665', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'code', '编码', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '${order_num_rule_param}', '0', '1', '1', '0', 'single', '', '', '2', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:01', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
INSERT INTO `onl_cgform_field` (`id`, `cgform_head_id`, `db_field_name`, `db_field_txt`, `db_field_name_old`, `db_is_key`, `db_is_null`, `db_type`, `db_length`, `db_point_length`, `db_default_val`, `dict_field`, `dict_table`, `dict_text`, `field_show_type`, `field_href`, `field_length`, `field_valid_type`, `field_must_input`, `field_extend_json`, `field_default_value`, `is_query`, `is_show_form`, `is_show_list`, `is_read_only`, `query_mode`, `main_table`, `main_field`, `order_num`, `update_by`, `update_time`, `create_time`, `create_by`, `converter`, `query_def_val`, `query_dict_text`, `query_dict_field`, `query_dict_table`, `query_show_type`, `query_config_flag`, `query_valid_type`, `query_must_input`, `sort_flag`) VALUES ('faaaca21b7b2b16089c885f3224e4dc5', '4fb8e12a697f4d5bbe9b9fb1e9009486', 'main_id', '主表ID', NULL, '0', '1', 'String', '200', '0', '', '', '', '', 'text', '', '120', NULL, '0', '', '', '0', '0', '0', '0', 'single', 'demo_field_def_val_main', 'id', '5', 'admin', '2020-04-10 19:51:27', '2020-04-10 19:47:55', 'admin', '', '', '', '', '', NULL, '0', NULL, NULL, '0');
ALTER TABLE `onl_cgform_index`
ADD COLUMN `is_db_synch` varchar(2) NULL DEFAULT 'N' COMMENT '是否同步数据库 N未同步 Y已同步' AFTER `update_time`,
ADD COLUMN `del_flag` int(1) NULL DEFAULT 0 COMMENT '是否删除 0未删除 1删除' AFTER `is_db_synch`;
ALTER TABLE `onl_cgform_button`
ADD COLUMN `OPT_POSITION` varchar(3) NULL COMMENT '按钮位置1侧面 2底部' AFTER `ORDER_NUM`;
update ONL_CGFORM_BUTTON SET OPT_POSITION = '2';
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 ('1234371726545010689', '4e4602b3e3686f0911384e188dc7efb4', '左模糊', 'LEFT_LIKE', '左模糊', 7.00, 1, 'admin', '2020-03-02 14:55:27', 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 ('1234371809495760898', '4e4602b3e3686f0911384e188dc7efb4', '右模糊', 'RIGHT_LIKE', '右模糊', 7.00, 1, 'admin', '2020-03-02 14:55:47', NULL, NULL);
-- 将空字符串改为null
UPDATE sys_user SET phone = NULL WHERE phone = '';
UPDATE sys_user SET email = NULL WHERE email = '';
ALTER TABLE `sys_user`
ADD UNIQUE INDEX `uniq_sys_user_username` (`username`) USING BTREE,
ADD UNIQUE INDEX `uniq_sys_user_phone` (`phone`) USING BTREE,
ADD UNIQUE INDEX `uniq_sys_user_email` (`email`) USING BTREE;
ALTER TABLE `sys_user`
ADD COLUMN `third_id` varchar(100) NULL COMMENT '第三方登录的唯一标识' AFTER `del_flag`;
ALTER TABLE `sys_user`
ADD COLUMN `third_type` varchar(100) NULL COMMENT '第三方类型' AFTER `third_id`;
INSERT INTO `sys_role` (`id`, `role_name`, `role_code`, `description`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('1169504891467464705', '第三方登录角色', 'third_role', '第三方登录角色', 'admin', '2019-09-05 14:57:49', 'admin', '2019-09-05 14:57:56');
ALTER TABLE `sys_category`
ADD UNIQUE INDEX `index_code`(`code`);
ALTER TABLE `sys_announcement`
ADD COLUMN `msg_abstract` text COMMENT '摘要' AFTER `user_ids`;
ALTER TABLE `sys_user`
CHANGE COLUMN `identity` `user_identity` tinyint(1) DEFAULT NULL COMMENT '身份1普通成员 2上级' AFTER `update_time`;
ALTER TABLE `sys_quartz_job`
ADD UNIQUE INDEX `uniq_job_class_name` USING BTREE (`job_class_name`) ;
ALTER TABLE `sys_position`
ADD UNIQUE INDEX `uniq_code` USING BTREE (`code`) ;
ALTER TABLE `sys_depart`
ADD UNIQUE INDEX `uniq_depart_org_code` USING BTREE (`org_code`) ;
update sys_permission set component = 'modules/online/desform/auto/AutoDesignDataListTable' where component = 'modules/online/desform/auto/AutoDesignDataForm'
ALTER TABLE `sys_depart`
MODIFY COLUMN `description` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述' AFTER `depart_order`;
INSERT INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`, `type`) VALUES ('1250687930947620866', '定时任务状态', 'quartz_status', '', '0', 'admin', '2020-04-16 15:30:14', '', 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 ('1250688147579228161', '1250687930947620866', '正常', '0', '', '1', '1', 'admin', '2020-04-16 15:31:05', '', 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 ('1250688201064992770', '1250687930947620866', '停止', '-1', '', '1', '1', 'admin', '2020-04-16 15:31:18', '', NULL);
UPDATE `sys_dict` SET `id`='1174511106530525185', `dict_name`='机构类型', `dict_code`='org_category', `description`='机构类型 1公司2部门 3岗位', `del_flag`='0', `create_by`='admin', `create_time`='2019-09-19 10:30:43', `update_by`=NULL, `update_time`=NULL, `type`='0' WHERE (`id`='1174511106530525185');
UPDATE `sys_dict_item` SET `id`='1174511197735665665', `dict_id`='1174511106530525185', `item_text`='公司', `item_value`='1', `description`='公司', `sort_order`='1', `status`='1', `create_by`='admin', `create_time`='2019-09-19 10:31:05', `update_by`=NULL, `update_time`=NULL WHERE (`id`='1174511197735665665');
UPDATE `sys_dict_item` SET `id`='1174511244036587521', `dict_id`='1174511106530525185', `item_text`='部门', `item_value`='2', `description`='部门', `sort_order`='1', `status`='1', `create_by`='admin', `create_time`='2019-09-19 10:31:16', `update_by`=NULL, `update_time`=NULL WHERE (`id`='1174511244036587521');
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 ('1174509082208395266', '1174511106530525185', '岗位', '3', '岗位', '1', '1', 'admin', '2019-09-19 10:31:16', '', NULL);
update SYS_PERMISSION set URL = '/account/settings/BaseSetting',COMPONENT_NAME='account-settings-base' where id = '1367a93f2c410b169faa7abcbad2f77c';
update SYS_PERMISSION set URL = '/account/settings/Index' where id = '6e73eb3c26099c191bf03852ee1310a1';

View File

@ -3,12 +3,11 @@
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.4</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.1.4</version>
<version>2.2.0</version>
</parent>
<repositories>

View File

@ -0,0 +1,18 @@
package org.jeecg.common.aspect.annotation;
import java.lang.annotation.*;
/**
* online请求拦截专用注解
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE,ElementType.METHOD})
@Documented
public @interface OnlineAuth {
/**
* 请求关键字在xxx/code之前的字符串
* @return
*/
String value();
}

View File

@ -43,4 +43,9 @@ public interface CacheConstant {
*/
public static final String TEST_DEMO_CACHE = "test:demo";
/**
* 字典信息缓存
*/
public static final String SYS_DYNAMICDB_CACHE = "sys:cache:dbconnect:dynamic:";
}

View File

@ -126,9 +126,9 @@ public interface CommonConstant {
/**
* 同步工作流引擎1同步0不同步
*/
public static final String ACT_SYNC_0 = "0";
public static final String ACT_SYNC_1 = "1";
public static final Integer ACT_SYNC_1 = 1;
public static final Integer ACT_SYNC_0 = 0;
/**
* 消息类型1:通知公告2:系统消息
*/
@ -142,7 +142,7 @@ public interface CommonConstant {
public static final Integer RULE_FLAG_1 = 1;
/**
* 是否用户已被冻结 1(解冻)正常 2冻结
* 是否用户已被冻结 1正常(解冻) 2冻结
*/
public static final Integer USER_UNFREEZE = 1;
public static final Integer USER_FREEZE = 2;
@ -204,9 +204,62 @@ public interface CommonConstant {
public static final String UPLOAD_TYPE_MINIO = "minio";
public static final String UPLOAD_TYPE_OSS = "alioss";
/**
* 文档上传自定义桶名称
*/
public static final String UPLOAD_CUSTOM_BUCKET = "eoafile";
/**
* 文档上传自定义路径
*/
public static final String UPLOAD_CUSTOM_PATH = "eoafile";
/**
* 文件外链接有效天数
*/
public static final Integer UPLOAD_EFFECTIVE_DAYS = 1;
/**
* 员工身份 1:普通员工 2:上级)
*/
public static final Integer USER_IDENTITY_1 = 1;
public static final Integer USER_IDENTITY_2 = 2;
/** sys_user 表 username 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_USERNAME = "uniq_sys_user_username";
/** sys_user 表 work_no 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_WORK_NO = "uniq_sys_user_work_no";
/** sys_user 表 phone 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_PHONE = "uniq_sys_user_phone";
/** sys_user 表 email 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_USER_EMAIL = "uniq_sys_user_email";
/** sys_quartz_job 表 job_class_name 唯一键索引 */
public static final String SQL_INDEX_UNIQ_JOB_CLASS_NAME = "uniq_job_class_name";
/** sys_position 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_CODE = "uniq_code";
/** sys_role 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_SYS_ROLE_CODE = "uniq_sys_role_role_code";
/** sys_depart 表 code 唯一键索引 */
public static final String SQL_INDEX_UNIQ_DEPART_ORG_CODE = "uniq_depart_org_code";
/**
* 在线聊天 是否为默认分组
*/
public static final String IM_DEFAULT_GROUP = "1";
/**
* 在线聊天 图片文件保存路径
*/
public static final String IM_UPLOAD_CUSTOM_PATH = "imfile";
/**
* 在线聊天 用户状态
*/
public static final String IM_STATUS_ONLINE = "online";
/**
* 在线聊天 SOCKET消息类型
*/
public static final String IM_SOCKET_TYPE = "chatMessage";
/**
* 考勤补卡业务状态 1同意 2不同意
*/
public static final String SIGN_PATCH_BIZ_STATUS_1 = "1";
public static final String SIGN_PATCH_BIZ_STATUS_2 = "2";
}

View File

@ -0,0 +1,25 @@
package org.jeecg.common.constant;
/**
* 规则值生成 编码常量类
* @author: taoyan
* @date: 2020年04月02日
*/
public class FillRuleConstant {
/**
* 公文发文编码
*/
public static final String DOC_SEND = "doc_send_code";
/**
* 部门编码
*/
public static final String DEPART = "org_num_role";
/**
* 分类字典编码
*/
public static final String CATEGORY = "category_code_rule";
}

View File

@ -0,0 +1,135 @@
package org.jeecg.common.constant;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Set;
import java.util.List;
@Component("pca")
public class ProvinceCityArea {
@Value("classpath:static/pca.json")
private Resource jsonData;
List<Area> areaList;
public String getText(String code){
this.initAreaList();
if(this.areaList!=null || this.areaList.size()>0){
List<String> ls = new ArrayList<String>();
getAreaByCode(code,ls);
return String.join("/",ls);
}
return "";
}
public String getCode(String text){
this.initAreaList();
if(areaList!=null || areaList.size()>0){
for(int i=areaList.size()-1;i>=0;i--){
if(text.indexOf(areaList.get(i).getText())>=0){
return areaList.get(i).getId();
}
}
}
return null;
}
public void getAreaByCode(String code,List<String> ls){
for(Area area: areaList){
if(area.getId().equals(code)){
String pid = area.getPid();
ls.add(0,area.getText());
getAreaByCode(pid,ls);
}
}
}
private void initAreaList(){
//System.out.println("=====================");
if(this.areaList==null || this.areaList.size()==0){
this.areaList = new ArrayList<Area>();
try {
File file = jsonData.getFile();
String jsonData = this.jsonRead(file);
JSONObject baseJson = JSONObject.parseObject(jsonData);
//第一层 省
JSONObject provinceJson = baseJson.getJSONObject("86");
for(String provinceKey: provinceJson.keySet()){
//System.out.println("===="+provinceKey);
Area province = new Area(provinceKey,provinceJson.getString(provinceKey),"86");
this.areaList.add(province);
//第二层 市
JSONObject cityJson = baseJson.getJSONObject(provinceKey);
for(String cityKey:cityJson.keySet()){
//System.out.println("-----"+cityKey);
Area city = new Area(cityKey,cityJson.getString(cityKey),provinceKey);
this.areaList.add(city);
//第三层 区
JSONObject areaJson = baseJson.getJSONObject(cityKey);
if(areaJson!=null){
for(String areaKey:areaJson.keySet()){
//System.out.println("········"+areaKey);
Area area = new Area(areaKey,areaJson.getString(areaKey),cityKey);
this.areaList.add(area);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
private String jsonRead(File file){
Scanner scanner = null;
StringBuilder buffer = new StringBuilder();
try {
scanner = new Scanner(file, "utf-8");
while (scanner.hasNextLine()) {
buffer.append(scanner.nextLine());
}
} catch (Exception e) {
} finally {
if (scanner != null) {
scanner.close();
}
}
return buffer.toString();
}
class Area{
String id;
String text;
String pid;
public Area(String id,String text,String pid){
this.id = id;
this.text = text;
this.pid = pid;
}
public String getId() {
return id;
}
public String getText() {
return text;
}
public String getPid() {
return pid;
}
}
}

View File

@ -0,0 +1,56 @@
package org.jeecg.common.constant;
/**
* @Description: Websocket常量类
* @author: taoyan
* @date: 2020年03月23日
*/
public class WebsocketConst {
/**
* 消息json key:cmd
*/
public static final String MSG_CMD = "cmd";
/**
* 消息json key:msgId
*/
public static final String MSG_ID = "msgId";
/**
* 消息json key:msgTxt
*/
public static final String MSG_TXT = "msgTxt";
/**
* 消息json key:userId
*/
public static final String MSG_USER_ID = "userId";
/**
* 消息类型 heartcheck
*/
public static final String CMD_CHECK = "heartcheck";
/**
* 消息类型 user 用户消息
*/
public static final String CMD_USER = "user";
/**
* 消息类型 topic 系统通知
*/
public static final String CMD_TOPIC = "topic";
/**
* 消息类型 email
*/
public static final String CMD_EMAIL = "email";
/**
* 消息类型 meetingsign 会议签到
*/
public static final String CMD_SIGN = "sign";
}

View File

@ -1,398 +1,481 @@
//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.jeecg.common.util.oConvertUtils;
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.*;
/**
* 关于 ElasticSearch 的一些方法(创建索引、添加数据、查询等)
*
* @author sunjianlei
*/
@Slf4j
@Component
public class JeecgElasticsearchTemplate {
/** es服务地址 */
private String baseUrl;
private final String FORMAT_JSON = "format=json";
// ElasticSearch 最大可返回条目数
public static final int ES_MAX_SIZE = 10000;
public JeecgElasticsearchTemplate(@Value("${jeecg.elasticsearch.cluster-nodes}") String baseUrl, @Value("${jeecg.elasticsearch.check-enabled}") boolean checkEnabled) {
log.debug("JeecgElasticsearchTemplate BaseURL" + baseUrl);
if (StringUtils.isNotEmpty(baseUrl)) {
this.baseUrl = baseUrl;
// 验证配置的ES地址是否有效
if (checkEnabled) {
try {
RestUtil.get(this.getBaseUrl().toString());
log.info("ElasticSearch 服务连接成功");
} catch (Exception e) {
log.warn("ElasticSearch 服务连接失败原因配置未通过。可能是BaseURL未配置或配置有误也可能是Elasticsearch服务未启动。接下来将会拒绝执行任何方法");
}
}
}
}
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) {
String url = this.getBaseUrl().append("/_cat").append(urlAfter).append("?").append(FORMAT_JSON).toString();
return RestUtil.request(url, HttpMethod.GET, null, null, null, responseType);
}
/**
* 查询所有索引
* <p>
* 查询地址GET http://{baseUrl}/_cat/indices
*/
public JSONArray getIndices() {
return getIndices(null);
}
/**
* 查询单个索引
* <p>
* 查询地址GET http://{baseUrl}/_cat/indices/{indexName}
*/
public JSONArray getIndices(String indexName) {
StringBuilder urlAfter = new StringBuilder("/indices");
if (!StringUtils.isEmpty(indexName)) {
urlAfter.append("/").append(indexName.trim().toLowerCase());
}
return _cat(urlAfter.toString(), JSONArray.class).getBody();
}
/**
* 索引是否存在
*/
public boolean indexExists(String indexName) {
try {
JSONArray array = getIndices(indexName);
return array != null;
} catch (org.springframework.web.client.HttpClientErrorException ex) {
if (HttpStatus.NOT_FOUND == ex.getStatusCode()) {
return false;
} else {
throw ex;
}
}
}
/**
* 根据ID获取索引数据未查询到返回null
* <p>
* 查询地址GET http://{baseUrl}/{indexName}/{typeName}/{dataId}
*
* @param indexName 索引名称
* @param typeName type一个任意字符串用于分类
* @param dataId 数据id
* @return
*/
public JSONObject getDataById(String indexName, String typeName, String dataId) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
log.info("url:" + url);
JSONObject result = RestUtil.get(url);
boolean found = result.getBoolean("found");
if (found) {
return result.getJSONObject("_source");
} else {
return null;
}
}
/**
* 创建索引
* <p>
* 查询地址PUT http://{baseUrl}/{indexName}
*/
public boolean createIndex(String indexName) {
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) {
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;
}
/**
* 获取索引字段映射(可获取字段类型)
* <p>
*
* @param indexName 索引名称
* @param typeName 分类名称
* @return
*/
public JSONObject getIndexMapping(String indexName, String typeName) {
String url = this.getBaseUrl(indexName, typeName).append("/_mapping?").append(FORMAT_JSON).toString();
log.info("getIndexMapping-url:" + url);
/*
* 参考返回JSON结构
*
*{
* // 索引名称
* "[indexName]": {
* "mappings": {
* // 分类名称
* "[typeName]": {
* "properties": {
* // 字段名
* "input_number": {
* // 字段类型
* "type": "long"
* },
* "input_string": {
* "type": "text",
* "fields": {
* "keyword": {
* "type": "keyword",
* "ignore_above": 256
* }
* }
* }
* }
* }
* }
* }
* }
*/
try {
return RestUtil.get(url);
} catch (org.springframework.web.client.HttpClientErrorException e) {
String message = e.getMessage();
if (message != null && message.contains("404 Not Found")) {
return null;
}
throw e;
}
}
/**
* 获取索引字段映射返回Java实体类
*
* @param indexName
* @param typeName
* @return
*/
public <T> Map<String, T> getIndexMappingFormat(String indexName, String typeName, Class<T> clazz) {
JSONObject mapping = this.getIndexMapping(indexName, typeName);
Map<String, T> map = new HashMap<>();
if (mapping == null) {
return map;
}
// 获取字段属性
JSONObject properties = mapping.getJSONObject(indexName)
.getJSONObject("mappings")
.getJSONObject(typeName)
.getJSONObject("properties");
// 封装成 java类型
for (String key : properties.keySet()) {
T entity = properties.getJSONObject(key).toJavaObject(clazz);
map.put(key, entity);
}
return map;
}
/**
* 保存数据详见saveOrUpdate
*/
public boolean save(String indexName, String typeName, String dataId, JSONObject data) {
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
/**
* 更新数据详见saveOrUpdate
*/
public boolean update(String indexName, String typeName, String dataId, JSONObject data) {
return this.saveOrUpdate(indexName, typeName, dataId, data);
}
/**
* 保存或修改索引数据
* <p>
* 查询地址PUT http://{baseUrl}/{indexName}/{typeName}/{dataId}
*
* @param indexName 索引名称
* @param typeName type一个任意字符串用于分类
* @param dataId 数据id
* @param data 要存储的数据
* @return
*/
public boolean saveOrUpdate(String indexName, String typeName, String dataId, JSONObject data) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).append("?refresh=wait_for").toString();
/* 返回结果(仅供参考)
"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);
//1、剔除空值
if (oConvertUtils.isEmpty(value) || "[]".equals(value)) {
emptyKeys.add(key);
}
//2、剔除上传控件值(会导致ES同步失败报异常failed to parse field [ge_pic] of type [text] )
if (oConvertUtils.isNotEmpty(value) && value.indexOf("[{")!=-1) {
emptyKeys.add(key);
log.info("-------剔除上传控件字段------------key: "+ key);
}
}
for (String key : emptyKeys) {
data.remove(key);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
String result = RestUtil.put(url, data).getString("result");
return "created".equals(result) || "updated".equals(result);
} catch (Exception e) {
log.error(e.getMessage() + "\n-- url: " + url + "\n-- data: " + data.toJSONString());
//TODO 打印接口返回异常json
return false;
}
}
/**
* 删除索引数据
* <p>
* 请求地址DELETE http://{baseUrl}/{indexName}/{typeName}/{dataId}
*/
public boolean delete(String indexName, String typeName, String dataId) {
String url = this.getBaseUrl(indexName, typeName).append("/").append(dataId).toString();
/* 返回结果(仅供参考)
{
"_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) {
String url = this.getBaseUrl(indexName, typeName).append("/_search").toString();
log.info("url:" + url + " ,search: " + queryObject.toJSONString());
JSONObject res = RestUtil.post(url, queryObject);
log.info("url:" + url + " ,return res: \n" + res.toJSONString());
return res;
}
/**
* @param _source 源滤波器指定返回的字段传null返回所有字段
* @param query
* @param from 从第几条数据开始
* @param size 返回条目数
* @return { "query": query }
*/
public JSONObject buildQuery(List<String> _source, JSONObject query, int from, int size) {
JSONObject json = new JSONObject();
if (_source != null) {
json.put("_source", _source);
}
json.put("query", query);
json.put("from", from);
json.put("size", size);
return json;
}
/**
* @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;
}
}

View File

@ -9,22 +9,84 @@ public class QueryStringBuilder {
StringBuilder builder;
public QueryStringBuilder(String field, String str) {
builder = new StringBuilder(field).append(":(").append(str);
public QueryStringBuilder(String field, String str, boolean not, boolean addQuot) {
builder = this.createBuilder(field, str, not, addQuot);
}
public QueryStringBuilder(String field, String str, boolean not) {
builder = this.createBuilder(field, str, not, true);
}
/**
* 创建 StringBuilder
*
* @param field
* @param str
* @param not 是否是不匹配
* @param addQuot 是否添加双引号
* @return
*/
public StringBuilder createBuilder(String field, String str, boolean not, boolean addQuot) {
StringBuilder sb = new StringBuilder(field).append(":(");
if (not) {
sb.append(" NOT ");
}
this.addQuotEffect(sb, str, addQuot);
return sb;
}
public QueryStringBuilder and(String str) {
builder.append(" AND ").append(str);
return this.and(str, true);
}
public QueryStringBuilder and(String str, boolean addQuot) {
builder.append(" AND ");
this.addQuot(str, addQuot);
return this;
}
public QueryStringBuilder or(String str) {
builder.append(" OR ").append(str);
return this.or(str, true);
}
public QueryStringBuilder or(String str, boolean addQuot) {
builder.append(" OR ");
this.addQuot(str, addQuot);
return this;
}
public QueryStringBuilder not(String str) {
builder.append(" NOT ").append(str);
return this.not(str, true);
}
public QueryStringBuilder not(String str, boolean addQuot) {
builder.append(" NOT ");
this.addQuot(str, addQuot);
return this;
}
/**
* 添加双引号(模糊查询,不能加双引号)
*/
private QueryStringBuilder addQuot(String str, boolean addQuot) {
return this.addQuotEffect(this.builder, str, addQuot);
}
/**
* 是否在两边加上双引号
* @param builder
* @param str
* @param addQuot
* @return
*/
private QueryStringBuilder addQuotEffect(StringBuilder builder, String str, boolean addQuot) {
if (addQuot) {
builder.append('"');
}
builder.append(str);
if (addQuot) {
builder.append('"');
}
return this;
}

View File

@ -5,9 +5,12 @@ import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.jeecg.common.system.vo.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* @Description: 底层共通业务API提供其他独立模块调用
* @Author: scott
@ -96,7 +99,13 @@ public interface ISysBaseAPI {
* @return
*/
public List<DictModel> queryAllDepartBackDictModel();
/**
* 查询所有部门,拼接查询条件
* @return
*/
List<JSONObject> queryAllDepart(Wrapper wrapper);
/**
* 发送系统消息
* @param fromUser 发送人(用户登录账户)
@ -184,6 +193,7 @@ public interface ISysBaseAPI {
* @param keyArray
* @return
*/
@Deprecated
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray);
/**
@ -199,6 +209,13 @@ public interface ISysBaseAPI {
*/
public JSONObject queryAllUser(String[] userIds, int pageNo, int pageSize);
/**
* 获取所有有效用户 拼接查询条件
*
* @return
*/
List<JSONObject> queryAllUser(Wrapper wrapper);
/**
* 获取所有角色
* @return
@ -271,4 +288,49 @@ public interface ISysBaseAPI {
*/
public String upload(MultipartFile file,String bizPath,String uploadType);
/**
* 文件上传 自定义桶
* @param file
* @param bizPath
* @param uploadType
* @param customBucket
* @return
*/
public String upload(MultipartFile file,String bizPath,String uploadType,String customBucket);
/**
* 文档管理文件下载预览
* @param filePath
* @param uploadpath
* @param response
*/
public void viewAndDownload(String filePath, String uploadpath, String uploadType,HttpServletResponse response);
/**
* 给指定用户发消息
* @param userIds
* @param cmd
*/
public void sendWebSocketMsg(String[] userIds, String cmd);
/**
* 根据id获取所有参与用户
* userIds
* @return
*/
public List<LoginUser> queryAllUserByIds(String[] userIds);
/**
* 将会议签到信息推动到预览
* userIds
* @return
* @param userId
*/
void meetingSignWebsocket(String userId);
/**
* 根据name获取所有参与用户
* userNames
* @return
*/
List<LoginUser> queryUserByNames(String[] userNames);
}

View File

@ -1,21 +1,11 @@
package org.jeecg.common.system.base.controller;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecg.common.system.base.service.JeecgService;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
@ -29,9 +19,13 @@ import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description: Controller基类

View File

@ -1,35 +1,34 @@
package org.jeecg.common.system.controller;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.RestUtil;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.GetMapping;
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.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLDecoder;
/**
* <p>
@ -80,15 +79,25 @@ public class CommonController {
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
if(oConvertUtils.isEmpty(bizPath)){
if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
result.setMessage("使用阿里云文件上传时,必须添加目录!");
result.setSuccess(false);
return result;
//未指定目录,则用阿里云默认目录 upload
bizPath = "upload";
//result.setMessage("使用阿里云文件上传时,必须添加目录!");
//result.setSuccess(false);
//return result;
}else{
bizPath = "";
}
}
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
savePath = this.uploadLocal(file,bizPath);
//针对jeditor编辑器如何使 lcaol模式采用 base64格式存储
String jeditor = request.getParameter("jeditor");
if(oConvertUtils.isNotEmpty(jeditor)){
result.setMessage(CommonConstant.UPLOAD_TYPE_LOCAL);
result.setSuccess(true);
return result;
}else{
savePath = this.uploadLocal(file,bizPath);
}
}else{
savePath = sysBaseAPI.upload(file,bizPath,uploadType);
}
@ -117,7 +126,12 @@ public class CommonController {
file.mkdirs();// 创建文件根目录
}
String orgName = mf.getOriginalFilename();// 获取文件名
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
orgName = CommonUtils.getFileName(orgName);
if(orgName.indexOf(".")!=-1){
fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
}else{
fileName = orgName+ "_" + System.currentTimeMillis();
}
String savePath = file.getPath() + File.separator + fileName;
File savefile = new File(savePath);
FileCopyUtils.copy(mf.getBytes(), savefile);
@ -185,6 +199,9 @@ public class CommonController {
public void view(HttpServletRequest request, HttpServletResponse response) {
// ISO-8859-1 ==> UTF-8 进行编码转换
String imgPath = extractPathFromPattern(request);
if(oConvertUtils.isEmpty(imgPath) || imgPath=="null"){
return;
}
// 其余处理略
InputStream inputStream = null;
OutputStream outputStream = null;
@ -194,8 +211,11 @@ public class CommonController {
imgPath = imgPath.substring(0, imgPath.length() - 1);
}
String filePath = uploadpath + File.separator + imgPath;
String downloadFilePath = uploadpath + File.separator + filePath;
File file = new File(downloadFilePath);
File file = new File(filePath);
if(!file.exists()){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
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));
@ -208,7 +228,8 @@ public class CommonController {
response.flushBuffer();
} catch (IOException e) {
log.error("预览文件失败" + e.getMessage());
// e.printStackTrace();
response.setStatus(404);
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
@ -309,4 +330,53 @@ public class CommonController {
return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path);
}
/**
* 中转HTTP请求解决跨域问题
*
* @param url 必填:请求地址
* @return
*/
@RequestMapping("/transitRESTful")
public Result transitRESTful(@RequestParam("url") String url, HttpServletRequest request) {
try {
ServletServerHttpRequest httpRequest = new ServletServerHttpRequest(request);
// 中转请求method、body
HttpMethod method = httpRequest.getMethod();
JSONObject params;
try {
params = JSON.parseObject(JSON.toJSONString(httpRequest.getBody()));
} catch (Exception e) {
params = new JSONObject();
}
// 中转请求问号参数
JSONObject variables = JSON.parseObject(JSON.toJSONString(request.getParameterMap()));
variables.remove("url");
// 在 headers 里传递Token
String token = TokenUtils.getTokenByRequest(request);
HttpHeaders headers = new HttpHeaders();
headers.set("X-Access-Token", token);
// 发送请求
String httpURL = URLDecoder.decode(url, "UTF-8");
ResponseEntity<String> response = RestUtil.request(httpURL, method, headers , variables, params, String.class);
// 封装返回结果
Result<Object> result = new Result<>();
int statusCode = response.getStatusCodeValue();
result.setCode(statusCode);
result.setSuccess(statusCode == 200);
String responseBody = response.getBody();
try {
// 尝试将返回结果转为JSON
Object json = JSON.parse(responseBody);
result.setResult(json);
} catch (Exception e) {
// 转成JSON失败直接返回原始数据
result.setResult(responseBody);
}
return result;
} catch (Exception e) {
log.debug("中转HTTP请求失败", e);
return Result.error(e.getMessage());
}
}
}

View File

@ -1,20 +1,8 @@
package org.jeecg.common.system.query;
import java.beans.PropertyDescriptor;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.PropertyUtils;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.DataBaseConstant;
@ -22,15 +10,21 @@ import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JeecgDataAutorUtils;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecgframework.core.util.ApplicationContextUtil;
import org.springframework.util.NumberUtils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import java.beans.PropertyDescriptor;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
public class QueryGenerator {
@ -38,6 +32,10 @@ public class QueryGenerator {
private static final String BEGIN = "_begin";
private static final String END = "_end";
/**
* 数字类型字段,拼接此后缀 接受多值参数
*/
private static final String MULTI = "_MultiString";
private static final String STAR = "*";
private static final String COMMA = ",";
private static final String NOT_EQUAL = "!";
@ -45,7 +43,10 @@ public class QueryGenerator {
private static final String QUERY_SEPARATE_KEYWORD = " ";
/**高级查询前端传来的参数名*/
private static final String SUPER_QUERY_PARAMS = "superQueryParams";
/** 高级查询前端传来的拼接方式参数名 */
private static final String SUPER_QUERY_MATCH_TYPE = "superQueryMatchType";
/** 单引号 */
public static final String SQL_SQ = "'";
/**排序列*/
private static final String ORDER_COLUMN = "column";
/**排序方式*/
@ -131,7 +132,12 @@ public class QueryGenerator {
endValue = parameterMap.get(name + END)[0].trim();
addQueryByRule(queryWrapper, name, type, endValue, QueryRuleEnum.LE);
}
//多值查询
if (parameterMap != null && parameterMap.containsKey(name + MULTI)) {
endValue = parameterMap.get(name + MULTI)[0].trim();
addQueryByRule(queryWrapper, name.replace(MULTI,""), type, endValue, QueryRuleEnum.IN);
}
//判断单值 参数带不同标识字符串 走不同的查询
//TODO 这种前后带逗号的支持分割后模糊查询需要否 使多选字段的查询生效
Object value = PropertyUtils.getSimpleProperty(searchObj, name);
@ -209,21 +215,43 @@ public class QueryGenerator {
public static void doSuperQuery(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap) {
if(parameterMap!=null&& parameterMap.containsKey(SUPER_QUERY_PARAMS)){
String superQueryParams = parameterMap.get(SUPER_QUERY_PARAMS)[0];
// 解码
try {
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("--高级查询参数转码失败!", e);
}
List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
log.info("---高级查询参数-->"+conditions.toString());
for (QueryCondition rule : conditions) {
if(oConvertUtils.isNotEmpty(rule.getField()) && oConvertUtils.isNotEmpty(rule.getRule()) && oConvertUtils.isNotEmpty(rule.getVal())){
addEasyQuery(queryWrapper, rule.getField(), QueryRuleEnum.getByValue(rule.getRule()), rule.getVal());
}
}
String superQueryMatchType = parameterMap.get(SUPER_QUERY_MATCH_TYPE) != null ? parameterMap.get(SUPER_QUERY_MATCH_TYPE)[0] : MatchTypeEnum.AND.getValue();
MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
// update-begin--Author:sunjianlei Date:20200325 for高级查询的条件要用括号括起来防止和用户的其他条件冲突 -------
try {
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
if (conditions == null || conditions.size() == 0) {
return;
}
log.info("---高级查询参数-->" + conditions.toString());
queryWrapper.and(andWrapper -> {
for (int i = 0; i < conditions.size(); i++) {
QueryCondition rule = conditions.get(i);
if (oConvertUtils.isNotEmpty(rule.getField())
&& oConvertUtils.isNotEmpty(rule.getRule())
&& oConvertUtils.isNotEmpty(rule.getVal())) {
log.debug("SuperQuery ==> " + rule.toString());
addEasyQuery(andWrapper, rule.getField(), QueryRuleEnum.getByValue(rule.getRule()), rule.getVal());
// 如果拼接方式是OR就拼接OR
if (MatchTypeEnum.OR == matchType && i < (conditions.size() - 1)) {
andWrapper.or();
}
}
}
return andWrapper;
});
} catch (UnsupportedEncodingException e) {
log.error("--高级查询参数转码失败:" + superQueryParams, e);
} catch (Exception e) {
log.error("--高级查询拼接失败:" + e.getMessage());
e.printStackTrace();
}
// update-end--Author:sunjianlei Date:20200325 for高级查询的条件要用括号括起来防止和用户的其他条件冲突 -------
}
//log.info(" superQuery getCustomSqlSegment: "+ queryWrapper.getCustomSqlSegment());
}
/**
* 根据所传的值 转化成对应的比较方式
@ -319,6 +347,13 @@ public class QueryGenerator {
private static void addQueryByRule(QueryWrapper<?> queryWrapper,String name,String type,String value,QueryRuleEnum rule) throws ParseException {
if(oConvertUtils.isNotEmpty(value)) {
Object temp;
// 针对数字类型字段,多值查询
if(value.indexOf(COMMA)!=-1){
temp = value;
addEasyQuery(queryWrapper, name, rule, temp);
return;
}
switch (type) {
case "class java.lang.Integer":
temp = Integer.parseInt(value);
@ -476,7 +511,14 @@ public class QueryGenerator {
}else {
if (propertyType.equals(String.class)) {
addEasyQuery(queryWrapper, name, rule, converRuleValue(dataRule.getRuleValue()));
} else {
}else if (propertyType.equals(Date.class)) {
String dateStr =converRuleValue(dataRule.getRuleValue());
if(dateStr.length()==10){
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.date_sdf.get()));
}else{
addEasyQuery(queryWrapper, name, rule, DateUtils.str2Date(dateStr,DateUtils.datetimeFormat.get()));
}
}else {
addEasyQuery(queryWrapper, name, rule, NumberUtils.parseNumber(dataRule.getRuleValue(), propertyType));
}
}
@ -489,6 +531,26 @@ public class QueryGenerator {
}
return value!= null ? value : ruleValue;
}
/**
* @author: scott
* @Description: 去掉值前后单引号
* @date: 2020/3/19 21:26
* @param ruleValue:
* @Return: java.lang.String
*/
public static String trimSingleQuote(String ruleValue) {
if (oConvertUtils.isEmpty(ruleValue)) {
return "";
}
if (ruleValue.startsWith(QueryGenerator.SQL_SQ)) {
ruleValue = ruleValue.substring(1);
}
if (ruleValue.endsWith(QueryGenerator.SQL_SQ)) {
ruleValue = ruleValue.substring(0, ruleValue.length() - 1);
}
return ruleValue;
}
public static String getSqlRuleValue(String sqlRule){
try {
@ -642,9 +704,17 @@ public class QueryGenerator {
}else {
if(str.indexOf("%")>=0) {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
return "N"+str;
if(str.startsWith("'") && str.endsWith("'")){
return "N"+str;
}else{
return "N"+"'"+str+"'";
}
}else{
return str;
if(str.startsWith("'") && str.endsWith("'")){
return str;
}else{
return "'"+str+"'";
}
}
}else {
if(DataBaseConstant.DB_TYPE_SQLSERVER.equals(getDbType())){
@ -726,6 +796,50 @@ public class QueryGenerator {
}
}
/**
* 转换sql中的系统变量
* @param sql
* @return
*/
public static String convertSystemVariables(String sql){
return getSqlRuleValue(sql);
}
/**
* 获取所有配置的权限 返回sql字符串 不受字段限制 配置什么就拿到什么
* @return
*/
public static String getAllConfigAuth() {
StringBuffer sb = new StringBuffer();
//权限查询
Map<String,SysPermissionDataRuleModel> ruleMap = getRuleMap();
String sql_and = " and ";
for (String c : ruleMap.keySet()) {
SysPermissionDataRuleModel dataRule = ruleMap.get(c);
String ruleValue = dataRule.getRuleValue();
if(oConvertUtils.isEmpty(ruleValue)){
continue;
}
if(oConvertUtils.isNotEmpty(c) && c.startsWith(SQL_RULES_COLUMN)){
sb.append(sql_and+getSqlRuleValue(ruleValue));
}else{
boolean isString = false;
ruleValue = ruleValue.trim();
if(ruleValue.startsWith("'") && ruleValue.endsWith("'")){
isString = true;
ruleValue = ruleValue.substring(1,ruleValue.length()-1);
}
QueryRuleEnum rule = QueryRuleEnum.getByValue(dataRule.getRuleConditions());
String value = converRuleValue(ruleValue);
String filedSql = getSingleSqlByRule(rule, c, value,isString);
sb.append(sql_and+filedSql);
}
}
log.info("query auth sql is = "+sb.toString());
return sb.toString();
}
/** 当前系统数据库类型 */
private static String DB_TYPE;

View File

@ -147,7 +147,7 @@ public class JwtUtil {
key = key;
}
//替换为系统登录用户帐号
if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
if (key.equals(DataBaseConstant.SYS_USER_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_CODE_TABLE)) {
if(user==null) {
returnValue = sysUser.getUsername();
}else {
@ -155,7 +155,7 @@ public class JwtUtil {
}
}
//替换为系统登录用户真实名字
else if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
else if (key.equals(DataBaseConstant.SYS_USER_NAME)|| key.toLowerCase().equals(DataBaseConstant.SYS_USER_NAME_TABLE)) {
if(user==null) {
returnValue = sysUser.getRealname();
}else {
@ -164,7 +164,7 @@ public class JwtUtil {
}
//替换为系统用户登录所使用的机构编码
else if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
else if (key.equals(DataBaseConstant.SYS_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_ORG_CODE_TABLE)) {
if(user==null) {
returnValue = sysUser.getOrgCode();
}else {
@ -172,7 +172,7 @@ public class JwtUtil {
}
}
//替换为系统用户所拥有的所有机构编码
else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
else if (key.equals(DataBaseConstant.SYS_MULTI_ORG_CODE)|| key.toLowerCase().equals(DataBaseConstant.SYS_MULTI_ORG_CODE_TABLE)) {
if(user.isOneDepart()) {
returnValue = user.getSysMultiOrgCode().get(0);
}else {
@ -180,15 +180,15 @@ public class JwtUtil {
}
}
//替换为当前系统时间(年月日)
else if (key.equals(DataBaseConstant.SYS_DATE)|| key.equals(DataBaseConstant.SYS_DATE_TABLE)) {
else if (key.equals(DataBaseConstant.SYS_DATE)|| key.toLowerCase().equals(DataBaseConstant.SYS_DATE_TABLE)) {
returnValue = user.getSysDate();
}
//替换为当前系统时间(年月日时分秒)
else if (key.equals(DataBaseConstant.SYS_TIME)|| key.equals(DataBaseConstant.SYS_TIME_TABLE)) {
else if (key.equals(DataBaseConstant.SYS_TIME)|| key.toLowerCase().equals(DataBaseConstant.SYS_TIME_TABLE)) {
returnValue = user.getSysTime();
}
//流程状态默认值(默认未发起)
else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.equals(DataBaseConstant.BPM_STATUS_TABLE)) {
else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1";
}
if(returnValue!=null){returnValue = returnValue + moshi;}

View File

@ -0,0 +1,34 @@
package org.jeecg.common.system.vo;
import lombok.Data;
/**
* 字典查询参数实体
*/
@Data
public class DictQuery {
/**
* 表名
*/
private String table;
/**
* 存储列
*/
private String code;
/**
* 显示列
*/
private String text;
/**
* 关键字查询
*/
private String keyword;
/**
* 存储列的值 用于回显查询
*/
private String codeValue;
}

View File

@ -79,11 +79,11 @@ public class LoginUser {
*/
private Integer status;
private String delFlag;
private Integer delFlag;
/**
* 同步工作流引擎1同步0不同步
*/
private String activitiSync;
private Integer activitiSync;
/**
* 创建时间
@ -93,11 +93,21 @@ public class LoginUser {
/**
* 身份1 普通员工 2 上级)
*/
private Integer identity;
private Integer userIdentity;
/**
* 管理部门ids
*/
private String departIds;
/**
* 职务,关联职务表
*/
private String post;
/**
* 座机号
*/
private String telephone;
}

View File

@ -17,7 +17,7 @@ public class SysDepartModel {
/**排序*/
private Integer departOrder;
/**描述*/
private Object description;
private String description;
/**机构类别 1组织机构2岗位*/
private String orgCategory;
/**机构类型*/
@ -81,11 +81,11 @@ public class SysDepartModel {
this.departOrder = departOrder;
}
public Object getDescription() {
public String getDescription() {
return description;
}
public void setDescription(Object description) {
public void setDescription(String description) {
this.description = description;
}

View File

@ -191,4 +191,16 @@ public class BrowserUtils {
return browserLangCode;
}
/** 判断请求是否来自电脑端 */
public static boolean isDesktop(HttpServletRequest request) {
return !isMobile(request);
}
/** 判断请求是否来自移动端 */
public static boolean isMobile(HttpServletRequest request) {
String ua = request.getHeader("User-Agent").toLowerCase();
Pattern pattern = Pattern.compile("(phone|pad|pod|iphone|ipod|ios|ipad|android|mobile|blackberry|iemobile|mqqbrowser|juc|fennec|wosbrowser|browserng|webos|symbian|windows phone)");
return pattern.matcher(ua).find();
}
}

View File

@ -0,0 +1,64 @@
package org.jeecg.common.util;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.oss.OssBootUtil;
import org.jeecgframework.poi.util.PoiPublicUtil;
import org.springframework.util.FileCopyUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
public class CommonUtils {
public static String uploadOnlineImage(byte[] data,String basePath,String bizPath,String uploadType){
String dbPath = null;
String fileName = "image" + Math.round(Math.random() * 100000000000L);
fileName += "." + PoiPublicUtil.getFileExtendName(data);
try {
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
File file = new File(basePath + File.separator + bizPath + File.separator );
if (!file.exists()) {
file.mkdirs();// 创建文件根目录
}
String savePath = file.getPath() + File.separator + fileName;
File savefile = new File(savePath);
FileCopyUtils.copy(data, savefile);
dbPath = bizPath + File.separator + fileName;
}else {
InputStream in = new ByteArrayInputStream(data);
String relativePath = bizPath+"/"+fileName;
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
dbPath = MinioUtil.upload(in,relativePath);
}else if(CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)){
dbPath = OssBootUtil.upload(in,relativePath);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dbPath;
}
/**
* 判断文件名是否带盘符,重新处理
* @param fileName
* @return
*/
public static String getFileName(String fileName){
//判断是否带有盘符信息
// Check for Unix-style path
int unixSep = fileName.lastIndexOf('/');
// Check for Windows-style path
int winSep = fileName.lastIndexOf('\\');
// Cut off at latest possible point
int pos = (winSep > unixSep ? winSep : unixSep);
if (pos != -1) {
// Any sort of path separator found...
fileName = fileName.substring(pos + 1);
}
//替换上传文件名字的特殊字符
fileName = fileName.replace("=","").replace(",","").replace("&","");
return fileName;
}
}

View File

@ -0,0 +1,96 @@
package org.jeecg.common.util;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* 导出返回信息
*/
@Slf4j
public class ImportExcelUtil {
public static Result<?> imporReturnRes(int errorLines,int successLines,List<String> errorMessage) throws IOException {
if (errorLines == 0) {
return Result.ok("" + successLines + "行数据全部导入成功!");
} else {
JSONObject result = new JSONObject(5);
int totalCount = successLines + errorLines;
result.put("totalCount", totalCount);
result.put("errorCount", errorLines);
result.put("successCount", successLines);
result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines);
String fileUrl = PmsUtil.saveErrorTxtByList(errorMessage, "userImportExcelErrorLog");
int lastIndex = fileUrl.lastIndexOf(File.separator);
String fileName = fileUrl.substring(lastIndex + 1);
result.put("fileUrl", "/sys/common/static/" + fileUrl);
result.put("fileName", fileName);
Result res = Result.ok(result);
res.setCode(201);
res.setMessage("文件导入成功,但有错误。");
return res;
}
}
public static List<String> importDateSave(List<Object> list, Class serviceClass,List<String> errorMessage,String errorFlag) {
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
for (int i = 0; i < list.size(); i++) {
try {
boolean save = bean.save(list.get(i));
if(!save){
throw new Exception(errorFlag);
}
} catch (Exception e) {
String message = e.getMessage();
int lineNumber = i + 1;
// 通过索引名判断出错信息
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。");
}else {
errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e);
}
}
}
return errorMessage;
}
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) {
IService bean =(IService) SpringContextUtils.getBean(serviceClass);
try {
boolean save = bean.save(obj);
if(!save){
throw new Exception(errorFlag);
}
} catch (Exception e) {
String message = e.getMessage();
int lineNumber = i + 1;
// 通过索引名判断出错信息
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) {
errorMessage.add("" + lineNumber + " 行:角色编码已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
errorMessage.add("" + lineNumber + " 行:任务类名已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {
errorMessage.add("" + lineNumber + " 行:职务编码已经存在,忽略导入。");
}else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) {
errorMessage.add("" + lineNumber + " 行:部门编码已经存在,忽略导入。");
}else {
errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e);
}
}
return errorMessage;
}
}

View File

@ -0,0 +1,208 @@
package org.jeecg.common.util;
import io.minio.MinioClient;
import io.minio.errors.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLDecoder;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
/**
* minio文件上传工具类
*/
@Slf4j
public class MinioUtil {
private static String minioUrl;
private static String minioName;
private static String minioPass;
private static String bucketName;
public static void setMinioUrl(String minioUrl) {
MinioUtil.minioUrl = minioUrl;
}
public static void setMinioName(String minioName) {
MinioUtil.minioName = minioName;
}
public static void setMinioPass(String minioPass) {
MinioUtil.minioPass = minioPass;
}
public static void setBucketName(String bucketName) {
MinioUtil.bucketName = bucketName;
}
public static String getMinioUrl() {
return minioUrl;
}
public static String getBucketName() {
return bucketName;
}
private static MinioClient minioClient = null;
/**
* 上传文件
* @param file
* @return
*/
public static String upload(MultipartFile file, String bizPath, String customBucket) {
String file_url = "";
String newBucket = bucketName;
if(oConvertUtils.isNotEmpty(customBucket)){
newBucket = customBucket;
}
try {
initMinio(minioUrl, minioName,minioPass);
// 检查存储桶是否已经存在
if(minioClient.bucketExists(newBucket)) {
log.info("Bucket already exists.");
} else {
// 创建一个名为ota的存储桶
minioClient.makeBucket(newBucket);
log.info("create a new bucket.");
}
InputStream stream = file.getInputStream();
// 获取文件名
String orgName = file.getOriginalFilename();
orgName = CommonUtils.getFileName(orgName);
String objectName = bizPath+"/"+orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
// 使用putObject上传一个本地文件到存储桶中。
minioClient.putObject(newBucket,objectName, stream,stream.available(),"application/octet-stream");
stream.close();
file_url = minioUrl+newBucket+"/"+objectName;
}catch (IOException e){
log.error(e.getMessage(), e);
} catch (InvalidKeyException e) {
log.error(e.getMessage(), e);
} catch (NoSuchAlgorithmException e) {
log.error(e.getMessage(), e);
} catch (NoResponseException e) {
log.error(e.getMessage(), e);
} catch (XmlPullParserException e) {
log.error(e.getMessage(), e);
} catch (InvalidArgumentException e) {
log.error(e.getMessage(), e);
} catch (RegionConflictException e) {
log.error(e.getMessage(), e);
} catch (InvalidBucketNameException e) {
log.error(e.getMessage(), e);
} catch (ErrorResponseException e) {
log.error(e.getMessage(), e);
} catch (InternalException e) {
log.error(e.getMessage(), e);
} catch (InsufficientDataException e) {
log.error(e.getMessage(), e);
}
return file_url;
}
/**
* 文件上传
* @param file
* @param bizPath
* @return
*/
public static String upload(MultipartFile file, String bizPath) {
return upload(file,bizPath,null);
}
/**
* 获取文件流
* @param bucketName
* @param objectName
* @return
*/
public static InputStream getMinioFile(String bucketName,String objectName){
InputStream inputStream = null;
try {
initMinio(minioUrl, minioName, minioPass);
inputStream = minioClient.getObject(bucketName, objectName);
} catch (Exception e) {
log.info("文件获取失败" + e.getMessage());
}
return inputStream;
}
/**
* 删除文件
* @param bucketName
* @param objectName
* @throws Exception
*/
public static void removeObject(String bucketName, String objectName) {
try {
initMinio(minioUrl, minioName,minioPass);
minioClient.removeObject(bucketName, objectName);
}catch (Exception e){
log.info("文件删除失败" + e.getMessage());
}
}
/**
* 获取文件外链
* @param bucketName
* @param objectName
* @param expires
* @return
*/
public static String getObjectURL(String bucketName, String objectName, Integer expires) {
initMinio(minioUrl, minioName,minioPass);
try{
String url = minioClient.presignedGetObject(bucketName, objectName, expires);
return URLDecoder.decode(url,"UTF-8");
}catch (Exception e){
log.info("文件路径获取失败" + e.getMessage());
}
return null;
}
/**
* 初始化客户端
* @param minioUrl
* @param minioName
* @param minioPass
* @return
*/
private static MinioClient initMinio(String minioUrl, String minioName,String minioPass) {
if (minioClient == null) {
try {
minioClient = new MinioClient(minioUrl, minioName,minioPass);
} catch (InvalidEndpointException e) {
e.printStackTrace();
} catch (InvalidPortException e) {
e.printStackTrace();
}
}
return minioClient;
}
/**
* 上传文件到minio
* @param stream
* @param relativePath
* @return
*/
public static String upload(InputStream stream,String relativePath) throws IOException, InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, InternalException, NoResponseException, InvalidBucketNameException, XmlPullParserException, ErrorResponseException, RegionConflictException, InvalidArgumentException {
initMinio(minioUrl, minioName,minioPass);
if(minioClient.bucketExists(bucketName)) {
log.info("Bucket already exists.");
} else {
// 创建一个名为ota的存储桶
minioClient.makeBucket(bucketName);
log.info("create a new bucket.");
}
minioClient.putObject(bucketName,relativePath, stream, stream.available(),"application/octet-stream");
stream.close();
return minioUrl+bucketName+"/"+relativePath;
}
}

View File

@ -199,7 +199,7 @@ public class ReflectHelper {
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());
//log.info(fields[i].getType());
fieldNames[i] = fields[i].getName();
}
return fieldNames;

View File

@ -3,8 +3,11 @@ package org.jeecg.common.util;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.Map;
@ -40,7 +43,16 @@ public class RestUtil {
/**
* RestAPI 调用器
*/
private final static RestTemplate RT = new RestTemplate();
private final static RestTemplate RT;
static {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(3000);
requestFactory.setReadTimeout(3000);
RT = new RestTemplate(requestFactory);
// 解决乱码问题
RT.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
}
public static RestTemplate getRestTemplate() {
return RT;

View File

@ -1,6 +1,9 @@
package org.jeecg.common.util;
import cn.hutool.crypto.SecureUtil;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.exception.JeecgBootException;
import javax.servlet.http.HttpServletRequest;
/**
* sql注入处理工具类
@ -9,7 +12,32 @@ import lombok.extern.slf4j.Slf4j;
*/
@Slf4j
public class SqlInjectionUtil {
final static String xssStr = "'|and |exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|,";
/**
* sign 用于表字典加签的盐值【SQL漏洞】
* (上线修改值 20200501同步修改前端的盐值
*/
private final static String TABLE_DICT_SIGN_SALT = "20200501";
private final static String xssStr = "'|and |exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|,";
/*
* 针对表字典进行额外的sign签名校验增加安全机制
* @param dictCode:
* @param sign:
* @param request:
* @Return: void
*/
public static void checkDictTableSign(String dictCode, String sign, HttpServletRequest request) {
//表字典SQL注入漏洞,签名校验
String accessToken = request.getHeader("X-Access-Token");
String signStr = dictCode + SqlInjectionUtil.TABLE_DICT_SIGN_SALT + accessToken;
String javaSign = SecureUtil.md5(signStr);
if (!javaSign.equals(sign)) {
log.error("表字典SQL注入漏洞签名校验失败 " + sign + "!=" + javaSign+ ",dictCode=" + dictCode);
throw new JeecgBootException("无权限访问!");
}
log.info(" 表字典SQL注入漏洞签名校验成功sign=" + sign + ",dictCode=" + dictCode);
}
/**
* sql注入过滤处理遇到注入关键字抛异常
@ -82,13 +110,13 @@ public class SqlInjectionUtil {
}
return;
}
/**
* @特殊方法(不通用) 仅用于Online报表SQL解析注入过滤
* @param value
* @return
*/
/**
* @特殊方法(不通用) 仅用于Online报表SQL解析注入过滤
* @param value
* @return
*/
@Deprecated
public static void specialFilterContentForOnlineReport(String value) {
String specialXssStr = " exec | insert | delete | update | drop | chr | mid | master | truncate | char | declare |";

View File

@ -1,10 +1,12 @@
package org.jeecg.common.util.dynamic.db;
import org.apache.commons.dbcp.BasicDataSource;
import com.alibaba.druid.pool.DruidDataSource;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.vo.DynamicDataSourceModel;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.SpringContextUtils;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.HashMap;
import java.util.Map;
@ -13,21 +15,15 @@ import java.util.Map;
* 数据源缓存池
*/
public class DataSourceCachePool {
/** 数据源连接池缓存【本地 class缓存 - 不支持分布式】 */
private static Map<String, DruidDataSource> dbSources = new HashMap<>();
private static RedisTemplate<String, Object> redisTemplate;
/**
* DynamicDataSourceModel的 code 和 id 的对应关系。key为idvalue为code
*/
private static Map<String, String> dynamicDbSourcesIdToCode = new HashMap<>();
/**
* DynamicDataSourceModel的缓存。key为codevalue为数据源
*/
private static Map<String, DynamicDataSourceModel> dynamicDbSourcesCache = new HashMap<>();
/**
* 动态数据源参数配置【缓存】
*/
public static Map<String, DynamicDataSourceModel> getCacheAllDynamicDataSourceModel() {
return dynamicDbSourcesCache;
private static RedisTemplate<String, Object> getRedisTemplate() {
if (redisTemplate == null) {
redisTemplate = (RedisTemplate<String, Object>) SpringContextUtils.getBean("redisTemplate");
}
return redisTemplate;
}
/**
@ -37,22 +33,19 @@ public class DataSourceCachePool {
* @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);
String redisCacheKey = CacheConstant.SYS_DYNAMICDB_CACHE + dbKey;
if (getRedisTemplate().hasKey(redisCacheKey)) {
return (DynamicDataSourceModel) getRedisTemplate().opsForValue().get(redisCacheKey);
}
ISysBaseAPI sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
DynamicDataSourceModel dbSource = sysBaseAPI.getDynamicDbSourceByCode(dbKey);
if (dbSource != null) {
getRedisTemplate().opsForValue().set(redisCacheKey, dbSource);
}
return dbSource;
}
/**
* 动态数据源连接池【本地class缓存 - 不支持分布式】
*/
private static Map<String, BasicDataSource> dbSources = new HashMap<>();
public static BasicDataSource getCacheBasicDataSource(String dbKey) {
public static DruidDataSource getCacheBasicDataSource(String dbKey) {
return dbSources.get(dbKey);
}
@ -62,26 +55,38 @@ public class DataSourceCachePool {
* @param dbKey
* @param db
*/
public static void putCacheBasicDataSource(String dbKey, BasicDataSource db) {
public static void putCacheBasicDataSource(String dbKey, DruidDataSource db) {
dbSources.put(dbKey, db);
}
/**
* 清空数据源缓存
*/
public static void cleanCacheBasicDataSource() {
public static void cleanAllCache() {
//关闭数据源连接
for(Map.Entry<String, DruidDataSource> entry : dbSources.entrySet()){
String dbkey = entry.getKey();
DruidDataSource druidDataSource = entry.getValue();
if(druidDataSource!=null && druidDataSource.isEnable()){
druidDataSource.close();
}
//清空redis缓存
getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbkey);
}
//清空缓存
dbSources.clear();
}
public static void removeCache(String dbKey) {
//关闭数据源连接
DruidDataSource druidDataSource = dbSources.get(dbKey);
if(druidDataSource!=null && druidDataSource.isEnable()){
druidDataSource.close();
}
//清空redis缓存
getRedisTemplate().delete(CacheConstant.SYS_DYNAMICDB_CACHE + dbKey);
//清空缓存
dbSources.remove(dbKey);
dynamicDbSourcesCache.remove(dbKey);
}
public static void removeCacheById(String dbId) {
String dbKey = dynamicDbSourcesIdToCode.get(dbId);
dbSources.remove(dbKey);
dynamicDbSourcesCache.remove(dbKey);
}
}

View File

@ -0,0 +1,31 @@
package org.jeecg.common.util.dynamic.db;
public enum DbValidationQueryEnum {
ORACLE("oracle", "SELECT 1 FROM DUAL"),
MYSQL("mysql", "select 1"),
SQLSERVER("sqlserver", "SELECT 1 FROM DUAL"),;
DbValidationQueryEnum(String dbType, String validationQuerySql) {
this.dbType = dbType;
this.validationQuerySql = validationQuerySql;
}
private String dbType;
private String validationQuerySql;
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
public String getValidationQuerySql() {
return validationQuerySql;
}
public void setValidationQuerySql(String validationQuerySql) {
this.validationQuerySql = validationQuerySql;
}
}

View File

@ -1,14 +1,17 @@
package org.jeecg.common.util.dynamic.db;
import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang.ArrayUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.exception.JeecgBootException;
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 javax.sql.DataSource;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
@ -30,20 +33,30 @@ public class DynamicDBUtil {
* @param dbSource
* @return
*/
@Deprecated
private static BasicDataSource getJdbcDataSource(final DynamicDataSourceModel dbSource) {
BasicDataSource dataSource = new BasicDataSource();
private static DruidDataSource getJdbcDataSource(final DynamicDataSourceModel dbSource) {
DruidDataSource dataSource = new DruidDataSource();
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.setValidationQuery("SELECT 1 FROM DUAL");
dataSource.setTestWhileIdle(true);
dataSource.setTestOnBorrow(false);
dataSource.setTestOnReturn(false);
dataSource.setBreakAfterAcquireFailure(true);
dataSource.setConnectionErrorRetryAttempts(0);
dataSource.setUsername(dbUser);
dataSource.setMaxWait(60000);
dataSource.setPassword(dbPassword);
log.info("******************************************");
log.info("* *");
log.info("*====【"+dbSource.getCode()+"】=====Druid连接池已启用 ====*");
log.info("* *");
log.info("******************************************");
return dataSource;
}
@ -53,17 +66,21 @@ public class DynamicDBUtil {
* @param dbKey
* @return
*/
public static BasicDataSource getDbSourceByDbKey(final String dbKey) {
public static DruidDataSource getDbSourceByDbKey(final String dbKey) {
//获取多数据源配置
DynamicDataSourceModel dbSource = DataSourceCachePool.getCacheDynamicDataSourceModel(dbKey);
//先判断缓存中是否存在数据库链接
BasicDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
DruidDataSource cacheDbSource = DataSourceCachePool.getCacheBasicDataSource(dbKey);
if (cacheDbSource != null && !cacheDbSource.isClosed()) {
log.debug("--------getDbSourceBydbKey------------------从缓存中获取DB连接-------------------");
return cacheDbSource;
} else {
BasicDataSource dataSource = getJdbcDataSource(dbSource);
DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
DruidDataSource dataSource = getJdbcDataSource(dbSource);
if(dataSource!=null && dataSource.isEnable()){
DataSourceCachePool.putCacheBasicDataSource(dbKey, dataSource);
}else{
throw new JeecgBootException("动态数据源连接失败dbKey"+dbKey);
}
log.info("--------getDbSourceBydbKey------------------创建DB数据库连接-------------------");
return dataSource;
}
@ -76,7 +93,7 @@ public class DynamicDBUtil {
* @return
*/
public static void closeDbKey(final String dbKey) {
BasicDataSource dataSource = getDbSourceByDbKey(dbKey);
DruidDataSource dataSource = getDbSourceByDbKey(dbKey);
try {
if (dataSource != null && !dataSource.isClosed()) {
dataSource.getConnection().commit();
@ -90,7 +107,7 @@ public class DynamicDBUtil {
private static JdbcTemplate getJdbcTemplate(String dbKey) {
BasicDataSource dataSource = getDbSourceByDbKey(dbKey);
DruidDataSource dataSource = getDbSourceByDbKey(dbKey);
return new JdbcTemplate(dataSource);
}

View File

@ -0,0 +1,28 @@
package org.jeecg.common.util.jsonschema;
import lombok.Data;
/**
* 列 配置基本信息
*/
@Data
public class BaseColumn {
/**
* 列配置 描述 -对应数据库字段描述
*/
private String title;
/**
* 列配置 名称 -对应数据库字段名
*/
private String field;
public BaseColumn(){}
public BaseColumn(String title,String field){
this.title = title;
this.field = field;
}
}

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.vo.DictModel;
import com.alibaba.fastjson.JSONObject;
@ -52,7 +53,17 @@ public abstract class CommonProperty implements Serializable{
protected Integer order;//字段显示排序
protected boolean disabled;//是否禁用
protected String defVal; // 字段默认值
public String getDefVal() {
return defVal;
}
public void setDefVal(String defVal) {
this.defVal = defVal;
}
public boolean isDisabled() {
return disabled;
}
@ -150,6 +161,9 @@ public abstract class CommonProperty implements Serializable{
JSONObject ui = JSONObject.parseObject(str);
json.put("ui", ui);
}
if (StringUtils.isNotBlank(defVal)) {
json.put("defVal", defVal);
}
return json;
}

View File

@ -0,0 +1,66 @@
package org.jeecg.common.util.jsonschema.validate;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.jsonschema.BaseColumn;
import org.jeecg.common.util.jsonschema.CommonProperty;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 级联下拉
*/
public class LinkDownProperty extends CommonProperty {
/**
* 配置信息
*/
String dictTable;
/**
* 级联下拉组件 的其他级联列
*/
List<BaseColumn> otherColumns;
public String getDictTable(){
return this.dictTable;
}
public void setDictTable(String dictTable){
this.dictTable = dictTable;
}
public List<BaseColumn> getOtherColumns(){
return this.otherColumns;
}
public void setOtherColumns(List<BaseColumn> otherColumns){
this.otherColumns = otherColumns;
}
public LinkDownProperty() {}
/**
* 构造器
*/
public LinkDownProperty(String key,String title,String dictTable) {
this.type = "string";
this.view = "link_down";
this.key = key;
this.title = title;
this.dictTable= dictTable;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String, Object> map = new HashMap<>();
map.put("key", getKey());
JSONObject prop = getCommonJson();
JSONObject temp = JSONObject.parseObject(this.dictTable);
prop.put("config", temp);
prop.put("others", otherColumns);
map.put("prop", prop);
return map;
}
}

View File

@ -0,0 +1,46 @@
package org.jeecg.common.util.jsonschema.validate;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.util.jsonschema.CommonProperty;
import java.util.HashMap;
import java.util.Map;
/**
* 开关 属性
*/
public class SwitchProperty extends CommonProperty {
//扩展参数配置信息
private String extendStr;
public SwitchProperty() {}
/**
* 构造器
*/
public SwitchProperty(String key, String title, String extendStr) {
this.type = "string";
this.view = "switch";
this.key = key;
this.title = title;
this.extendStr = extendStr;
}
@Override
public Map<String, Object> getPropertyJson() {
Map<String,Object> map = new HashMap<>();
map.put("key",getKey());
JSONObject prop = getCommonJson();
JSONArray array = new JSONArray();
if(extendStr!=null) {
array = JSONArray.parseArray(extendStr);
prop.put("extendOption",array);
}
map.put("prop",prop);
return map;
}
//TODO 重构问题:数据字典 只是字符串类的还是有存储的数值类型?只有字符串请跳过这个 只改前端
}

View File

@ -21,6 +21,11 @@ public class TreeSelectProperty extends CommonProperty {
private String pidValue;//父级节点的值 暂时没用到 默认为0
private String hasChildField;
private String textField;//树形下拉保存text值的字段名
/**
* 是不是pid 组件 1是 0否
*/
private Integer pidComponent = 0;
public String getDict() {
return dict;
@ -64,6 +69,14 @@ public class TreeSelectProperty extends CommonProperty {
this.textField = textField;
}
public Integer getPidComponent() {
return pidComponent;
}
public void setPidComponent(Integer pidComponent) {
this.pidComponent = pidComponent;
}
/**
* 构造器 构造普通树形下拉
*/
@ -123,6 +136,9 @@ public class TreeSelectProperty extends CommonProperty {
if(hasChildField!=null) {
prop.put("hasChildField",hasChildField);
}
if(pidComponent!=null) {
prop.put("pidComponent",pidComponent);
}
map.put("prop",prop);
return map;
}

View File

@ -4,18 +4,27 @@ import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.PutObjectResult;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.http.fileupload.FileItemStream;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Date;
import java.util.UUID;
/**
* @Description: 阿里云 oss 上传工具类(高依赖版)
* @Date: 2019/5/10
*/
@Slf4j
public class OssBootUtil {
private static String endPoint;
@ -44,11 +53,14 @@ public class OssBootUtil {
OssBootUtil.staticDomain = staticDomain;
}
public static String getStaticDomain() {
return staticDomain;
}
/**
* oss 工具客户端
*/
private static OSSClient ossClient = null;
private static String FILE_URL;
/**
* 上传文件至阿里云 OSS
@ -59,12 +71,23 @@ public class OssBootUtil {
* @param fileDir 文件保存目录
* @return oss 中的相对文件路径
*/
public static String upload(MultipartFile file, String fileDir) {
public static String upload(MultipartFile file, String fileDir,String customBucket) {
String FILE_URL = null;
initOSS(endPoint, accessKeyId, accessKeySecret);
StringBuilder fileUrl = new StringBuilder();
String newBucket = bucketName;
if(oConvertUtils.isNotEmpty(customBucket)){
newBucket = customBucket;
}
try {
String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.'));
String fileName = UUID.randomUUID().toString().replace("-", "") + suffix;
//判断桶是否存在,不存在则创建桶
if(!ossClient.doesBucketExist(newBucket)){
ossClient.createBucket(newBucket);
}
// 获取文件名
String orgName = file.getOriginalFilename();
orgName = CommonUtils.getFileName(orgName);
String fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
if (!fileDir.endsWith("/")) {
fileDir = fileDir.concat("/");
}
@ -73,13 +96,13 @@ public class OssBootUtil {
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) {
FILE_URL = staticDomain + "/" + fileUrl;
} else {
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
FILE_URL = "https://" + newBucket + "." + endPoint + "/" + fileUrl;
}
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(), file.getInputStream());
PutObjectResult result = ossClient.putObject(newBucket, fileUrl.toString(), file.getInputStream());
// 设置权限(公开读)
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
// ossClient.setBucketAcl(newBucket, CannedAccessControlList.PublicRead);
if (result != null) {
System.out.println("------OSS文件上传成功------" + fileUrl);
log.info("------OSS文件上传成功------" + fileUrl);
}
} catch (IOException e) {
e.printStackTrace();
@ -88,6 +111,15 @@ public class OssBootUtil {
return FILE_URL;
}
/**
* 文件上传
* @param file
* @param fileDir
* @return
*/
public static String upload(MultipartFile file, String fileDir) {
return upload(file, fileDir,null);
}
/**
* 上传文件至阿里云 OSS
@ -99,6 +131,7 @@ public class OssBootUtil {
* @return oss 中的相对文件路径
*/
public static String upload(FileItemStream file, String fileDir) {
String FILE_URL = null;
initOSS(endPoint, accessKeyId, accessKeySecret);
StringBuilder fileUrl = new StringBuilder();
try {
@ -118,7 +151,7 @@ public class OssBootUtil {
// 设置权限(公开读)
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
if (result != null) {
System.out.println("------OSS文件上传成功------" + fileUrl);
log.info("------OSS文件上传成功------" + fileUrl);
}
} catch (IOException e) {
e.printStackTrace();
@ -132,10 +165,26 @@ public class OssBootUtil {
* @param url
*/
public static void deleteUrl(String url) {
String bucketUrl = "https://" + bucketName + "." + endPoint + "/";
//String bucketUrl = staticDomain + "/";
deleteUrl(url,null);
}
/**
* 删除文件
* @param url
*/
public static void deleteUrl(String url,String bucket) {
String newBucket = bucketName;
if(oConvertUtils.isNotEmpty(bucket)){
newBucket = bucket;
}
String bucketUrl = "";
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) {
bucketUrl = staticDomain + "/" ;
} else {
bucketUrl = "https://" + newBucket + "." + endPoint + "/";
}
url = url.replace(bucketUrl,"");
ossClient.deleteObject(bucketName, url);
ossClient.deleteObject(newBucket, url);
}
/**
@ -146,6 +195,57 @@ public class OssBootUtil {
ossClient.deleteObject(bucketName, fileName);
}
/**
* 获取文件流
* @param objectName
* @param bucket
* @return
*/
public static InputStream getOssFile(String objectName,String bucket){
InputStream inputStream = null;
try{
String newBucket = bucketName;
if(oConvertUtils.isNotEmpty(bucket)){
newBucket = bucket;
}
initOSS(endPoint, accessKeyId, accessKeySecret);
OSSObject ossObject = ossClient.getObject(newBucket,objectName);
inputStream = new BufferedInputStream(ossObject.getObjectContent());
}catch (Exception e){
log.info("文件获取失败" + e.getMessage());
}
return inputStream;
}
/**
* 获取文件流
* @param objectName
* @return
*/
public static InputStream getOssFile(String objectName){
return getOssFile(objectName,null);
}
/**
* 获取文件外链
* @param bucketName
* @param objectName
* @param expires
* @return
*/
public static String getObjectURL(String bucketName, String objectName, Date expires) {
initOSS(endPoint, accessKeyId, accessKeySecret);
try{
if(ossClient.doesObjectExist(bucketName,objectName)){
URL url = ossClient.generatePresignedUrl(bucketName,objectName,expires);
return URLDecoder.decode(url.toString(),"UTF-8");
}
}catch (Exception e){
log.info("文件路径获取失败" + e.getMessage());
}
return null;
}
/**
* 初始化 oss 客户端
*
@ -160,4 +260,30 @@ public class OssBootUtil {
return ossClient;
}
/**
* 上传文件到oss
* @param stream
* @param relativePath
* @return
*/
public static String upload(InputStream stream, String relativePath) {
String FILE_URL = null;
String fileUrl = relativePath;
initOSS(endPoint, accessKeyId, accessKeySecret);
if (oConvertUtils.isNotEmpty(staticDomain) && staticDomain.toLowerCase().startsWith("http")) {
FILE_URL = staticDomain + "/" + relativePath;
} else {
FILE_URL = "https://" + bucketName + "." + endPoint + "/" + fileUrl;
}
PutObjectResult result = ossClient.putObject(bucketName, fileUrl.toString(),stream);
// 设置权限(公开读)
ossClient.setBucketAcl(bucketName, CannedAccessControlList.PublicRead);
if (result != null) {
log.info("------OSS文件上传成功------" + fileUrl);
}
return FILE_URL;
}
}

File diff suppressed because one or more lines are too long

View File

@ -3,12 +3,11 @@
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.4</version>
<parent>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>jeecg-boot-parent</artifactId>
<version>2.1.4</version>
<version>2.2.0</version>
</parent>
<repositories>

View File

@ -1,29 +1,25 @@
package org.jeecg;
import java.net.InetAddress;
import java.net.UnknownHostException;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.Context;
import org.apache.tomcat.util.scan.StandardJarScanner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Slf4j
@EnableSwagger2
@SpringBootApplication
@EnableAutoConfiguration
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();
@ -34,9 +30,21 @@ public class JeecgApplication {
"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" +
"Swagger-UI: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
/**
* tomcat-embed-jasper引用后提示jar找不到的问题
*/
@Bean
public TomcatServletWebServerFactory tomcatFactory() {
return new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
}
};
}
}

View File

@ -4,8 +4,9 @@ import org.jeecgframework.codegenerate.window.CodeWindow;
/**
* @Title: 单表代码生成器入口
* 【 GUI模式已弃用请转移Online模式进行代码生成 】
* @Author 张代浩
* @site www.jeecg.org
* @site www.jeecg.com
* @Version:V1.0.1
*/
public class JeecgOneGUI {

View File

@ -9,6 +9,7 @@ import org.jeecgframework.codegenerate.generate.pojo.onetomany.SubTableVo;
/**
* 代码生成器入口【一对多】
* 【 GUI模式已弃用请转移Online模式进行代码生成 】
* @Author 张代浩
* @site www.jeecg.org
*
@ -23,17 +24,17 @@ public class JeecgOneToMainUtil {
//第一步:设置主表配置
MainTableVo mainTable = new MainTableVo();
mainTable.setTableName("jeecg_order_main");//表名
mainTable.setEntityName("TestOrderMain"); //实体名
mainTable.setEntityPackage("test2"); //包名
mainTable.setFtlDescription("订单"); //描述
mainTable.setEntityName("GuiTestOrderMain"); //实体名
mainTable.setEntityPackage("gui"); //包名
mainTable.setFtlDescription("GUI订单管理"); //描述
//第二步:设置子表集合配置
List<SubTableVo> subTables = new ArrayList<SubTableVo>();
//[1].子表一
SubTableVo po = new SubTableVo();
po.setTableName("jeecg_order_customer");//表名
po.setEntityName("TestOrderCustom"); //实体名
po.setEntityPackage("test2"); //包名
po.setEntityName("GuiTestOrderCustom"); //实体名
po.setEntityPackage("gui"); //包名
po.setFtlDescription("客户明细"); //描述
//子表外键参数配置
/*说明:
@ -46,8 +47,8 @@ public class JeecgOneToMainUtil {
//[2].子表二
SubTableVo po2 = new SubTableVo();
po2.setTableName("jeecg_order_ticket"); //表名
po2.setEntityName("TestOrderTicket"); //实体名
po2.setEntityPackage("test2"); //包名
po2.setEntityName("GuiTestOrderTicket"); //实体名
po2.setEntityPackage("gui"); //包名
po2.setFtlDescription("产品明细"); //描述
//子表外键参数配置
/*说明:

View File

@ -1,7 +1,7 @@
package org.jeecg.config;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.system.util.MinioUtil;
import org.jeecg.common.util.MinioUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

View File

@ -70,11 +70,12 @@ public class ShiroConfig {
//cas验证登录
filterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
// 配置不会被拦截的链接 顺序判断
filterChainDefinitionMap.put("/sys/getCheckCode", "anon"); //登录验证码接口排除
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
filterChainDefinitionMap.put("/sys/checkCaptcha", "anon"); //登录验证码接口排除
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
filterChainDefinitionMap.put("/thirdLogin/**", "anon"); //第三方登录
filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
@ -85,8 +86,6 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
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");
@ -117,19 +116,16 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
filterChainDefinitionMap.put("/actuator/redis/**", "anon");
//大屏设计器排除
filterChainDefinitionMap.put("/big/screen/**", "anon");
//测试示例
filterChainDefinitionMap.put("/test/jeecgDemo/html", "anon"); //模板页面
filterChainDefinitionMap.put("/test/jeecgDemo/redis/**", "anon"); //redis测试
//排除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());
@ -173,6 +169,12 @@ public class ShiroConfig {
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
defaultAdvisorAutoProxyCreator.setProxyTargetClass(true);
/**
* 解决重复代理问题 github#994
* 添加前缀判断 不匹配 任何Advisor
*/
defaultAdvisorAutoProxyCreator.setUsePrefix(true);
defaultAdvisorAutoProxyCreator.setAdvisorBeanNamePrefix("_no_advisor");
return defaultAdvisorAutoProxyCreator;
}

View File

@ -1,32 +1,31 @@
package org.jeecg.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.shiro.vo.DefContants;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Parameter;
import lombok.extern.slf4j.Slf4j;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Parameter;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @Author scott
*/
@ -34,6 +33,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
public class Swagger2Config implements WebMvcConfigurer {
/**

View File

@ -1,18 +1,20 @@
package org.jeecg.config;
import org.jeecg.modules.shiro.authc.interceptor.OnlineInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Spring Boot 2.0 解决跨域问题
*
*
* @Author qinfeng
*
*/
@ -26,6 +28,11 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
@Value("${spring.resource.static-locations}")
private String staticLocations;
@Bean
public OnlineInterceptor onlineInterceptor(){
return new OnlineInterceptor();
}
@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
@ -60,4 +67,10 @@ public class WebMvcConfiguration implements WebMvcConfigurer {
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("doc.html");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
String [] exculudes = new String[]{"/*.html","/html/**","/js/**","/css/**","/images/**"};
registry.addInterceptor(onlineInterceptor()).excludePathPatterns(exculudes).addPathPatterns("/online/cgform/api/**");
}
}

View File

@ -194,7 +194,7 @@ public class MockController {
//json = FileUtils.re.readFileToString(jsonFile);
//换个写法解决springboot读取jar包中文件的问题
InputStream stream = getClass().getClassLoader().getResourceAsStream(jsonSrc.replace("classpath:", ""));
json = IOUtils.toString(stream);
json = IOUtils.toString(stream,"UTF-8");
} catch (IOException e) {
log.error(e.getMessage(),e);
}

View File

@ -0,0 +1,36 @@
[
{"value": "110000", "label": "北京市"},
{"value": "120000", "label": "天津市"},
{"value": "130000", "label": "河北省"},
{"value": "140000", "label": "山西省"},
{"value": "150000", "label": "内蒙古自治区"},
{"value": "210000", "label": "辽宁省"},
{"value": "220000", "label": "吉林省"},
{"value": "230000", "label": "黑龙江省"},
{"value": "310000", "label": "上海市"},
{"value": "320000", "label": "江苏省"},
{"value": "330000", "label": "浙江省"},
{"value": "340000", "label": "安徽省"},
{"value": "350000", "label": "福建省"},
{"value": "360000", "label": "江西省"},
{"value": "370000", "label": "山东省"},
{"value": "410000", "label": "河南省"},
{"value": "420000", "label": "湖北省"},
{"value": "430000", "label": "湖南省"},
{"value": "440000", "label": "广东省"},
{"value": "450000", "label": "广西壮族自治区"},
{"value": "460000", "label": "海南省"},
{"value": "500000", "label": "重庆市"},
{"value": "510000", "label": "四川省"},
{"value": "520000", "label": "贵州省"},
{"value": "530000", "label": "云南省"},
{"value": "540000", "label": "西藏自治区"},
{"value": "610000", "label": "陕西省"},
{"value": "620000", "label": "甘肃省"},
{"value": "630000", "label": "青海省"},
{"value": "640000", "label": "宁夏回族自治区"},
{"value": "650000", "label": "新疆维吾尔自治区"},
{"value": "710000", "label": "台湾省"},
{"value": "810000", "label": "香港特别行政区"},
{"value": "820000", "label": "澳门特别行政区"}
]

View File

@ -0,0 +1,84 @@
package org.jeecg.modules.demo.test.controller;
import io.minio.MinioClient;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
/**
* @Author scott
* @Date 2020/1/12 17:19
* @Description: Minio文件服务测试
*/
@RestController
@RequestMapping("/test/minio")
public class MinioController {
//minio服务的IP端口
private static String url = "http://111.225.222.176:9000";
private static String accessKey = "admin";
private static String secretKey = "jeecg1357";
private static String bucketName = "jeecgtest";
/**
* 上传文件到minio服务
*
* @param file
* @return
*/
@PostMapping("upload")
public String upload(@RequestParam("file") MultipartFile file) {
try {
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
InputStream is = file.getInputStream(); //得到文件流
String fileName = "/upload/img/" + file.getOriginalFilename(); //文件名
String contentType = file.getContentType(); //类型
minioClient.putObject(bucketName, fileName, is, contentType); //把文件放置Minio桶(文件夹)
return "上传成功";
} catch (Exception e) {
return "上传失败";
}
}
/**
* 下载minio服务的文件
*
* @param response
* @return
*/
@GetMapping("download")
public String download(HttpServletResponse response) {
try {
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
InputStream fileInputStream = minioClient.getObject(bucketName, "11.jpg");
response.setHeader("Content-Disposition", "attachment;filename=" + "11.jpg");
response.setContentType("application/force-download");
response.setCharacterEncoding("UTF-8");
IOUtils.copy(fileInputStream, response.getOutputStream());
return "下载完成";
} catch (Exception e) {
e.printStackTrace();
return "下载失败";
}
}
/**
* 获取minio文件的下载地址
*
* @return
*/
@GetMapping("url")
public String getUrl() {
try {
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
String url = minioClient.presignedGetObject(bucketName, "11.jpg");
return url;
} catch (Exception e) {
e.printStackTrace();
return "获取失败";
}
}
}

View File

@ -1,13 +1,15 @@
package org.jeecg.modules.message.handle.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.message.handle.ISendMsgHandle;
@Slf4j
public class SmsSendMsgHandle implements ISendMsgHandle {
@Override
public void SendMsg(String es_receiver, String es_title, String es_content) {
// TODO Auto-generated method stub
System.out.println("发短信");
log.info("发短信");
}
}

View File

@ -1,13 +1,14 @@
package org.jeecg.modules.message.handle.impl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.message.handle.ISendMsgHandle;
@Slf4j
public class WxSendMsgHandle implements ISendMsgHandle {
@Override
public void SendMsg(String es_receiver, String es_title, String es_content) {
// TODO Auto-generated method stub
System.out.println("发微信消息模板");
log.info("发微信消息模板");
}
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.message.websocket;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.WebsocketConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -21,24 +22,24 @@ public class TestController {
Result<String> result = new Result<String>();
String message = jsonObject.getString("message");
JSONObject obj = new JSONObject();
obj.put("cmd", "topic");
obj.put("msgId", "M0001");
obj.put("msgTxt", message);
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, "M0001");
obj.put(WebsocketConst.MSG_TXT, message);
webSocket.sendAllMessage(obj.toJSONString());
result.setResult("群发!");
return result;
}
@PostMapping("/sendUser")
public Result<String> sendUser(@RequestBody JSONObject jsonObject) {
Result<String> result = new Result<String>();
String userId = jsonObject.getString("userId");
String message = jsonObject.getString("message");
JSONObject obj = new JSONObject();
obj.put("cmd", "user");
obj.put("userId", userId);
obj.put("msgId", "M0001");
obj.put("msgTxt", message);
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_USER_ID, userId);
obj.put(WebsocketConst.MSG_ID, "M0001");
obj.put(WebsocketConst.MSG_TXT, message);
webSocket.sendOneMessage(userId, obj.toJSONString());
result.setResult("单发");
return result;

View File

@ -11,6 +11,7 @@ import javax.websocket.Session;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import org.jeecg.common.constant.WebsocketConst;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
@ -57,8 +58,8 @@ public class WebSocket {
//todo 现在有个定时任务刷,应该去掉
log.debug("【websocket消息】收到客户端消息:"+message);
JSONObject obj = new JSONObject();
obj.put("cmd", "heartcheck");//业务类型
obj.put("msgTxt", "心跳响应");//消息内容
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK);//业务类型
obj.put(WebsocketConst.MSG_TXT, "心跳响应");//消息内容
session.getAsyncRemote().sendText(obj.toJSONString());
}

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.oss.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.oss.OssBootUtil;
import org.jeecg.modules.oss.entity.OSSFile;
import org.jeecg.modules.oss.mapper.OSSFileMapper;
@ -16,6 +17,7 @@ public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> impl
@Override
public void upload(MultipartFile multipartFile) throws IOException {
String fileName = multipartFile.getOriginalFilename();
fileName = CommonUtils.getFileName(fileName);
OSSFile ossFile = new OSSFile();
ossFile.setFileName(fileName);
String url = OssBootUtil.upload(multipartFile,"upload/test");

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.quartz.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -13,6 +14,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
@ -235,9 +237,12 @@ public class QuartzJobController {
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// 错误信息
List<String> errorMessage = new ArrayList<>();
int successLines = 0, errorLines = 0;
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
@ -245,11 +250,10 @@ public class QuartzJobController {
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<QuartzJob> listQuartzJobs = ExcelImportUtil.importExcel(file.getInputStream(), QuartzJob.class, params);
for (QuartzJob quartzJobExcel : listQuartzJobs) {
quartzJobService.save(quartzJobExcel);
}
return Result.ok("文件导入成功!数据行数:" + listQuartzJobs.size());
List<Object> listQuartzJobs = ExcelImportUtil.importExcel(file.getInputStream(), QuartzJob.class, params);
List<String> list = ImportExcelUtil.importDateSave(listQuartzJobs, IQuartzJobService.class, errorMessage,CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME);
errorLines+=list.size();
successLines+=(listQuartzJobs.size()-errorLines);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败!");
@ -261,6 +265,6 @@ public class QuartzJobController {
}
}
}
return Result.error("文件导入失败!");
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
}
}

View File

@ -2,6 +2,7 @@ package org.jeecg.modules.quartz.entity;
import java.io.Serializable;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@ -54,7 +55,8 @@ public class QuartzJob implements Serializable {
@Excel(name="描述",width=40)
private java.lang.String description;
/**状态 0正常 -1停止*/
@Excel(name="状态",width=15)
@Excel(name="状态",width=15,dicCode="quartz_status")
@Dict(dicCode = "quartz_status")
private java.lang.Integer status;
}

View File

@ -115,7 +115,7 @@ public class ShiroRealm extends AuthorizingRealm {
}
// 查询用户信息
log.info("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
LoginUser loginUser = sysBaseAPI.getUserByName(username);
if (loginUser == null) {
throw new AuthenticationException("用户不存在!");

View File

@ -0,0 +1,141 @@
package org.jeecg.modules.shiro.authc.interceptor;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.OnlineAuth;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysPermission;
import org.jeecg.modules.system.service.ISysPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Online 自定义请求拦截器
*
* @author: taoyan
* @date: 2020年03月20日
*/
@Slf4j
public class OnlineInterceptor implements HandlerInterceptor {
@Autowired
private ISysPermissionService sysPermissionService;
/**
* online表单菜单地址
*/
private static final String ONLINE_FORM = "/online/cgform";
/**
* online功能测试地址 前缀
*/
private static final String[] ONLINE_TEST_PRE = {"/online/cgformErpList", "/online/cgformList", "/online/cgformTreeList"};
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 请求的方法是否有注解
boolean anno = handler.getClass().isAssignableFrom(HandlerMethod.class);
if (anno) {
OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
if (onlineAuth != null) {
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
requestPath = filterUrl(requestPath);
//1.通过前端请求地址得到code
String authKey = onlineAuth.value();
String code = requestPath.substring(requestPath.lastIndexOf(authKey) + authKey.length());
log.info("拦截请求(" + request.getMethod() + ")" + requestPath + ",");
if ("form".equals(authKey) && "DELETE".equals(request.getMethod())) {
code = code.substring(0, code.lastIndexOf("/"));
}
List<String> possibleUrl = new ArrayList<>();
//获取可能的表单地址
for (String pre : ONLINE_TEST_PRE) {
possibleUrl.add(pre + code);
}
//查询菜单
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
query.eq(SysPermission::getDelFlag, 0);
query.in(SysPermission::getUrl, possibleUrl);
List<SysPermission> permissionList = sysPermissionService.list(query);
String username = JwtUtil.getUserNameByToken(request);
if (permissionList == null || permissionList.size() == 0) {
//没有配置菜单 找online表单菜单地址
boolean hasPermission = sysPermissionService.hasPermission(username, ONLINE_FORM);
if (!hasPermission) {
backError(response, authKey);
return false;
}
} else {
//找到菜单了
boolean has = false;
for (SysPermission p : permissionList) {
has = has || sysPermissionService.hasPermission(username, p);
}
if (!has) {
backError(response, authKey);
return false;
}
}
}
}
return true;
}
/**
* 地址过滤
*
* @param requestPath
* @return
*/
private String filterUrl(String requestPath) {
String url = "";
if (oConvertUtils.isNotEmpty(requestPath)) {
url = requestPath.replace("\\", "/");
url = requestPath.replace("//", "/");
if (url.indexOf("//") >= 0) {
url = filterUrl(url);
}
}
return url;
}
/**
* 返回一个错误信息
*
* @param response
* @param authKey
*/
private void backError(HttpServletResponse response, String authKey) {
PrintWriter writer = null;
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json; charset=utf-8");
response.setHeader("auth", "fail");
try {
writer = response.getWriter();
if ("exportXls".equals(authKey)) {
writer.print("");
} else {
Result<?> result = Result.error("无权限访问(操作)");
writer.print(JSON.toJSON(result));
}
} catch (IOException e) {
log.error(e.getMessage());
} finally {
if (writer != null) {
writer.close();
}
}
}
}

View File

@ -2,6 +2,6 @@ package org.jeecg.modules.shiro.vo;
public class DefContants {
public static String X_ACCESS_TOKEN = "X-Access-Token";
public final static String X_ACCESS_TOKEN = "X-Access-Token";
}

View File

@ -6,6 +6,7 @@ import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.SecurityUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@ -19,6 +20,7 @@ import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.system.entity.SysLog;
import org.jeecg.modules.system.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
@ -80,17 +82,11 @@ public class AutoLogAspect {
sysLog.setOperateType(getOperateType(methodName, syslog.operateType()));
}
//请求的参数
Object[] args = joinPoint.getArgs();
try{
String params = JSONObject.toJSONString(args);
sysLog.setRequestParam(params);
}catch (Exception e){
}
//获取request
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
//请求的参数
sysLog.setRequestParam(getReqestParams(request,joinPoint));
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
@ -134,4 +130,35 @@ public class AutoLogAspect {
}
return CommonConstant.OPERATE_TYPE_1;
}
/**
* @Description: 获取请求参数
* @author: scott
* @date: 2020/4/16 0:10
* @param request: request
* @param joinPoint: joinPoint
* @Return: java.lang.String
*/
private String getReqestParams(HttpServletRequest request, JoinPoint joinPoint) {
String httpMethod = request.getMethod();
String params = "";
if ("POST".equals(httpMethod) || "PUT".equals(httpMethod) || "PATCH".equals(httpMethod)) {
Object[] paramsArray = joinPoint.getArgs();
params = JSONObject.toJSONString(paramsArray);
} else {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
// 请求的方法参数值
Object[] args = joinPoint.getArgs();
// 请求的方法参数名称
LocalVariableTableParameterNameDiscoverer u = new LocalVariableTableParameterNameDiscoverer();
String[] paramNames = u.getParameterNames(method);
if (args != null && paramNames != null) {
for (int i = 0; i < args.length; i++) {
params += " " + paramNames[i] + ": " + args[i];
}
}
}
return params;
}
}

View File

@ -125,7 +125,7 @@ public class DictAspect {
}
/**
* 翻译字典文本
* 翻译字典文本
* @param code
* @param text
* @param table
@ -145,6 +145,7 @@ public class DictAspect {
continue; //跳过循环
}
if (!StringUtils.isEmpty(table)){
log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
tmpValue= dictService.queryTableDictTextByKey(table,text,code,k.trim());
}else {
tmpValue = dictService.queryDictTextByKey(code, k.trim());

View File

@ -90,7 +90,9 @@ public class PermissionDataAspect {
queryQserMatch.eq(SysPermission::getMenuType, 1);
queryQserMatch.eq(SysPermission::getDelFlag, 0);
queryQserMatch.eq(SysPermission::getUrl, userMatchUrl);
currentSyspermission = sysPermissionService.list(queryQserMatch);
if(oConvertUtils.isNotEmpty(userMatchUrl)){
currentSyspermission = sysPermissionService.list(queryQserMatch);
}
}
//3.未找到 再通过正则匹配获取菜单
if(currentSyspermission==null || currentSyspermission.size()==0) {

View File

@ -7,7 +7,11 @@ package org.jeecg.modules.system.aspect;
*/
public enum UrlMatchEnum {
CGFORM_DATA("/online/cgform/api/getData/", "/online/cgformList/"),
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/");
CGFORM_EXCEL_DATA("/online/cgform/api/exportXls/", "/online/cgformList/"),
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/"),
CGREPORT_DATA("/online/cgreport/api/getColumnsAndData/", "/online/cgreport/"),
CGREPORT_EXCEL_DATA("/online/cgreport/api/exportXls/", "/online/cgreport/");
UrlMatchEnum(String url, String match_url) {
this.url = url;

View File

@ -21,6 +21,7 @@ import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.model.SysLoginModel;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysDictService;
import org.jeecg.modules.system.service.ISysLogService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.util.RandImageUtil;
@ -50,7 +51,9 @@ public class LoginController {
private RedisUtil redisUtil;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private ISysDictService sysDictService;
private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890";
@ApiOperation("登录接口")
@ -353,6 +356,7 @@ public class LoginController {
}
obj.put("token", token);
obj.put("userInfo", sysUser);
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
result.setResult(obj);
result.success("登录成功");
return result;
@ -371,39 +375,13 @@ public class LoginController {
result.setResult(map);
return result;
}
/**
* 获取校验码
*/
@ApiOperation("获取验证码")
@GetMapping(value = "/getCheckCode")
public Result<Map<String,String>> getCheckCode(){
Result<Map<String,String>> result = new Result<Map<String,String>>();
Map<String,String> map = new HashMap<String,String>();
try {
String code = RandomUtil.randomString(BASE_CHECK_CODES,4);
String key = MD5Util.MD5Encode(code+System.currentTimeMillis(), "utf-8");
redisUtil.set(key, code, 60);
map.put("key", key);
//update-begin-authortaoyan date:20200210 for:TASK #3391 【bug】安全问题返回验证码不安全
String encode = java.util.Base64.getEncoder().encodeToString(code.getBytes("UTF-8"));
map.put("code",encode);
//update-end-authortaoyan date:20200210 for:TASK #3391 【bug】安全问题返回验证码不安全
result.setResult(map);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setSuccess(false);
}
return result;
}
/**
* 后台生成图形验证码
* 后台生成图形验证码 :有效
* @param response
* @param key
*/
@ApiOperation("获取验证码2")
@ApiOperation("获取验证码")
@GetMapping(value = "/randomImage/{key}")
public Result<String> randomImage(HttpServletResponse response,@PathVariable String key){
Result<String> res = new Result<String>();
@ -479,4 +457,25 @@ public class LoginController {
return result;
}
/**
* 图形验证码
* @param sysLoginModel
* @return
*/
@RequestMapping(value = "/checkCaptcha", method = RequestMethod.POST)
public Result<?> checkCaptcha(@RequestBody SysLoginModel sysLoginModel){
String captcha = sysLoginModel.getCaptcha();
String checkKey = sysLoginModel.getCheckKey();
if(captcha==null){
return Result.error("验证码无效");
}
String lowerCaseCaptcha = captcha.toLowerCase();
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+checkKey, "utf-8");
Object checkCode = redisUtil.get(realKey);
if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
return Result.error("验证码错误");
}
return Result.ok();
}
}

View File

@ -11,10 +11,12 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.constant.CommonSendStatus;
import org.jeecg.common.constant.WebsocketConst;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.system.vo.LoginUser;
@ -24,6 +26,7 @@ import org.jeecg.modules.system.entity.SysAnnouncement;
import org.jeecg.modules.system.entity.SysAnnouncementSend;
import org.jeecg.modules.system.service.ISysAnnouncementSendService;
import org.jeecg.modules.system.service.ISysAnnouncementService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@ -227,9 +230,9 @@ public class SysAnnouncementController {
result.success("该系统通知发布成功");
if(sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) {
JSONObject obj = new JSONObject();
obj.put("cmd", "topic");
obj.put("msgId", sysAnnouncement.getId());
obj.put("msgTxt", sysAnnouncement.getTitile());
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendAllMessage(obj.toJSONString());
}else {
// 2.插入用户通告阅读标记表记录
@ -238,9 +241,9 @@ public class SysAnnouncementController {
String anntId = sysAnnouncement.getId();
Date refDate = new Date();
JSONObject obj = new JSONObject();
obj.put("cmd", "user");
obj.put("msgId", sysAnnouncement.getId());
obj.put("msgTxt", sysAnnouncement.getTitile());
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendMoreMessage(userIds, obj.toJSONString());
}
}
@ -274,7 +277,6 @@ public class SysAnnouncementController {
/**
* @功能:补充用户数据,并返回系统消息
* @param id
* @return
*/
@RequestMapping(value = "/listByUser", method = RequestMethod.GET)
@ -378,4 +380,42 @@ public class SysAnnouncementController {
}
return Result.error("文件导入失败!");
}
/**
*同步消息
* @param anntId
* @return
*/
@RequestMapping(value = "/syncNotic", method = RequestMethod.GET)
public Result<SysAnnouncement> syncNotic(@RequestParam(name="anntId",required=false) String anntId, HttpServletRequest request) {
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
JSONObject obj = new JSONObject();
if(StringUtils.isNotBlank(anntId)){
SysAnnouncement sysAnnouncement = sysAnnouncementService.getById(anntId);
if(sysAnnouncement==null) {
result.error500("未找到对应实体");
}else {
if(sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) {
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendAllMessage(obj.toJSONString());
}else {
// 2.插入用户通告阅读标记表记录
String userId = sysAnnouncement.getUserIds();
if(oConvertUtils.isNotEmpty(userId)){
String[] userIds = userId.substring(0, (userId.length()-1)).split(",");
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
obj.put(WebsocketConst.MSG_ID, sysAnnouncement.getId());
obj.put(WebsocketConst.MSG_TXT, sysAnnouncement.getTitile());
webSocket.sendMoreMessage(userIds, obj.toJSONString());
}
}
}
}else{
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC);
obj.put(WebsocketConst.MSG_TXT, "批量设置已读");
webSocket.sendAllMessage(obj.toJSONString());
}
return result;
}
}

View File

@ -189,7 +189,6 @@ public class SysCategoryController {
* 导出excel
*
* @param request
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
@ -376,8 +375,8 @@ public class SysCategoryController {
result.setMessage("加载分类字典树参数有误.[null]!");
return result;
}else{
if(sysCategoryService.ROOT_PID_VALUE.equals(pcode)){
pid = sysCategoryService.ROOT_PID_VALUE;
if(ISysCategoryService.ROOT_PID_VALUE.equals(pcode)){
pid = ISysCategoryService.ROOT_PID_VALUE;
}else{
pid = this.sysCategoryService.queryIdByCode(pcode);
}
@ -452,5 +451,4 @@ public class SysCategoryController {
}

View File

@ -102,8 +102,9 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
@ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
SysDataSource d = sysDataSourceService.getById(sysDataSource.getId());
DataSourceCachePool.removeCache(d.getCode());
sysDataSourceService.updateById(sysDataSource);
DataSourceCachePool.removeCacheById(sysDataSource.getId());
return Result.ok("编辑成功!");
}
@ -117,8 +118,9 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
@ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name = "id") String id) {
SysDataSource sysDataSource = sysDataSourceService.getById(id);
DataSourceCachePool.removeCache(sysDataSource.getCode());
sysDataSourceService.removeById(id);
DataSourceCachePool.removeCacheById(id);
return Result.ok("删除成功!");
}
@ -133,8 +135,11 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
List<String> idList = Arrays.asList(ids.split(","));
idList.forEach(item->{
SysDataSource sysDataSource = sysDataSourceService.getById(item);
DataSourceCachePool.removeCache(sysDataSource.getCode());
});
this.sysDataSourceService.removeByIds(idList);
idList.forEach(DataSourceCachePool::removeCacheById);
return Result.ok("批量删除成功!");
}

View File

@ -1,15 +1,12 @@
package org.jeecg.modules.system.controller;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.jeecg.common.api.vo.Result;
@ -18,25 +15,25 @@ 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.ImportExcelUtil;
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;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysPositionService;
import org.jeecg.modules.system.util.FindsDepartsChildrenUtil;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.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.util.CollectionUtils;
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;
@ -59,7 +56,8 @@ public class SysDepartController {
@Autowired
private ISysDepartService sysDepartService;
@Autowired
public RedisTemplate<String, Object> redisTemplate;
/**
* 查询数据 查出我的部门,并以树结构数据格式响应给前端
*
@ -70,7 +68,7 @@ public class SysDepartController {
Result<List<SysDepartTreeModel>> result = new Result<>();
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
try {
if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
result.setResult(list);
result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
@ -114,6 +112,7 @@ public class SysDepartController {
* @param sysDepart
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
@ -139,6 +138,7 @@ public class SysDepartController {
* @param sysDepart
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
@ -166,6 +166,7 @@ public class SysDepartController {
* @param id
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {
@ -193,6 +194,7 @@ public class SysDepartController {
* @param ids
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
@ -253,9 +255,15 @@ public class SysDepartController {
* @return
*/
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord,@RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) {
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
//部门查询myDeptSearch为1时为我的部门查询登录用户为上级时查只查负责部门下数据
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String departIds = null;
if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
departIds = user.getDepartIds();
}
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord,myDeptSearch,departIds);
if (treeList == null || treeList.size() == 0) {
result.setSuccess(false);
result.setMessage("未查询匹配数据!");
@ -301,10 +309,13 @@ public class SysDepartController {
* @param response
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
List<String> errorMessageList = new ArrayList<>();
List<SysDepart> listSysDeparts = null;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
@ -315,7 +326,7 @@ public class SysDepartController {
try {
// orgCode编码长度
int codeLength = 3;
List<SysDepart> listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
//按长度排序
Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
@Override
@ -323,6 +334,8 @@ public class SysDepartController {
return arg0.getOrgCode().length() - arg1.getOrgCode().length();
}
});
int num = 0;
for (SysDepart sysDepart : listSysDeparts) {
String orgCode = sysDepart.getOrgCode();
if(orgCode.length() > codeLength) {
@ -342,9 +355,16 @@ public class SysDepartController {
}else{
sysDepart.setParentId("");
}
sysDepartService.save(sysDepart);
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
ImportExcelUtil.importDateSaveOne(sysDepart, ISysDepartService.class, errorMessageList, num, CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE);
num++;
}
return Result.ok("文件导入成功!数据行数:" + listSysDeparts.size());
//清空部门缓存
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
redisTemplate.delete(keys3);
redisTemplate.delete(keys4);
return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList);
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -358,4 +378,24 @@ public class SysDepartController {
}
return Result.error("文件导入失败!");
}
/**
* 查询所有部门信息
* @return
*/
@GetMapping("listAll")
public Result<List<SysDepart>> listAll(@RequestParam(name = "id", required = false) String id) {
Result<List<SysDepart>> result = new Result<>();
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
query.orderByAsc(SysDepart::getOrgCode);
if(oConvertUtils.isNotEmpty(id)){
String arr[] = id.split(",");
query.in(SysDepart::getId,arr);
}
List<SysDepart> ls = this.sysDepartService.list(query);
result.setSuccess(true);
result.setResult(ls);
return result;
}
}

View File

@ -65,7 +65,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param req
* @return
*/
@AutoLog(value = "部门权限表-分页列表查询")
@ApiOperation(value="部门权限表-分页列表查询", notes="部门权限表-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysDepartPermission sysDepartPermission,
@ -84,7 +83,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param sysDepartPermission
* @return
*/
@AutoLog(value = "部门权限表-添加")
@ApiOperation(value="部门权限表-添加", notes="部门权限表-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysDepartPermission sysDepartPermission) {
@ -98,7 +96,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param sysDepartPermission
* @return
*/
@AutoLog(value = "部门权限表-编辑")
@ApiOperation(value="部门权限表-编辑", notes="部门权限表-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysDepartPermission sysDepartPermission) {
@ -112,7 +109,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param id
* @return
*/
@AutoLog(value = "部门权限表-通过id删除")
@ApiOperation(value="部门权限表-通过id删除", notes="部门权限表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
@ -126,7 +122,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param ids
* @return
*/
@AutoLog(value = "部门权限表-批量删除")
@ApiOperation(value="部门权限表-批量删除", notes="部门权限表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
@ -140,7 +135,6 @@ public class SysDepartPermissionController extends JeecgController<SysDepartPerm
* @param id
* @return
*/
@AutoLog(value = "部门权限表-通过id查询")
@ApiOperation(value="部门权限表-通过id查询", notes="部门权限表-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {

View File

@ -7,16 +7,14 @@ 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.apache.shiro.authz.annotation.RequiresRoles;
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.entity.*;
import org.jeecg.modules.system.service.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -65,7 +63,6 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param req
* @return
*/
@AutoLog(value = "部门角色-分页列表查询")
@ApiOperation(value="部门角色-分页列表查询", notes="部门角色-分页列表查询")
@GetMapping(value = "/list")
public Result<?> queryPageList(SysDepartRole sysDepartRole,
@ -77,16 +74,19 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
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);
// if(oConvertUtils.isEmpty(deptId)){
// if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals(CommonConstant.USER_IDENTITY_2) ){
// deptIds = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
// }else{
// return Result.ok(null);
// }
// }else{
// deptIds = sysDepartService.getSubDepIdsByDepId(deptId);
// }
// queryWrapper.in("depart_id",deptIds);
//我的部门,选中部门只能看当前部门下的角色
queryWrapper.eq("depart_id",deptId);
IPage<SysDepartRole> pageList = sysDepartRoleService.page(page, queryWrapper);
return Result.ok(pageList);
}
@ -97,7 +97,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param sysDepartRole
* @return
*/
@AutoLog(value = "部门角色-添加")
//@RequiresRoles({"admin"})
@ApiOperation(value="部门角色-添加", notes="部门角色-添加")
@PostMapping(value = "/add")
public Result<?> add(@RequestBody SysDepartRole sysDepartRole) {
@ -111,7 +111,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param sysDepartRole
* @return
*/
@AutoLog(value = "部门角色-编辑")
//@RequiresRoles({"admin"})
@ApiOperation(value="部门角色-编辑", notes="部门角色-编辑")
@PutMapping(value = "/edit")
public Result<?> edit(@RequestBody SysDepartRole sysDepartRole) {
@ -125,6 +125,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param id
* @return
*/
//@RequiresRoles({"admin"})
@AutoLog(value = "部门角色-通过id删除")
@ApiOperation(value="部门角色-通过id删除", notes="部门角色-通过id删除")
@DeleteMapping(value = "/delete")
@ -139,6 +140,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param ids
* @return
*/
//@RequiresRoles({"admin"})
@AutoLog(value = "部门角色-批量删除")
@ApiOperation(value="部门角色-批量删除", notes="部门角色-批量删除")
@DeleteMapping(value = "/deleteBatch")
@ -153,7 +155,6 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @param id
* @return
*/
@AutoLog(value = "部门角色-通过id查询")
@ApiOperation(value="部门角色-通过id查询", notes="部门角色-通过id查询")
@GetMapping(value = "/queryById")
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
@ -167,9 +168,11 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
* @return
*/
@RequestMapping(value = "/getDeptRoleList", method = RequestMethod.GET)
public Result<List<SysDepartRole>> getDeptRoleList(@RequestParam(value = "departId") String departId){
public Result<List<SysDepartRole>> getDeptRoleList(@RequestParam(value = "departId") String departId,@RequestParam(value = "userId") String userId){
Result<List<SysDepartRole>> result = new Result<>();
List<SysDepartRole> deptRoleList = sysDepartRoleService.list(new QueryWrapper<SysDepartRole>().eq("depart_id",departId));
//查询管理部门下,用户所在部门的所有角色
SysDepart depart = sysDepartService.getById(departId);
List<SysDepartRole> deptRoleList = sysDepartRoleService.queryDeptRoleByDeptAndUser(depart.getOrgCode(),userId);
result.setSuccess(true);
result.setResult(deptRoleList);
return result;

View File

@ -1,22 +1,29 @@
package org.jeecg.modules.system.controller;
import java.io.InputStream;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.exception.JeecgBootException;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.DictQuery;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.SqlInjectionUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.shiro.vo.DefContants;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.model.SysDictTree;
@ -33,12 +40,7 @@ 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;
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;
@ -125,7 +127,7 @@ public class SysDictController {
* @return
*/
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode) {
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
log.info(" dictCode : "+ dictCode);
Result<List<DictModel>> result = new Result<List<DictModel>>();
List<DictModel> ls = null;
@ -169,13 +171,25 @@ public class SysDictController {
return result;
}
/**
* 获取全部字典数据
*
* @return
*/
@RequestMapping(value = "/queryAllDictItems", method = RequestMethod.GET)
public Result<?> queryAllDictItems(HttpServletRequest request) {
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
res = sysDictService.queryAllDictItems();
return Result.ok(res);
}
/**
* 获取字典数据
* @param dictCode
* @return
*/
@RequestMapping(value = "/getDictText/{dictCode}/{key}", method = RequestMethod.GET)
public Result<String> getDictItems(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key) {
public Result<String> getDictText(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key) {
log.info(" dictCode : "+ dictCode);
Result<String> result = new Result<String>();
String text = null;
@ -191,11 +205,121 @@ public class SysDictController {
return result;
}
/**
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
* @param dictCode
* @return
*/
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,@RequestParam(name="keyword") String keyword, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
log.info(" 加载字典表数据,加载关键字: "+ keyword);
Result<List<DictModel>> result = new Result<List<DictModel>>();
List<DictModel> ls = null;
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确");
return result;
}
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
result.setSuccess(true);
result.setResult(ls);
log.info(result.toString());
}else {
result.error500("字典Code格式不正确");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
return result;
}
return result;
}
/**
* 根据字典code加载字典text 返回
*/
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String key, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
Result<List<String>> result = new Result<>();
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确");
return result;
}
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], key.split(","));
result.setSuccess(true);
result.setResult(texts);
log.info(result.toString());
}else {
result.error500("字典Code格式不正确");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
return result;
}
return result;
}
/**
* 根据表名——显示字段-存储字段 pid 加载树形数据
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadTreeData(@RequestParam(name="pid") String pid,@RequestParam(name="pidField") String pidField,
@RequestParam(name="tableName") String tbname,
@RequestParam(name="text") String text,
@RequestParam(name="code") String code,
@RequestParam(name="hasChildField") String hasChildField,
@RequestParam(name="condition") String condition,
@RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
Map<String, String> query = null;
if(oConvertUtils.isNotEmpty(condition)) {
query = JSON.parseObject(condition, Map.class);
}
// SQL注入漏洞 sign签名校验(表名,label字段,val字段,条件)
String dictCode = tbname+","+text+","+code+","+condition;
List<TreeSelectModel> ls = sysDictService.queryTreeList(query,tbname, text, code, pidField, pid,hasChildField);
result.setSuccess(true);
result.setResult(ls);
return result;
}
/**
* 【APP接口】根据字典配置查询表字典数据
* @param query
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/queryTableData")
public Result<List<DictModel>> queryTableData(DictQuery query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(value = "sign",required = false) String sign,HttpServletRequest request){
Result<List<DictModel>> res = new Result<List<DictModel>>();
// SQL注入漏洞 sign签名校验
String dictCode = query.getTable()+","+query.getText()+","+query.getCode();
List<DictModel> ls = this.sysDictService.queryDictTablePageList(query,pageSize,pageNo);
res.setResult(ls);
res.setSuccess(true);
return res;
}
/**
* @功能:新增
* @param sysDict
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result<SysDict> add(@RequestBody SysDict sysDict) {
Result<SysDict> result = new Result<SysDict>();
@ -216,6 +340,7 @@ public class SysDictController {
* @param sysDict
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
Result<SysDict> result = new Result<SysDict>();
@ -237,6 +362,7 @@ public class SysDictController {
* @param id
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
@ -255,6 +381,7 @@ public class SysDictController {
* @param ids
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
@ -331,7 +458,7 @@ public class SysDictController {
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
@ -341,15 +468,29 @@ public class SysDictController {
params.setNeedSave(true);
try {
List<SysDictPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SysDictPage.class, params);
for (SysDictPage page : list) {
// 错误信息
List<String> errorMessage = new ArrayList<>();
int successLines = 0, errorLines = 0;
for (int i=0;i< list.size();i++) {
SysDict po = new SysDict();
BeanUtils.copyProperties(page, po);
if(page.getDelFlag()==null){
po.setDelFlag(1);
}
sysDictService.saveMain(po, page.getSysDictItemList());
BeanUtils.copyProperties(list.get(i), po);
po.setDelFlag(CommonConstant.DEL_FLAG_0);
try {
Integer integer = sysDictService.saveMain(po, list.get(i).getSysDictItemList());
if(integer>0){
successLines++;
}else{
errorLines++;
int lineNumber = i + 1;
errorMessage.add("" + lineNumber + " 行:字典编码已经存在,忽略导入。");
}
} catch (Exception e) {
errorLines++;
int lineNumber = i + 1;
errorMessage.add("" + lineNumber + " 行:字典编码已经存在,忽略导入。");
}
}
return Result.ok("文件导入成功!");
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("文件导入失败:"+e.getMessage());
@ -364,91 +505,6 @@ public class SysDictController {
return Result.error("文件导入失败!");
}
/**
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
* @param dictCode
* @return
*/
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,@RequestParam(name="keyword") String keyword) {
log.info(" 加载字典表数据,加载关键字: "+ keyword);
Result<List<DictModel>> result = new Result<List<DictModel>>();
List<DictModel> ls = null;
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确");
return result;
}
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
result.setSuccess(true);
result.setResult(ls);
log.info(result.toString());
}else {
result.error500("字典Code格式不正确");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
return result;
}
return result;
}
/**
* 根据字典code加载字典text 返回
*/
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String key) {
Result<List<String>> result = new Result<>();
try {
if(dictCode.indexOf(",")!=-1) {
String[] params = dictCode.split(",");
if(params.length!=3) {
result.error500("字典Code格式不正确");
return result;
}
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], key.split(","));
result.setSuccess(true);
result.setResult(texts);
log.info(result.toString());
}else {
result.error500("字典Code格式不正确");
}
} catch (Exception e) {
log.error(e.getMessage(),e);
result.error500("操作失败");
return result;
}
return result;
}
/**
* 根据表名——显示字段-存储字段 pid 加载树形数据
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid") String pid,@RequestParam(name="pidField") String pidField,
@RequestParam(name="tableName") String tbname,
@RequestParam(name="text") String text,
@RequestParam(name="code") String code,
@RequestParam(name="hasChildField") String hasChildField,
@RequestParam(name="condition") String condition) {
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
Map<String, String> query = null;
if(oConvertUtils.isNotEmpty(condition)) {
query = JSON.parseObject(condition, Map.class);
}
List<TreeSelectModel> ls = sysDictService.queryTreeList(query,tbname, text, code, pidField, pid,hasChildField);
result.setSuccess(true);
result.setResult(ls);
return result;
}
/**
* 查询被删除的列表

View File

@ -6,6 +6,7 @@ import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.common.system.query.QueryGenerator;
@ -65,7 +66,6 @@ public class SysDictItemController {
/**
* @功能:新增
* @param sysDict
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.POST)

View File

@ -5,12 +5,10 @@ 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;
@ -18,7 +16,6 @@ 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;
@ -231,9 +228,9 @@ public class SysPermissionController {
this.getAllAuthJsonArray(allauthjsonArray, allAuthList);
//路由菜单
json.put("menu", menujsonArray);
//按钮权限
//按钮权限(用户拥有的权限集合)
json.put("auth", authjsonArray);
//全部权限配置(按钮权限,访问权限)
//全部权限配置集合(按钮权限,访问权限)
json.put("allAuth", allauthjsonArray);
result.setResult(json);
result.success("查询成功");
@ -295,7 +292,6 @@ public class SysPermissionController {
Result<SysPermission> result = new Result<>();
try {
sysPermissionService.deletePermission(id);
sysPermissionService.deletePermRuleByPermId(id);
result.success("删除成功!");
} catch (Exception e) {
log.error(e.getMessage(), e);

View File

@ -7,10 +7,14 @@ 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.apache.poi.ss.formula.functions.T;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.ImportExcelUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.jeecg.modules.system.entity.SysPosition;
import org.jeecg.modules.system.service.ISysPositionService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
@ -29,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -219,9 +224,12 @@ public class SysPositionController {
* @return
*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// 错误信息
List<String> errorMessage = new ArrayList<>();
int successLines = 0, errorLines = 0;
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
@ -229,9 +237,10 @@ public class SysPositionController {
params.setHeadRows(1);
params.setNeedSave(true);
try {
List<SysPosition> listSysPositions = ExcelImportUtil.importExcel(file.getInputStream(), SysPosition.class, params);
sysPositionService.saveBatch(listSysPositions);
return Result.ok("文件导入成功!数据行数:" + listSysPositions.size());
List<Object> listSysPositions = ExcelImportUtil.importExcel(file.getInputStream(), SysPosition.class, params);
List<String> list = ImportExcelUtil.importDateSave(listSysPositions, ISysPositionService.class, errorMessage,CommonConstant.SQL_INDEX_UNIQ_CODE);
errorLines+=list.size();
successLines+=(listSysPositions.size()-errorLines);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("文件导入失败:" + e.getMessage());
@ -243,7 +252,7 @@ public class SysPositionController {
}
}
}
return Result.ok("文件导入失败!");
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
}
}

View File

@ -109,6 +109,7 @@ public class SysRoleController {
* @return
*/
@RequestMapping(value = "/add", method = RequestMethod.POST)
//@RequiresRoles({"admin"})
public Result<SysRole> add(@RequestBody SysRole role) {
Result<SysRole> result = new Result<SysRole>();
try {
@ -127,6 +128,7 @@ public class SysRoleController {
* @param role
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
public Result<SysRole> edit(@RequestBody SysRole role) {
Result<SysRole> result = new Result<SysRole>();
@ -150,6 +152,7 @@ public class SysRoleController {
* @param id
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
sysRoleService.deleteRole(id);
@ -161,6 +164,7 @@ public class SysRoleController {
* @param ids
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<SysRole> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
Result<SysRole> result = new Result<SysRole>();

View File

@ -2,10 +2,11 @@ package org.jeecg.modules.system.controller;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.CommonUtils;
import org.jeecg.common.util.MinioUtil;
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;
@ -39,6 +40,7 @@ public class SysUploadController {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
String orgName = file.getOriginalFilename();// 获取文件名
orgName = CommonUtils.getFileName(orgName);
String file_url = MinioUtil.upload(file,bizPath);
//保存文件信息
OSSFile minioFile = new OSSFile();

View File

@ -23,6 +23,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -57,6 +58,9 @@ import lombok.extern.slf4j.Slf4j;
public class SysUserAgentController {
@Autowired
private ISysUserAgentService sysUserAgentService;
@Value("${jeecg.path.upload}")
private String upLoadPath;
/**
* 分页列表查询
@ -199,8 +203,8 @@ public class SysUserAgentController {
/**
* 导出excel
*
* @param sysUserAgent
* @param request
* @param response
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) {
@ -213,7 +217,9 @@ public class SysUserAgentController {
mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"));
ExportParams exportParams = new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息");
exportParams.setImageBasePath(upLoadPath);
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}

View File

@ -16,24 +16,20 @@ 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.aspect.annotation.PermissionData;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
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.PasswordUtil;
import org.jeecg.common.util.PmsUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
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.entity.*;
import org.jeecg.modules.system.model.DepartIdModel;
import org.jeecg.modules.system.model.SysUserSysDepartModel;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserDepartService;
import org.jeecg.modules.system.service.ISysUserRoleService;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.system.service.*;
import org.jeecg.modules.system.vo.SysDepartUsersVO;
import org.jeecg.modules.system.vo.SysUserRoleVO;
import org.jeecgframework.poi.excel.ExcelImportUtil;
@ -42,6 +38,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -49,6 +46,7 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@ -83,14 +81,34 @@ public class SysUserController {
@Autowired
private ISysUserRoleService userRoleService;
@Autowired
private ISysDepartRoleUserService departRoleUserService;
@Autowired
private ISysDepartRoleService departRoleService;
@Autowired
private RedisUtil redisUtil;
@Value("${jeecg.path.upload}")
private String upLoadPath;
/**
* 获取用户列表数据
* @param user
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@PermissionData(pageComponent = "system/UserList")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
//TODO 外部模拟登陆临时账号,列表不显示
queryWrapper.ne("username","_reserve_user_external");
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
@ -125,7 +143,7 @@ public class SysUserController {
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), salt);
user.setPassword(passwordEncode);
user.setStatus(1);
user.setDelFlag("0");
user.setDelFlag(CommonConstant.DEL_FLAG_0);
sysUserService.addUserWithRole(user, selectedRoles);
sysUserService.addUserWithDepart(user, selectedDeparts);
result.success("添加成功!");
@ -137,6 +155,7 @@ public class SysUserController {
}
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
//@RequiresRoles({"admin"})
//@RequiresPermissions("user:edit")
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>();
@ -154,6 +173,7 @@ public class SysUserController {
String departs = jsonObject.getString("selecteddeparts");
sysUserService.editUserWithRole(user, roles);
sysUserService.editUserWithDepart(user, departs);
sysUserService.updateNullPhoneEmail();
result.success("修改成功!");
}
} catch (Exception e) {
@ -166,6 +186,7 @@ public class SysUserController {
/**
* 删除用户
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
sysBaseAPI.addLog("删除用户id " +id ,CommonConstant.LOG_TYPE_2, 3);
@ -176,6 +197,7 @@ public class SysUserController {
/**
* 批量删除用户
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
sysBaseAPI.addLog("批量删除用户, ids " +ids ,CommonConstant.LOG_TYPE_2, 3);
@ -188,6 +210,7 @@ public class SysUserController {
* @param jsonObject
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/frozenBatch", method = RequestMethod.PUT)
public Result<SysUser> frozenBatch(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>();
@ -274,7 +297,7 @@ public class SysUserController {
/**
* 修改密码
*/
@RequiresRoles({"admin"})
//@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()));
@ -336,11 +359,11 @@ public class SysUserController {
* @return
*/
@RequestMapping(value = "/queryUserByDepId", method = RequestMethod.GET)
public Result<List<SysUser>> queryUserByDepId(@RequestParam(name = "id", required = true) String id) {
public Result<List<SysUser>> queryUserByDepId(@RequestParam(name = "id", required = true) String id,@RequestParam(name="realname",required=false) String realname) {
Result<List<SysUser>> result = new Result<>();
//List<SysUser> userList = sysUserDepartService.queryUserByDepId(id);
SysDepart sysDepart = sysDepartService.getById(id);
List<SysUser> userList = sysUserDepartService.queryUserByDepCode(sysDepart.getOrgCode());
List<SysUser> userList = sysUserDepartService.queryUserByDepCode(sysDepart.getOrgCode(),realname);
//批量查询用户的所属部门
//step.1 先拿到全部的 useids
@ -365,20 +388,6 @@ public class SysUserController {
}
}
/**
* 查询所有用户所对应的角色信息
*
* @return
*/
@RequestMapping(value = "/queryUserRoleMap", method = RequestMethod.GET)
public Result<Map<String, String>> queryUserRole() {
Result<Map<String, String>> result = new Result<>();
Map<String, String> map = userRoleService.queryUserRole();
result.setResult(map);
result.setSuccess(true);
return result;
}
/**
* 导出excel
*
@ -403,7 +412,9 @@ public class SysUserController {
mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
ExportParams exportParams = new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息");
exportParams.setImageBasePath(upLoadPath);
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
return mv;
}
@ -420,6 +431,9 @@ public class SysUserController {
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
// 错误信息
List<String> errorMessage = new ArrayList<>();
int successLines = 0, errorLines = 0;
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
MultipartFile file = entity.getValue();// 获取上传文件对象
ImportParams params = new ImportParams();
@ -428,17 +442,54 @@ public class SysUserController {
params.setNeedSave(true);
try {
List<SysUser> listSysUsers = ExcelImportUtil.importExcel(file.getInputStream(), SysUser.class, params);
for (SysUser sysUserExcel : listSysUsers) {
if (sysUserExcel.getPassword() == null) {
// 密码默认为“123456”
for (int i = 0; i < listSysUsers.size(); i++) {
SysUser sysUserExcel = listSysUsers.get(i);
if (StringUtils.isBlank(sysUserExcel.getPassword())) {
// 密码默认为 “123456”
sysUserExcel.setPassword("123456");
}
sysUserService.save(sysUserExcel);
// 密码加密加盐
String salt = oConvertUtils.randomGen(8);
sysUserExcel.setSalt(salt);
String passwordEncode = PasswordUtil.encrypt(sysUserExcel.getUsername(), sysUserExcel.getPassword(), salt);
sysUserExcel.setPassword(passwordEncode);
try {
sysUserService.save(sysUserExcel);
successLines++;
} catch (Exception e) {
errorLines++;
String message = e.getMessage();
int lineNumber = i + 1;
// 通过索引名判断出错信息
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_USERNAME)) {
errorMessage.add("" + lineNumber + " 行:用户名已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_WORK_NO)) {
errorMessage.add("" + lineNumber + " 行:工号已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_PHONE)) {
errorMessage.add("" + lineNumber + " 行:手机号已经存在,忽略导入。");
} else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_USER_EMAIL)) {
errorMessage.add("" + lineNumber + " 行:电子邮件已经存在,忽略导入。");
} else {
errorMessage.add("" + lineNumber + " 行:未知错误,忽略导入");
log.error(e.getMessage(), e);
}
}
// 批量将部门和用户信息建立关联关系
String departIds = sysUserExcel.getDepartIds();
if (StringUtils.isNotBlank(departIds)) {
String userId = sysUserExcel.getId();
String[] departIdArray = departIds.split(",");
List<SysUserDepart> userDepartList = new ArrayList<>(departIdArray.length);
for (String departId : departIdArray) {
userDepartList.add(new SysUserDepart(userId, departId));
}
sysUserDepartService.saveBatch(userDepartList);
}
}
return Result.ok("文件导入成功!数据行数:" + listSysUsers.size());
} catch (Exception e) {
log.error(e.getMessage(),e);
return Result.error("抱歉! 您导入的数据中用户名已经存在.");
errorMessage.add("发生异常:" + e.getMessage());
log.error(e.getMessage(), e);
} finally {
try {
file.getInputStream().close();
@ -447,7 +498,27 @@ public class SysUserController {
}
}
}
return Result.error("文件导入失败!");
if (errorLines == 0) {
return Result.ok("" + successLines + "行数据全部导入成功!");
} else {
JSONObject result = new JSONObject(5);
int totalCount = successLines + errorLines;
result.put("totalCount", totalCount);
result.put("errorCount", errorLines);
result.put("successCount", successLines);
result.put("msg", "总上传行数:" + totalCount + ",已导入行数:" + successLines + ",错误行数:" + errorLines);
String fileUrl = PmsUtil.saveErrorTxtByList(errorMessage, "userImportExcelErrorLog");
int lastIndex = fileUrl.lastIndexOf(File.separator);
String fileName = fileUrl.substring(lastIndex + 1);
result.put("fileUrl", "/sys/common/static/" + fileUrl);
result.put("fileName", fileName);
Result res = Result.ok(result);
res.setCode(201);
res.setMessage("文件导入成功,但有错误。");
return res;
}
}
/**
@ -469,6 +540,7 @@ public class SysUserController {
/**
* 首页用户重置密码
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/updatePassword", method = RequestMethod.PUT)
public Result<?> changPassword(@RequestBody JSONObject json) {
String username = json.getString("username");
@ -501,6 +573,7 @@ public class SysUserController {
* @param
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/addSysUserRole", method = RequestMethod.POST)
public Result<String> addSysUserRole(@RequestBody SysUserRoleVO sysUserRoleVO) {
Result<String> result = new Result<String>();
@ -531,6 +604,7 @@ public class SysUserController {
* @param
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteUserRole", method = RequestMethod.DELETE)
public Result<SysUserRole> deleteUserRole(@RequestParam(name="roleId") String roleId,
@RequestParam(name="userId",required=true) String userId
@ -554,6 +628,7 @@ public class SysUserController {
* @param
* @return
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteUserRoleBatch", method = RequestMethod.DELETE)
public Result<SysUserRole> deleteUserRoleBatch(
@RequestParam(name="roleId") String roleId,
@ -586,7 +661,7 @@ public class SysUserController {
//部门id为空时查询我的部门下所有用户
if(oConvertUtils.isEmpty(depId)){
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
int userIdentity = user.getIdentity() != null?user.getIdentity():CommonConstant.USER_IDENTITY_1;
int userIdentity = user.getUserIdentity() != null?user.getUserIdentity():CommonConstant.USER_IDENTITY_1;
if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
}
@ -652,21 +727,21 @@ public class SysUserController {
JSONArray resultJson = new JSONArray(list.size());
for (SysUserSysDepartModel item : list) {
String userId = item.getSysUser().getId();
String userId = item.getId();
// userId
JSONObject getModel = hasUser.get(userId);
// 之前已存在过该用户,直接合并数据
if (getModel != null) {
String departName = getModel.get("departName").toString();
getModel.put("departName", (departName + " | " + item.getSysDepart().getDepartName()));
getModel.put("departName", (departName + " | " + item.getDepartName()));
} else {
// 将用户对象转换为json格式并将部门信息合并到 json 中
JSONObject json = JSON.parseObject(JSON.toJSONString(item.getSysUser()));
JSONObject json = JSON.parseObject(JSON.toJSONString(item));
json.remove("id");
json.put("userId", userId);
json.put("departId", item.getSysDepart().getId());
json.put("departName", item.getSysDepart().getDepartName());
json.put("departId", item.getDepartId());
json.put("departName", item.getDepartName());
// json.put("avatar", item.getSysUser().getAvatar());
resultJson.add(json);
hasUser.put(userId, json);
}
@ -680,6 +755,7 @@ public class SysUserController {
/**
* 给指定部门添加对应的用户
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/editSysDepartWithUser", method = RequestMethod.POST)
public Result<String> editSysDepartWithUser(@RequestBody SysDepartUsersVO sysDepartUsersVO) {
Result<String> result = new Result<String>();
@ -708,6 +784,7 @@ public class SysUserController {
/**
* 删除指定机构的用户关系
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteUserInDepart", method = RequestMethod.DELETE)
public Result<SysUserDepart> deleteUserInDepart(@RequestParam(name="depId") String depId,
@RequestParam(name="userId",required=true) String userId
@ -718,6 +795,13 @@ public class SysUserController {
queryWrapper.eq("dep_id", depId).eq("user_id",userId);
boolean b = sysUserDepartService.remove(queryWrapper);
if(b){
List<SysDepartRole> sysDepartRoleList = departRoleService.list(new QueryWrapper<SysDepartRole>().eq("depart_id",depId));
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
if(roleIds != null && roleIds.size()>0){
QueryWrapper<SysDepartRoleUser> query = new QueryWrapper<>();
query.eq("user_id",userId).in("drole_id",roleIds);
departRoleUserService.remove(query);
}
result.success("删除成功!");
}else{
result.error500("当前选中部门与用户无关联关系!");
@ -732,6 +816,7 @@ public class SysUserController {
/**
* 批量删除指定机构的用户关系
*/
//@RequiresRoles({"admin"})
@RequestMapping(value = "/deleteUserInDepartBatch", method = RequestMethod.DELETE)
public Result<SysUserDepart> deleteUserInDepartBatch(
@RequestParam(name="depId") String depId,
@ -740,7 +825,10 @@ public class SysUserController {
try {
QueryWrapper<SysUserDepart> queryWrapper = new QueryWrapper<SysUserDepart>();
queryWrapper.eq("dep_id", depId).in("user_id",Arrays.asList(userIds.split(",")));
sysUserDepartService.remove(queryWrapper);
boolean b = sysUserDepartService.remove(queryWrapper);
if(b){
departRoleUserService.removeDeptRoleUser(Arrays.asList(userIds.split(",")),depId);
}
result.success("删除成功!");
}catch(Exception e) {
log.error(e.getMessage(), e);
@ -836,9 +924,9 @@ public class SysUserController {
user.setPassword(passwordEncode);
user.setEmail(email);
user.setPhone(phone);
user.setStatus(1);
user.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
user.setActivitiSync(CommonConstant.ACT_SYNC_1);
user.setStatus(CommonConstant.USER_UNFREEZE);
user.setDelFlag(CommonConstant.DEL_FLAG_0);
user.setActivitiSync(CommonConstant.ACT_SYNC_0);
sysUserService.addUserWithRole(user,"ee8626f80f7c2619917b6236f3a7f02b");//默认临时角色 test
result.success("注册成功");
} catch (Exception e) {
@ -848,8 +936,8 @@ public class SysUserController {
}
/**
*
* @param 根据用户名或手机号查询用户信息
* 根据用户名或手机号查询用户信息
* @param
* @return
*/
@GetMapping("/querySysUser")
@ -984,7 +1072,7 @@ public class SysUserController {
}
/**
* 获取用户列表 根据用户名和真实名 模糊匹配
* 【APP端接口】获取用户列表 根据用户名和真实名 模糊匹配
* @param keyword
* @param pageNo
* @param pageSize
@ -992,6 +1080,7 @@ public class SysUserController {
*/
@GetMapping("/appUserList")
public Result<?> appUserList(@RequestParam(name = "keyword", required = false) String keyword,
@RequestParam(name = "username", required = false) String username,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
try {
@ -999,8 +1088,11 @@ public class SysUserController {
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
query.eq(SysUser::getActivitiSync, "1");
query.eq(SysUser::getDelFlag,"0");
query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
if(oConvertUtils.isNotEmpty(username)){
query.eq(SysUser::getUsername,username);
}else{
query.and(i -> i.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname, keyword));
}
Page<SysUser> page = new Page<>(pageNo, pageSize);
IPage<SysUser> res = this.sysUserService.page(page, query);
return Result.ok(res);
@ -1033,16 +1125,17 @@ public class SysUserController {
/**
* 还原被逻辑删除的用户
*
* @param userIds 被还原的用户ID是个 list 集合
* @param jsonObject
* @return
*/
@PutMapping("/recycleBin")
public Result putRecycleBin(@RequestBody List<String> userIds, HttpServletRequest request) {
if (userIds != null && userIds.size() > 0) {
@RequestMapping(value = "/putRecycleBin", method = RequestMethod.PUT)
public Result putRecycleBin(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
String userIds = jsonObject.getString("userIds");
if (StringUtils.isNotBlank(userIds)) {
SysUser updateUser = new SysUser();
updateUser.setUpdateBy(JwtUtil.getUserNameByToken(request));
updateUser.setUpdateTime(new Date());
sysUserService.revertLogicDeleted(userIds, updateUser);
sysUserService.revertLogicDeleted(Arrays.asList(userIds.split(",")), updateUser);
}
return Result.ok("还原成功");
}
@ -1053,7 +1146,7 @@ public class SysUserController {
* @param userIds 被删除的用户ID多个id用半角逗号分割
* @return
*/
@DeleteMapping("/recycleBin")
@RequestMapping(value = "/deleteRecycleBin", method = RequestMethod.DELETE)
public Result deleteRecycleBin(@RequestParam("userIds") String userIds) {
if (StringUtils.isNotBlank(userIds)) {
sysUserService.removeLogicDeleted(Arrays.asList(userIds.split(",")));
@ -1061,4 +1154,31 @@ public class SysUserController {
return Result.ok("删除成功");
}
/**
* 移动端修改用户信息
* @param jsonObject
* @return
*/
@RequestMapping(value = "/appEdit", method = RequestMethod.PUT)
public Result<SysUser> appEdit(@RequestBody JSONObject jsonObject) {
Result<SysUser> result = new Result<SysUser>();
try {
SysUser sysUser = sysUserService.getById(jsonObject.getString("id"));
sysBaseAPI.addLog("移动端编辑用户id " +jsonObject.getString("id") ,CommonConstant.LOG_TYPE_2, 2);
if(sysUser==null) {
result.error500("未找到对应用户!");
}else {
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
user.setUpdateTime(new Date());
user.setPassword(sysUser.getPassword());
sysUserService.updateById(user);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
result.error500("操作失败!");
}
return result;
}
}

View File

@ -0,0 +1,140 @@
package org.jeecg.modules.system.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xkcoding.justauth.AuthRequestFactory;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @Author scott
* @since 2018-12-17
*/
@Controller
@RequestMapping("/thirdLogin")
@Slf4j
public class ThirdLoginController {
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysBaseAPI sysBaseAPI;
@Autowired
private RedisUtil redisUtil;
@Autowired
private AuthRequestFactory factory;
@RequestMapping("/render/{source}")
public void render(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
log.info("第三方登录进入render" + source);
AuthRequest authRequest = factory.get(source);
String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
log.info("第三方登录认证地址:" + authorizeUrl);
response.sendRedirect(authorizeUrl);
}
@RequestMapping("/{source}/callback")
public String login(@PathVariable("source") String source, AuthCallback callback,ModelMap modelMap) {
log.info("第三方登录进入callback" + source + " params" + JSONObject.toJSONString(callback));
AuthRequest authRequest = factory.get(source);
AuthResponse response = authRequest.login(callback);
log.info(JSONObject.toJSONString(response));
Result<JSONObject> result = new Result<JSONObject>();
if(response.getCode()==2000) {
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(response.getData()));
String username = data.getString("username");
String avatar = data.getString("avatar");
String uuid = data.getString("uuid");
//判断有没有这个人
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>();
query.eq(SysUser::getThirdId, uuid);
query.eq(SysUser::getThirdType, source);
List<SysUser> thridList = sysUserService.list(query);
SysUser user = null;
if(thridList==null || thridList.size()==0) {
user = new SysUser();
user.setActivitiSync(CommonConstant.ACT_SYNC_0);
user.setDelFlag(CommonConstant.DEL_FLAG_0);
user.setStatus(1);
user.setThirdId(uuid);
user.setThirdType(source);
user.setAvatar(avatar);
user.setUsername(uuid);
user.setRealname(username);
//设置初始密码
String salt = oConvertUtils.randomGen(8);
user.setSalt(salt);
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), "123456", salt);
user.setPassword(passwordEncode);
sysUserService.saveThirdUser(user);
}else {
//已存在 只设置用户名 不设置头像
user = thridList.get(0);
//user.setUsername(username);
//sysUserService.updateById(user);
}
// 生成token
String token = JwtUtil.sign(user.getUsername(), user.getPassword());
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
// 设置超时时间
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
modelMap.addAttribute("token", token);
}
result.setSuccess(false);
result.setMessage("第三方登录异常,请联系管理员");
return "thirdLogin";
}
@SuppressWarnings("unchecked")
@RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET)
@ResponseBody
public Result<JSONObject> getLoginUser(@PathVariable("token") String token) throws Exception {
Result<JSONObject> result = new Result<JSONObject>();
String username = JwtUtil.getUsername(token);
//1. 校验用户是否有效
SysUser sysUser = sysUserService.getUserByName(username);
result = sysUserService.checkUserIsEffective(sysUser);
if(!result.isSuccess()) {
return result;
}
JSONObject obj = new JSONObject();
//用户登录信息
obj.put("userInfo", sysUser);
//token 信息
obj.put("token", token);
result.setResult(obj);
result.setSuccess(true);
result.setCode(200);
sysBaseAPI.addLog("用户名: " + username + ",登录成功[第三方用户]", CommonConstant.LOG_TYPE_1, null);
return result;
}
}

View File

@ -140,4 +140,8 @@ public class SysAnnouncement implements Serializable {
* 组件/路由 地址
*/
private java.lang.String openPage;
/**
* 摘要
*/
private java.lang.String msgAbstract;
}

View File

@ -90,13 +90,11 @@ public class SysDataSource {
/**
* 创建人
*/
@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 = "创建日期")
@ -104,13 +102,11 @@ public class SysDataSource {
/**
* 更新人
*/
@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 = "更新日期")

View File

@ -46,12 +46,11 @@ public class SysDepart implements Serializable {
private Integer departOrder;
/**描述*/
@Excel(name="描述",width=15)
private Object description;
private String description;
/**机构类别 1组织机构2岗位*/
@Excel(name="机构类别",width=15)
@Excel(name="机构类别",width=15,dicCode="org_category")
private String orgCategory;
/**机构类型*/
@Excel(name="机构类型",width=15)
private String orgType;
/**机构编码*/
@Excel(name="机构编码",width=15)
@ -69,11 +68,9 @@ public class SysDepart implements Serializable {
@Excel(name="备注",width=15)
private String memo;
/**状态1启用0不启用*/
@Excel(name="状态",width=15)
@Dict(dicCode = "depart_status")
private String status;
/**删除状态0正常1已删除*/
@Excel(name="删除状态",width=15)
@Dict(dicCode = "del_flag")
private String delFlag;
/**创建人*/

View File

@ -164,6 +164,7 @@ public class SysPermission implements Serializable {
this.id = "9502685863ab87f0ad1134142788a385";
this.name="首页";
this.component="dashboard/Analysis";
this.componentName="dashboard-analysis";
this.url="/dashboard/analysis";
this.icon="home";
this.menuType=0;

View File

@ -60,13 +60,11 @@ public class SysPosition {
/**
* 创建人
*/
@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 = "创建时间")
@ -74,13 +72,11 @@ public class SysPosition {
/**
* 修改人
*/
@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 = "修改时间")

View File

@ -67,7 +67,7 @@ public class SysUser implements Serializable {
/**
* 头像
*/
@Excel(name = "头像", width = 15)
@Excel(name = "头像", width = 15,type = 2)
private String avatar;
/**
@ -114,7 +114,7 @@ public class SysUser implements Serializable {
*/
@Excel(name = "删除状态", width = 15,dicCode="del_flag")
@TableLogic
private String delFlag;
private Integer delFlag;
/**
* 工号,唯一键
@ -156,13 +156,13 @@ public class SysUser implements Serializable {
/**
* 同步工作流引擎1同步0不同步
*/
private String activitiSync;
private Integer activitiSync;
/**
* 身份0 普通成员 1 上级)
*/
@Excel(name="1普通成员 2上级",width = 15)
private Integer identity;
private Integer userIdentity;
/**
* 负责部门
@ -170,4 +170,16 @@ public class SysUser implements Serializable {
@Excel(name="负责部门",width = 15,dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
private String departIds;
/**
* 第三方登录的唯一标识
*/
private String thirdId;
/**
* 第三方类型 <br>
* github/githubwechat_enterprise/企业微信dingtalk/钉钉)
*/
private String thirdType;
}

View File

@ -13,5 +13,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @Version: V1.0
*/
public interface SysDepartRoleMapper extends BaseMapper<SysDepartRole> {
/**
* 根据用户id部门id查询可授权所有部门角色
* @param orgCode
* @param userId
* @return
*/
public List<SysDepartRole> queryDeptRoleByDeptAndUser(@Param("orgCode") String orgCode, @Param("userId") String userId);
}

View File

@ -3,11 +3,13 @@ package org.jeecg.modules.system.mapper;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.system.vo.DictQuery;
import org.jeecg.modules.system.entity.SysDict;
import org.jeecg.modules.system.model.DuplicateCheckVo;
import org.jeecg.modules.system.model.TreeSelectModel;
@ -32,14 +34,19 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);
public List<DictModel> queryDictItemsByCode(@Param("code") String code);
public List<DictModel> queryTableDictItemsByCode(@Param("table") String table,@Param("text") String text,@Param("code") String code);
public List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("filterSql") String filterSql);
@Deprecated
public List<DictModel> queryTableDictItemsByCode(@Param("table") String table,@Param("text") String text,@Param("code") String code);
@Deprecated
public List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("filterSql") String filterSql);
public String queryDictTextByKey(@Param("code") String code,@Param("key") String key);
@Deprecated
public String queryTableDictTextByKey(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("key") String key);
@Deprecated
public List<DictModel> queryTableDictByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyArray") String[] keyArray);
/**
@ -62,6 +69,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
* @param keyword
* @return
*/
@Deprecated
public List<DictModel> queryTableDictItems(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("keyword") String keyword);
/**
@ -73,6 +81,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
* @param hasChildField
* @return
*/
@Deprecated
List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
/**
@ -97,4 +106,13 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
@Update("update sys_dict set del_flag = #{flag,jdbcType=INTEGER} where id = #{id,jdbcType=VARCHAR}")
public void updateDictDelFlag(@Param("flag") int delFlag, @Param("id") String id);
/**
* 分页查询字典表数据
* @param page
* @param query
* @return
*/
@Deprecated
public Page<DictModel> queryDictTablePageList(Page page, @Param("query") DictQuery query);
}

View File

@ -43,4 +43,15 @@ public interface SysPermissionMapper extends BaseMapper<SysPermission> {
@Select("SELECT url FROM sys_permission WHERE del_flag = 0 and menu_type = 2 and url like '%*%'")
public List<String> queryPermissionUrlWithStar();
/**
* 根据用户账号查询菜单权限
* @param sysPermission
* @param username
* @return
*/
public int queryCountByUsername(@Param("username") String username, @Param("permission") SysPermission sysPermission);
}

View File

@ -130,4 +130,13 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
*/
int deleteLogicDeleted(@Param("userIds") String userIds);
/** 更新空字符串为null【此写法有sql注入风险禁止随便用】 */
int updateNullByEmptyString(@Param("fieldName") String fieldName);
/**
* 根据部门Ids,查询部门下用户信息
* @param departIds
* @return
*/
List<SysUser> queryByDepIds(@Param("departIds")List<String> departIds,@Param("username") String username);
}

View File

@ -33,7 +33,8 @@
where send_status = '1'
and del_flag = '0'
and msg_category = #{msgCategory}
and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = '0')
and id IN ( select annt_id from sys_announcement_send where user_id = #{userId} and read_flag = '0')
order by create_time DESC
</select>
</mapper>

View File

@ -36,19 +36,32 @@
sa.send_time as send_time,
sa.bus_id as bus_id,
sa.open_type as open_type,
sa.open_page as open_page
sa.open_page as open_page,
sa.msg_abstract
from sys_announcement_send sas
left join sys_announcement sa ON sas.annt_id = sa.id
where sa.send_status = '1'
and sa.del_flag = '0'
and sas.user_id = #{announcementSendModel.userId}
<if test="announcementSendModel.titile !=null and announcementSendModel.titile != ''">
and sa.titile = #{announcementSendModel.titile}
and sa.titile LIKE concat(concat('%',#{announcementSendModel.titile}),'%')
</if>
<if test="announcementSendModel.sender !=null and announcementSendModel.sender != ''">
and sa.sender = #{announcementSendModel.sender}
and sa.sender LIKE concat(concat('%',#{announcementSendModel.sender}),'%')
</if>
order by sa.send_time desc
<if test="announcementSendModel.readFlag !=null and announcementSendModel.readFlag != ''">
and sas.read_flag = #{announcementSendModel.readFlag}
</if>
<if test="announcementSendModel.busType !=null and announcementSendModel.busType != ''">
and sa.bus_type = #{announcementSendModel.busType}
</if>
<if test="announcementSendModel.bizSource !=null and announcementSendModel.bizSource =='isNoBpm'">
and (sa.bus_type != 'bpm' or sa.bus_type is null)
</if>
<if test="announcementSendModel.msgCategory !=null and announcementSendModel.msgCategory != ''">
and sa.msg_category = #{announcementSendModel.msgCategory}
</if>
order by sas.read_flag,sa.send_time desc
</select>
</mapper>

View File

@ -2,4 +2,11 @@
<!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">
<!--根据用户id部门id查询可授权所有部门角色 -->
<select id="queryDeptRoleByDeptAndUser" resultType="org.jeecg.modules.system.entity.SysDepartRole">
SELECT * FROM sys_depart_role WHERE depart_id IN (
SELECT id FROM sys_depart WHERE id IN (SELECT dep_id FROM sys_user_depart WHERE user_id=#{userId})
AND org_code LIKE CONCAT(#{orgCode},'%')
)
</select>
</mapper>

View File

@ -92,6 +92,18 @@
</foreach>
</if>
</select>
<!-- 分页查询字典表数据 -->
<select id="queryDictTablePageList" parameterType="Object" resultType="org.jeecg.common.system.vo.DictModel">
select ${query.text} as "text",${query.code} as "value" from ${query.table}
where 1 = 1
<if test="query.keyword != null and query.keyword != ''">
and (${query.text} like '%${query.keyword}%' or ${query.code} like '%${query.keyword}%')
</if>
<if test="query.codeValue != null and query.codeValue != ''">
and ${query.code} = #{query.codeValue}
</if>
</select>
</mapper>

View File

@ -51,12 +51,10 @@
join sys_user d on d.id = c.user_id
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
)
<!--update begin Author:taoyan Date:20200225 for默认授权online的auto动态隐藏路由 -->
or (p.url like '%:code' and p.url like '/online%' and p.hidden = 1)
or (p.url = '/online') )
<!--update end Author:taoyan Date:20200213 for默认授权online的auto动态隐藏路由 -->
or p.url = '/online')
and p.del_flag = 0
<!--update begin Author:lvdandan Date:20200225 for加入部门权限 -->
<!--update begin Author:lvdandan Date:20200213 for加入部门权限 -->
UNION
SELECT p.*
FROM sys_permission p
@ -71,7 +69,40 @@
<!--update end Author:lvdandan Date:20200213 for加入部门权限 -->
) h order by h.sort_no ASC
</select>
<!-- 根据用户账号查询菜单权限 -->
<select id="queryCountByUsername" parameterType="Object" resultType="int">
select sum(cnt) from (
select count(*) as cnt
from sys_role_permission a
join sys_permission b on a.permission_id = b.id
join sys_role c on a.role_id = c.id
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}
<if test="permission.id !=null and permission.id != ''">
and b.id = #{permission.id}
</if>
<if test="permission.url !=null and permission.url != ''">
and b.url = #{permission.url}
</if>
union all
select count(*) as cnt
from sys_permission z
join sys_depart_role_permission y on z.id = y.permission_id
join sys_depart_role x on y.role_id = x.id
join sys_depart_role_user w on w.drole_id = x.id
join sys_user v on w.user_id = v.id
where v.username = #{username}
<if test="permission.id !=null and permission.id != ''">
and z.id = #{permission.id}
</if>
<if test="permission.url !=null and permission.url != ''">
and z.url = #{permission.url}
</if>
) temp
</select>
</mapper>

View File

@ -4,12 +4,12 @@
<!-- 根据用户名查询 -->
<select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where username = #{username} and del_flag = '0'
select * from sys_user where username = #{username} and del_flag = 0
</select>
<!-- 根据部门Id查询 -->
<select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_depart where dep_id=#{departId})
select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_depart where dep_id=#{departId})
<if test="username!=null and username!=''">
and username = #{username}
</if>
@ -25,7 +25,7 @@
<!-- 通过多个部门IDS查询部门下的用户信息 -->
<select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where del_flag = '0'
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=")">
@ -40,7 +40,7 @@
<!-- 根据角色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})
select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_role where role_id=#{roleId})
<if test="username!=null and username!=''">
and username = #{username}
</if>
@ -53,31 +53,29 @@
<!-- 根据手机号查询 -->
<select id="getUserByPhone" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where phone = #{phone} and del_flag = '0'
select * from sys_user where phone = #{phone} and del_flag = 0
</select>
<!-- 根据邮箱查询用户信息 -->
<select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser">
select * from sys_user where email = #{email} and del_flag = '0'
select * from sys_user where email = #{email} and del_flag = 0
</select>
<!-- SQL片段getUserByOrgCode 的 FROM 和 WHERE 部分 -->
<sql id="getUserByOrgCodeFromSql">
FROM
sys_depart
-- 关联查询出该部门有哪些用户
INNER JOIN sys_user_depart ON sys_user_depart.dep_id = sys_depart.id
-- 关联查询出该用户的详细信息
INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id
WHERE
sys_user.del_flag = "0" AND 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 != ''">
AND sys_user.realname LIKE '%${userParams.realname}%'
AND sys_user.realname LIKE concat(concat('%',#{userParams.realname}),'%')
</if>
<if test="userParams.workNo != null and userParams.workNo != ''">
AND sys_user.work_no LIKE '%${userParams.workNo}%'
AND sys_user.work_no LIKE concat(concat('%',#{userParams.workNo}),'%')
</if>
</if>
</sql>
@ -85,15 +83,15 @@
<!-- 根据 orgCode 查询用户,包括子部门下的用户 -->
<select id="getUserByOrgCode" resultType="org.jeecg.modules.system.model.SysUserSysDepartModel">
SELECT
sys_user.id AS "sys_user.id",
sys_user.realname AS "sys_user.realname",
sys_user.work_no AS "sys_user.work_no",
sys_user.post AS "sys_user.post",
sys_user.telephone AS "sys_user.telephone",
sys_user.email AS "sys_user.email",
sys_user.phone AS "sys_user.phone",
sys_depart.id AS "sys_depart.id",
sys_depart.depart_name AS "sys_depart.depart_name"
sys_user.id AS id,
sys_user.realname AS realname,
sys_user.work_no AS workNo,
sys_user.post AS post,
sys_user.telephone AS telephone,
sys_user.email AS email,
sys_user.phone AS phone,
sys_depart.id AS departId,
sys_depart.depart_name AS departName
<include refid="getUserByOrgCodeFromSql"/>
ORDER BY
sys_depart.org_code ASC
@ -131,17 +129,36 @@
UPDATE
sys_user
SET
del_flag = "0",
del_flag = 0,
update_by = #{entity.updateBy},
update_time = #{entity.updateTime}
WHERE
del_flag = "1"
del_flag = 1
AND id IN (${userIds})
</update>
<!-- 彻底删除被逻辑删除的用户 -->
<delete id="deleteLogicDeleted">
DELETE FROM sys_user WHERE del_flag = "1" AND id IN (${userIds})
DELETE FROM sys_user WHERE del_flag = 1 AND id IN (${userIds})
</delete>
<!-- 更新空字符串为null -->
<update id="updateNullByEmptyString">
UPDATE sys_user SET ${fieldName} = NULL WHERE ${fieldName} = ''
</update>
<!-- 通过多个部门IDS查询部门下的用户信息 -->
<select id="queryByDepIds" 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>
</mapper>

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