diff --git a/README.md b/README.md index 166fe6210..32e984fba 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ https://pig4cloud.com ### 使用说明 -[目录](doc/md/catalog.md) +请参考VIP群共享 《从零开始部署pigx》 +[>> 目录](doc/md/catalog.md) ## 协议和授权 diff --git a/doc/pigx.sql b/doc/pigx.sql index b8282bb13..b070e5f44 100644 --- a/doc/pigx.sql +++ b/doc/pigx.sql @@ -1,19 +1,3 @@ -/* - Navicat Premium Data Transfer - - Source Server : 114.116.45.246 - Source Server Type : MySQL - Source Server Version : 50722 - Source Host : 114.116.45.246 - Source Database : pigx - - Target Server Type : MySQL - Target Server Version : 50722 - File Encoding : utf-8 - - Date: 08/18/2018 12:11:52 PM -*/ - SET NAMES utf8; SET FOREIGN_KEY_CHECKS = 0; @@ -30,13 +14,13 @@ CREATE TABLE `sys_dept` ( `del_flag` char(1) DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常', `parent_id` int(11) DEFAULT NULL, PRIMARY KEY (`dept_id`) -) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='部门管理'; +) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='部门管理'; -- ---------------------------- -- Records of `sys_dept` -- ---------------------------- BEGIN; -INSERT INTO `sys_dept` VALUES ('1', '山东农信', null, '2018-01-22 19:00:23', '2018-01-23 12:40:46', '0', '0'), ('2', '沙县国际', null, '2018-01-22 19:00:38', '2018-01-23 12:42:04', '0', '0'), ('3', '潍坊农信', null, '2018-01-22 19:00:44', '2018-01-23 12:40:56', '0', '1'), ('4', '高新农信', null, '2018-01-22 19:00:52', '2018-01-23 12:41:11', '0', '3'), ('5', '院校农信', null, '2018-01-22 19:00:57', '2018-01-23 12:41:22', '0', '4'), ('6', '潍坊学院农信', '115', '2018-01-22 19:01:06', '2018-03-07 16:22:04', '0', '5'), ('7', '山东沙县', null, '2018-01-22 19:01:57', '2018-01-23 12:42:15', '0', '2'), ('8', '潍坊沙县', null, '2018-01-22 19:02:03', '2018-01-23 12:42:23', '0', '7'), ('9', '高新沙县', null, '2018-01-22 19:02:14', '2018-08-03 04:33:16', '1', '8'), ('10', '测试', '110', '2018-06-26 21:26:59', '2018-06-26 21:27:14', '1', '5'); +INSERT INTO `sys_dept` VALUES ('1', '山东农信', null, '2018-01-22 19:00:23', '2018-01-23 12:40:46', '0', '0'), ('2', '沙县国际', null, '2018-01-22 19:00:38', '2018-01-23 12:42:04', '0', '0'), ('3', '潍坊农信', null, '2018-01-22 19:00:44', '2018-01-23 12:40:56', '0', '1'), ('4', '高新农信', null, '2018-01-22 19:00:52', '2018-01-23 12:41:11', '0', '3'), ('5', '院校农信', null, '2018-01-22 19:00:57', '2018-01-23 12:41:22', '0', '4'), ('6', '潍坊学院农信', '1234657', '2018-01-22 19:01:06', '2018-09-09 07:47:20', '1', '5'), ('7', '山东沙县', null, '2018-01-22 19:01:57', '2018-01-23 12:42:15', '0', '2'), ('8', '潍坊沙县', null, '2018-01-22 19:02:03', '2018-01-23 12:42:23', '0', '7'), ('9', '高新沙县', null, '2018-01-22 19:02:14', '2018-08-03 04:33:16', '1', '8'); COMMIT; -- ---------------------------- @@ -55,7 +39,7 @@ CREATE TABLE `sys_dept_relation` ( -- Records of `sys_dept_relation` -- ---------------------------- BEGIN; -INSERT INTO `sys_dept_relation` VALUES ('1', '1'), ('1', '3'), ('1', '4'), ('1', '5'), ('1', '6'), ('2', '2'), ('2', '7'), ('2', '8'), ('3', '3'), ('3', '4'), ('3', '5'), ('3', '6'), ('4', '4'), ('4', '5'), ('4', '6'), ('5', '5'), ('5', '6'), ('6', '6'), ('7', '7'), ('7', '8'), ('8', '8'); +INSERT INTO `sys_dept_relation` VALUES ('1', '1'), ('1', '3'), ('1', '4'), ('1', '5'), ('2', '2'), ('2', '7'), ('2', '8'), ('3', '3'), ('3', '4'), ('3', '5'), ('4', '4'), ('4', '5'), ('5', '5'), ('7', '7'), ('7', '8'), ('8', '8'); COMMIT; -- ---------------------------- @@ -83,7 +67,7 @@ CREATE TABLE `sys_dict` ( -- Records of `sys_dict` -- ---------------------------- BEGIN; -INSERT INTO `sys_dict` VALUES ('2', '9', '异常', 'log_type', '日志异常', '1', '2018-07-09 06:16:14', '2018-07-09 06:16:14', '日志异常', '0'), ('3', '0', '正常', 'log_type', '正常', '0', '2018-07-09 06:15:40', '2018-07-09 06:15:40', '正常', '0'), ('4', '123', '123', '1234', '123', '123', '2018-08-09 07:16:47', '2018-08-16 14:01:03', '123', '1'), ('5', 'WX', '微信', 'social_type', '微信登录', '0', '2018-08-16 14:01:45', '2018-08-16 14:01:45', '微信登录', '0'), ('6', 'QQ', 'QQ', 'social_type', 'QQ登录', '1', '2018-07-09 06:15:40', '2018-07-09 06:15:40', 'QQ登录', '0'); +INSERT INTO `sys_dict` VALUES ('2', '9', '异常', 'log_type', '日志异常', '1', '2018-07-09 06:16:14', '2018-07-09 06:16:14', '日志异常', '0'), ('3', '0', '正常', 'log_type', '正常', '0', '2018-07-09 06:15:40', '2018-07-09 06:15:40', '正常', '0'), ('5', 'WX', '微信', 'social_type', '微信登录', '0', '2018-08-16 14:01:45', '2018-08-16 14:01:45', '微信登录', '0'), ('6', 'QQ', 'QQ', 'social_type', 'QQ登录', '1', '2018-07-09 06:15:40', '2018-07-09 06:15:40', 'QQ登录', '0'); COMMIT; -- ---------------------------- @@ -111,14 +95,7 @@ CREATE TABLE `sys_log` ( KEY `sys_log_request_uri` (`request_uri`), KEY `sys_log_type` (`type`), KEY `sys_log_create_date` (`create_time`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='日志表'; - --- ---------------------------- --- Records of `sys_log` --- ---------------------------- -BEGIN; -INSERT INTO `sys_log` VALUES ('1', '0', '添加字典', 'pig', 'admin', '2018-08-09 07:16:49', null, '0:0:0:0:0:0:0:1', 'PostmanRuntime/7.2.0', '/dict', 'POST', '', '781', '0', null), ('2', '0', '修改字典', 'pig', 'admin', '2018-08-13 15:56:24', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '757', '0', null), ('3', '0', '修改字典', 'pig', 'admin', '2018-08-13 15:59:58', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '521', '0', null), ('4', '0', '修改字典', 'pig', 'admin', '2018-08-13 16:11:35', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '429', '0', null), ('5', '0', '修改字典', 'pig', 'admin', '2018-08-13 16:18:18', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '633', '0', null), ('6', '0', '修改字典', 'pig', 'admin', '2018-08-13 16:21:44', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '487', '0', null), ('7', '0', '修改字典', 'pig', 'admin', '2018-08-14 03:24:48', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '283', '0', null), ('8', '0', '修改字典', 'pig', 'admin', '2018-08-14 03:25:50', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '249', '0', null), ('9', '0', '修改字典', 'pig', 'admin', '2018-08-14 04:03:35', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '209', '0', null), ('10', '0', '修改字典', 'pig', 'admin', '2018-08-14 04:03:35', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '308', '0', null), ('11', '0', '修改字典', 'pig', 'admin', '2018-08-14 04:49:28', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '267', '0', null), ('12', '0', '修改字典', 'pig', 'admin', '2018-08-14 04:52:00', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '414', '0', null), ('13', '0', '删除字典', 'pig', 'admin', '2018-08-16 14:01:05', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict/4/1234', 'DELETE', '', '462', '0', null), ('14', '0', '添加字典', 'pig', 'admin', '2018-08-16 14:01:46', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'POST', '', '448', '0', null), ('15', '0', '修改字典', 'pig', 'admin', '2018-08-16 14:02:01', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '497', '0', null), ('16', '0', '修改字典', 'pig', 'admin', '2018-08-16 14:02:16', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '550', '0', null), ('17', '0', '修改字典', 'pig', 'admin', '2018-08-16 14:02:16', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'PUT', '', '374', '0', null), ('18', '0', '添加字典', 'pig', 'admin', '2018-08-16 14:02:44', null, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', '/dict', 'POST', '', '460', '0', null); -COMMIT; +) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='日志表'; -- ---------------------------- -- Table structure for `sys_menu` @@ -144,7 +121,7 @@ CREATE TABLE `sys_menu` ( -- Records of `sys_menu` -- ---------------------------- BEGIN; -INSERT INTO `sys_menu` VALUES ('1', '系统管理', null, '/admin', '-1', 'icon-xitongguanli', 'Layout', '1', '0', '2017-11-07 20:56:00', '2018-05-14 21:53:22', '0'), ('2', '用户管理', null, 'user', '1', 'icon-yonghuguanli', 'views/admin/user/index', '2', '0', '2017-11-02 22:24:37', '2018-05-14 22:11:35', '0'), ('3', '菜单管理', null, 'menu', '1', 'icon-caidanguanli', 'views/admin/menu/index', '3', '0', '2017-11-08 09:57:27', '2018-05-14 22:11:21', '0'), ('4', '角色管理', null, 'role', '1', 'icon-jiaoseguanli', 'views/admin/role/index', '4', '0', '2017-11-08 10:13:37', '2018-05-14 22:11:19', '0'), ('5', '日志管理', null, 'log', '1', 'icon-rizhiguanli', 'views/admin/log/index', '5', '0', '2017-11-20 14:06:22', '2018-05-14 22:11:18', '0'), ('6', '字典管理', null, 'dict', '1', 'icon-zygl', 'views/admin/dict/index', '6', '0', '2017-11-29 11:30:52', '2018-05-14 22:12:48', '0'), ('7', '部门管理', null, 'dept', '1', 'icon-iconbmgl', 'views/admin/dept/index', '7', '0', '2018-01-20 13:17:19', '2018-05-14 22:11:16', '0'), ('8', '客户端管理', '', 'client', '1', 'icon-bangzhushouji', 'views/admin/client/index', '8', '0', '2018-01-20 13:17:19', '2018-07-29 13:38:19', '0'), ('9', '代码生成', '', 'gen', '1', 'icon-weibiaoti46', 'views/admin/gen/index', '9', '0', '2018-01-20 13:17:19', '2018-08-02 08:19:59', '0'), ('10', '密钥管理', '1', 'social', '1', 'icon-miyue', 'views/admin/social/index', '10', '0', '2018-01-20 13:17:19', '2018-08-16 13:47:27', '0'), ('11', '密钥新增', 'generator_syssocialdetails_add', null, '10', '1', null, '0', '1', '2018-05-15 21:35:18', '2018-08-16 13:39:43', '0'), ('12', '密钥修改', 'generator_syssocialdetails_edit', null, '10', '1', null, '1', '1', '2018-05-15 21:35:18', '2018-08-16 13:39:48', '0'), ('13', '密钥删除', 'generator_syssocialdetails_del', null, '10', '1', null, '2', '1', '2018-05-15 21:35:18', '2018-08-16 13:39:54', '0'), ('22', '用户新增', 'sys_user_add', null, '2', null, null, null, '1', '2017-11-08 09:52:09', '2017-12-04 16:31:10', '0'), ('23', '用户修改', 'sys_user_edit', null, '2', null, null, null, '1', '2017-11-08 09:52:48', '2018-06-26 21:16:57', '0'), ('24', '用户删除', 'sys_user_del', null, '2', null, null, null, '1', '2017-11-08 09:54:01', '2017-12-04 16:31:18', '0'), ('32', '菜单新增', 'sys_menu_add', null, '3', null, null, null, '1', '2017-11-08 10:15:53', '2018-01-20 14:37:50', '0'), ('33', '菜单修改', 'sys_menu_edit', null, '3', null, null, null, '1', '2017-11-08 10:16:23', '2018-01-20 14:37:56', '0'), ('34', '菜单删除', 'sys_menu_del', null, '3', null, null, null, '1', '2017-11-08 10:16:43', '2018-01-20 14:38:03', '0'), ('42', '角色新增', 'sys_role_add', null, '4', null, null, null, '1', '2017-11-08 10:14:18', '2018-04-20 07:21:38', '0'), ('43', '角色修改', 'sys_role_edit', null, '4', null, null, null, '1', '2017-11-08 10:14:41', '2018-04-20 07:21:50', '0'), ('44', '角色删除', 'sys_role_del', null, '4', null, null, null, '1', '2017-11-08 10:14:59', '2018-04-20 07:22:00', '0'), ('45', '分配权限', 'sys_role_perm', null, '4', null, null, null, '1', '2018-04-20 07:22:55', '2018-04-20 07:24:40', '0'), ('52', '日志删除', 'sys_log_del', null, '5', null, null, null, '1', '2017-11-20 20:37:37', '2017-11-28 17:36:52', '0'), ('62', '字典删除', 'sys_dict_del', null, '6', null, null, null, '1', '2017-11-29 11:30:11', '2018-01-07 15:40:51', '0'), ('63', '字典新增', 'sys_dict_add', null, '6', null, null, null, '1', '2018-05-11 22:34:55', null, '0'), ('64', '字典修改', 'sys_dict_edit', null, '6', null, null, null, '1', '2018-05-11 22:36:03', '2018-06-26 21:17:36', '0'), ('72', '部门新增', 'sys_dept_add', null, '7', null, null, null, '1', '2018-01-20 14:56:16', '2018-01-20 21:17:57', '0'), ('73', '部门修改', 'sys_dept_edit', null, '7', null, null, null, '1', '2018-01-20 14:56:59', '2018-01-20 21:17:59', '0'), ('74', '部门删除', 'sys_dept_del', null, '7', null, null, null, '1', '2018-01-20 14:57:28', '2018-01-20 21:18:05', '0'), ('81', '客户端新增', 'sys_client_add', null, '8', '1', null, null, '1', '2018-05-15 21:35:18', '2018-07-29 13:38:59', '0'), ('82', '客户端修改', 'sys_client_edit', null, '8', null, null, null, '1', '2018-05-15 21:37:06', '2018-07-29 13:39:01', '0'), ('83', '客户端删除', 'sys_client_del', null, '8', null, null, null, '1', '2018-05-15 21:39:16', '2018-07-29 13:39:06', '0'), ('100', '系统监控', null, '/daemon', '-1', 'icon-iconbmgl', 'Layout', '2', '0', '2018-07-27 01:13:21', '2018-08-03 14:28:24', '0'), ('101', '服务监控', null, 'http://127.0.0.1:5001', '100', 'icon-jiankong', null, '0', '0', '2018-06-26 10:50:32', '2018-07-29 13:39:48', '0'), ('102', '接口文档', null, 'http://localhost:9999/swagger-ui.html', '100', 'icon-wendangdocument72', null, '1', '0', '2018-06-26 10:50:32', '2018-07-29 13:39:51', '0'), ('103', '任务监控', null, 'http://localhost:http://localhost:8899', '100', 'icon-msnui-supervise', null, '2', '0', '2018-06-26 10:50:32', '2018-07-29 13:40:00', '0'), ('110', '任务轨迹', '', 'statustracelog', '100', 'icon-guiji', 'views/daemon/statustracelog/index', '8', '0', '2018-01-20 13:17:19', '2018-08-03 15:14:28', '0'), ('111', '删除', 'daemon_statustracelog_del', null, '110', '1', null, '2', '1', '2018-05-15 21:35:18', '2018-08-03 15:47:21', '0'); +INSERT INTO `sys_menu` VALUES ('1', '系统管理', null, '/admin', '-1', 'icon-xitongguanli', 'Layout', '1', '0', '2017-11-07 20:56:00', '2018-05-14 21:53:22', '0'), ('2', '用户管理', null, 'user', '1', 'icon-yonghuguanli', 'views/admin/user/index', '2', '0', '2017-11-02 22:24:37', '2018-05-14 22:11:35', '0'), ('3', '菜单管理', null, 'menu', '1', 'icon-caidanguanli', 'views/admin/menu/index', '3', '0', '2017-11-08 09:57:27', '2018-05-14 22:11:21', '0'), ('4', '角色管理', null, 'role', '1', 'icon-jiaoseguanli', 'views/admin/role/index', '4', '0', '2017-11-08 10:13:37', '2018-05-14 22:11:19', '0'), ('5', '日志管理', null, 'log', '1', 'icon-rizhiguanli', 'views/admin/log/index', '5', '0', '2017-11-20 14:06:22', '2018-05-14 22:11:18', '0'), ('6', '字典管理', null, 'dict', '1', 'icon-zygl', 'views/admin/dict/index', '6', '0', '2017-11-29 11:30:52', '2018-05-14 22:12:48', '0'), ('7', '部门管理', null, 'dept', '1', 'icon-iconbmgl', 'views/admin/dept/index', '7', '0', '2018-01-20 13:17:19', '2018-05-14 22:11:16', '0'), ('8', '终端管理', '', 'client', '1', 'icon-bangzhushouji', 'views/admin/client/index', '9', '0', '2018-01-20 13:17:19', '2018-07-29 13:38:19', '0'), ('9', '代码生成', '', 'gen', '1', 'icon-weibiaoti46', 'views/admin/gen/index', '8', '0', '2018-01-20 13:17:19', '2018-08-02 08:19:59', '0'), ('10', '密钥管理', '', 'social', '1', 'icon-miyue', 'views/admin/social/index', '10', '0', '2018-01-20 13:17:19', '2018-09-04 05:51:38', '0'), ('11', '密钥新增', 'generator_syssocialdetails_add', null, '10', '1', null, '0', '1', '2018-05-15 21:35:18', '2018-08-19 07:52:17', '0'), ('12', '密钥修改', 'generator_syssocialdetails_edit', null, '10', '1', null, '1', '1', '2018-05-15 21:35:18', '2018-08-19 07:52:11', '0'), ('13', '密钥删除', 'generator_syssocialdetails_del', null, '10', '1', null, '2', '1', '2018-05-15 21:35:18', '2018-08-19 07:52:06', '0'), ('14', '令牌管理', null, 'token', '1', 'icon-denglvlingpai', 'views/admin/token/index', '11', '0', '2018-09-04 05:58:41', '2018-09-04 05:59:58', '0'), ('15', '令牌删除', 'sys_token_del', null, '14', null, null, '1', '1', '2018-09-04 05:59:50', null, '0'), ('20', '多级菜单', null, '/crud', '-1', 'icon-caidanguanli', 'Layout', '3', '0', '2018-08-28 01:50:22', '2018-08-28 01:52:43', '0'), ('21', '一级菜单', null, 'index', '20', 'icon-caidanguanli', 'Layout', '1', '0', '2018-08-28 01:50:48', '2018-08-28 01:53:07', '0'), ('22', '用户新增', 'sys_user_add', null, '2', null, null, null, '1', '2017-11-08 09:52:09', '2017-12-04 16:31:10', '0'), ('23', '用户修改', 'sys_user_edit', null, '2', null, null, null, '1', '2017-11-08 09:52:48', '2018-06-26 21:16:57', '0'), ('24', '用户删除', 'sys_user_del', null, '2', null, null, null, '1', '2017-11-08 09:54:01', '2017-12-04 16:31:18', '0'), ('32', '菜单新增', 'sys_menu_add', null, '3', null, null, null, '1', '2017-11-08 10:15:53', '2018-01-20 14:37:50', '0'), ('33', '菜单修改', 'sys_menu_edit', null, '3', null, null, null, '1', '2017-11-08 10:16:23', '2018-01-20 14:37:56', '0'), ('34', '菜单删除', 'sys_menu_del', null, '3', null, null, null, '1', '2017-11-08 10:16:43', '2018-01-20 14:38:03', '0'), ('40', '二级菜单', null, 'index', '21', 'icon-caidanguanli', 'views/crud/index', '1', '0', '2018-08-28 01:51:23', '2018-08-28 01:52:37', '0'), ('42', '角色新增', 'sys_role_add', null, '4', null, null, null, '1', '2017-11-08 10:14:18', '2018-04-20 07:21:38', '0'), ('43', '角色修改', 'sys_role_edit', null, '4', null, null, null, '1', '2017-11-08 10:14:41', '2018-04-20 07:21:50', '0'), ('44', '角色删除', 'sys_role_del', null, '4', null, null, null, '1', '2017-11-08 10:14:59', '2018-04-20 07:22:00', '0'), ('45', '分配权限', 'sys_role_perm', null, '4', null, null, null, '1', '2018-04-20 07:22:55', '2018-04-20 07:24:40', '0'), ('52', '日志删除', 'sys_log_del', null, '5', null, null, null, '1', '2017-11-20 20:37:37', '2017-11-28 17:36:52', '0'), ('62', '字典删除', 'sys_dict_del', null, '6', null, null, null, '1', '2017-11-29 11:30:11', '2018-01-07 15:40:51', '0'), ('63', '字典新增', 'sys_dict_add', null, '6', null, null, null, '1', '2018-05-11 22:34:55', null, '0'), ('64', '字典修改', 'sys_dict_edit', null, '6', null, null, null, '1', '2018-05-11 22:36:03', '2018-06-26 21:17:36', '0'), ('72', '部门新增', 'sys_dept_add', null, '7', null, null, null, '1', '2018-01-20 14:56:16', '2018-01-20 21:17:57', '0'), ('73', '部门修改', 'sys_dept_edit', null, '7', null, null, null, '1', '2018-01-20 14:56:59', '2018-01-20 21:17:59', '0'), ('74', '部门删除', 'sys_dept_del', null, '7', null, null, null, '1', '2018-01-20 14:57:28', '2018-01-20 21:18:05', '0'), ('81', '客户端新增', 'sys_client_add', null, '8', '1', null, null, '1', '2018-05-15 21:35:18', '2018-07-29 13:38:59', '0'), ('82', '客户端修改', 'sys_client_edit', null, '8', null, null, null, '1', '2018-05-15 21:37:06', '2018-07-29 13:39:01', '0'), ('83', '客户端删除', 'sys_client_del', null, '8', null, null, null, '1', '2018-05-15 21:39:16', '2018-07-29 13:39:06', '0'), ('100', '系统监控', null, '/daemon', '-1', 'icon-iconbmgl', 'Layout', '2', '0', '2018-07-27 01:13:21', '2018-08-03 14:28:24', '0'), ('101', '服务监控', null, 'http://139.224.200.249:15001', '100', 'icon-jiankong', null, '0', '0', '2018-06-26 10:50:32', '2018-09-03 03:22:23', '0'), ('102', '接口文档', null, 'http://139.224.200.249:19999/swagger-ui.html', '100', 'icon-wendangdocument72', null, '1', '0', '2018-06-26 10:50:32', '2018-08-22 11:45:48', '0'), ('103', '任务监控', null, 'http://139.224.200.249:8899', '100', 'icon-msnui-supervise', null, '7', '0', '2018-06-26 10:50:32', '2018-08-22 11:46:52', '0'), ('105', '事务监控', null, 'tx', '100', 'icon-gtsquanjushiwufuwuGTS', 'views/admin/tx/index', '5', '0', '2018-08-19 11:02:39', '2018-08-19 11:04:02', '0'), ('106', '在线事务', null, 'model', '100', 'icon-online', 'views/admin/tx/model', '6', '0', '2018-08-19 11:32:04', '2018-08-19 11:32:19', '0'), ('110', '任务轨迹', '', 'statustracelog', '100', 'icon-guiji', 'views/daemon/statustracelog/index', '8', '0', '2018-01-20 13:17:19', '2018-08-03 15:14:28', '0'), ('111', '删除', 'daemon_statustracelog_del', null, '110', '1', null, '2', '1', '2018-05-15 21:35:18', '2018-08-03 15:47:21', '0'), ('112', '调用拓扑', null, 'http://139.224.200.249:8081', '100', 'icon-xiazaihuancun', null, '10', '0', '2018-01-25 11:08:52', '2018-08-22 11:46:48', '0'), ('113', '缓存状态', null, 'http://139.224.200.249:8585', '100', 'icon-ecs-status', null, '12', '0', '2018-01-23 10:56:11', '2018-08-22 11:45:53', '0'); COMMIT; -- ---------------------------- @@ -187,13 +164,13 @@ CREATE TABLE `sys_role` ( `del_flag` char(1) COLLATE utf8mb4_bin DEFAULT '0' COMMENT '删除标识(0-正常,1-删除)', PRIMARY KEY (`role_id`), UNIQUE KEY `role_idx1_role_code` (`role_code`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; -- ---------------------------- -- Records of `sys_role` -- ---------------------------- BEGIN; -INSERT INTO `sys_role` VALUES ('1', 'admin', 'ROLE_ADMIN', '超级管理员', '2017-10-29 15:45:51', '2018-04-22 11:40:29', '0'), ('2', 'demo', 'demo', 'demo用户', '2018-04-20 07:14:32', '2018-07-27 01:22:07', '0'); +INSERT INTO `sys_role` VALUES ('1', 'admin', 'ROLE_ADMIN', '超级管理员', '2017-10-29 15:45:51', '2018-04-22 11:40:29', '0'); COMMIT; -- ---------------------------- @@ -205,13 +182,13 @@ CREATE TABLE `sys_role_dept` ( `role_id` int(20) DEFAULT NULL COMMENT '角色ID', `dept_id` int(20) DEFAULT NULL COMMENT '部门ID', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='角色与部门对应关系'; +) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='角色与部门对应关系'; -- ---------------------------- -- Records of `sys_role_dept` -- ---------------------------- BEGIN; -INSERT INTO `sys_role_dept` VALUES ('11', '1', '1'), ('16', '2', '6'); +INSERT INTO `sys_role_dept` VALUES ('1', '1', '8'); COMMIT; -- ---------------------------- @@ -228,7 +205,7 @@ CREATE TABLE `sys_role_menu` ( -- Records of `sys_role_menu` -- ---------------------------- BEGIN; -INSERT INTO `sys_role_menu` VALUES ('1', '1'), ('1', '2'), ('1', '3'), ('1', '4'), ('1', '5'), ('1', '6'), ('1', '7'), ('1', '8'), ('1', '9'), ('1', '10'), ('1', '11'), ('1', '12'), ('1', '22'), ('1', '23'), ('1', '24'), ('1', '32'), ('1', '33'), ('1', '34'), ('1', '42'), ('1', '43'), ('1', '44'), ('1', '45'), ('1', '52'), ('1', '62'), ('1', '63'), ('1', '64'), ('1', '72'), ('1', '73'), ('1', '74'), ('1', '81'), ('1', '82'), ('1', '83'), ('1', '100'), ('1', '101'), ('1', '102'), ('1', '103'), ('1', '110'), ('1', '111'), ('2', '200'), ('2', '201'); +INSERT INTO `sys_role_menu` VALUES ('1', '1'), ('1', '2'), ('1', '3'), ('1', '4'), ('1', '5'), ('1', '6'), ('1', '7'), ('1', '8'), ('1', '9'), ('1', '10'), ('1', '11'), ('1', '12'), ('1', '13'), ('1', '14'), ('1', '15'), ('1', '20'), ('1', '21'), ('1', '22'), ('1', '23'), ('1', '24'), ('1', '32'), ('1', '33'), ('1', '34'), ('1', '40'), ('1', '42'), ('1', '43'), ('1', '44'), ('1', '45'), ('1', '52'), ('1', '62'), ('1', '63'), ('1', '64'), ('1', '72'), ('1', '73'), ('1', '74'), ('1', '81'), ('1', '82'), ('1', '83'), ('1', '100'), ('1', '101'), ('1', '102'), ('1', '103'), ('1', '105'), ('1', '106'), ('1', '110'), ('1', '111'), ('1', '112'), ('1', '113'); COMMIT; -- ---------------------------- @@ -246,7 +223,7 @@ CREATE TABLE `sys_social_details` ( `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `del_flag` char(50) NOT NULL DEFAULT '0' COMMENT '删除标记', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='系统社交登录账号表'; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='系统社交登录账号表'; -- ---------------------------- -- Records of `sys_social_details` @@ -276,13 +253,13 @@ CREATE TABLE `sys_user` ( UNIQUE KEY `user_idx1_username` (`username`), KEY `user_wx_openid` (`wx_openid`), KEY `user_qq_openid` (`qq_openid`) -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='用户表'; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='用户表'; -- ---------------------------- -- Records of `sys_user` -- ---------------------------- BEGIN; -INSERT INTO `sys_user` VALUES ('1', 'admin', '$2a$10$SJiz7YONcq5ATINeF3s/aOB9O3jKFXVfblHCerRntXAArPp4rKtvu', null, '17034642888', null, '1', '2018-04-20 07:15:18', '2018-08-18 04:09:32', '0', '', null), ('2', 'demo', '$2a$10$SJiz7YONcq5ATINeF3s/aOB9O3jKFXVfblHCerRntXAArPp4rKtvu', null, '17034642118', null, '1', '2018-04-22 11:39:07', '2018-07-29 10:36:38', '0', null, null); +INSERT INTO `sys_user` VALUES ('1', 'admin', '$2a$10$RpFJjxYiXdEsAGnWp/8fsOetMuOON96Ntk/Ym2M/RKRyU0GZseaDC', null, '17034642888', null, '1', '2018-04-20 07:15:18', '2018-09-01 15:57:21', '0', 'o_0FT0uyg_H1vVy2H0JpSwlVGhWQ', null); COMMIT; -- ---------------------------- @@ -299,7 +276,7 @@ CREATE TABLE `sys_user_role` ( -- Records of `sys_user_role` -- ---------------------------- BEGIN; -INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); +INSERT INTO `sys_user_role` VALUES ('1', '1'); COMMIT; SET FOREIGN_KEY_CHECKS = 1; diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java index 223a53505..d90714f4d 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/PigxAuthApplication.java @@ -20,9 +20,9 @@ package com.pig4cloud.pigx.auth; +import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients; import org.springframework.boot.SpringApplication; import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.openfeign.EnableFeignClients; /** * @author lengleng @@ -30,7 +30,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; * 认证授权中心 */ @SpringCloudApplication -@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"}) +@EnablePigxFeignClients public class PigxAuthApplication { public static void main(String[] args) { diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java index ac2b43d01..24674832d 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/config/WebSecurityConfigurer.java @@ -64,6 +64,8 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter { .antMatchers( "/actuator/**", "/oauth/removeToken", + "/oauth/delToken/*", + "/oauth/listToken", "/mobile/**").permitAll() .anyRequest().authenticated() .and().csrf().disable() diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java new file mode 100644 index 000000000..142b71fe6 --- /dev/null +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java @@ -0,0 +1,181 @@ +/* + * + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + * + */ + +package com.pig4cloud.pigx.auth.endpoint; + +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.common.core.util.R; +import com.pig4cloud.pigx.common.security.service.PigxUser; +import lombok.AllArgsConstructor; +import org.springframework.data.redis.core.ConvertingCursor; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ScanOptions; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.provider.OAuth2Authentication; +import org.springframework.security.oauth2.provider.token.TokenStore; +import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author lengleng + * @date 2018/6/24 + * 删除token端点 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/oauth") +public class PigxTokenEndpoint { + private static final String PIGX_OAUTH_ACCESS = "pigx_oauth:access:"; + private final TokenStore tokenStore; + private final RedisTemplate redisTemplate; + + /** + * 退出token + * + * @param authHeader Authorization + */ + @GetMapping("/removeToken") + public R logout(@RequestHeader(value = "Authorization", required = false) String authHeader) { + if (StringUtils.hasText(authHeader)) { + String tokenValue = authHeader.replace("Bearer", "").trim(); + OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); + if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) { + return new R<>(false, "退出失败,token 为空"); + } + tokenStore.removeAccessToken(accessToken); + } + + return new R<>(Boolean.TRUE); + } + + /** + * 令牌管理调用 + * + * @param token token + * @param from 内部调用标志 + * @return + */ + @DeleteMapping("/delToken/{token}") + public R delToken(@PathVariable("token") String token, @RequestHeader(required = false) String from) { + if (StrUtil.isBlank(from)) { + return null; + } + return new R<>(redisTemplate.delete(PIGX_OAUTH_ACCESS + token)); + } + + + /** + * 查询token + * + * @param params 分页参数 + * @param from 标志 + * @return + */ + @PostMapping("/listToken") + public Page tokenList(@RequestBody Map params, @RequestHeader(required = false) String from) { + if (StrUtil.isBlank(from)) { + return null; + } + + List> list = new ArrayList<>(); + //根据分页参数获取对应数据 + List pages = findKeysForPage(PIGX_OAUTH_ACCESS + "*", MapUtil.getInt(params, "page"), MapUtil.getInt(params, "limit")); + + for (String page : pages) { + String accessToken = StrUtil.subAfter(page, PIGX_OAUTH_ACCESS, true); + OAuth2AccessToken token = tokenStore.readAccessToken(accessToken); + Map map = new HashMap<>(8); + + + map.put("token_type", token.getTokenType()); + map.put("token_value", token.getValue()); + map.put("expires_in", token.getExpiresIn() + ""); + + + OAuth2Authentication oAuth2Auth = tokenStore.readAuthentication(token); + Authentication authentication = oAuth2Auth.getUserAuthentication(); + + map.put("client_id", oAuth2Auth.getOAuth2Request().getClientId()); + map.put("grant_type", oAuth2Auth.getOAuth2Request().getGrantType()); + + if (authentication instanceof UsernamePasswordAuthenticationToken) { + UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) authentication; + + if (authenticationToken.getPrincipal() instanceof PigxUser) { + PigxUser user = (PigxUser) authenticationToken.getPrincipal(); + map.put("user_id", user.getId() + ""); + map.put("user_name", user.getUsername() + ""); + } + } else if (authentication instanceof PreAuthenticatedAuthenticationToken) { + //刷新token方式 + PreAuthenticatedAuthenticationToken authenticationToken = (PreAuthenticatedAuthenticationToken) authentication; + if (authenticationToken.getPrincipal() instanceof PigxUser) { + PigxUser user = (PigxUser) authenticationToken.getPrincipal(); + map.put("user_id", user.getId() + ""); + map.put("user_name", user.getUsername() + ""); + } + } + list.add(map); + } + + Page result = new Page(MapUtil.getInt(params, "page"), MapUtil.getInt(params, "limit")); + result.setRecords(list); + result.setTotal(redisTemplate.keys(PIGX_OAUTH_ACCESS + "*").size()); + return result; + } + + private List findKeysForPage(String patternKey, int pageNum, int pageSize) { + ScanOptions options = ScanOptions.scanOptions().match(patternKey).build(); + RedisSerializer redisSerializer = (RedisSerializer) redisTemplate.getKeySerializer(); + Cursor cursor = (Cursor) redisTemplate.executeWithStickyConnection(redisConnection -> { + return new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize); + }); + List result = new ArrayList<>(); + int tmpIndex = 0; + int startIndex = (pageNum - 1) * pageSize; + int end = pageNum * pageSize; + + assert cursor != null; + while (cursor.hasNext()) { + if (tmpIndex >= startIndex && tmpIndex < end) { + result.add(cursor.next().toString()); + tmpIndex++; + continue; + } + if (tmpIndex >= end) { + break; + } + tmpIndex++; + cursor.next(); + } + return result; + } +} diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java deleted file mode 100644 index 8e6384ac7..000000000 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/RevokeTokenEndpoint.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright (c) 2018-2025, lengleng All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * Neither the name of the pig4cloud.com developer nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * Author: lengleng (wangiegie@gmail.com) - * - */ - -package com.pig4cloud.pigx.auth.endpoint; - -import cn.hutool.core.util.StrUtil; -import com.pig4cloud.pigx.common.core.util.R; -import lombok.AllArgsConstructor; -import org.springframework.security.oauth2.common.OAuth2AccessToken; -import org.springframework.security.oauth2.provider.token.TokenStore; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author lengleng - * @date 2018/6/24 - * 删除token端点 - */ -@RestController -@AllArgsConstructor -public class RevokeTokenEndpoint { - private final TokenStore tokenStore; - - /** - * 删除token - * - * @param authHeader Authorization - */ - @GetMapping("/oauth/removeToken") - public R logout(@RequestHeader(value = "Authorization", required = false) String authHeader) { - if (StringUtils.hasText(authHeader)) { - String tokenValue = authHeader.replace("Bearer", "").trim(); - OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue); - if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) { - return new R<>(false, "退出失败,token 为空"); - } - tokenStore.removeAccessToken(accessToken); - } - - return new R<>(Boolean.TRUE); - } -} diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml index 6074f0c68..a74dc9f6d 100644 --- a/pigx-common/pigx-common-core/pom.xml +++ b/pigx-common/pigx-common-core/pom.xml @@ -72,8 +72,10 @@ - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 + com.fasterxml.jackson.module + jackson-modules-java8 + ${jackson.modules} + pom diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java index 37792eda6..f828857dd 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java @@ -21,20 +21,13 @@ package com.pig4cloud.pigx.common.core.config; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; +import com.fasterxml.jackson.databind.SerializationFeature; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; /** * JacksonConfig @@ -43,24 +36,25 @@ import java.time.format.DateTimeFormatter; * @date: 2018/7/28 12:29 */ @Configuration +@ConditionalOnClass(ObjectMapper.class) +@AutoConfigureBefore(JacksonAutoConfiguration.class) public class JacksonConfig { /** - * 处理序列化后的1.8的日期时间格式 + * 针对JDK 1.8 特殊处理 + * .registerModule(new ParameterNamesModule()) + * .registerModule(new Jdk8Module()) + * .registerModule(new JavaTimeModule()); // new module, NOT JSR310Module * * @return */ @Bean - public ObjectMapper getObjectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - JavaTimeModule javaTimeModule = new JavaTimeModule(); - javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); - javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); - javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); - javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss"))); - objectMapper.registerModule(javaTimeModule); + public ObjectMapper getObjectMapper(Jackson2ObjectMapperBuilder builder) { + ObjectMapper objectMapper = builder.createXmlMapper(false).build(); + objectMapper.findAndRegisterModules(); + // 忽略json字符串中不识别的属性 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + // 忽略无法转换的对象 + objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); return objectMapper; } } diff --git a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java index 196576f58..968ae1600 100644 --- a/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java +++ b/pigx-common/pigx-common-log/src/main/java/com/pig4cloud/pigx/common/log/util/SysLogUtils.java @@ -19,7 +19,6 @@ package com.pig4cloud.pigx.common.log.util; -import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.URLUtil; import cn.hutool.http.HttpUtil; import com.pig4cloud.pigx.admin.api.entity.SysLog; @@ -36,22 +35,8 @@ import javax.servlet.http.HttpServletRequest; * @author L.cm */ public class SysLogUtils { - - private static final String PASSWORD = "password"; - public static SysLog getSysLog() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - StringBuilder params = new StringBuilder(); - request.getParameterMap().forEach((key, values) -> { - params.append(key).append("="); - if (PASSWORD.equalsIgnoreCase(key)) { - params.append("******"); - } else { - params.append(ArrayUtil.toString(values)); - } - params.append("&"); - }); - SysLog sysLog = new SysLog(); sysLog.setCreateBy(SecurityUtils.getUser().getUsername()); sysLog.setType(CommonConstant.STATUS_NORMAL); diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerTokenRelayAutoConfiguration.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerTokenRelayAutoConfiguration.java new file mode 100644 index 000000000..54c406dea --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/component/PigxResourceServerTokenRelayAutoConfiguration.java @@ -0,0 +1,87 @@ +package com.pig4cloud.pigx.common.security.component; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration; +import org.springframework.cloud.security.oauth2.client.AccessTokenContextRelay; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.client.OAuth2ClientContext; +import org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration; +import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.lang.annotation.*; + +/** + * @author lengleng + * @date 2018/9/5 + * 注入AccessTokenContextRelay 解决feign 传递token 为空问题 + */ +@Configuration +@AutoConfigureAfter(OAuth2AutoConfiguration.class) +@ConditionalOnWebApplication +@ConditionalOnProperty("security.oauth2.client.client-id") +public class PigxResourceServerTokenRelayAutoConfiguration { + + @Bean + public AccessTokenContextRelay accessTokenContextRelay(OAuth2ClientContext context) { + return new AccessTokenContextRelay(context); + } + + @Configuration + public static class ResourceServerTokenRelayRegistrationAutoConfiguration implements WebMvcConfigurer { + @Autowired + AccessTokenContextRelay accessTokenContextRelay; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor( + new HandlerInterceptorAdapter() { + @Override + public boolean preHandle(HttpServletRequest request, + HttpServletResponse response, Object handler) throws Exception { + accessTokenContextRelay.copyToken(); + return true; + } + } + + ); + } + + } + + @Target({ElementType.TYPE, ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @Documented + @Conditional(OAuth2OnClientInResourceServerCondition.class) + @interface ConditionalOnOAuth2ClientInResourceServer { + + } + + private static class OAuth2OnClientInResourceServerCondition + extends AllNestedConditions { + + public OAuth2OnClientInResourceServerCondition() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(ResourceServerConfiguration.class) + static class Server { + } + + @ConditionalOnBean(OAuth2ClientConfiguration.class) + static class Client { + } + + } +} diff --git a/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/EnablePigxFeignClients.java b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/EnablePigxFeignClients.java new file mode 100644 index 000000000..db8d46698 --- /dev/null +++ b/pigx-common/pigx-common-security/src/main/java/com/pig4cloud/pigx/common/security/feign/EnablePigxFeignClients.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.common.security.feign; + +import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; +import com.pig4cloud.pigx.admin.api.feign.RemoteUserService; +import org.springframework.cloud.openfeign.EnableFeignClients; + +import java.lang.annotation.*; + +/** + * @author lengleng + * @date 2018/9/5 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@EnableFeignClients +public @interface EnablePigxFeignClients { + /** + * Alias for the {@link #basePackages()} attribute. Allows for more concise annotation + * declarations e.g.: {@code @ComponentScan("org.my.pkg")} instead of + * {@code @ComponentScan(basePackages="org.my.pkg")}. + * + * @return the array of 'basePackages'. + */ + String[] value() default {}; + + /** + * Base packages to scan for annotated components. + *

+ * {@link #value()} is an alias for (and mutually exclusive with) this attribute. + *

+ * Use {@link #basePackageClasses()} for a type-safe alternative to String-based + * package names. + * + * @return the array of 'basePackages'. + */ + String[] basePackages() default {}; + + /** + * Type-safe alternative to {@link #basePackages()} for specifying the packages to + * scan for annotated components. The package of each class specified will be scanned. + *

+ * Consider creating a special no-op marker class or interface in each package that + * serves no purpose other than being referenced by this attribute. + * + * @return the array of 'basePackageClasses'. + */ + Class[] basePackageClasses() default {}; + + /** + * A custom @Configuration for all feign clients. Can contain override + * @Bean definition for the pieces that make up the client, for instance + * {@link feign.codec.Decoder}, {@link feign.codec.Encoder}, {@link feign.Contract}. + * + * @see FeignClientsConfiguration for the defaults + */ + Class[] defaultConfiguration() default {}; + + /** + * List of classes annotated with @FeignClient. If not empty, disables classpath scanning. + * + * @return + */ + Class[] clients() default {RemoteUserService.class, RemoteLogService.class}; +} diff --git a/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories index 016400a67..d54329f51 100644 --- a/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories +++ b/pigx-common/pigx-common-security/src/main/resources/META-INF/spring.factories @@ -2,6 +2,7 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.pig4cloud.pigx.common.security.component.PermissionService,\ com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler,\ com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint,\ + com.pig4cloud.pigx.common.security.component.PigxResourceServerTokenRelayAutoConfiguration,\ com.pig4cloud.pigx.common.security.feign.PigxFeignClientConfiguration,\ com.pig4cloud.pigx.common.security.service.PigxUserDetailsServiceImpl,\ com.pig4cloud.pigx.common.security.social.QqSocialConfig,\ diff --git a/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/feign/TransactionRestTemplateInterceptor.java b/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/feign/TransactionRestTemplateInterceptor.java index dfab8124b..4b20d6c68 100755 --- a/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/feign/TransactionRestTemplateInterceptor.java +++ b/pigx-common/pigx-common-transaction/src/main/java/com/pig4cloud/pigx/common/transaction/tx/springcloud/feign/TransactionRestTemplateInterceptor.java @@ -21,8 +21,6 @@ import com.codingapi.tx.aop.bean.TxTransactionLocal; import feign.RequestInterceptor; import feign.RequestTemplate; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** *@author LCN on 2017/6/26. diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java index abb0febdd..e4ee52643 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/config/RouterFunctionConfiguration.java @@ -45,7 +45,7 @@ public class RouterFunctionConfiguration { @Bean public RouterFunction routerFunction() { return RouterFunctions.route( - RequestPredicates.GET("/fallback") + RequestPredicates.path("/fallback") .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), hystrixFallbackHandler) .andRoute(RequestPredicates.GET("/code") .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), imageCodeHandler) diff --git a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java index 6a977287e..d1578ddc7 100644 --- a/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java +++ b/pigx-gateway/src/main/java/com/pig4cloud/pigx/gateway/filter/PreviewGatewayFilter.java @@ -29,7 +29,7 @@ import org.springframework.stereotype.Component; /** * @author lengleng - * @date 2018/8/421 + * @date 2018/8/21 * 演示环境过滤处理 */ @Slf4j diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java index 8ab824b01..54a3de806 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteLogService.java @@ -20,7 +20,7 @@ package com.pig4cloud.pigx.admin.api.feign; import com.pig4cloud.pigx.admin.api.entity.SysLog; -import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl; +import com.pig4cloud.pigx.admin.api.feign.factory.RemoteLogServiceFallbackFactory; import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant; import com.pig4cloud.pigx.common.core.util.R; import org.springframework.cloud.openfeign.FeignClient; @@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.RequestBody; * @author lengleng * @date 2018/6/28 */ -@FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallback = RemoteLogServiceFallbackImpl.class) +@FeignClient(value = ServiceNameConstant.UMPS_SERVICE, fallbackFactory = RemoteLogServiceFallbackFactory.class) public interface RemoteLogService { /** * 保存日志 diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java new file mode 100644 index 000000000..e7c2b49a7 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/RemoteTokenService.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.feign; + +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.feign.factory.RemoteTokenServiceFallbackFactory; +import com.pig4cloud.pigx.common.core.constant.ServiceNameConstant; +import com.pig4cloud.pigx.common.core.util.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author lengleng + * @date 2018/9/4 + */ +@FeignClient(value = ServiceNameConstant.AUTH_SERVICE, fallbackFactory = RemoteTokenServiceFallbackFactory.class) +public interface RemoteTokenService { + /** + * 分页查询token 信息 + * + * @param params 分页参数 + * @param from 内部调用标志 + * @return page + */ + @PostMapping("/oauth/listToken") + Page selectPage(@RequestBody Map params, @RequestHeader("from") String from); + + /** + * 删除token + * + * @param token token + * @param from 调用标志 + * @return + */ + @DeleteMapping("/oauth/delToken/{token}") + R deleteTokenById(@PathVariable("token") String token, @RequestHeader("from") String from); +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteLogServiceFallbackFactory.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteLogServiceFallbackFactory.java new file mode 100644 index 000000000..f6b0ebd09 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteLogServiceFallbackFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.feign.factory; + +import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; +import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl; +import feign.hystrix.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/9/4 + */ +@Component +public class RemoteLogServiceFallbackFactory implements FallbackFactory { + + @Override + public RemoteLogService create(Throwable throwable) { + RemoteLogServiceFallbackImpl remoteLogServiceFallback = new RemoteLogServiceFallbackImpl(); + remoteLogServiceFallback.setCause(throwable); + return remoteLogServiceFallback; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteTokenServiceFallbackFactory.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteTokenServiceFallbackFactory.java new file mode 100644 index 000000000..ebe82bc19 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/factory/RemoteTokenServiceFallbackFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.feign.factory; + +import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService; +import com.pig4cloud.pigx.admin.api.feign.fallback.RemoteTokenServiceFallbackImpl; +import feign.hystrix.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * @author lengleng + * @date 2018/9/4 + */ +@Component +public class RemoteTokenServiceFallbackFactory implements FallbackFactory { + + @Override + public RemoteTokenService create(Throwable throwable) { + RemoteTokenServiceFallbackImpl remoteTokenServiceFallback = new RemoteTokenServiceFallbackImpl(); + remoteTokenServiceFallback.setCause(throwable); + return remoteTokenServiceFallback; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java index 722e0435d..4d0fbca3d 100644 --- a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteLogServiceFallbackImpl.java @@ -22,6 +22,7 @@ package com.pig4cloud.pigx.admin.api.feign.fallback; import com.pig4cloud.pigx.admin.api.entity.SysLog; import com.pig4cloud.pigx.admin.api.feign.RemoteLogService; import com.pig4cloud.pigx.common.core.util.R; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -32,6 +33,8 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class RemoteLogServiceFallbackImpl implements RemoteLogService { + @Setter + private Throwable cause; /** * 保存日志 @@ -41,7 +44,7 @@ public class RemoteLogServiceFallbackImpl implements RemoteLogService { */ @Override public R saveLog(SysLog sysLog) { - log.error("feign 插入日志失败:{}"); + log.error("feign 插入日志失败", cause); return null; } } diff --git a/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java new file mode 100644 index 000000000..0878486d8 --- /dev/null +++ b/pigx-upms/pigx-upms-api/src/main/java/com/pig4cloud/pigx/admin/api/feign/fallback/RemoteTokenServiceFallbackImpl.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.api.feign.fallback; + +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author lengleng + * @date 2018/9/4 + * feign token fallback + */ +@Slf4j +@Component +public class RemoteTokenServiceFallbackImpl implements RemoteTokenService { + @Setter + private Throwable cause; + + /** + * 分页查询token 信息 + * + * @param params 分页参数 + * @param from 内部调用标志 + * @return page + */ + @Override + public Page selectPage(Map params, String from) { + log.error("调用认证中心查询token 失败", cause); + return null; + } + + /** + * 删除token + * + * + * @param s + * @param id + * @return + */ + @Override + public R deleteTokenById(String s, String id) { + log.error("删除token 失败 {}", id, cause); + return null; + } +} diff --git a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories index cc68aecba..5fab2a739 100644 --- a/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories +++ b/pigx-upms/pigx-upms-api/src/main/resources/META-INF/spring.factories @@ -1,4 +1,7 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.pig4cloud.pigx.admin.api.feign.fallback.RemoteUserServiceFallbackImpl,\ com.pig4cloud.pigx.admin.api.feign.fallback.RemoteLogServiceFallbackImpl,\ - com.pig4cloud.pigx.admin.api.feign.factory.RemoteUserServiceFallbackFactory + com.pig4cloud.pigx.admin.api.feign.fallback.RemoteTokenServiceFallbackImpl,\ + com.pig4cloud.pigx.admin.api.feign.factory.RemoteUserServiceFallbackFactory,\ + com.pig4cloud.pigx.admin.api.feign.factory.RemoteLogServiceFallbackFactory,\ + com.pig4cloud.pigx.admin.api.feign.factory.RemoteTokenServiceFallbackFactory diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java index 2371f6a99..f8783b80d 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/PigxAdminApplication.java @@ -20,10 +20,10 @@ package com.pig4cloud.pigx.admin; +import com.pig4cloud.pigx.common.security.feign.EnablePigxFeignClients; import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2; import org.springframework.boot.SpringApplication; import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.openfeign.EnableFeignClients; /** * @author lengleng @@ -32,7 +32,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; */ @EnablePigxSwagger2 @SpringCloudApplication -@EnableFeignClients({"com.pig4cloud.pigx.admin.api.feign"}) +@EnablePigxFeignClients public class PigxAdminApplication { public static void main(String[] args) { SpringApplication.run(PigxAdminApplication.class, args); diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/TokenController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/TokenController.java new file mode 100644 index 000000000..7ddc150e2 --- /dev/null +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/TokenController.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018-2025, lengleng All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the pig4cloud.com developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: lengleng (wangiegie@gmail.com) + */ + +package com.pig4cloud.pigx.admin.controller; + +import com.baomidou.mybatisplus.plugins.Page; +import com.pig4cloud.pigx.admin.api.feign.RemoteTokenService; +import com.pig4cloud.pigx.common.core.constant.SecurityConstants; +import com.pig4cloud.pigx.common.core.util.R; +import lombok.AllArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author lengleng + * @date 2018/9/4 + * token 管理 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/token") +public class TokenController { + private final RemoteTokenService remoteTokenService; + + /** + * 分页token 信息 + * + * @param params 参数集 + * @return token集合 + */ + @GetMapping("/page") + public Page token(@RequestParam Map params) { + return remoteTokenService.selectPage(params, SecurityConstants.FROM_IN); + } + + /** + * 删除 + * + * @param id ID + * @return success/false + */ + @DeleteMapping("/{id}") + @PreAuthorize("@pms.hasPermission('sys_token_del')") + public R delete(@PathVariable String id) { + return remoteTokenService.deleteTokenById(id, SecurityConstants.FROM_IN); + } +} diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java index 880419e45..08cd8b9b3 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/mapper/SysUserMapper.java @@ -48,8 +48,8 @@ public interface SysUserMapper extends BaseMapper { /** * 分页查询用户信息(含角色) * - * @param query 查询条件 - * @param username 用户名 + * @param query 查询条件 + * @param username 用户名 * @param dataScope * @return list */ @@ -65,16 +65,19 @@ public interface SysUserMapper extends BaseMapper { /** * 通过用户名查找已经删除的用户 + * * @param username 用户名 * @return 用户对象 */ - SysUser selectDeletedUserByUsername(@Param("username")String username); + SysUser selectDeletedUserByUsername(@Param("username") String username); /** * 根据用户名删除用户(真实删除) - * @param username + * + * @param username username + * @param userId userId * @return */ - Boolean deleteSysUserByUsernameAndUserId(@Param("username")String username,@Param("userId")Integer userId); + Boolean deleteSysUserByUsernameAndUserId(@Param("username") String username, @Param("userId") Integer userId); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java index 00319d947..dfb2825b6 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/SysUserService.java @@ -87,6 +87,7 @@ public interface SysUserService extends IService { /** * 通过用户名查找已经删除的用户 + * * @param username 用户名 * @return */ @@ -94,10 +95,12 @@ public interface SysUserService extends IService { /** * 根据用户名删除用户(真实删除) - * @param username + * + * @param username username + * @param userId userId * @return */ - Boolean deleteSysUserByUsernameAndUserId(String username,Integer userId); + Boolean deleteSysUserByUsernameAndUserId(String username, Integer userId); } diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java index 844895699..383abd920 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysRoleMenuServiceImpl.java @@ -20,6 +20,7 @@ package com.pig4cloud.pigx.admin.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.pig4cloud.pigx.admin.api.entity.SysRoleMenu; @@ -59,11 +60,14 @@ public class SysRoleMenuServiceImpl extends ServiceImpl(condition)); - List roleMenuList = new ArrayList<>(); - List menuIdList = Arrays.asList(menuIds.split(",")); - if (CollUtil.isEmpty(menuIdList)) { + + if (StrUtil.isBlank(menuIds)) { return Boolean.TRUE; } + + List roleMenuList = new ArrayList<>(); + List menuIdList = Arrays.asList(menuIds.split(",")); + for (String menuId : menuIdList) { SysRoleMenu roleMenu = new SysRoleMenu(); roleMenu.setRoleId(roleId); diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java index f53652adf..5dbfab2c1 100644 --- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java +++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysUserServiceImpl.java @@ -78,7 +78,7 @@ public class SysUserServiceImpl extends ServiceImpl impl * @return */ @Override - @Cacheable(value = "user_details", key = "#username") + @Cacheable(value = "user_details", key = "#username",unless = "#result == null") public UserInfo findUserInfo(String type, String username) { SysUser condition = new SysUser(); if (EnumLoginType.PWD.getType().equals(type)) { diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/SysGeneratorMapper.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/SysGeneratorMapper.java index dce9db073..e774a7339 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/SysGeneratorMapper.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/mapper/SysGeneratorMapper.java @@ -18,6 +18,7 @@ package com.pig4cloud.pigx.codegen.mapper; import com.pig4cloud.pigx.common.core.util.Query; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -34,20 +35,14 @@ public interface SysGeneratorMapper { * 分页查询表格 * * @param params + * @param tableName * @return */ - List> queryList(Query params); - - /** - * 查询表数量 - * - * @param query - * @return - */ - int queryTotal(Map query); + List> queryList(Query params, @Param("tableName") Object tableName); /** * 查询表信息 + * * @param tableName 表名称 * @return */ @@ -55,6 +50,7 @@ public interface SysGeneratorMapper { /** * 查询表列信息 + * * @param tableName 表名称 * @return */ diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/SysGeneratorServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/SysGeneratorServiceImpl.java index 731f756e7..204f7a9e8 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/SysGeneratorServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/SysGeneratorServiceImpl.java @@ -50,8 +50,9 @@ public class SysGeneratorServiceImpl implements SysGeneratorService { * @return */ @Override - public List> queryPage(Query query) { - return sysGeneratorMapper.queryList(query); + public List> queryPage(Query query) { + Object tableName = query.getCondition().get("tableName"); + return sysGeneratorMapper.queryList(query, tableName); } /** diff --git a/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.xml.vm b/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.xml.vm index 047f472c6..54411736d 100755 --- a/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.xml.vm +++ b/pigx-visual/pigx-codegen/src/main/resources/template/Mapper.xml.vm @@ -1,7 +1,7 @@ - + diff --git a/pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java b/pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java index 0142309b8..eff6870fc 100644 --- a/pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java +++ b/pigx-visual/pigx-tx-manager/src/main/java/com/pig4cloud/pigx/manager/compensate/service/impl/CompensateServiceImpl.java @@ -131,7 +131,7 @@ public class CompensateServiceImpl implements CompensateService { logger.info("Auto Compensate->" + json); //自动补偿业务执行... final int tryTime = configReader.getCompensateTryTime(); - boolean autoExecuteRes = false; + boolean autoExecuteRes; try { int executeCount = 0; autoExecuteRes = executeCompensate_(json); diff --git a/pom.xml b/pom.xml index c1b23fc7f..d541a868c 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ - 1.6.0 + 1.6.1 2.0.4.RELEASE Finchley.SR1 UTF-8 @@ -55,6 +55,7 @@ 2.1.0 2.1.5 2.3.3.RELEASE + 2.9.6 http://192.168.0.13:4243 192.168.0.13:5000