diff --git a/README.md b/README.md index d7d590b9..24dfefda 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ JEECG 微云快速开发平台 =============== -当前最新版本: 3.7.5 beta(发布日期:20180519) +当前最新版本: 3.7.6(发布日期:20180607) 前言: ----------------------------------- @@ -27,8 +27,7 @@ JEECG * 4.封装完善的用户基础权限、强大的数据权限、和数据字典等基础功能,直接使用无需修改 * 5.常用共通封装,各种工具类(定时任务,短信接口,邮件发送,Excel导出等),基本满足80%项目需求 * 6.集成简易报表工具,图像报表和数据导出非常方便,可极其方便的生成pdf、excel、word等报表; -* 7.集成工作流activiti,并实现在线画流程、在线配置表单、流程串表单无需编码,强大的OA自动化能力,极大的简化bpm工作流的开发;另外通过扩展接口编写业务,方便业务扩展; -* 7.工作流的实现,实现了各种中国国情的功能,任意跳转、任意驳回、任意委派等等;流程节点支持配置个性化表单;同时web端审批与移动端审批保持同步进行,一次配置双点审批。 +* 7.集成工作流activiti,并实现了只需在页面配置流程转向,可极大的简化jbpm工作流的开发;用jbpm的流程设计器画出了流程走向,一个工作流基本就完成了,只需写很少量的java代码; * 8.UI标签库,针对WEB UI进行标准式封装,页面统一采用自定义标签实现功能:列表数据展现、页面校验等,标签使用简单清晰且便于维护 * 9.在线流程设计,采用开源Activiti流程引擎,实现在线画流程,自定义表单,表单挂靠,业务流转 * 10.查询过滤器:查询功能自动生成,后台动态拼SQL追加查询条件;支持多种匹配方式(全匹配/模糊查询/包含查询/不匹配查询); @@ -79,7 +78,7 @@ JEECG * 技术点二十五:支持二级管理员,权限细化管理 * 技术点二十六:代码生成器支持resutful接口生成 -* JEECG V3.7.5 beta, 经过了专业压力测试,性能测试,保证后台数据的准确性和页面访问速度 +* JEECG V3.7.6, 经过了专业压力测试,性能测试,保证后台数据的准确性和页面访问速度 * 支持多种浏览器: IE, 火狐, Google 等 * 支持数据库: Mysql,Oracle,Postgre,SqlServer等 * 基础权限: 用户,角色,菜单权限,按钮权限,数据权限 diff --git a/jeecg-framework/docs/jeecg_3.7.5_beta_mysql.sql b/jeecg-framework/docs/jeecg_3.7.6_mysql.sql similarity index 99% rename from jeecg-framework/docs/jeecg_3.7.5_beta_mysql.sql rename to jeecg-framework/docs/jeecg_3.7.6_mysql.sql index eea10549..c879c327 100644 --- a/jeecg-framework/docs/jeecg_3.7.5_beta_mysql.sql +++ b/jeecg-framework/docs/jeecg_3.7.6_mysql.sql @@ -4,13 +4,13 @@ Navicat MySQL Data Transfer Source Server : mysql Source Server Version : 50037 Source Host : 127.0.0.1:3306 -Source Database : jeecg_3_7_5 +Source Database : jeecg_3_7_6 Target Server Type : MYSQL Target Server Version : 50037 File Encoding : 65001 -Date: 2018-05-19 16:40:58 +Date: 2018-06-06 20:37:32 */ SET FOREIGN_KEY_CHECKS=0; @@ -1021,7 +1021,7 @@ CREATE TABLE `jeecg_demo` ( `name` varchar(255) NOT NULL COMMENT '鍚嶇О', `age` int(10) default NULL COMMENT '骞撮緞', `birthday` datetime default NULL COMMENT '鐢熸棩', - `content` varchar(255) default NULL COMMENT '涓汉浠嬬粛', + `content` text COMMENT '涓汉浠嬬粛', `dep_id` varchar(255) default NULL COMMENT '閮ㄩ棬', `email` varchar(255) default NULL COMMENT '閭', `phone` varchar(255) default NULL COMMENT '鐢佃瘽', @@ -1705,7 +1705,7 @@ CREATE TABLE `jform_graphreport_head` ( `update_by` varchar(50) default NULL, `update_name` varchar(100) default NULL, PRIMARY KEY (`id`), - KEY `index_code` (`code`) + UNIQUE KEY `index_code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- @@ -3059,21 +3059,14 @@ CREATE TABLE `t_s_black_list` ( `sys_company_code` varchar(50) default NULL COMMENT '鎵灞炲叕鍙', `bpm_status` varchar(32) default '1' COMMENT '娴佺▼鐘舵', `ip` varchar(32) default NULL COMMENT 'ip鍦板潃', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `unique_key_ip` (`ip`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of t_s_black_list -- ---------------------------- INSERT INTO `t_s_black_list` VALUES ('402881e75f91017e015f91023f7c0001', '绠$悊鍛', 'admin', '2017-11-06 19:06:04', null, null, null, 'A03', 'A03', '1', '192.1562.1.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f947fc7015f9481be250004', '绠$悊鍛', 'admin', '2017-11-06 14:53:22', '绠$悊鍛', 'admin', '2018-05-19 14:03:18', 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f948375015f94842cc30001', '绠$悊鍛', 'admin', '2017-11-06 14:53:22', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f94878e015f948921d30001', '绠$悊鍛', 'admin', '2017-11-06 18:53:22', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f94878e015f94896bb80002', '绠$悊鍛', 'admin', '2017-11-06 00:00:00', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f949b19015f949cde920001', '绠$悊鍛', 'admin', '2017-11-11 14:53:22', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f949b19015f949d07ad0002', '绠$悊鍛', 'admin', '2017-11-11 00:00:00', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f94a099015f94a1c66e0001', '绠$悊鍛', 'admin', '2017-11-11 14:53:22', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); -INSERT INTO `t_s_black_list` VALUES ('402881e75f94a099015f94a1dd040002', '绠$悊鍛', 'admin', '2017-11-11 00:00:00', null, null, null, 'A03', 'A03', '1', '1.0.0.1'); INSERT INTO `t_s_black_list` VALUES ('402881e75f94a099015f94afe9700003', '绠$悊鍛', 'admin', '2017-11-07 12:14:37', null, null, '2017-11-11 08:00:00', 'A03', 'A03', '1', '1.0.0.1'); INSERT INTO `t_s_black_list` VALUES ('402881e75fa48e5b015fa494806a0002', '绠$悊鍛', 'admin', '2017-11-12 06:14:12', null, null, null, 'A03', 'A03', '1', '2.2.2.2'); INSERT INTO `t_s_black_list` VALUES ('402881e75fa48e5b015fa49494680003', '绠$悊鍛', 'admin', '2017-11-12 06:14:12', null, null, null, 'A03', 'A03', '1', '2.2.2.3'); @@ -3232,7 +3225,6 @@ INSERT INTO `t_s_data_rule` VALUES ('4028ab775dca0d1b015dca4183530018', '琛ㄥ悕 INSERT INTO `t_s_data_rule` VALUES ('402880ec5ddec439015ddf9225060038', '澶嶆潅鍏崇郴', '', 'USE_SQL_RULES', 'name like \'%寮%\' or age > 10', null, null, null, '2017-08-14 15:10:25', 'demo', 'demo', '40288088481d019401481d2fcebf000d'); INSERT INTO `t_s_data_rule` VALUES ('402880ec5ddfdd26015ddfe3e0570011', '澶嶆潅sql閰嶇疆', '', 'USE_SQL_RULES', 'table_name like \'%test%\' or is_tree = \'Y\'', null, null, null, '2017-08-14 16:38:55', 'demo', 'demo', '4028ab775dca0d1b015dca3fccb60016'); INSERT INTO `t_s_data_rule` VALUES ('40283181614231d401614234fe670003', 'createBy', 'createBy', '=', '#{sys_user_code}', '2018-01-29 21:57:04', 'admin', '绠$悊鍛', null, null, null, '40283181614231d401614232cd1c0001'); -INSERT INTO `t_s_data_rule` VALUES ('4028318161424e730161424fca6f0004', 'createBy', 'createBy', '=', '#{sys_user_code}', '2018-01-29 22:26:20', 'admin', '绠$悊鍛', null, null, null, '4028318161424e730161424f61510002'); INSERT INTO `t_s_data_rule` VALUES ('402881e56266f43101626727aff60067', '閿鍞嚜宸辩湅鑷繁鐨勬暟鎹', 'createBy', '=', '#{sys_user_code}', '2018-03-27 19:11:16', 'admin', '绠$悊鍛', null, null, null, '402881e56266f43101626724eb730065'); INSERT INTO `t_s_data_rule` VALUES ('402881e56266f4310162672fb1a70082', '閿鍞粡鐞嗙湅鎵鏈変笅绾ф暟鎹', 'sysOrgCode', 'LIKE', '#{sys_org_code}', '2018-03-27 19:20:01', 'admin', '绠$悊鍛', null, null, null, '402881e56266f43101626724eb730065'); INSERT INTO `t_s_data_rule` VALUES ('402881e56266f431016267387c9f0088', '鍙湅閲戦澶т簬1000鐨勬暟鎹', 'money', '>=', '1000', '2018-03-27 19:29:37', 'admin', '绠$悊鍛', null, null, null, '402881e56266f43101626724eb730065'); @@ -3496,7 +3488,6 @@ INSERT INTO `t_s_function` VALUES ('297e7ae162b925a20162b9271b300001', null, '1' INSERT INTO `t_s_function` VALUES ('297edb626033bbcb016033fd0a190001', null, '1', 'Online缁勫悎鏌ヨ閰嶇疆', '6', 'superQueryMainController.do?list', '8a8ab0b246dc81120146dc8180ce0019', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', 'admin', '2018-05-06 14:53:26', '2017-12-08 10:38:29', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('2c90ac564c9d1734014c9d6f4e370024', null, '1', 'menu.graph.configuration', '4', 'jformGraphreportHeadController.do?jformGraphreportHead', '8a8ab0b246dc81120146dc8180ce0019', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', null, null, null, null, null, null, null); INSERT INTO `t_s_function` VALUES ('40283181614231d401614232cd1c0001', null, '1', '绉诲姩鎶ヨ〃鏁版嵁鏉冮檺', '9', 'cgDynamGraphConfigHeadController.do?datagrid', '402889fb486e848101486e8de3d60005', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', 'admin', '2018-01-29 22:25:34', '2018-01-29 21:54:41', '绠$悊鍛'); -INSERT INTO `t_s_function` VALUES ('4028318161424e730161424f61510002', null, '1', '鍦ㄧ嚎鎶ヨ〃鏉冮檺', '10', 'jformGraphreportHeadController.do?datagrid', '402889fb486e848101486e8de3d60005', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', null, null, '2018-01-29 22:25:54', null); INSERT INTO `t_s_function` VALUES ('40284a815b48b411015b48b56fd80001', null, '1', '鍔ㄦ乼ab璁捐', '24', 'jeecgFormDemoController.do?ueditor', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'icon-bug', null, null, 'admin', '2017-11-14 11:32:23', null, '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('40284a815bb75d7b015bb7607ba00001', null, '1', '鐢靛瓙绛剧珷', '25', 'jeecgFormDemoController.do?eSign', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-empire', 'admin', '绠$悊鍛', 'admin', '2017-11-14 11:32:52', '2017-04-29 09:43:25', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('40284a815c1bac76015c1bc02abe0003', null, '1', '榛戝悕鍗曠鐞', '9', 'tsBlackListController.do?list', '8a8ab0b246dc81120146dc8180d9001d', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', null, null, 'admin', '2018-05-06 17:02:49', null, '绠$悊鍛'); @@ -3570,6 +3561,9 @@ INSERT INTO `t_s_function` VALUES ('402881f4606cc3d501606cd07a520005', null, '1' INSERT INTO `t_s_function` VALUES ('402881f4609299ad0160929ab2e00001', null, '1', '浜岀骇绠$悊鍛', '6', '', '8a8ab0b246dc81120146dc8180d2001a', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-group', 'admin', '绠$悊鍛', 'admin', '2018-01-16 17:20:57', '2017-12-26 19:35:00', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('402881f462bcd9fe0162bcdd0e4c0001', null, '1', 'vue鍒楄〃', '32', 'jeecgListDemoController.do?vueList', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-vimeo-square', 'admin', '绠$悊鍛', 'admin', '2018-05-06 14:56:17', '2018-04-13 10:37:07', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('402881f462fa6ee90162fa78deba0001', null, '1', 'vueBootstrap', '33', 'jeecgListDemoController.do?vueBootstrapTableList', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-vimeo-square', 'admin', '绠$悊鍛', 'admin', '2018-05-06 14:56:04', '2018-04-25 09:44:08', '绠$悊鍛'); +INSERT INTO `t_s_function` VALUES ('402881f463a591710163a5e59a830010', null, '2', '鎺ュ彛鐢ㄦ埛绠$悊', '3', 'userController.do?interfaceUser', '402881fc60a07a350160a07cf68e0001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', null, null, '2018-05-28 16:37:58', null); +INSERT INTO `t_s_function` VALUES ('402881f463b4e5d20163b4f9a81b0001', null, '1', 'Bootstrap甯冨眬鎶ヨ〃', '34', 'jeecgListDemoController.do?bootStrapEchartsDemo', '8a8ab0b246dc81120146dc8180d4001b', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', 'admin', '2018-05-31 19:48:06', '2018-05-31 14:54:10', '绠$悊鍛'); +INSERT INTO `t_s_function` VALUES ('402881f463b56b950163b5aefcdb0002', null, '1', '鑷畾涔夊祵濂楀瓙琛ㄥ垪琛', '35', 'jfromOrderController.do?gridViewlist', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', null, null, '2018-05-31 18:12:14', null); INSERT INTO `t_s_function` VALUES ('402881f66260fc8e016260ffdde70001', null, '1', '涓婁笅甯冨眬琛ㄥ崟浜', '21', 'jformOrderMain2Controller.do?index', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-facebook-official', 'admin', '绠$悊鍛', 'admin', '2018-05-06 15:39:26', '2018-03-26 14:30:04', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('402881fc60a07a350160a07cf68e0001', null, '1', '鎺ュ彛鏉冮檺', '6', '', '8a8ab0b246dc81120146dc8180d2001a', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-share-alt', 'admin', '绠$悊鍛', 'admin', '2018-01-16 17:20:36', '2017-12-29 12:17:12', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('402881fc60a07a350160a07d4f860003', null, '2', '鎺ュ彛鏉冮檺绠$悊', '1', 'interfaceController.do?interface', '402881fc60a07a350160a07cf68e0001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', null, null, '2017-12-29 12:17:35', null); @@ -3614,6 +3608,7 @@ INSERT INTO `t_s_function` VALUES ('4028f6815af9fb56015af9fc51d30001', null, '1' INSERT INTO `t_s_function` VALUES ('4028f6815afa8964015afa8a63e20001', null, '1', '琛岀紪杈戝垪琛', '4', 'jeecgListDemoController.do?rowListDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'icon-frown', 'admin', '绠$悊鍛', 'admin', '2018-05-06 15:00:17', '2017-03-23 17:40:57', '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('4028f6815b0b1017015b0b1265cf0002', null, '2', '鏃ュ織鎶ヨ〃', '25', 'jeecgListDemoController.do?log', '4028810061f41d790161f4e293140015', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-pencil-square', null, null, 'admin', '2018-05-06 16:57:13', null, '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('4028f681630b600701630bc1eee30030', null, '1', 'Easyui鍘熺敓鍒楄〃', '5', 'jeecgListDemoController.do?natureAceTableDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-code', 'admin', '绠$悊鍛', 'admin', '2018-05-06 15:29:42', '2018-04-28 18:17:29', '绠$悊鍛'); +INSERT INTO `t_s_function` VALUES ('4028f68163b5547e0163b55616930001', null, '1', '涓婁紶閲嶆瀯demo', '34', 'jeecgFormDemoController.do?webuploader', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', null, null, '2018-05-31 16:35:08', null); INSERT INTO `t_s_function` VALUES ('4028fbc65c3ab6e3015c3ab7ba690003', null, '1', '鏂囦欢涓婁紶涓', '14', 'commonController.do?listTurn&turn=system/document/filesList', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-files-o', null, null, 'admin', '2018-05-06 15:07:01', null, '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('4028fbc65c56ece6015c56f508300002', null, '1', '鏍戝舰鍒楄〃', '4', 'jeecgFormDemoController.do?function', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-tree', null, null, 'admin', '2017-11-14 11:35:33', null, '绠$悊鍛'); INSERT INTO `t_s_function` VALUES ('8a8ab0b246dc81120146dc8180ce0019', null, '0', 'online.develop', '5', '', null, '8a8ab0b246dc81120146dc8180890008', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-cloud', null, null, 'admin', '2016-04-08 22:28:17', null, '绠$悊鍛'); @@ -14513,6 +14508,13 @@ INSERT INTO `t_s_log` VALUES ('4028608163773dd40163776268610012', 'Chrome', '閿 INSERT INTO `t_s_log` VALUES ('4028608163773dd401637762890d0013', 'Chrome', '閿欒寮傚父: ObjectNotFoundException,閿欒鎻忚堪锛歂o row with the given identifier exists: [org.jeecgframework.web.system.pojo.base.TSFunction#4028838d5f351a87015f351fc33d0002]', '6', '鏈湴', '2018-05-19 15:52:16', '3', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); INSERT INTO `t_s_log` VALUES ('4028608163773dd401637762e7190014', 'Chrome', '閿欒寮傚父: ObjectNotFoundException,閿欒鎻忚堪锛歂o row with the given identifier exists: [org.jeecgframework.web.system.pojo.base.TSFunction#4028838d5f351a87015f351fc33d0002]', '6', '鏈湴', '2018-05-19 15:52:40', '3', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); INSERT INTO `t_s_log` VALUES ('4028608163773dd401637767f5c60015', 'Chrome', '閿欒寮傚父: ObjectNotFoundException,閿欒鎻忚堪锛歂o row with the given identifier exists: [org.jeecgframework.web.system.pojo.base.TSFunction#4028911b5c0bf9b9015c0c034d8e0013]', '6', '鏈湴', '2018-05-19 15:58:11', '3', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d50eb6bd0000', 'Chrome', '鐢ㄦ埛: admin[JEECG寮婧愮ぞ鍖篯common.login.success', '1', '192.168.224.1', '2018-06-06 20:25:01', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d50fc4310001', 'Chrome', '鎿嶄綔鍒犻櫎鎴愬姛', '4', '鏈湴', '2018-06-06 20:26:10', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d50fd51f0002', 'Chrome', '鑿滃崟鍒犻櫎鎴愬姛', '4', '鏈湴', '2018-06-06 20:26:14', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d50fe9ce0003', 'Chrome', 'admin', '2', '鏈湴', '2018-06-06 20:26:19', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d51004580004', 'Chrome', '鐢ㄦ埛: admin[JEECG寮婧愮ぞ鍖篯common.login.success', '1', '192.168.224.1', '2018-06-06 20:26:26', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d510c7e40005', 'Chrome', 'admin', '2', '鏈湴', '2018-06-06 20:27:16', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_log` VALUES ('4028608163d50e5d0163d510dd7b0006', 'Chrome', '鐢ㄦ埛: admin[JEECG寮婧愮ぞ鍖篯common.login.success', '1', '192.168.224.1', '2018-06-06 20:27:22', '1', '8a8ab0b246dc81120146dc8181950052', 'admin', '绠$悊鍛'); -- ---------------------------- -- Table structure for t_s_muti_lang @@ -15209,8 +15211,8 @@ INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533051360153305c60c90008', 'form.te INSERT INTO `t_s_muti_lang` VALUES ('4028ef815335c1da015335c8647d0003', 'self.defined.form', 'use defined form', 'en', '2016-03-02 13:23:58', 'admin', '绠$悊鍛', null, null, null); INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533a788e01533a7a53180005', 'form.tb.db.table.name', 'table', 'en', '2016-03-03 11:16:48', 'admin', '绠$悊鍛', '2016-03-03 11:17:56', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533a788e01533a7ba98c0008', 'form.tb.db.key', 'db source', 'en', '2016-03-03 11:18:16', 'admin', '绠$悊鍛', null, null, null); -INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533c078201533c08b1ca0001', 'system.version.number', '3.7.5-beta', 'zh-cn', '2016-03-03 18:31:56', 'admin', '绠$悊鍛', '2016-06-29 11:50:18', 'admin', '绠$悊鍛'); -INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533c078201533c08e2370003', 'system.version.number', '3.7.5-beta', 'en', '2016-03-03 18:32:08', 'admin', '绠$悊鍛', '2016-06-29 11:50:12', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533c078201533c08b1ca0001', 'system.version.number', '3.7.6', 'zh-cn', '2016-03-03 18:31:56', 'admin', '绠$悊鍛', '2016-06-29 11:50:18', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_muti_lang` VALUES ('4028ef81533c078201533c08e2370003', 'system.version.number', '3.7.6', 'en', '2016-03-03 18:32:08', 'admin', '绠$悊鍛', '2016-06-29 11:50:12', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028ef8154753f26015475436db30001', 'common.returntxttype', 'return type', 'en', '2016-05-03 14:17:13', 'admin', '绠$悊鍛', '2016-05-03 14:41:57', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028ef8154753f26015475438dd00003', 'common.returntxttype', '杩斿洖绫诲瀷', 'zh-cn', '2016-05-03 14:17:22', 'admin', '绠$悊鍛', '2016-05-03 14:42:06', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028efa2523a030601523a55381d0004', 'self.defined.form', '鑷畾涔夎〃鍗', 'zh-cn', '2016-01-13 17:33:29', 'admin', '绠$悊鍛', null, null, null); @@ -15221,8 +15223,8 @@ INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4a15aa60003', 'common. INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4a190580005', 'common.calendar', 'Calendar', 'en', '2014-06-23 01:31:01', 'admin', '绠$悊鍛', '2014-06-23 01:31:01', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4a2dc220007', 'common.map', '鍦板浘', 'zh-cn', '2014-06-23 01:32:26', 'admin', '绠$悊鍛', '2014-06-23 01:32:26', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4a2f24e0009', 'common.map', 'Map', 'en', '2014-06-23 01:32:31', 'admin', '绠$悊鍛', '2014-06-23 01:32:31', 'admin', '绠$悊鍛'); -INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4aff7ea000b', 'common.please.select', '-- 璇烽夋嫨 --', 'zh-cn', '2014-06-23 01:46:45', 'admin', '绠$悊鍛', '2017-11-06 10:37:16', 'admin', '绠$悊鍛'); -INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4b03310000d', 'common.please.select', 'Please Select', 'en', '2014-06-23 01:47:00', 'admin', '绠$悊鍛', '2014-06-23 02:01:20', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4aff7ea000b', 'common.please.select', ' ', 'zh-cn', '2014-06-23 01:46:45', 'admin', '绠$悊鍛', '2017-11-06 10:37:16', 'admin', '绠$悊鍛'); +INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4b03310000d', 'common.please.select', ' ', 'en', '2014-06-23 01:47:00', 'admin', '绠$悊鍛', '2014-06-23 02:01:20', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4b8af79000f', 'common.please.input.keyword', '璇疯緭鍏ュ叧閿瓧', 'zh-cn', '2014-06-23 01:56:16', 'admin', '绠$悊鍛', '2014-06-23 01:56:16', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4b8f7aa0011', 'common.please.input.keyword', 'Keyword', 'en', '2014-06-23 01:56:34', 'admin', '绠$悊鍛', '2014-06-23 01:56:34', 'admin', '绠$悊鍛'); INSERT INTO `t_s_muti_lang` VALUES ('4028fc4d46c481da0146c4ba979a0013', 'common.please.input.query.keyword', '璇疯緭鍏ユ煡璇㈠叧閿瓧', 'zh-cn', '2014-06-23 01:58:21', 'admin', '绠$悊鍛', '2014-06-23 01:58:21', 'admin', '绠$悊鍛'); @@ -19460,10 +19462,10 @@ CREATE TABLE `t_s_role` ( -- Records of t_s_role -- ---------------------------- INSERT INTO `t_s_role` VALUES ('4028608163773dd4016377623cf2000f', '11', '11', '402881f4609299ad0160929bd4ac000c', '1', null, null, null, '绠$悊鍛', '2018-05-19 15:51:56', 'admin'); -INSERT INTO `t_s_role` VALUES ('402880e74d75c4dd014d75d3c5f40001', 'demo', 'demo', null, null, '绠$悊鍛', '2017-03-01 21:54:06', 'admin', null, null, null); -INSERT INTO `t_s_role` VALUES ('402881875b19f141015b19fb1d490019', 'dep_jingli', '缁忕悊瑙掕壊', null, null, null, null, null, '绠$悊鍛', '2017-03-29 20:12:19', 'admin'); -INSERT INTO `t_s_role` VALUES ('8a8ab0b246dc81120146dc8181870050', 'admin', '绠$悊鍛', null, null, '绠$悊鍛', '2018-05-19 14:25:06', 'admin', null, null, null); -INSERT INTO `t_s_role` VALUES ('8a8ab0b246dc81120146dc81818b0051', 'manager', '鏅氱敤鎴', null, null, '绠$悊鍛', '2016-05-29 17:42:19', 'admin', null, null, null); +INSERT INTO `t_s_role` VALUES ('402880e74d75c4dd014d75d3c5f40001', 'demo', 'demo', null, '0', '绠$悊鍛', '2017-03-01 21:54:06', 'admin', null, null, null); +INSERT INTO `t_s_role` VALUES ('402881875b19f141015b19fb1d490019', 'dep_jingli', '缁忕悊瑙掕壊', null, '0', null, null, null, '绠$悊鍛', '2017-03-29 20:12:19', 'admin'); +INSERT INTO `t_s_role` VALUES ('8a8ab0b246dc81120146dc8181870050', 'admin', '绠$悊鍛', null, '0', '绠$悊鍛', '2018-05-19 14:25:06', 'admin', null, null, null); +INSERT INTO `t_s_role` VALUES ('8a8ab0b246dc81120146dc81818b0051', 'manager', '鏅氱敤鎴', null, '0', '绠$悊鍛', '2016-05-29 17:42:19', 'admin', null, null, null); -- ---------------------------- -- Table structure for t_s_role_function @@ -19489,7 +19491,6 @@ INSERT INTO `t_s_role_function` VALUES ('40283181614231d40161423538320006', null INSERT INTO `t_s_role_function` VALUES ('40283181614231d40161423561340007', null, '8a8ab0b246dc81120146dc818109002e', '402880e74d75c4dd014d75d3c5f40001', null); INSERT INTO `t_s_role_function` VALUES ('40283181614231d40161423561370008', null, '2c90ac564c9d1734014c9d6f4e370024', '402880e74d75c4dd014d75d3c5f40001', null); INSERT INTO `t_s_role_function` VALUES ('40283181614231d40161424756b0001e', null, '40287d81522a428401522a44aafb0002', '402880e74d75c4dd014d75d3c5f40001', null); -INSERT INTO `t_s_role_function` VALUES ('4028318161424e73016142501c930006', null, '4028318161424e730161424f61510002', '402880e74d75c4dd014d75d3c5f40001', '4028318161424e730161424fca6f0004,'); INSERT INTO `t_s_role_function` VALUES ('4028318163342ab60163342ce743000a', null, '4028ef8155fd32e40155fd33c6670001', '8a8ab0b246dc81120146dc8181870050', null); INSERT INTO `t_s_role_function` VALUES ('40284a815bb75d7b015bb760d9130003', null, '40284a815bb75d7b015bb7607ba00001', '8a8ab0b246dc81120146dc8181870050', null); INSERT INTO `t_s_role_function` VALUES ('402860816367e48e016367ea19a50002', null, '402860816361f06a016361f1be0d0001', '8a8ab0b246dc81120146dc8181870050', null); diff --git a/jeecg-framework/docs/鍏ラ棬蹇呰.txt b/jeecg-framework/docs/鍏ラ棬蹇呰.txt index fd4aae1e..77de0d39 100644 --- a/jeecg-framework/docs/鍏ラ棬蹇呰.txt +++ b/jeecg-framework/docs/鍏ラ棬蹇呰.txt @@ -4,7 +4,7 @@ eclipse + maven + jdk7 + tomcat7 + mysql 2. 手工执行初始化SQL脚本 - docs/db/jeecg_3.7.5_beta_mysql.sql + docs/db/jeecg_3.7.6_mysql.sql 注意: 必须手工执行doc\db下的数据库脚本 3. 入门开发环境搭建 diff --git a/jeecg-framework/docs/鏁版嵁搴撹鏄.txt b/jeecg-framework/docs/鏁版嵁搴撹鏄.txt index f2632119..561443c8 100644 --- a/jeecg-framework/docs/鏁版嵁搴撹鏄.txt +++ b/jeecg-framework/docs/鏁版嵁搴撹鏄.txt @@ -5,9 +5,9 @@ 1.oracle 导入命令 说明: jeecg脚本导出用户是scott - imp scott/tiger@orcl file=jeecg_3.7.5_beta_oracle11g.dmp + imp scott/tiger@orcl file=jeecg_3.7.6_oracle11g.dmp 导入其他用户的表 - imp jeecgos/jeecgos@orcl file=/opt/datatmp/jeecg_3.7.5_oracle11g.dmp fromuser=scott touser=jeecgos ignore=y commit=y buffer=300000000 feedback=10000 + imp jeecgos/jeecgos@orcl file=/opt/datatmp/jeecg_3.7.6_oracle11g.dmp fromuser=scott touser=jeecgos ignore=y commit=y buffer=300000000 feedback=10000 2. oracle、SqlServer脚步索引会有部分丢失,为了系统性能,请自行补加索引。 @@ -16,6 +16,6 @@ 4.老版本数据库增量升级 执行老版本升级SQL脚本 - 3.7.3升级到3.7.5_beta - docs/老版本增量升级/jeecg_mysql-3.7.3_beta-update-3.7.5.sql + 3.7.5_beta升级到3.7.6 + docs/老版本增量升级/jeecg_mysql-3.7.5_beta-update-3.7.6.sql \ No newline at end of file diff --git a/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.3_beta-update-3.7.5.sql b/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.3_beta-update-3.7.5.sql deleted file mode 100644 index 83bbf099..00000000 --- a/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.3_beta-update-3.7.5.sql +++ /dev/null @@ -1,35 +0,0 @@ -锘縄NSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bda83d80008', '绠$悊鍛', 'admin', '2018-03-22 11:57:15', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo鎺ュ彛', '1', '0', '', 'jeecgDemo', 'GET', NULL); -INSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bdaea80000a', '绠$悊鍛', 'admin', '2018-03-22 11:57:41', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo鍒楄〃鏌ヨ', '1', '1', '/rest/jeecgListDemoController/list', 'jeecgdemo_list', 'GET', '402881ef624bd23701624bda83d80008'); -INSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bdb477e000c', '绠$悊鍛', 'admin', '2018-03-22 11:58:05', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo鍗曟潯鏁版嵁鏌ヨ', '2', '1', '/rest/jeecgListDemoController/{id}', 'jeecgdemo_get', 'GET', '402881ef624bd23701624bda83d80008'); -INSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bdba184000e', '绠$悊鍛', 'admin', '2018-03-22 11:58:28', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo娣诲姞', '3', '1', '/rest/jeecgListDemoController', 'jeecgdemo_add', 'POST', '402881ef624bd23701624bda83d80008'); -INSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bdbfcec0010', '绠$悊鍛', 'admin', '2018-03-22 11:58:51', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo缂栬緫', '4', '1', '/rest/jeecgListDemoController', 'jeecgdemo_edit', 'PUT', '402881ef624bd23701624bda83d80008'); -INSERT INTO `t_s_interface` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `interface_name`, `interface_order`, `interface_level`, `interface_url`, `interface_code`, `interface_method`, `parent_interface_id`) VALUES ('402881ef624bd23701624bdc56f30012', '绠$悊鍛', 'admin', '2018-03-22 11:59:14', NULL, NULL, NULL, 'A03', 'A03', 'jeecgDemo鍒犻櫎', '5', '1', '/rest/jeecgListDemoController/{id}', 'jeecgdemo_delete', 'DELETE', '402881ef624bd23701624bda83d80008'); -update cgform_template set template_code = 'rowsEdit' where id = '40288af454ff777c0154ffad599e0003'; -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881ff6265de9b016266eb26380035', NULL, '1', '鎺ュ彛娴嬭瘯', '28', 'jeecgFormDemoController.do?interfaceTestDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180f00026', '0', 'fa-check-circle-o', 'admin', '绠$悊鍛', NULL, NULL, '2018-03-27 18:05:09', NULL); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f66260fc8e016260ffdde70001', NULL, '1', '涓瀵瑰琛ㄥ崟浜', '99', 'jformOrderMain2Controller.do?index', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-list-ul', 'admin', '绠$悊鍛', 'admin', '2018-03-27 16:14:26', '2018-03-26 14:30:04', '绠$悊鍛'); -INSERT INTO `super_query_main` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `query_name`, `query_code`, `query_type`, `content`) VALUES ('402881f66265f83b016266197dcf0005', '绠$悊鍛', 'admin', '2018-03-27 14:16:09', '绠$悊鍛', 'admin', '2018-03-27 17:42:28', 'A03', 'A03', '涓瀵瑰琛ㄥ崟娴嬭瘯楂樼骇鏌ヨ', 'jformOrderMain2', 'M', '涓瀵瑰琛ㄥ崟娴嬭瘯楂樼骇鏌ヨ'); -INSERT INTO `super_query_table` (`id`, `create_name`, `create_by`, `create_date`, `update_name`, `update_by`, `update_date`, `sys_org_code`, `sys_company_code`, `seq`, `table_name`, `instruction`, `is_main`, `fk_field`, `main_id`) VALUES ('402881f66265f83b016266197dcf0006', '绠$悊鍛', 'admin', '2018-03-27 14:16:09', '绠$悊鍛', 'admin', '2018-03-27 17:42:28', 'A03', 'A03', '1', 'jform_order_main', '鍚堝悓娴嬭瘯琛', 'Y', NULL, '402881f66265f83b016266197dcf0005'); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f462bcd9fe0162bcdd0e4c0001', NULL, '1', 'vue鍒楄〃', '1', 'jeecgListDemoController.do?vueList', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-vimeo-square', 'admin', '绠$悊鍛', 'admin', '2018-04-13 11:49:34', '2018-04-13 10:37:07', '绠$悊鍛'); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('297e7ae162b925a20162b9271b300001', NULL, '1', 'BootstrapTable', '30', 'jeecgListDemoController.do?bootTableDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-life-ring', 'admin', '绠$悊鍛', 'admin', '2018-04-19 10:32:54', '2018-04-12 17:19:31', '绠$悊鍛'); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f462fa6ee90162fa78deba0001', NULL, '1', 'vueBootstrapTable', '1', 'jeecgListDemoController.do?vueBootstrapTableList', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-vimeo-square', 'admin', '绠$悊鍛', 'admin', '2018-04-26 10:24:34', '2018-04-25 09:44:08', '绠$悊鍛'); -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('402881fc6305bc640163061f9a79000f', 'confirm.online.delete.record', '纭鍒犻櫎璇ヨ褰曞悧锛(鍚屾椂鍒犻櫎琛)', 'zh-cn', '2018-04-27 16:02:04', 'admin', '绠$悊鍛', NULL, NULL, NULL); -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('402881fc6305bc640163061fd1dc0011', 'confirm.online.delete.record', 'Confirm delete record?(Drop table)', 'en', '2018-04-27 16:02:18', 'admin', '绠$悊鍛', NULL, NULL, NULL); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('4028f681630b600701630bc1eee30030', NULL, '1', 'easyui鍘熺敓鎬', '30', 'jeecgListDemoController.do?aceTableDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', NULL, NULL, '2018-04-28 18:17:29', NULL); -delete from t_s_role_function where functionid = '402881ef5f5c650e015f5c67ddd20001'; -delete from t_s_function where id = '402881ef5f5c650e015f5c67ddd20001'; -update t_s_function set functionname = '涓瀵瑰琛ㄥ崟' where id = '402881f66260fc8e016260ffdde70001'; -update t_s_function set functionurl='jeecgListDemoController.do?natureAceTableDemo' where id='4028f681630b600701630bc1eee30030'; -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402860816329336901632a527c4d0028', NULL, '1', 'BootstrapTable(鏍囩鐗)', '31', 'jeecgListDemoController.do?bootstrapTableTagDemo', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-life-ring', 'admin', '绠$悊鍛', 'admin', '2018-05-04 16:44:42', '2018-05-04 16:43:58', '绠$悊鍛'); -ALTER TABLE `t_s_base_user` -MODIFY COLUMN `username` varchar(50) NOT NULL COMMENT '鐢ㄦ埛璐﹀彿' AFTER `userkey`; -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('402881f2635d5b6e01635d773ab20001', 'username.rang2to50', '鐢ㄦ埛璐﹀彿鑼冨洿鍦2~50浣嶅瓧绗', 'zh-cn', '2018-05-14 15:04:44', 'admin', '绠$悊鍛', NULL, NULL, NULL); -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('402881f2635d5b6e01635d77bb650003', 'username.rang2to50', 'User account need 2~50 bits', 'en', '2018-05-14 15:05:17', 'admin', '绠$悊鍛', NULL, NULL, NULL); -INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402860816361f06a016361f1be0d0001', NULL, '1', 'BootstrapTable(鏍囩鐗2)', '32', 'jeecgListDemoController.do?bootstrapTableTagDemo2', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', 'fa-life-ring', 'admin', '绠$悊鍛', 'admin', '2018-05-15 19:27:32', '2018-05-15 11:57:02', '绠$悊鍛'); -ALTER TABLE `jform_graphreport_head` -MODIFY COLUMN `create_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `create_by`, -MODIFY COLUMN `update_name` varchar(100) NULL DEFAULT NULL AFTER `update_by`; -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('40286081637677e601637724773f0037', 'common.please.select.two.item', '璇烽夋嫨涓ゆ潯鏁版嵁', 'zh-cn', '2018-05-19 14:44:28', 'admin', '绠$悊鍛', NULL, NULL, NULL); -INSERT INTO `t_s_muti_lang` (`id`, `lang_key`, `lang_context`, `lang_code`, `create_date`, `create_by`, `create_name`, `update_date`, `update_by`, `update_name`) VALUES ('40286081637677e601637725f4a50039', 'common.please.select.two.item', 'Please select two data', 'en', '2018-05-19 14:46:06', 'admin', '绠$悊鍛', NULL, NULL, NULL); -delete FROM t_s_depart_authg_function_rel where auth_id = '4028838d5f351a87015f351fc33d0002'; -delete FROM t_s_depart_authg_function_rel where auth_id = '4028911b5c0bf9b9015c0c034d8e0013'; -update t_s_muti_lang set lang_context = '3.7.5-beta' where lang_key ='system.version.number'; diff --git a/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.5_beta-update-3.7.6.sql b/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.5_beta-update-3.7.6.sql new file mode 100644 index 00000000..81fcb399 --- /dev/null +++ b/jeecg-framework/docs/鑰佺増鏈閲忓崌绾/jeecg_mysql-3.7.5_beta-update-3.7.6.sql @@ -0,0 +1,16 @@ +锘縰pdate t_s_role set role_type=0 where role_type is null; +ALTER TABLE `jeecg_demo` +MODIFY COLUMN `content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '涓汉浠嬬粛' AFTER `birthday`; +INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f463a591710163a5e59a830010', NULL, '2', '鎺ュ彛鐢ㄦ埛绠$悊', '3', 'userController.do?interfaceUser', '402881fc60a07a350160a07cf68e0001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', NULL, NULL, '2018-05-28 16:37:58', NULL); +delete from t_s_black_list where ip in (select a.ip from (select ip from t_s_black_list GROUP BY ip HAVING COUNT(1) > 1) a ) +and id not in (select b.md from (select max(id) md from t_s_black_list GROUP BY ip HAVING COUNT(1) > 1) b ); +ALTER TABLE `t_s_black_list` +ADD UNIQUE INDEX `unique_key_ip` (`ip`) ; +INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('4028f68163b5547e0163b55616930001', NULL, '1', '涓婁紶閲嶆瀯demo', '34', 'jeecgFormDemoController.do?webuploader', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', NULL, NULL, '2018-05-31 16:35:08', NULL); +INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f463b56b950163b5aefcdb0002', NULL, '1', '鑷畾涔夊祵濂楀瓙琛ㄥ垪琛', '35', 'jfromOrderController.do?gridViewlist', '4028f6815af3ce54015af3d1ad610001', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', NULL, NULL, '2018-05-31 18:12:14', NULL); +INSERT INTO `t_s_function` (`ID`, `functioniframe`, `functionlevel`, `functionname`, `functionorder`, `functionurl`, `parentfunctionid`, `iconid`, `desk_iconid`, `functiontype`, `function_icon_style`, `create_by`, `create_name`, `update_by`, `update_date`, `create_date`, `update_name`) VALUES ('402881f463b4e5d20163b4f9a81b0001', NULL, '1', 'Bootstrap甯冨眬鎶ヨ〃', '34', 'jeecgListDemoController.do?bootStrapEchartsDemo', '8a8ab0b246dc81120146dc8180d4001b', '8a8ab0b246dc81120146dc8180460000', '8a8ab0b246dc81120146dc8180dd001e', '0', '', 'admin', '绠$悊鍛', 'admin', '2018-05-31 19:48:06', '2018-05-31 14:54:10', '绠$悊鍛'); +update t_s_muti_lang set lang_context = ' ' where lang_key ='common.please.select'; +ALTER TABLE `jform_graphreport_head` +DROP INDEX `index_code`, +ADD UNIQUE INDEX `index_code`(`code`); +update t_s_muti_lang set lang_context = '3.7.6' where lang_key ='system.version.number'; diff --git a/jeecg-framework/pom.xml b/jeecg-framework/pom.xml index 7d5a77db..83a09209 100644 --- a/jeecg-framework/pom.xml +++ b/jeecg-framework/pom.xml @@ -1,14 +1,14 @@ - 4.0.0 org.jeecgframework jeecg - 3.7.5-beta + 3.7.6 war + - UTF-8 3.6.3 - 1.6.2 + 1.6.4 16.0.1 4.0.9.RELEASE @@ -45,7 +45,7 @@ 2.6 3.1 1.2 - 1.0.4 + 1.1.3 1.1 1.3.1 2.4.3 @@ -61,7 +61,7 @@ 0.9.1 1.6 1.4 - 0.2.9 + 1.1.9 5.1.27 4.0 @@ -81,8 +81,8 @@ 0.4.6 - 2.5.0 - 1.6.2 + 2.5.1 + 2.3.0 1.1.1 1.0 1.4.4 @@ -96,6 +96,13 @@ 2.9.0 8080 UTF-8 + + + 1.0.0 + + 1.0.2 + 1.0.4 + 1.0.0 @@ -146,22 +153,12 @@ codegenerate ${codegenerate.version} system - ${project.basedir}/src/main/webapp/WEB-INF/lib/codegenerate-3.6.3-20180503.jar + ${project.basedir}/src/main/webapp/WEB-INF/lib/codegenerate-3.6.3-20180606.jar org.jeecgframework minidao-pe ${minidao.version} - - - org.springframework - spring-asm - - - org.junit - com.springsource.org.junit - - @@ -169,26 +166,37 @@ thumbnailator ${thumbnailator.version} + - + + com.belerweb + pinyin4j + ${pinyin4j.version} + + + + + org.quartz-scheduler + quartz + ${org.quartz.version} @@ -245,11 +253,13 @@ hibernate-ehcache ${hibernate.version} + org.hibernate.common hibernate-commons-annotations @@ -274,7 +284,7 @@ - + + + commons-pool commons-pool @@ -307,6 +319,7 @@ ${commons-dbcp.version} compile + com.alibaba druid @@ -320,12 +333,13 @@ ${mysql.version} runtime - + @@ -480,23 +495,12 @@ - - - org.slf4j - slf4j-api - ${slf4j.version} - + org.slf4j slf4j-log4j12 ${slf4j.version} - - - log4j - log4j - ${log4j.version} - - + @@ -534,24 +538,24 @@ commons-collections ${commons-collections.version} - + commons-codec commons-codec ${commons-codec.version} - + commons-io @@ -594,30 +598,35 @@ - + + --> + net.sf.ehcache ehcache-core ${ehcache.version} - + + + org.freemarker + freemarker + ${freemarker.version} @@ -704,11 +713,13 @@ ${project.basedir}/src/main/webapp/WEB-INF/lib/jodconverter-3.0-beta-4-20170917.jar + + @@ -723,86 +734,69 @@ hamcrest-all ${hamcrest.version} - + org.springframework spring-test ${spring.version} - + + --> - org.jeecgframework - batik-all - 1.6 - system - ${project.basedir}/src/main/webapp/WEB-INF/lib/batik-all-1.6-20170917.jar - + com.hynnet + jacob + 1.18 + + + - org.jeecgframework - fop - 1.0 - system - ${project.basedir}/src/main/webapp/WEB-INF/lib/fop-1.0-20170917.jar + org.apache.xmlgraphics + batik-codec + 1.7 xerces xercesImpl 2.7.1 - - xml-apis - xml-apis-ext - 1.3.04 - - - xml-apis - xml-apis - 1.3.04 - - - org.apache.xmlgraphics - xmlgraphics-commons - 1.4 - - - xalan - xalan - 2.7.0 - - com.thoughtworks.xstream xstream ${xstream.version} + commons-httpclient commons-httpclient 3.0.1 + + - + @@ -833,7 +827,7 @@ jsoup 1.8.3 - + com.google.guava guava @@ -848,7 +842,7 @@ - + - org.p3framework + org.jeecgframework.p3 jeecg-p3-core - 1.1.1 + ${jeecg-p3-core.version} - org.p3framework - jeecg-p3-ui - 1.1.3 - jar + org.jeecgframework.p3 + jeecg-p3-core-api + ${jeecg-p3-core.version} + + + org.jeecgframework.p3 + jeecg-p3-core + + - org.p3framework - jeecg-p3-bizcore - 1.0-SNAPSHOT - jar + org.jeecgframework.p3 + jeecg-p3-core-ui + ${jeecg-p3-core.version} + + + org.jeecgframework.p3 + jeecg-p3-core + + - + - org.p3framework + org.jeecgframework.p3 jeecg-p3-biz-demo - 1.0.2 + ${jeecg-p3-biz-demo.version} + + + org.jeecgframework.p3 + jeecg-p3-start-quick + + - + - org.p3framework - jeecg-p3-biz-mail - 1.0.0 - jar + org.jeecgframework.p3 + jeecg-p3-biz-chat + ${jeecg-p3-biz-chat.version} + + + org.jeecgframework.p3 + jeecg-p3-start-quick + + - + - org.p3framework - jeecg-p3-biz-chat - 1.0.3 + org.jeecgframework.p3 + jeecg-p3-biz-mail + ${jeecg-p3-biz-mail.version} + + + org.jeecgframework.p3 + jeecg-p3-start-quick + + @@ -986,9 +1008,9 @@ tomcat-maven-plugin 1.1 - /jeecg - 8080 - UTF-8 + /${project.artifactId} + ${webserver.port} + ${project.build.sourceEncoding} http://localhost:8080/manager/html tomcat6 diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgFormDemoController.java b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgFormDemoController.java index 403d62d4..1f0d6e1f 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgFormDemoController.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgFormDemoController.java @@ -1,11 +1,20 @@ package com.jeecg.demo.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.net.URLEncoder; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -21,6 +30,7 @@ import org.jeecgframework.core.common.model.json.ComboTree; import org.jeecgframework.core.common.model.json.DataGrid; import org.jeecgframework.core.common.model.json.TreeGrid; import org.jeecgframework.core.constant.Globals; +import org.jeecgframework.core.enums.StoreUploadFilePathEnum; import org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil; import org.jeecgframework.core.util.DateUtils; import org.jeecgframework.core.util.HttpRequest; @@ -28,12 +38,14 @@ import org.jeecgframework.core.util.JSONHelper; import org.jeecgframework.core.util.MutiLangUtil; import org.jeecgframework.core.util.MyClassLoader; import org.jeecgframework.core.util.NumberComparator; +import org.jeecgframework.core.util.ResourceUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.tag.core.easyui.TagUtil; import org.jeecgframework.tag.vo.datatable.SortDirection; import org.jeecgframework.tag.vo.easyui.ComboTreeModel; import org.jeecgframework.tag.vo.easyui.TreeGridModel; +import org.jeecgframework.web.cgform.exception.BusinessException; import org.jeecgframework.web.system.pojo.base.TSAttachment; import org.jeecgframework.web.system.pojo.base.TSDepart; import org.jeecgframework.web.system.pojo.base.TSFunction; @@ -44,9 +56,12 @@ import org.jeecgframework.web.system.service.SystemService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import com.alibaba.fastjson.JSONObject; @@ -582,7 +597,9 @@ public class JeecgFormDemoController extends BaseController { public AjaxJson del(TSDepart depart, HttpServletRequest request) { AjaxJson j = new AjaxJson(); depart = systemService.getEntity(TSDepart.class, depart.getId()); - Long childCount = systemService.getCountForJdbc("select count(1) from t_s_depart where parentdepartid ='" + depart.getId() + "'"); + + Long childCount = systemService.getCountForJdbcParam("select count(1) from t_s_depart where parentdepartid = ?", depart.getId()); + if(childCount>0){ j.setSuccess(false); j.setMsg("鏈変笅绾,涓嶈兘鍒犻櫎"); @@ -660,4 +677,128 @@ public class JeecgFormDemoController extends BaseController { return j; } + + @RequestMapping(params = "webuploader") + public ModelAndView webuploader(HttpServletRequest request) { + logger.info("----webuploaderdemo-----"); + return new ModelAndView("com/jeecg/demo/form_webuploader"); + } + + /** + * WebUploader + * 鏂囦欢涓婁紶澶勭悊 + */ + @RequestMapping("/filedeal") + @ResponseBody + public AjaxJson filedeal(HttpServletRequest request, HttpServletResponse response) { + AjaxJson j = new AjaxJson(); + String msg=""; + String ctxPath=ResourceUtil.getConfigByName("webUploadpath");//demo涓缃负D://upFiles,瀹為檯椤圭洰搴斿洜浜嬪埗瀹 + try { + String fileName = null; + String bizType=request.getParameter("bizType");//涓婁紶涓氬姟鍚嶇О + String bizPath=StoreUploadFilePathEnum.getPath(bizType);//鏍规嵁涓氬姟鍚嶇О鍒ゆ柇涓婁紶璺緞 + String nowday=new SimpleDateFormat("yyyyMMdd").format(new Date()); + File file = new File(ctxPath+"/"+bizPath+"/"+nowday); + if (!file.exists()) { + file.mkdirs();// 鍒涘缓鏂囦欢鏍圭洰褰 + } + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + MultipartFile mf=multipartRequest.getFile("file");// 鑾峰彇涓婁紶鏂囦欢瀵硅薄 + String orgName = mf.getOriginalFilename();// 鑾峰彇鏂囦欢鍚 + fileName = String.valueOf(UUID.randomUUID().getMostSignificantBits()).replace("-", "")+ orgName.substring(orgName.lastIndexOf(".")); + String savePath = file.getPath() + "/" + fileName; + File savefile = new File(savePath); + FileCopyUtils.copy(mf.getBytes(), savefile); + msg="涓婁紶鎴愬姛"; + j.setMsg(msg); + String dbpath=bizPath+"/"+nowday+"/"+fileName; + Map info = new HashMap(); + info.put("filename", orgName.substring(0,orgName.lastIndexOf("."))); + info.put("filesize", mf.getSize()); + info.put("filetype", orgName.substring(orgName.lastIndexOf("."))); + info.put("filepath", dbpath); + j.setAttributes(info); + } catch (IOException e) { + j.setSuccess(false); + logger.info(e.getMessage()); + } + j.setMsg(msg); + return j; + } + /** + * 鍒犻櫎澶勭悊 + * @param request + * @param response + * @return + */ + @RequestMapping("/filedelete") + @ResponseBody + public AjaxJson filedelete(HttpServletRequest request, HttpServletResponse response) { + AjaxJson j = new AjaxJson(); + String msg=""; + String ctxPath=ResourceUtil.getConfigByName("webUploadpath");//demo涓缃负D://upFiles,瀹為檯椤圭洰搴斿洜浜嬪埗瀹 + String path=request.getParameter("filepath"); + String delpath=ctxPath+"/"+path; + File fileDelete = new File(delpath); + if (!fileDelete.exists() || !fileDelete.isFile()) { + msg="璀﹀憡: " + delpath + "涓嶅瓨鍦!"; + logger.info(msg); + j.setSuccess(true);//涓嶅瓨鍦ㄥ墠鍙颁篃缁欎粬鍒犻櫎 + }else{ + if(fileDelete.delete()){ + msg="--------鎴愬姛鍒犻櫎鏂囦欢---------"+delpath; + logger.info(msg); + }else{ + j.setSuccess(false); + msg="娌″垹闄ゆ垚鍔--jdk鐨勯棶棰樿繕鏄綘鏂囦欢鐨勯棶棰樿閲嶆柊璇曡瘯"; + logger.info(msg); + } + } + j.setMsg(msg); + return j; + } + + @RequestMapping("/filedown") + public void getImgByurl(HttpServletResponse response,HttpServletRequest request) throws Exception{ + String dbpath = request.getParameter("filepath"); + if(oConvertUtils.isNotEmpty(dbpath)&&dbpath.endsWith(",")){ + dbpath = dbpath.substring(0, dbpath.length()-1); + } + response.setContentType("application/x-msdownload;charset=utf-8"); + String fileType = dbpath.substring(dbpath.lastIndexOf(".")); + String fileName=request.getParameter("filename")+fileType; + String userAgent = request.getHeader("user-agent").toLowerCase(); + if (userAgent.contains("msie") || userAgent.contains("like gecko") ) { + fileName = URLEncoder.encode(fileName, "UTF-8"); + }else { + fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1"); + } + response.setHeader("Content-disposition", "attachment; filename="+ fileName); + + InputStream inputStream = null; + OutputStream outputStream=null; + try { + String localPath=ResourceUtil.getConfigByName("webUploadpath"); + String imgurl = localPath+"/"+dbpath; + inputStream = new BufferedInputStream(new FileInputStream(imgurl)); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (Exception e) { + logger.info("--閫氳繃娴佺殑鏂瑰紡鑾峰彇鏂囦欢寮傚父--"+e.getMessage()); + }finally{ + if(inputStream!=null){ + inputStream.close(); + } + if(outputStream!=null){ + outputStream.close(); + } + } + } + } diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgListDemoController.java b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgListDemoController.java index 31007f1b..249a5e92 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgListDemoController.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JeecgListDemoController.java @@ -1,4 +1,8 @@ package com.jeecg.demo.controller; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + import java.io.IOException; import java.io.OutputStreamWriter; import java.io.StringReader; @@ -61,7 +65,6 @@ import org.jeecgframework.web.system.service.MutiLangServiceI; import org.jeecgframework.web.system.service.SystemService; import org.jeecgframework.web.system.util.InterfaceUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -71,7 +74,6 @@ 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.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; @@ -84,10 +86,6 @@ import com.jeecg.demo.entity.JeecgDemoPage; import com.jeecg.demo.entity.JeecgLogReport; import com.jeecg.demo.service.JeecgDemoServiceI; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; - /** * @Title: Controller * @Description: jeecg_demo @@ -605,28 +603,26 @@ public class JeecgListDemoController extends BaseController { } } } - - @RequestMapping(params = "minidaoDatagrid") public void minidaoDatagrid(JeecgDemoEntity jeecgDemo,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { /** * 娉ㄦ剰锛歮inidao浼氶伒寰猻pringjdbc瑙勫垯锛屼細鑷姩鎶婃暟鎹簱浠ヤ笅鍒掔嚎鐨勫瓧娈碉紝杞寲涓洪┘宄板啓娉 - * 渚嬪鏁版嵁搴撹〃瀛楁锛歿USER_NAME} + * 渚嬪鏁版嵁搴撹〃瀛楁锛歿user_name} * 杞寲瀹炰綋瀵瑰簲瀛楁锛歿userName} */ - + + //step.1 鑾峰彇鏁版嵁鏉冮檺SQL鐗囨 String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); + + //step.2 灏嗘潈闄怱QL鐗囨娉ㄥ叆鍒颁笟鍔QL涓 MiniDaoPage list = jeecgMinidaoDao.getAllEntities(jeecgDemo, dataGrid.getPage(), dataGrid.getRows(),authSql); - dataGrid.setTotal(list.getTotal()); dataGrid.setResults(list.getResults()); - + + //step.3 鍚堣锛屾牸寮忎负 瀛楁鍚:鍊(鍙夛紝涓嶅啓璇ュ兼椂涓哄垎椤垫暟鎹殑鍚堣) 澶氫釜鍚堣 浠 , 鍒嗗壊 String total_salary = String.valueOf(jeecgMinidaoDao.getSumSalary()); - /* - * 璇存槑锛氭牸寮忎负 瀛楁鍚:鍊(鍙夛紝涓嶅啓璇ュ兼椂涓哄垎椤垫暟鎹殑鍚堣) 澶氫釜鍚堣 浠 , 鍒嗗壊 - */ dataGrid.setFooter("salary:"+(total_salary.equalsIgnoreCase("null")?"0.0":total_salary)+",age,email:鍚堣"); TagUtil.datagrid(response, dataGrid); } @@ -671,8 +667,8 @@ public class JeecgListDemoController extends BaseController { m.put("extField",this.jeecgMinidaoDao.getOrgCode(temp.getDepId())); extMap.put(temp.getId(), m); } - //dataGrid.setFooter("extField,salary,age,name:鍚堣"); - dataGrid.setFooter("salary,age,name:鍚堣"); +// dataGrid.setFooter("salary,age,name:鍚堣"); + dataGrid.setFooter("[{'salary':'','age':'','name':'鍚堣'}]"); TagUtil.datagrid(response, dataGrid, extMap); } @@ -995,6 +991,7 @@ public class JeecgListDemoController extends BaseController { jeecgDemoService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { + message = "JeecgDemo渚嬪瓙: " + jeecgDemo.getName() + "鏇存柊澶辫触!!"; e.printStackTrace(); } } else { @@ -1004,6 +1001,7 @@ public class JeecgListDemoController extends BaseController { jeecgDemoService.save(jeecgDemo); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); } catch (Exception e) { + message = "JeecgDemo渚嬪瓙: " + jeecgDemo.getName() + "娣诲姞澶辫触!!"; e.printStackTrace(); } @@ -1364,5 +1362,10 @@ public class JeecgListDemoController extends BaseController { return new ModelAndView("com/jeecg/demo/jeecgDemo-bootstrap-add2"); } + @RequestMapping(params = "bootStrapEchartsDemo") + public ModelAndView bootStrapEchartsDemo(HttpServletRequest request) { + return new ModelAndView("com/jeecg/demo/echartsDemo/bootstrap-echarts"); + } + } diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JformOrderMain2Controller.java b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JformOrderMain2Controller.java index af6c8f9b..67e3b49b 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JformOrderMain2Controller.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JformOrderMain2Controller.java @@ -55,7 +55,7 @@ import com.jeecg.demo.entity.JformOrderMain2Entity; import com.jeecg.demo.entity.JformOrderTicket2Entity; import com.jeecg.demo.page.JformOrderMain2Page; import com.jeecg.demo.service.JformOrderMain2ServiceI; -import com.jeecg.superquery.util.SuperQueryUtil; +import org.jeecgframework.web.superquery.util.SuperQueryUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JfromOrderController.java b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JfromOrderController.java index a0912626..86526889 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/controller/JfromOrderController.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/controller/JfromOrderController.java @@ -58,7 +58,7 @@ import com.jeecg.demo.entity.JfromOrderEntity; import com.jeecg.demo.entity.JfromOrderLineEntity; import com.jeecg.demo.page.JfromOrderPage; import com.jeecg.demo.service.JfromOrderServiceI; -import com.jeecg.superquery.util.SuperQueryUtil; +import org.jeecgframework.web.superquery.util.SuperQueryUtil; /** * @Title: Controller @@ -92,8 +92,19 @@ public class JfromOrderController extends BaseController { @RequestMapping(params = "list") public ModelAndView list(HttpServletRequest request) { return new ModelAndView("com/jeecg/demo/jfromOrderList"); + } + + /** + * 璁㈠崟鍒楄〃鍒楄〃 椤甸潰璺宠浆 (鑷畾涔夊瓙琛ㄦ樉绀篸emo) + * + * @return + */ + @RequestMapping(params = "gridViewlist") + public ModelAndView gridViewlist(HttpServletRequest request) { + return new ModelAndView("com/jeecg/demo/jfromOrderGridViewList"); } + /** * easyui AJAX璇锋眰鏁版嵁 * @@ -274,6 +285,17 @@ public class JfromOrderController extends BaseController { return new ModelAndView("com/jeecg/demo/jfromOrderLineList"); } + @RequestMapping(params = "jfromOrderLineDatagrid") + public void jfromOrderLineDatagrid(JfromOrderLineEntity jfromOrderLineEntity,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { + CriteriaQuery cq = new CriteriaQuery(JfromOrderLineEntity.class, dataGrid); + //鏌ヨ鏉′欢缁勮鍣 + org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, jfromOrderLineEntity); + cq.add(); + this.jfromOrderService.getDataGridReturn(cq, true); + TagUtil.datagrid(response, dataGrid); + } + + /** * 瀵煎嚭excel * diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/dao/JeecgMinidaoDao.java b/jeecg-framework/src/main/java/com/jeecg/demo/dao/JeecgMinidaoDao.java index 1a96b602..d0372b94 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/dao/JeecgMinidaoDao.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/dao/JeecgMinidaoDao.java @@ -16,48 +16,26 @@ import org.jeecgframework.minidao.pojo.MiniDaoPage; public interface JeecgMinidaoDao { @Arguments("pid") - @Sql("select ID,NAME,PID from t_s_region where pid=:pid order by name_en") + @Sql("select id,name,pid from t_s_region where pid=:pid order by name_en") List> getProCity(String pid); - @Sql("select ID,NAME,PID from t_s_region order by name_en") + @Sql("select id,name,pid from t_s_region order by name_en") List> getAllRegions(); @ResultType(JeecgDemoEntity.class) public MiniDaoPage getAllEntities(@Param("jeecgDemo") JeecgDemoEntity jeecgDemo, @Param("page") int page, @Param("rows") int rows,@Param("authSql") String authSql); - @Sql("SELECT count(*) FROM jeecg_demo") + @Sql("select count(*) from jeecg_demo") Integer getCount(); - @Sql("SELECT SUM(salary) FROM jeecg_demo") + @Sql("select sum(salary) from jeecg_demo") Integer getSumSalary(); @Arguments("id") @ResultType(String.class) - @Sql("SELECT org_code FROM t_s_depart where id=:id") + @Sql("select org_code from t_s_depart where id=:id") public java.lang.String getOrgCode(String id); - /*@Arguments({"jeecgMinidao", "page", "rows"}) - public List getAllEntities(JeecgMinidaoEntity jeecgMinidao, int page, int rows); - - @Arguments({"jeecgMinidao", "page", "rows"}) - @ResultType(JeecgMinidaoEntity.class) - public List getAllEntities2(JeecgMinidaoEntity jeecgMinidao, int page, int rows);*/ - - //@Arguments("id") - //JeecgMinidaoEntity getJeecgMinidao(String id); - -/* -*/ - - /*@Arguments("jeecgMinidao") - int update(JeecgMinidaoEntity jeecgMinidao); - - @Arguments("jeecgMinidao") - void insert(JeecgMinidaoEntity jeecgMinidao); - - @Arguments("jeecgMinidao") - void delete(JeecgMinidaoEntity jeecgMinidao);*/ - @Arguments("log") @ResultType(JeecgLogReport.class) List getLogReportData(JeecgLogReport log); diff --git a/jeecg-framework/src/main/java/com/jeecg/demo/entity/JeecgDemoEntity.java b/jeecg-framework/src/main/java/com/jeecg/demo/entity/JeecgDemoEntity.java index e3a96506..abe63553 100644 --- a/jeecg-framework/src/main/java/com/jeecg/demo/entity/JeecgDemoEntity.java +++ b/jeecg-framework/src/main/java/com/jeecg/demo/entity/JeecgDemoEntity.java @@ -48,7 +48,7 @@ public class JeecgDemoEntity implements java.io.Serializable { private java.lang.String phone; /**宸ヨ祫*/ @Excel(name="宸ヨ祫") - private java.lang.String salary; + private Double salary; /**鎬у埆*/ @Excel(name="鎬у埆",dicCode="sex") private java.lang.String sex; @@ -214,7 +214,7 @@ public class JeecgDemoEntity implements java.io.Serializable { *@return: java.lang.String 宸ヨ祫 */ @Column(name ="SALARY",nullable=true,scale=2,length=19) - public java.lang.String getSalary(){ + public Double getSalary(){ return this.salary; } @@ -222,7 +222,7 @@ public class JeecgDemoEntity implements java.io.Serializable { *鏂规硶: 璁剧疆java.lang.String *@param: java.lang.String 宸ヨ祫 */ - public void setSalary(java.lang.String salary){ + public void setSalary(Double salary){ this.salary = salary; } /** diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/Ehcache.java b/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/Ehcache.java index 6f389dfc..04df05a5 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/Ehcache.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/Ehcache.java @@ -21,6 +21,7 @@ public @interface Ehcache { // 澧炲姞缂撳瓨杩樻槸鍒犻櫎缂撳瓨锛岄粯璁や负澧炲姞缂撳瓨 boolean addOrdel() default true; - //涓存椂缂撳瓨杩樻槸姘镐箙缂撳瓨锛岄粯璁や负姘镐箙缂撳瓨 + //涓存椂缂撳瓨杩樻槸姘镐箙缂撳瓨锛岄粯璁や负缂撳瓨缂撳瓨 + //TODO 鏆傛椂鍙敮鎸佷复鏃剁紦瀛橈紝鏈疄鐜版案涔呯紦瀛 boolean eternal() default true; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/JAuth.java b/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/JAuth.java index 487215d6..4fa378e6 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/JAuth.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/annotation/JAuth.java @@ -16,5 +16,5 @@ import org.jeecgframework.core.enums.Permission; @Documented public @interface JAuth { String value() default ""; - Permission auth() default Permission.NORMAL; + Permission auth() default Permission.SKIP_AUTH; } \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/aop/EhcacheAspect.java b/jeecg-framework/src/main/java/org/jeecgframework/core/aop/EhcacheAspect.java index 341d933d..f80cfabd 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/aop/EhcacheAspect.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/aop/EhcacheAspect.java @@ -7,12 +7,14 @@ import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Element; +import org.apache.log4j.Logger; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.jeecgframework.core.annotation.Ehcache; +import org.jeecgframework.core.util.oConvertUtils; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSON; @@ -20,23 +22,14 @@ import com.alibaba.fastjson.JSON; /** * * @author 寮犱唬娴 + * @ * */ @Component @Aspect public class EhcacheAspect { -// private static Cache dictCache; -// private static Cache eternalCache; -// -// static { -// if (eternalCache == null) { -// eternalCache = CacheManager.getInstance().getCache("eternalCache"); -// } -// if (dictCache == null) { -// dictCache = CacheManager.getInstance().getCache("dictCache"); -// } -// } - + private static final Logger logger = Logger.getLogger(EhcacheAspect.class); + @Pointcut("@annotation(org.jeecgframework.core.annotation.Ehcache)") public void simplePointcut() { } @@ -46,40 +39,42 @@ public class EhcacheAspect { } @Around("simplePointcut()") - public Object aroundLogCalls(ProceedingJoinPoint joinPoint) - throws Throwable { - - Cache eternalCache = CacheManager.getInstance().getCache("eternalCache"); - Cache dictCache = CacheManager.getInstance().getCache("eternalCache"); - + public Object aroundLogCalls(ProceedingJoinPoint joinPoint)throws Throwable { String targetName = joinPoint.getTarget().getClass().toString(); String methodName = joinPoint.getSignature().getName(); - Object[] arguments = joinPoint.getArgs(); + Object[] arguments = joinPoint.getArgs(); + + logger.debug("-------ehcache------aspect-----targetclass: "+ targetName); //璇曞浘寰楀埌鏍囨敞鐨凟hcache绫 @SuppressWarnings("unused") Method[] methods = joinPoint.getTarget().getClass().getMethods(); Ehcache flag = null; - for(Method m:methods){ - if(m.getName().equals(methodName)){ - Class[] tmpCs = m.getParameterTypes(); - if(tmpCs.length==arguments.length){ - flag = m.getAnnotation(Ehcache.class); - break; - } + for (Method m : methods) { + if (m.getName().equals(methodName)) { + Class[] tmpCs = m.getParameterTypes(); + if (tmpCs.length == arguments.length) { + flag = m.getAnnotation(Ehcache.class); + break; + } } } if(flag==null){ return null; } - //Ehcache flag =joinPoint.getTarget().getClass().getMethod(methodName).getAnnotation(Ehcache.class); Object result; String cacheKey = getCacheKey(targetName, methodName, arguments); Element element = null; + + Cache eternalCache = CacheManager.getInstance().getCache("eternalCache"); + //鑷畾涔夌紦瀛樺悕瀛 + if(oConvertUtils.isNotEmpty(flag.cacheName())){ + eternalCache = CacheManager.getInstance().getCache(flag.cacheName()); + } if(flag.eternal()){ //姘镐箙缂撳瓨 - element = dictCache.get(cacheKey); + element = eternalCache.get(cacheKey); }else{ //涓存椂缂撳瓨 element = eternalCache.get(cacheKey); @@ -96,7 +91,7 @@ public class EhcacheAspect { element = new Element(cacheKey, (Serializable) result); if(flag.eternal()){ //姘镐箙缂撳瓨 - dictCache.put(element); + eternalCache.put(element); }else{ //涓存椂缂撳瓨 eternalCache.put(element); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/aop/RedisCacheAspect.java b/jeecg-framework/src/main/java/org/jeecgframework/core/aop/RedisCacheAspect.java index 8453fa4e..b85cf525 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/aop/RedisCacheAspect.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/aop/RedisCacheAspect.java @@ -3,17 +3,15 @@ package org.jeecgframework.core.aop; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; +import javax.annotation.Resource; + import org.apache.commons.lang.StringUtils; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.jeecgframework.core.annotation.Ehcache; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.BoundValueOperations; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; -import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSON; @@ -24,15 +22,10 @@ import com.alibaba.fastjson.JSON; //@Component //@Aspect public class RedisCacheAspect { - - private RedisTemplate redisTemplate; - @Autowired - public void setRedis(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - //娉涘瀷璁剧疆鎴怢ong鍚庡繀椤绘洿鏀瑰搴旂殑搴忓垪鍖栨柟妗 - redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); - } + //TODO ? + @Resource + private RedisTemplate redisTemplate; @Pointcut("@annotation(org.jeecgframework.core.annotation.Ehcache)") public void simplePointcut() {} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/dao/impl/GenericBaseCommonDao.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/dao/impl/GenericBaseCommonDao.java index c7d1dbac..b4476fd8 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/dao/impl/GenericBaseCommonDao.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/dao/impl/GenericBaseCommonDao.java @@ -10,8 +10,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.lang.model.util.ElementScanner6; - import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.hibernate.Criteria; @@ -36,12 +34,10 @@ import org.jeecgframework.core.common.dao.IGenericBaseCommonDao; import org.jeecgframework.core.common.dao.jdbc.JdbcDao; import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery; -import org.jeecgframework.core.common.hibernate.qbc.DetachedCriteriaUtil; import org.jeecgframework.core.common.hibernate.qbc.HqlQuery; import org.jeecgframework.core.common.hibernate.qbc.PageList; import org.jeecgframework.core.common.hibernate.qbc.PagerUtil; import org.jeecgframework.core.common.model.common.DBTable; -import org.jeecgframework.core.common.model.json.DataGridReturn; import org.jeecgframework.core.util.MyBeanUtils; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.ToEntityUtil; @@ -685,7 +681,10 @@ public abstract class GenericBaseCommonDao } else { pageSize = allCounts; } - DetachedCriteriaUtil.selectColumn(cq.getDetachedCriteria(), cq.getField().split(","), cq.getEntityClass(), false); + + //DetachedCriteriaUtil.selectColumn(cq.getDetachedCriteria(), cq.getField().split(","), cq.getEntityClass(), false); + + return new DataTableReturn(allCounts, allCounts, cq.getDataTables().getEcho(), criteria.list()); } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/AliasToBean.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/AliasToBean.java index e00fc8b4..daf7e896 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/AliasToBean.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/AliasToBean.java @@ -1,67 +1,67 @@ -package org.jeecgframework.core.common.hibernate.qbc; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import ognl.Ognl; - -import org.hibernate.HibernateException; -import org.hibernate.transform.ResultTransformer; - -import com.opensymphony.xwork2.ognl.OgnlUtil; -import com.opensymphony.xwork2.util.reflection.ReflectionContextState; - -/** - * 姝ょ増鏈繍琛屽湪xwork-core-2.1.6.jar - * 鏀寔灞炴т负鑷畾涔夊璞$殑缁撴灉闆嗚浆鎹㈢殑閮ㄤ唤灞炴ф煡璇 - * 2009-3-30 - * @author 鑻嶉拱 - */ -public class AliasToBean implements ResultTransformer { - private static final long serialVersionUID = 1L; - private static final OgnlUtil ognlUntil = new OgnlUtil(); - private static final Map context = new HashMap(1); - static{ - context.put(ReflectionContextState.CREATE_NULL_OBJECTS, true); - } - - /** POJO鐨刢lass */ - private final Class> resultClass; - - public AliasToBean(Class> pojoClass) { - if(pojoClass==null) throw new IllegalArgumentException("resultClass cannot be null"); - this.resultClass = pojoClass; - } - - @SuppressWarnings("unchecked") - - public List transformList(List collection) { - return collection; - } - - /** - * 缁撴灉闆嗚浆鎹 - * 2009-4-7 - * @author 鑻嶉拱 - * @param tuple 灞炴у奸泦鍚 - * @param aliases 灞炴у悕闆嗗悎 - * @return 鍗曚釜POJO瀹炰緥--鏌ヨ缁撴灉 - */ - - public Object transformTuple(Object[] tuple, String[] aliases) { - try { - Object root = resultClass.newInstance(); - for (int i = 0; i < aliases.length; i++) { - if(aliases[i]!=null && !aliases[i].equals("")) - { - Ognl.setValue(ognlUntil.compile(aliases[i]), context, root, tuple[i]); - } - } - return root; - } catch (Exception e) { - throw new HibernateException(e.getMessage(),e); - } - } - -} +//package org.jeecgframework.core.common.hibernate.qbc; +// +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import ognl.Ognl; +// +//import org.hibernate.HibernateException; +//import org.hibernate.transform.ResultTransformer; +// +//import com.opensymphony.xwork2.ognl.OgnlUtil; +//import com.opensymphony.xwork2.util.reflection.ReflectionContextState; +// +///** +// * 姝ょ増鏈繍琛屽湪xwork-core-2.1.6.jar +// * 鏀寔灞炴т负鑷畾涔夊璞$殑缁撴灉闆嗚浆鎹㈢殑閮ㄤ唤灞炴ф煡璇 +// * 2009-3-30 +// * @author 鑻嶉拱 +// */ +//public class AliasToBean implements ResultTransformer { +// private static final long serialVersionUID = 1L; +// private static final OgnlUtil ognlUntil = new OgnlUtil(); +// private static final Map context = new HashMap(1); +// static{ +// context.put(ReflectionContextState.CREATE_NULL_OBJECTS, true); +// } +// +// /** POJO鐨刢lass */ +// private final Class> resultClass; +// +// public AliasToBean(Class> pojoClass) { +// if(pojoClass==null) throw new IllegalArgumentException("resultClass cannot be null"); +// this.resultClass = pojoClass; +// } +// +// @SuppressWarnings("unchecked") +// +// public List transformList(List collection) { +// return collection; +// } +// +// /** +// * 缁撴灉闆嗚浆鎹 +// * 2009-4-7 +// * @author 鑻嶉拱 +// * @param tuple 灞炴у奸泦鍚 +// * @param aliases 灞炴у悕闆嗗悎 +// * @return 鍗曚釜POJO瀹炰緥--鏌ヨ缁撴灉 +// */ +// +// public Object transformTuple(Object[] tuple, String[] aliases) { +// try { +// Object root = resultClass.newInstance(); +// for (int i = 0; i < aliases.length; i++) { +// if(aliases[i]!=null && !aliases[i].equals("")) +// { +// Ognl.setValue(ognlUntil.compile(aliases[i]), context, root, tuple[i]); +// } +// } +// return root; +// } catch (Exception e) { +// throw new HibernateException(e.getMessage(),e); +// } +// } +// +//} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/CriteriaQuery.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/CriteriaQuery.java index 30a375e6..432d3864 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/CriteriaQuery.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/CriteriaQuery.java @@ -145,12 +145,16 @@ public class CriteriaQuery { this.ordermap = new LinkedHashMap(); } + +// 銆恠cott 20180526 鍒犻櫎鏃犵敤浠g爜|xwork-core銆 public CriteriaQuery(Class entityClass,DataTables dataTables) { this.curPage = dataTables.getDisplayStart(); String[] fieldstring=dataTables.getsColumns().split(","); - this.detachedCriteria = DetachedCriteriaUtil - .createDetachedCriteria(entityClass, "start", "_table",fieldstring); - //this.detachedCriteria = DetachedCriteria.forClass(c); + + this.detachedCriteria = DetachedCriteria.forClass(entityClass); + //this.detachedCriteria = DetachedCriteriaUtil.createDetachedCriteria(entityClass, "start", "_table",fieldstring); + + this.field=dataTables.getsColumns(); this.entityClass=entityClass; this.dataTables=dataTables; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/DetachedCriteriaUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/DetachedCriteriaUtil.java index 9a409949..5c85209e 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/DetachedCriteriaUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/hibernate/qbc/DetachedCriteriaUtil.java @@ -1,253 +1,253 @@ -package org.jeecgframework.core.common.hibernate.qbc; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; - -import org.hibernate.FetchMode; -import org.hibernate.criterion.DetachedCriteria; -import org.hibernate.criterion.Projection; -import org.hibernate.criterion.ProjectionList; -import org.hibernate.criterion.Projections; -import org.hibernate.transform.Transformers; -import org.jeecgframework.core.util.ContextHolderUtils; -import org.jeecgframework.core.util.ResourceUtil; -import org.jeecgframework.core.util.StringUtil; - - - -/** - * 鎷艰Hibernate鏉′欢 - */ -public class DetachedCriteriaUtil { - - /** 灏忓啓瀛楁瘝X */ - public static final String MIDDLE_SEPRATOR_CHAR = "x"; - /** 涓や釜绌烘牸 */ - public static final String SEPARATOR_TWO_SPACE = " ";// 涓や釜绌烘牸锛岄伩鍏嶅拰"鏃ユ湡 鏃堕棿"涓殑绌烘牸娣锋穯 - /** 姝ゅ瓧绗︿覆鍐呭涓" <= x <= "锛屼笉鍖呮嫭寮曞彿 */ - static public ProjectionList projectionList; - - - public static ProjectionList getProjectionList() { - return projectionList; - } - - private DetachedCriteriaUtil(){ - //do not allow to create Object - } - - /** - * 鑷姩鎷艰鏉′欢 2008-11-3 - * - * @author 鑻嶉拱 - * @param pojoClazz - * 瀹炰綋绫诲悕 - * @param startChar - * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 - * @param alias - * 鍒悕 - * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 - */ - public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, - String startChar,String alias) { - return createDetachedCriteria(pojoClazz, startChar, alias,null); - } - - /** - * 鑷姩鎷艰鏉′欢 2008-11-3 - * - * @author 鑻嶉拱 - * @param pojoClazz - * 瀹炰綋绫诲悕 - * @param startChar - * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 - * @param alias - * 鍒悕 - * @param columnNames - * 浣滀负select瀛愬彞鐨勫睘鎬у悕闆嗗悎 - * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 - */ - public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, - String startChar,String alias,String[] columnNames) { - return createDetachedCriteria(pojoClazz, startChar, alias, columnNames, null); - } - - /** - * 鑷姩鎷艰鏉′欢 2008-11-3 - * - * @author 鑻嶉拱 - * @param pojoClazz - * 瀹炰綋绫诲悕 - * @param startChar - * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 - * @param columnNames - * 浣滀负select瀛愬彞鐨勫睘鎬у悕闆嗗悎 - * @param excludeParameters - * 涓嶄綔涓烘煡璇㈡潯浠剁殑鍙傛暟 - * @param alias - * 鍒悕 - * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 - */ - public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, - String startChar,String alias,String[] columnNames,String[] excludeParameters) { - DetachedCriteria criteria = DetachedCriteria.forClass(pojoClazz,alias); - if(columnNames!=null && columnNames.length>0){ - //selectColumn(criteria, columnNames, pojoClazz, false); - } - return criteria; - } - - private static final String ALIAS_KEY_IN_REQUEST = "ALIAS_KEY_IN_REQUEST"; - private static final String HAS_JOIN_TABLE_KEY_IN_REQUEST = "HAS_JOIN_TABLE_KEY_IN_REQUEST"; - - private static void setAliasToRequest(HttpServletRequest request,Set aliases) { - request.setAttribute(ALIAS_KEY_IN_REQUEST, aliases); - } - - @SuppressWarnings("unchecked") - private static Set getAliasesFromRequest(){ - Set aliases = (Set) ContextHolderUtils.getRequest().getAttribute(ALIAS_KEY_IN_REQUEST); - if(aliases==null){ - aliases = new HashSet(5); - setAliasToRequest(ContextHolderUtils.getRequest(), aliases); - } - return aliases; - } - - private static boolean getHasJoinTatleFromRequest(){ - Boolean hasJoin = (Boolean) ContextHolderUtils.getRequest().getAttribute(HAS_JOIN_TABLE_KEY_IN_REQUEST); - return hasJoin==null?false:hasJoin; - } - - - - - /** - * 璇ユ柟娉曟彁渚汥etachedCriteria瀵规煡璇㈠瓧娈电殑灏佽锛 2008-9-29 - * 2009.9.9淇敼鍚庯紝鍙敮鎸佹棤闄愮骇鑱斿彇閮ㄥ垎瀛楁锛屽鍙栧涓嬪瓧娈 - * user.organization.parentOrganization.parentOrganization.orgName - * 浣嗚娉ㄦ剰1鐐 ,杩炴帴閲囩敤鍐呰仈锛岀骇鑱旇秺澶氾紝缁撴灉闆嗗彲鑳藉氨瓒婂皯锛 - * @author - * @param columnNames - * 瀛楃涓叉暟缁勶紝浠ユ暟鎹殑褰㈠紡鎺ユ敹瑕佹煡璇㈢殑瀛楁灞炴э紝濡係tring[] column={"灞炴1","灞炴2","灞炴3"}; - * @param pojoClass - * 瀹炰綋绫荤殑Class,濡侻obile.class; - * @param aials - * 涓鸿鏌ヨ鐨凱OJO瀵硅薄鎸囧畾涓涓埆鍚 - * @return DetachedCriteria 鐨勪竴涓璞★紝濡傛灉闇瑕佹煡璇㈡潯浠讹紝鍦ㄤ簺瀵硅薄鍚庤拷鍔犳煡璇㈡潯浠躲 - * - * @param forJoinTable 鏄惁澶氳〃杩炴帴鏌ヨ - */ - public static void selectColumn(DetachedCriteria criteria, String[] columnNames, - Class> pojoClass,boolean forJoinTable) { - if (null == columnNames) { - return; - } - - //浣跨敤杩欎釜涓存椂鍙橀噺闆嗗悎锛屾槸鍥犱负dinstinct鍏抽敭瀛楄鏀惧湪鏈鍓嶉潰锛岃宒istinct鍏抽敭瀛楄鍦ㄤ笅闈㈡墠鍐冲畾鏀句笉鏀撅紝 - List tempProjectionList = new ArrayList(); - - Set aliases = getAliasesFromRequest(); - boolean hasJoniTable = false; - String rootAlias = criteria.getAlias(); - for (String property : columnNames) { - if(property.contains("_")){ - String[] propertyChain = property.split("_"); - createAlias(criteria,rootAlias,aliases,propertyChain,0); - tempProjectionList.add(Projections.property(StringUtil.getProperty(property)).as(StringUtil.getProperty(property))); - hasJoniTable = true; - }else{ - tempProjectionList.add(Projections.property(rootAlias + POINT + property).as(property)); - } - } - - projectionList = Projections.projectionList(); - if(hasJoniTable || forJoinTable || getHasJoinTatleFromRequest()){//杩欎釜涓瀹氳鏀惧湪tempProjectionList鐨勫墠闈紝鍥犱负distinct瑕佸湪鏈鍓嶉潰 - projectionList.add(Projections.distinct(Projections.id())); - } - - for (Projection proj : tempProjectionList) { - projectionList.add(proj); - } - - criteria.setProjection(projectionList); - - - if(!hasJoniTable){ - criteria.setResultTransformer(Transformers.aliasToBean(pojoClass)); - }else{//涓嬮潰杩欎釜鏄嚜瀹氫箟鐨勭粨鏋滆浆鎹㈠櫒 - criteria.setResultTransformer(new AliasToBean(pojoClass)); - } - } - - private static final String POINT = "."; - - /** - * 鍒涘缓鍒悕 - * @author 鑻嶉拱 - * 2009-9-9 - * @param criteria - * @param rootAlais - * @param aliases - * @param columns - * @param currentStep - */ - private static void createAlias(DetachedCriteria criteria, String rootAlais, Set aliases,String[] columns,int currentStep){ - if(currentStep0){ - criteria.createAlias(converArrayToAlias(columns, currentStep-1) + POINT +columns[currentStep], converArrayToAlias(columns, currentStep)).setFetchMode(columns[currentStep], FetchMode.JOIN); - }else{ - criteria.createAlias(rootAlais + POINT +columns[currentStep], converArrayToAlias(columns, currentStep)).setFetchMode(columns[currentStep], FetchMode.JOIN); - } - aliases.add(converArrayToAlias(columns, currentStep)); - } - currentStep++; - createAlias(criteria, rootAlais, aliases, columns, currentStep); - } - } - - - /** - * 浠"organization.parentOrganization.parentOrganization.parentOrganization.id" 寰楀埌 - * "organization_parentOrganization_parentOrganization_parentOrganization.id" - * @author 鑻嶉拱 - * 2009-9-20 - * @param property - * @return - */ - public static String getAliasFromPropertyChainString(String property){ - if(property.contains(".")){ - return property.substring(0, property.lastIndexOf(POINT)).replaceAll("\\.", "_") + property.substring(property.lastIndexOf(POINT)); - - } - return property; - } - - /** - * 浠庢暟缁勪腑鍒涘缓ALIAS - * @author 鑻嶉拱 - * 2009-9-10 - * @param columns - * @param currentStep - * @return - */ - private static String converArrayToAlias(String[] columns,int currentStep){ - StringBuilder alias = new StringBuilder(); - for (int i = 0; i <= currentStep; i++) { - if(alias.length()>0){ - alias.append("_"); - } - alias.append(columns[i]); - } - return alias.toString(); - } - - - - -} +//package org.jeecgframework.core.common.hibernate.qbc; +// +//import java.util.ArrayList; +//import java.util.HashSet; +//import java.util.List; +//import java.util.Set; +// +//import javax.servlet.http.HttpServletRequest; +// +//import org.hibernate.FetchMode; +//import org.hibernate.criterion.DetachedCriteria; +//import org.hibernate.criterion.Projection; +//import org.hibernate.criterion.ProjectionList; +//import org.hibernate.criterion.Projections; +//import org.hibernate.transform.Transformers; +//import org.jeecgframework.core.util.ContextHolderUtils; +//import org.jeecgframework.core.util.ResourceUtil; +//import org.jeecgframework.core.util.StringUtil; +// +// +// +///** +// * 鎷艰Hibernate鏉′欢 +// */ +//public class DetachedCriteriaUtil { +// +// /** 灏忓啓瀛楁瘝X */ +// public static final String MIDDLE_SEPRATOR_CHAR = "x"; +// /** 涓や釜绌烘牸 */ +// public static final String SEPARATOR_TWO_SPACE = " ";// 涓や釜绌烘牸锛岄伩鍏嶅拰"鏃ユ湡 鏃堕棿"涓殑绌烘牸娣锋穯 +// /** 姝ゅ瓧绗︿覆鍐呭涓" <= x <= "锛屼笉鍖呮嫭寮曞彿 */ +// static public ProjectionList projectionList; +// +// +// public static ProjectionList getProjectionList() { +// return projectionList; +// } +// +// private DetachedCriteriaUtil(){ +// //do not allow to create Object +// } +// +// /** +// * 鑷姩鎷艰鏉′欢 2008-11-3 +// * +// * @author 鑻嶉拱 +// * @param pojoClazz +// * 瀹炰綋绫诲悕 +// * @param startChar +// * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 +// * @param alias +// * 鍒悕 +// * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 +// */ +// public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, +// String startChar,String alias) { +// return createDetachedCriteria(pojoClazz, startChar, alias,null); +// } +// +// /** +// * 鑷姩鎷艰鏉′欢 2008-11-3 +// * +// * @author 鑻嶉拱 +// * @param pojoClazz +// * 瀹炰綋绫诲悕 +// * @param startChar +// * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 +// * @param alias +// * 鍒悕 +// * @param columnNames +// * 浣滀负select瀛愬彞鐨勫睘鎬у悕闆嗗悎 +// * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 +// */ +// public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, +// String startChar,String alias,String[] columnNames) { +// return createDetachedCriteria(pojoClazz, startChar, alias, columnNames, null); +// } +// +// /** +// * 鑷姩鎷艰鏉′欢 2008-11-3 +// * +// * @author 鑻嶉拱 +// * @param pojoClazz +// * 瀹炰綋绫诲悕 +// * @param startChar +// * 鍙傛暟缁熶竴鐨勫紑濮嬪瓧绗 +// * @param columnNames +// * 浣滀负select瀛愬彞鐨勫睘鎬у悕闆嗗悎 +// * @param excludeParameters +// * 涓嶄綔涓烘煡璇㈡潯浠剁殑鍙傛暟 +// * @param alias +// * 鍒悕 +// * @return DetachedCriteria 缁勮濂界殑鏌ヨ鏉′欢 +// */ +// public static DetachedCriteria createDetachedCriteria(Class> pojoClazz, +// String startChar,String alias,String[] columnNames,String[] excludeParameters) { +// DetachedCriteria criteria = DetachedCriteria.forClass(pojoClazz,alias); +// if(columnNames!=null && columnNames.length>0){ +// //selectColumn(criteria, columnNames, pojoClazz, false); +// } +// return criteria; +// } +// +// private static final String ALIAS_KEY_IN_REQUEST = "ALIAS_KEY_IN_REQUEST"; +// private static final String HAS_JOIN_TABLE_KEY_IN_REQUEST = "HAS_JOIN_TABLE_KEY_IN_REQUEST"; +// +// private static void setAliasToRequest(HttpServletRequest request,Set aliases) { +// request.setAttribute(ALIAS_KEY_IN_REQUEST, aliases); +// } +// +// @SuppressWarnings("unchecked") +// private static Set getAliasesFromRequest(){ +// Set aliases = (Set) ContextHolderUtils.getRequest().getAttribute(ALIAS_KEY_IN_REQUEST); +// if(aliases==null){ +// aliases = new HashSet(5); +// setAliasToRequest(ContextHolderUtils.getRequest(), aliases); +// } +// return aliases; +// } +// +// private static boolean getHasJoinTatleFromRequest(){ +// Boolean hasJoin = (Boolean) ContextHolderUtils.getRequest().getAttribute(HAS_JOIN_TABLE_KEY_IN_REQUEST); +// return hasJoin==null?false:hasJoin; +// } +// +// +// +// +// /** +// * 璇ユ柟娉曟彁渚汥etachedCriteria瀵规煡璇㈠瓧娈电殑灏佽锛 2008-9-29 +// * 2009.9.9淇敼鍚庯紝鍙敮鎸佹棤闄愮骇鑱斿彇閮ㄥ垎瀛楁锛屽鍙栧涓嬪瓧娈 +// * user.organization.parentOrganization.parentOrganization.orgName +// * 浣嗚娉ㄦ剰1鐐 ,杩炴帴閲囩敤鍐呰仈锛岀骇鑱旇秺澶氾紝缁撴灉闆嗗彲鑳藉氨瓒婂皯锛 +// * @author +// * @param columnNames +// * 瀛楃涓叉暟缁勶紝浠ユ暟鎹殑褰㈠紡鎺ユ敹瑕佹煡璇㈢殑瀛楁灞炴э紝濡係tring[] column={"灞炴1","灞炴2","灞炴3"}; +// * @param pojoClass +// * 瀹炰綋绫荤殑Class,濡侻obile.class; +// * @param aials +// * 涓鸿鏌ヨ鐨凱OJO瀵硅薄鎸囧畾涓涓埆鍚 +// * @return DetachedCriteria 鐨勪竴涓璞★紝濡傛灉闇瑕佹煡璇㈡潯浠讹紝鍦ㄤ簺瀵硅薄鍚庤拷鍔犳煡璇㈡潯浠躲 +// * +// * @param forJoinTable 鏄惁澶氳〃杩炴帴鏌ヨ +// */ +// public static void selectColumn(DetachedCriteria criteria, String[] columnNames, +// Class> pojoClass,boolean forJoinTable) { +// if (null == columnNames) { +// return; +// } +// +// //浣跨敤杩欎釜涓存椂鍙橀噺闆嗗悎锛屾槸鍥犱负dinstinct鍏抽敭瀛楄鏀惧湪鏈鍓嶉潰锛岃宒istinct鍏抽敭瀛楄鍦ㄤ笅闈㈡墠鍐冲畾鏀句笉鏀撅紝 +// List tempProjectionList = new ArrayList(); +// +// Set aliases = getAliasesFromRequest(); +// boolean hasJoniTable = false; +// String rootAlias = criteria.getAlias(); +// for (String property : columnNames) { +// if(property.contains("_")){ +// String[] propertyChain = property.split("_"); +// createAlias(criteria,rootAlias,aliases,propertyChain,0); +// tempProjectionList.add(Projections.property(StringUtil.getProperty(property)).as(StringUtil.getProperty(property))); +// hasJoniTable = true; +// }else{ +// tempProjectionList.add(Projections.property(rootAlias + POINT + property).as(property)); +// } +// } +// +// projectionList = Projections.projectionList(); +// if(hasJoniTable || forJoinTable || getHasJoinTatleFromRequest()){//杩欎釜涓瀹氳鏀惧湪tempProjectionList鐨勫墠闈紝鍥犱负distinct瑕佸湪鏈鍓嶉潰 +// projectionList.add(Projections.distinct(Projections.id())); +// } +// +// for (Projection proj : tempProjectionList) { +// projectionList.add(proj); +// } +// +// criteria.setProjection(projectionList); +// +// +// if(!hasJoniTable){ +// criteria.setResultTransformer(Transformers.aliasToBean(pojoClass)); +// }else{//涓嬮潰杩欎釜鏄嚜瀹氫箟鐨勭粨鏋滆浆鎹㈠櫒 +// criteria.setResultTransformer(new AliasToBean(pojoClass)); +// } +// } +// +// private static final String POINT = "."; +// +// /** +// * 鍒涘缓鍒悕 +// * @author 鑻嶉拱 +// * 2009-9-9 +// * @param criteria +// * @param rootAlais +// * @param aliases +// * @param columns +// * @param currentStep +// */ +// private static void createAlias(DetachedCriteria criteria, String rootAlais, Set aliases,String[] columns,int currentStep){ +// if(currentStep0){ +// criteria.createAlias(converArrayToAlias(columns, currentStep-1) + POINT +columns[currentStep], converArrayToAlias(columns, currentStep)).setFetchMode(columns[currentStep], FetchMode.JOIN); +// }else{ +// criteria.createAlias(rootAlais + POINT +columns[currentStep], converArrayToAlias(columns, currentStep)).setFetchMode(columns[currentStep], FetchMode.JOIN); +// } +// aliases.add(converArrayToAlias(columns, currentStep)); +// } +// currentStep++; +// createAlias(criteria, rootAlais, aliases, columns, currentStep); +// } +// } +// +// +// /** +// * 浠"organization.parentOrganization.parentOrganization.parentOrganization.id" 寰楀埌 +// * "organization_parentOrganization_parentOrganization_parentOrganization.id" +// * @author 鑻嶉拱 +// * 2009-9-20 +// * @param property +// * @return +// */ +// public static String getAliasFromPropertyChainString(String property){ +// if(property.contains(".")){ +// return property.substring(0, property.lastIndexOf(POINT)).replaceAll("\\.", "_") + property.substring(property.lastIndexOf(POINT)); +// +// } +// return property; +// } +// +// /** +// * 浠庢暟缁勪腑鍒涘缓ALIAS +// * @author 鑻嶉拱 +// * 2009-9-10 +// * @param columns +// * @param currentStep +// * @return +// */ +// private static String converArrayToAlias(String[] columns,int currentStep){ +// StringBuilder alias = new StringBuilder(); +// for (int i = 0; i <= currentStep; i++) { +// if(alias.length()>0){ +// alias.append("_"); +// } +// alias.append(columns[i]); +// } +// return alias.toString(); +// } +// +// +// +// +//} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/CommonService.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/CommonService.java index 7c151b1f..b5497a58 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/CommonService.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/CommonService.java @@ -338,7 +338,7 @@ public interface CommonService { * 浣跨敤鎸囧畾鐨勬绱㈡爣鍑嗘绱㈡暟鎹苟鍒嗛〉杩斿洖鏁版嵁For JDBC-閲囩敤棰勫鐞嗘柟寮 * */ - public Long getCountForJdbcParam(String sql, Object[] objs); + public Long getCountForJdbcParam(String sql, Object... objs); /** * 閫氳繃hql 鏌ヨ璇彞鏌ユ壘瀵硅薄 diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/CommonServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/CommonServiceImpl.java index 03596a64..2571b6ee 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/CommonServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/CommonServiceImpl.java @@ -437,7 +437,7 @@ public class CommonServiceImpl implements CommonService { } @Transactional(readOnly = true) - public Long getCountForJdbcParam(String sql, Object[] objs) { + public Long getCountForJdbcParam(String sql, Object... objs) { return commonDao.getCountForJdbcParam(sql,objs); } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/RedisService.java b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/RedisService.java new file mode 100644 index 00000000..47c61e42 --- /dev/null +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/common/service/impl/RedisService.java @@ -0,0 +1,67 @@ +package org.jeecgframework.core.common.service.impl; + + +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Resource; + +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; + +/** + * RedisService宸ュ叿绫 + */ +@Service +public class RedisService { + + @Resource + private StringRedisTemplate redisTemplate; + + /** + * 鍒犻櫎key鍜寁alue + */ + public void delete(String key){ + redisTemplate.delete(key); + } + + /** + * 鏍规嵁key鑾峰彇value + */ + public String get(String key){ + String value = redisTemplate.opsForValue().get(key); + return value; + } + + /** + * 灏唊ey鍜寁alue瀛樺叆redis锛屽苟璁剧疆鏈夋晥鏃堕棿锛屽崟浣嶏細澶 + */ + public void set(String key, String value, long timeout){ + redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.DAYS); + } + + /** + * 灏唊ey鍜寁alue瀛樺叆redis + */ + public void set(String key, String value){ + redisTemplate.opsForValue().set(key, value); + } + + /** + * 浠巖edis涓幏鍙杕ap + */ + public Map getMap(String key){ + HashOperations hash = redisTemplate.opsForHash(); + Map map = hash.entries(key); + return map; + } + + /** + * 灏唌ap瀛樺叆redis锛屽苟璁剧疆鏃舵晥 + */ + public void set(String key, Map extends String, ? extends Object> map, long timeout){ + redisTemplate.opsForHash().putAll(key, map); + redisTemplate.expire(key, timeout, TimeUnit.DAYS); + } +} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/constant/Globals.java b/jeecg-framework/src/main/java/org/jeecgframework/core/constant/Globals.java index 888446db..117ea24c 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/constant/Globals.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/constant/Globals.java @@ -84,8 +84,8 @@ public final class Globals { /** * 鏉冮檺绫诲瀷 */ - public static final Short Function_TYPE_PAGE=0;//椤甸潰锛堣彍鍗曪細鑿滃崟绫诲瀷锛 - public static final Short Function_TYPE_FROM=1;//琛ㄥ崟/鎴栬呭脊鍑猴紙鑿滃崟锛氳闂被鍨嬶級 + public static final Short Function_TYPE_PAGE=0;//鑿滃崟锛氳彍鍗曠被鍨 + public static final Short Function_TYPE_FROM=1;//鑿滃崟锛氭潈闄愮被鍨(鏉冮檺浣跨敤锛屼笉浣滀负鑿滃崟棣栭〉鍔犺浇) /** * 娌℃湁鍕鹃夌殑鎿嶄綔code */ diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/MenuButtonsEnum.java b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/MenuButtonsEnum.java index 4a5f5a54..173bb239 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/MenuButtonsEnum.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/MenuButtonsEnum.java @@ -4,6 +4,7 @@ import org.jeecgframework.core.util.oConvertUtils; /** * 涓讳粠椤甸潰 鑿滃崟閰嶇疆 ,code瀛楃涓蹭笉瑕佹湁鍖呭惈鐨勬儏鍐 (渚嬪锛氭湁浜哸dd 灏变笉鑳芥湁addOne) + * 銆愯埞鑸朵笓鐢ㄣ * @author taoYan * @since 2017骞12鏈25鏃 */ @@ -11,6 +12,13 @@ public enum MenuButtonsEnum { addgroup("addgroup","琛ㄥ崟鏂板&word妯″紡","iframeGoAdd&tempNoDo","fa fa-file-text-o&fa fa-file-word-o&fa fa-plus") ,editgroup("editgroup","琛ㄥ崟缂栬緫&word妯″紡","iframeGoUpdate&tempNoDo","fa fa-file-text-o&fa fa-file-word-o&fa fa-pencil-square-o") ,batchDel("batchDel","鎵归噺鍒犻櫎","iframeDeleteAll","fa fa-trash-o") + ,save("save","淇濆瓨","iframeGoSaveRow","fa fa-floppy-o") + ,reject("reject","鍙栨秷缂栬緫","iframeRejectUpdate","fa fa-reply") + ,template("template","妯℃澘涓嬭浇","iframeExportXlsByT","fa fa-upload") + ,importe("import","鏁版嵁瀵煎叆","iframeImportExcel","fa fa-download") + ,export("export","鏁版嵁瀵煎嚭","iframeExportXls","fa fa-share-square-o") + ,filter("filter","杩囨护","iframeFilter","fa fa-filter") + ,superQuery("superQuery","楂樼骇鏌ヨ","superQuery","fa fa-search-plus") ; String code; @@ -92,15 +100,4 @@ public enum MenuButtonsEnum { this.icon = icon; } - /*,addone("addone","鏂板涓琛","iframeAddRow","iconfont icon-xinzengyihang") - /*,save("save","鎻愪氦淇敼","iframeGoSaveRow","fa fa-share") - ,save("save","淇濆瓨","iframeGoSaveRow","fa fa-floppy-o") - ,reject("reject","鍙栨秷缂栬緫","iframeRejectUpdate","fa fa-reply") - /*,addform("addform","琛ㄥ崟鏂板","iframeGoAdd","fa fa-plus") - ,template("template","妯℃澘涓嬭浇","iframeExportXlsByT","fa fa-upload") - ,importe("import","鏁版嵁瀵煎叆","iframeImportExcel","fa fa-download") - ,export("export","鏁版嵁瀵煎嚭","iframeExportXls","fa fa-share-square-o") - ,filter("filter","杩囨护","iframeFilter","fa fa-filter") - ,superQuery("superQuery","楂樼骇鏌ヨ","superQuery","fa fa-search-plus")*/ - } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/OnlineGenerateEnum.java b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/OnlineGenerateEnum.java index ea615f32..7c667b74 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/OnlineGenerateEnum.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/OnlineGenerateEnum.java @@ -41,9 +41,10 @@ public enum OnlineGenerateEnum { ONLINE_DIV_SINGLE("div.single","DIV椋庢牸琛ㄥ崟","single","ext"), ONLINE_NOPOP_SINGLE("nopop.single","NOPOP椋庢牸琛ㄥ崟","single","ext"), ONLINE_ROW_SINGLE("rowedit.single","琛岀紪杈戦鏍艰〃鍗","single","ext"), - ONLINE_TAB_ONETOMANY("tab.onetomany","TAB椋庢牸琛ㄥ崟","onetomany","ext"), + ONLINE_TAB_ONETOMANY("tab.onetomany","TAB椋庢牸琛ㄥ崟","onetomany","ext"); - ONLINE_VUEBT_SINGLE("vuebt.single","Bootstrap琛ㄥ崟+VUE-Bootstrap-Table鍒楄〃椋庢牸","single","ext"); + //TODO 鏆傛椂涓嶆帹鑽愯繖涓増鏈唬鐮佺敓鎴愬櫒 +// ONLINE_VUEBT_SINGLE("vuebt.single","Bootstrap琛ㄥ崟+VUE-Bootstrap-Table鍒楄〃椋庢牸","single","ext"); // ONLINE_DEFAULT_SINGLE("default.single","鐢ㄦ埛鎵╁睍椋庢牸绀轰緥","single","ext"), // ONLINE_DEFAULT_ONETOMANY("default.onetomany","鐢ㄦ埛鎵╁睍椋庢牸绀轰緥","onetomany","ext"); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/StoreUploadFilePathEnum.java b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/StoreUploadFilePathEnum.java index 06a62e6d..97f52657 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/enums/StoreUploadFilePathEnum.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/enums/StoreUploadFilePathEnum.java @@ -1,5 +1,7 @@ package org.jeecgframework.core.enums; +import java.io.File; + import org.jeecgframework.core.util.oConvertUtils; /** @@ -8,8 +10,8 @@ import org.jeecgframework.core.util.oConvertUtils; * */ public enum StoreUploadFilePathEnum { - PHOTOSUCAI("photosucai", "upload/img/photosucai"), - DEFAULT("default", "upload/files"); + PHOTOSUCAI("photosucai", "upload"+File.separator+"img"+File.separator+"photosucai"), + DEFAULT("default", "upload"+File.separator+"files"); private String name; private String path; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/extend/hqlsearch/HqlGenerateUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/extend/hqlsearch/HqlGenerateUtil.java index c7fe1425..8232b0ed 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/extend/hqlsearch/HqlGenerateUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/extend/hqlsearch/HqlGenerateUtil.java @@ -473,7 +473,6 @@ public class HqlGenerateUtil { } return sb.toString(); } -// --author锛氶檲鐠 ------begin---date锛20150612--------for锛歴ql缁勮 /** * 鏍规嵁瀛楁鍚嶇О,鑾峰彇瀛楁鐨勭被鍨嬪瓧绗︿覆 * return: java.lang.Integer diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/AuthInterceptor.java b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/AuthInterceptor.java index f9104d4f..50ed4be9 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/AuthInterceptor.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/AuthInterceptor.java @@ -10,21 +10,21 @@ import java.util.Set; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import com.alibaba.fastjson.JSONObject; import org.apache.log4j.Logger; import org.jeecgframework.core.annotation.JAuth; -import org.jeecgframework.core.common.exception.GlobalExceptionResolver; import org.jeecgframework.core.common.model.json.AjaxJson; import org.jeecgframework.core.constant.Globals; import org.jeecgframework.core.enums.Permission; import org.jeecgframework.core.extend.hqlsearch.SysContextSqlConvert; -import org.jeecgframework.core.util.*; +import org.jeecgframework.core.util.ContextHolderUtils; +import org.jeecgframework.core.util.JSONHelper; +import org.jeecgframework.core.util.JeecgDataAutorUtils; +import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.web.system.manager.ClientManager; import org.jeecgframework.web.system.pojo.base.Client; import org.jeecgframework.web.system.pojo.base.TSDataRule; -import org.jeecgframework.web.system.pojo.base.TSFunction; import org.jeecgframework.web.system.pojo.base.TSOperation; import org.jeecgframework.web.system.pojo.base.TSUser; import org.jeecgframework.web.system.service.SystemService; @@ -38,283 +38,157 @@ import org.springframework.web.servlet.view.RedirectView; /** * 鏉冮檺鎷︽埅鍣 - * - * @author 寮犱唬娴 + * @Date 20180523 (閲嶆瀯) + * @Author 寮犱唬娴 + * @Description: [鏉冮檺鎷︽埅鍣細 鑿滃崟璁块棶鏉冮檺銆佹暟鎹潈闄愩佹寜閽潈闄愩侀〉闈㈣〃鍗曟潈闄怾 * */ public class AuthInterceptor implements HandlerInterceptor { private static final Logger logger = Logger.getLogger(AuthInterceptor.class); + @Autowired private SystemService systemService; + //绮剧‘鍖归厤鎺掗櫎URLS private List excludeUrls; - /** - * 鍖呭惈鍖归厤锛堣姹傞摼鎺ュ寘鍚閰嶇疆閾炬帴锛屽氨杩涜杩囨护澶勭悊锛 - */ + //妯$硦鍖归厤鎺掗櫎URLS private List excludeContainUrls; - - public List getExcludeUrls() { - return excludeUrls; - } - - public void setExcludeUrls(List excludeUrls) { - this.excludeUrls = excludeUrls; - } - - public List getExcludeContainUrls() { - return excludeContainUrls; - } - - public void setExcludeContainUrls(List excludeContainUrls) { - this.excludeContainUrls = excludeContainUrls; - } - - public SystemService getSystemService() { - return systemService; - } - - @Autowired - public void setSystemService(SystemService systemService) { - this.systemService = systemService; - } - - /** - * 鍦╟ontroller鍚庢嫤鎴 - */ - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception exception) throws Exception { - } - - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView) throws Exception { - - } + + /** * 鍦╟ontroller鍓嶆嫤鎴 */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object) throws Exception { - - //鍒ゆ柇鏄惁琚敞瑙h烦杩囨潈闄愯璇 鍏堝垽鏂被娉ㄨВ鐒跺悗鏂规硶娉ㄨВ 閮芥病鏈夊垯璧板師鏉ラ昏緫 + //-----------------------娉ㄨВ鎺掗櫎鏉冮檺鎷︽埅鏈哄埗--------------------------------------- HandlerMethod handlerMethod=(HandlerMethod)object; JAuth jauthType =handlerMethod.getBean().getClass().getAnnotation(JAuth.class); - if(jauthType!=null){ - if(jauthType.auth()==Permission.SKIP_AUTH){ - return true; - } + if(jauthType!=null && jauthType.auth()==Permission.SKIP_AUTH){ + return true; }else{ - //JAuthority jauthMethod =handlerMethod.getMethodAnnotation(JAuthority.class); JAuth jauthMethod =handlerMethod.getMethod().getAnnotation(JAuth.class); - if(jauthMethod!=null){ - Permission permission=jauthMethod.auth(); - if(permission==Permission.SKIP_AUTH){ - return true; - } + if(jauthMethod!=null && jauthMethod.auth()==Permission.SKIP_AUTH){ + return true; } } - - Boolean isAjax=isAjax(request,response); - - String requestPath = ResourceUtil.getRequestPath(request);// 鐢ㄦ埛璁块棶鐨勮祫婧愬湴鍧 - //logger.info("-----authInterceptor----requestPath------"+requestPath); - //姝ラ涓锛 鍒ゆ柇鏄惁鏄帓闄ゆ嫤鎴姹傦紝鐩存帴杩斿洖TRUE - + //-----------------------娉ㄨВ鎺掗櫎鏉冮檺鎷︽埅鏈哄埗--------------------------------------- + + + //閫氳繃杞崲锛岃幏鍙栫敤鎴风殑璇锋眰URL鍦板潃 + String requestPath = ResourceUtil.getJgAuthRequsetPath(request); + //API鎺ュ彛锛屼笉鍋氱櫥闄嗛獙璇 if (requestPath.length()>3&&"api/".equals(requestPath.substring(0,4))) { return true; } - + + //閽堝鎷︽埅鍣ㄦ帓闄RLS锛岃繘琛屾帓闄 if (excludeUrls.contains(requestPath)) { return true; - } else if(moHuContain(excludeContainUrls, requestPath)){ return true; - } else { - //姝ラ浜岋細 鏉冮檺鎺у埗锛屼紭鍏堥噸缁勮姹俇RL(鑰冭檻online璇锋眰鍓嶇紑涓鑷撮棶棰) - String clickFunctionId = request.getParameter("clickFunctionId"); Client client = ClientManager.getInstance().getClient(ContextHolderUtils.getSession().getId()); TSUser currLoginUser = client!=null?client.getUser():null; - if (client != null && currLoginUser!=null ) { - //onlinecoding鐨勮闂湴鍧鏈夎寰嬪彲寰紝鏁版嵁鏉冮檺閾炬帴绡℃敼 + if (currLoginUser!=null ) { + String loginUserName = currLoginUser.getUserName(); + String loginUserId = currLoginUser.getId(); + String orgId = currLoginUser.getDepartid(); + //鐐瑰嚮鑿滃崟ID + String functionId = request.getParameter("clickFunctionId"); + + //-----------------OnlineCoding-------------------------------------------------------------- + //姝ラ浜岋細 Online鍔熻兘璇锋眰URL鐗规畩瑙勫垯锛屾牴鎹鍒欓噸缁刄RL锛屾敮鎸佸涓弬鏁 if(requestPath.equals("cgAutoListController.do?datagrid")) { requestPath += "&configId=" + request.getParameter("configId"); - } - if(requestPath.equals("cgAutoListController.do?list")) { + }else if(requestPath.equals("cgAutoListController.do?list")) { requestPath += "&id=" + request.getParameter("id"); } - if(requestPath.endsWith("?olstylecode=")) { requestPath = requestPath.replace("?olstylecode=", ""); } + //------------------------OnlineCoding------------------------------------------------------- + logger.debug("-----authInterceptor----requestPath------"+requestPath); - //姝ラ涓夛細 鏍规嵁閲嶇粍璇锋眰URL,杩涜鏉冮檺鎺堟潈鍒ゆ柇 - if((!(hasMenuAuth(requestPath,clickFunctionId,currLoginUser)) && !currLoginUser.getUserName().equals("admin"))){ - + + //姝ラ涓夛細 鍒ゆ柇璇锋眰URL锛屾槸鍚︽湁鑿滃崟璁块棶鏉冮檺 + if(!systemService.loginUserIsHasMenuAuth(requestPath,functionId,loginUserId,orgId)){ + Boolean isAjax=isAjax(request); if(isAjax){ - processAjax(response); + processAjax(response); }else { response.sendRedirect(request.getSession().getServletContext().getContextPath()+"/loginController.do?noAuth"); } - return false; - } - - - //瑙e喅rest椋庢牸涓 鏉冮檺澶辨晥闂 - String functionId=""; - String uri= request.getRequestURI().substring(request.getContextPath().length() + 1); - String realRequestPath = null; - if(uri.endsWith(".do")||uri.endsWith(".action")){ - realRequestPath=requestPath; - }else { - realRequestPath=uri; } - -// if(!oConvertUtils.isEmpty(clickFunctionId)){ -// functionId = clickFunctionId; -// }else{ - - if(realRequestPath.indexOf("autoFormController/af/")>-1 && realRequestPath.indexOf("?")!=-1){ - realRequestPath = realRequestPath.substring(0, realRequestPath.indexOf("?")); - } - - List functions = systemService.findByProperty(TSFunction.class, "functionUrl", realRequestPath); - if (functions.size()>0){ - functionId = functions.get(0).getId(); - } -// } - - //Step.1 绗竴閮ㄥ垎澶勭悊椤甸潰琛ㄥ崟鍜屽垪琛ㄧ殑椤甸潰鎺т欢鏉冮檺锛堥〉闈㈣〃鍗曞瓧娈+椤甸潰鎸夐挳绛夋帶浠讹級 - if(!oConvertUtils.isEmpty(functionId)){ - - if(!currLoginUser.getUserName().equals("admin")){ - //鑾峰彇鑿滃崟瀵瑰簲鐨勯〉闈㈡帶鍒舵潈闄愶紙鍖呮嫭琛ㄥ崟瀛楁鍜屾搷浣滄寜閽級 - - List operations = systemService.getOperationsByUserIdAndFunctionId(currLoginUser, functionId); - request.setAttribute(Globals.NOAUTO_OPERATIONCODES, operations); - if(operations==null){ - request.setAttribute(Globals.OPERATIONCODES, null); - }else{ - Set operationCodes = new HashSet(); - for (TSOperation operation : operations) { - operationCodes.add(operation.getId()); - } - request.setAttribute(Globals.OPERATIONCODES, operationCodes); + + + //Admin鎷ユ湁鐗规潈锛屾暟鎹潈闄愩侀〉闈㈣〃鍗曟潈闄愩佹寜閽潈闄愪笉鍋氭帶鍒 + if(!"admin".equals(loginUserName)){ + //----------------------------------------------------------------------------------------------------------------- + if(oConvertUtils.isEmpty(functionId)){ + //鏌ヨ璇锋眰URL瀵瑰簲鐨勮彍鍗旾D锛堝洜涓烘暟鎹潈闄愩侀〉闈㈡帶浠舵潈闄愭槸鍩轰簬鑿滃崟ID閰嶇疆鐨勬暟鎹級 + String url = request.getRequestURI().substring(request.getContextPath().length() + 1); + functionId = systemService.getFunctionIdByUrl(url,requestPath); + //濡傛灉閫氳繃璇锋眰URL锛屾棤娉曞尮閰嶅嚭鏁版嵁搴撲腑鑿滃崟ID锛屽垯涓嶈繘琛屾暟鎹潈闄愩侀〉闈㈡帶浠舵潈闄愮殑閫昏緫澶勭悊 + if(oConvertUtils.isEmpty(functionId)){ + return true; } } - + //----------------------------------------------------------------------------------------------------------------- - //Set operationCodes = systemService.getOperationCodesByUserIdAndFunctionId(currLoginUser.getId(), functionId); - //request.setAttribute(Globals.OPERATIONCODES, operationCodes); - //} - //if(!oConvertUtils.isEmpty(functionId)){ + //Step.1 銆愰〉闈㈡帶浠舵潈闄愩戠涓閮ㄥ垎澶勭悊椤甸潰琛ㄥ崟鍜屽垪琛ㄧ殑椤甸潰鎺т欢鏉冮檺锛堥〉闈㈣〃鍗曞瓧娈+椤甸潰鎸夐挳绛夋帶浠讹級 + //鑾峰彇鑿滃崟瀵瑰簲鐨勯〉闈㈡帶鍒舵潈闄愶紙鍖呮嫭琛ㄥ崟瀛楁鍜屾搷浣滄寜閽級 + //澶氫釜瑙掕壊鏉冮檺锛堝苟闆嗛棶棰橈級锛屽洜涓烘槸鍙嶇殑鎺у埗锛屽鑷存湁admin鐨勬渶澶ф潈闄愬弽鑰屽彈灏忔潈闄愭帶鍒 - -// List allOperation=this.systemService.findByProperty(TSOperation.class, "TSFunction.id", functionId); -// List newall = new ArrayList(); -// if(allOperation.size()>0){ -// for(TSOperation s:allOperation){ -// //s=s.replaceAll(" ", ""); -// newall.add(s); -// } - -// String hasOperSql="SELECT operation FROM t_s_role_function fun, t_s_role_user role WHERE " + -// "fun.functionid='"+functionId+"' AND fun.operation is not null AND fun.roleid=role.roleid AND role.userid='"+currLoginUser.getId()+"' "; -// List hasOperList = this.systemService.findListbySql(hasOperSql); -// for(String operationIds:hasOperList){ -// for(String operationId:operationIds.split(",")){ -// operationId=operationId.replaceAll(" ", ""); -// TSOperation operation = new TSOperation(); -// operation.setId(operationId); -// newall.remove(operation); -// } -// } -// } - /*List newall = new ArrayList(); - String hasOperSql="SELECT operation FROM t_s_role_function fun, t_s_role_user role WHERE " + - "fun.functionid='"+functionId+"' AND fun.operation is not null AND fun.roleid=role.roleid AND role.userid='"+currLoginUser.getId()+"' "; - List hasOperList = this.systemService.findListbySql(hasOperSql); - for(String operationIds:hasOperList){ - for(String operationId:operationIds.split(",")){ - operationId=operationId.replaceAll(" ", ""); - TSOperation operation = systemService.get(TSOperation.class, operationId); - if(operation!=null && operation.getOperationcode()!=null && - (operation.getOperationcode().startsWith("#")|| operation.getOperationcode().startsWith("."))){ - newall.add(operation); - } - } - } - request.setAttribute(Globals.NOAUTO_OPERATIONCODES, newall);*/ + List operations = systemService.getLoginOperationsByUserId(loginUserId, functionId, orgId); + request.setAttribute(Globals.NOAUTO_OPERATIONCODES, operations); + if(operations!=null){ + Set operationCodes = new HashSet(); + for (TSOperation operation : operations) { + operationCodes.add(operation.getId()); + } + request.setAttribute(Globals.OPERATIONCODES, operationCodes); + } - //Step.2 绗簩閮ㄥ垎澶勭悊鍒楄〃鏁版嵁绾ф潈闄 (鑿滃崟鏁版嵁瑙勫垯闆嗗悎) + //Step.2 銆愭暟鎹潈闄愩戠浜岄儴鍒嗗鐞嗗垪琛ㄦ暟鎹骇鏉冮檺 (鑿滃崟鏁版嵁瑙勫垯闆嗗悎) List MENU_DATA_AUTHOR_RULES = new ArrayList(); String MENU_DATA_AUTHOR_RULE_SQL=""; - //鏁版嵁鏉冮檺瑙勫垯鐨勬煡璇 - //鏌ヨ鎵鏈夌殑褰撳墠杩欎釜鐢ㄦ埛鎵瀵瑰簲鐨勮鑹插拰鑿滃崟鐨刣atarule鐨勬暟鎹鍒檌d - - if(!currLoginUser.getUserName().equals("admin")){ - //Globals.BUTTON_AUTHORITY_CHECK - Set dataruleCodes = systemService.getOperationCodesByUserIdAndDataId(currLoginUser, functionId); - request.setAttribute("dataRulecodes", dataruleCodes); - for (String dataRuleId : dataruleCodes) { - TSDataRule dataRule = systemService.getEntity(TSDataRule.class, dataRuleId); - MENU_DATA_AUTHOR_RULES.add(dataRule); - MENU_DATA_AUTHOR_RULE_SQL += SysContextSqlConvert.setSqlModel(dataRule); - } - } + //鏌ヨ褰撳墠鐢ㄦ埛鎺堟潈鐨勬暟鎹鍒橧DS - JeecgDataAutorUtils.installDataSearchConditon(request, MENU_DATA_AUTHOR_RULES);//鑿滃崟鏁版嵁瑙勫垯闆嗗悎 - JeecgDataAutorUtils.installDataSearchConditon(request, MENU_DATA_AUTHOR_RULE_SQL);//鑿滃崟鏁版嵁瑙勫垯sql + Set dataRuleIds = systemService.getLoginDataRuleIdsByUserId(loginUserId, functionId, orgId); + request.setAttribute("dataRulecodes", dataRuleIds); + for (String dataRuleId : dataRuleIds) { + TSDataRule dataRule = systemService.getEntity(TSDataRule.class, dataRuleId); + MENU_DATA_AUTHOR_RULES.add(dataRule); + MENU_DATA_AUTHOR_RULE_SQL += SysContextSqlConvert.setSqlModel(dataRule); + } + //銆愬姞杞芥暟鎹潈闄愩戞暟鎹潈闄愯鍒欙紝Hibernate瀛楁鏂瑰紡 + JeecgDataAutorUtils.installDataSearchConditon(request, MENU_DATA_AUTHOR_RULES); + //銆愬姞杞芥暟鎹潈闄愩戞暟鎹潈闄愯鍒欙紝Sql鏂瑰紡 + JeecgDataAutorUtils.installDataSearchConditon(request, MENU_DATA_AUTHOR_RULE_SQL); } return true; } else { - //forword(request); - forward(request, response); + //鐧诲綍鐢ㄦ埛淇℃伅涓虹┖锛岃烦杞埌鐢ㄦ埛鐧诲綍瓒呮椂椤甸潰 + forwardTimeOut(request, response); return false; } - } } - + /** - * 鍒ゆ柇鐢ㄦ埛鏄惁鏈夎彍鍗曡闂潈闄 - * @param requestPath - * @param clickFunctionId - * @param currLoginUser - * @return + * 鍦╟ontroller鍚庢嫤鎴 */ - private boolean hasMenuAuth(String requestPath,String clickFunctionId,TSUser currLoginUser){ - String userid = currLoginUser.getId(); + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object object, Exception exception) throws Exception { + } - //step.1 鍏堝垽鏂姹傛槸鍚﹂厤缃彍鍗曪紝娌℃湁閰嶇疆鑿滃崟榛樿涓嶄綔鏉冮檺鎺у埗[娉ㄦ剰锛氳繖閲屼笉闄愬埗鏉冮檺绫诲瀷鑿滃崟] - String hasMenuSql = "select count(*) from t_s_function where functiontype = 0 and functionurl = '"+requestPath+"'"; - Long hasMenuCount = systemService.getCountForJdbc(hasMenuSql); - if(hasMenuCount<=0){ - return true; - } - - //step.2 鍒ゆ柇鑿滃崟鏄惁鏈夎鑹叉潈闄 - Long authSize = Long.valueOf(0); - String sql = "SELECT count(*) FROM t_s_function f,t_s_role_function rf,t_s_role_user ru " + - " WHERE f.id=rf.functionid AND rf.roleid=ru.roleid AND " + - "ru.userid='"+userid+"' AND f.functionurl = '"+requestPath+"'"; - authSize = this.systemService.getCountForJdbc(sql); - if(authSize <=0){ - //step.3 鍒ゆ柇鑿滃崟鏄惁鏈夌粍缁囨満鏋勮鑹叉潈闄 - String orgId = currLoginUser.getCurrentDepart().getId(); - Long orgAuthSize = Long.valueOf(0); - String functionOfOrgSql = "SELECT count(*) from t_s_function f, t_s_role_function rf, t_s_role_org ro " + - "WHERE f.ID=rf.functionid AND rf.roleid=ro.role_id " + - "AND ro.org_id='" +orgId+ "' AND f.functionurl = '"+requestPath+"'"; - orgAuthSize = this.systemService.getCountForJdbc(functionOfOrgSql); - return orgAuthSize > 0; - }else{ - return true; - } + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView) throws Exception { } - + /** * 杞彂 @@ -328,15 +202,15 @@ public class AuthInterceptor implements HandlerInterceptor { return new ModelAndView(new RedirectView("loginController.do?login")); } - private void forward(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - //瓒呮椂锛屾湭鐧婚檰椤甸潰璺宠浆 - //response.sendRedirect(request.getServletContext().getContextPath()+"/loginController.do?login"); - + /** + * 璺宠浆锛 鐧诲綍瓒呮椂椤甸潰 + * @param request + * @param response + * @throws ServletException + * @throws IOException + */ + private void forwardTimeOut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendRedirect(request.getSession().getServletContext().getContextPath()+"/webpage/login/timeout.jsp"); - - //request.getRequestDispatcher("loginController.do?login").forward(request, response); - } /** @@ -357,11 +231,14 @@ public class AuthInterceptor implements HandlerInterceptor { /** * 鍒ゆ柇褰撳墠璇锋眰鏄惁涓哄紓姝ヨ姹. */ - @SuppressWarnings("unused") - private boolean isAjax(HttpServletRequest request, HttpServletResponse response){ + private boolean isAjax(HttpServletRequest request){ return oConvertUtils.isNotEmpty(request.getHeader("X-Requested-With")); } - + + /** + * 杩斿洖Ajax鏍煎紡鐨勬潈闄愭彁閱掓秷鎭 + * @param response + */ private void processAjax(HttpServletResponse response){ AjaxJson json = new AjaxJson(); json.setSuccess(false); @@ -377,5 +254,21 @@ public class AuthInterceptor implements HandlerInterceptor { pw.close(); } } + + + public List getExcludeUrls() { + return excludeUrls; + } + + public void setExcludeUrls(List excludeUrls) { + this.excludeUrls = excludeUrls; + } + public List getExcludeContainUrls() { + return excludeContainUrls; + } + + public void setExcludeContainUrls(List excludeContainUrls) { + this.excludeContainUrls = excludeContainUrls; + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SignInterceptor.java b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SignInterceptor.java index cac44a4f..50297bf7 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SignInterceptor.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SignInterceptor.java @@ -13,7 +13,11 @@ import java.util.HashMap; import java.util.Map; /** - * Created by dangzhenghui on 2017-4-1. + * API鎺ュ彛绛惧悕鏍¢獙鏈哄埗 + * 鎻忚堪锛歿 鎷︽埅 /api/**鐨勮姹傦紝鍖归厤璇锋眰header涓殑鍙傛暟X-JEECG-SIGN锛屾槸鍚︿笌鏈嶅姟鍣ㄧ鍚嶄竴鑷 } + * date: 2017-4-1 + * @author dangzhenghui + * */ public class SignInterceptor implements HandlerInterceptor { private static final String SIGN_KEY = "26F72780372E84B6CFAED6F7B19139CC47B1912B6CAED753"; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SqlInjectInterceptor.java b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SqlInjectInterceptor.java new file mode 100644 index 00000000..7abd25e6 --- /dev/null +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/interceptors/SqlInjectInterceptor.java @@ -0,0 +1,138 @@ +package org.jeecgframework.core.interceptors; + + +import java.util.Enumeration; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.log4j.Logger; +import org.jeecgframework.core.common.model.json.AjaxJson; +import org.jeecgframework.core.util.IpUtil; +import org.jeecgframework.core.util.JSONHelper; +import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.web.cgform.common.CgAutoListConstant; +import org.jeecgframework.web.system.pojo.base.TSUser; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +/** + * 闃叉SQL娉ㄥ叆鐨勬嫤鎴櫒 + * + * @author scott + * @time 2018-05-21 + */ +public class SqlInjectInterceptor implements HandlerInterceptor { + private static final Logger logger = Logger.getLogger(SqlInjectInterceptor.class); + + /** + * 鍦ㄧ嚎寮鍙戠壒娈奤RL(闇瑕佸綍鍏QL鐗囨)锛岃繘琛岀壒娈婂鐞 + */ + private List onlineOptUrls; + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3) + throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object arg2, ModelAndView arg3) + throws Exception { + // TODO Auto-generated method stub + + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception { + + //1.鍦ㄧ嚎寮鍙戝姛鑳斤紙鏈塖QL鍊兼儏鍐碉級锛岄拡瀵规暟鎹簱SQL鎿嶄綔锛岃繘琛屽紑鍙戣呮潈闄愭帶鍒讹紝闃叉SQL娉ㄥ叆 + String requestPath = ResourceUtil.getJgAuthRequsetPath(request); + if (onlineOptUrls.contains(requestPath)) { + TSUser currentUser = ResourceUtil.getSessionUser(); + if(CgAutoListConstant.SYS_DEV_FLAG_0.equals(currentUser.getDevFlag())){ + logger.info(" ---鎿嶄綔澶辫触锛屽綋鍓嶇敤鎴锋湭鎺堟潈寮鍙戞潈闄-------- 璇锋眰IP ---------+"+IpUtil.getIpAddr(request)); + + AjaxJson json = new AjaxJson(); + json.setSuccess(false); + json.setMsg("鎿嶄綔澶辫触锛屽綋鍓嶇敤鎴锋湭鎺堟潈寮鍙戞潈闄愶紒锛"); + response.setHeader("Cache-Control", "no-store"); + response.getWriter().print(JSONHelper.bean2json(json)); + return false; + } + return true; + } + + //2锛屽父瑙勪笟鍔℃搷浣滐紙鏃燬QL鍊兼儏鍐碉級锛 閽堝鏁版嵁搴揝QL鎿嶄綔锛岃繘琛屽紑鍙戣呮潈闄愭帶鍒讹紝闃叉SQL娉ㄥ叆 + Enumeration names = request.getParameterNames(); + while(names.hasMoreElements()){ + String name = names.nextElement(); + String[] values = request.getParameterValues(name); + for(String value: values){ + //sql娉ㄥ叆鐩存帴鎷︽埅 + if(judgeSQLInject(value.toLowerCase())){ + logger.info("-----------Sql娉ㄥ叆鎷︽埅-----------name: "+name+" -------------value:"+ value); + response.setContentType("text/html;charset=UTF-8"); + response.getWriter().print("鍙傛暟鍚湁闈炴硶鏀诲嚮瀛楃,宸茬姝㈢户缁闂紒"); + return false; + } + //璺ㄧ珯xss娓呯悊 + clearXss(value); + } + } + return true; + } + + /** + * 鍒ゆ柇鍙傛暟鏄惁鍚湁鏀诲嚮涓 + * @param value + * @return + */ + public boolean judgeSQLInject(String value){ + if(value == null || "".equals(value)){ + return false; + } + String xssStr = "and |or |select |update |delete |drop |truncate |%20|=|--|!="; + String[] xssArr = xssStr.split("\\|"); + for(int i=0;i-1){ + return true; + } + } + return false; + } + + /** + * 澶勭悊璺ㄧ珯xss瀛楃杞箟 + * + * @param value + * @return + */ + private String clearXss(String value) { + logger.debug("----before--------澶勭悊璺ㄧ珯xss瀛楃杞箟----------"+ value); + if (value == null || "".equals(value)) { + return value; + } + value = value.replaceAll("<", "<").replaceAll(">", ">"); + value = value.replaceAll("\\(", "(").replace("\\)", ")"); + value = value.replaceAll("'", "'"); + value = value.replaceAll("eval\\((.*)\\)", ""); + value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", + "\"\""); + value = value.replace("script", ""); + + //涓轰簡鐢ㄦ埛瀵嗙爜瀹夊叏锛岀姝㈠垪琛ㄦ煡璇㈠睍绀虹敤鎴峰瘑鐮---------- + value = value.replace(",password","").replace("password",""); + logger.debug("----end--------澶勭悊璺ㄧ珯xss瀛楃杞箟----------"+ value); + return value; + } + + public List getOnlineOptUrls() { + return onlineOptUrls; + } + + public void setOnlineOptUrls(List onlineOptUrls) { + this.onlineOptUrls = onlineOptUrls; + } + +} \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/CgReportQueryParamUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/CgReportQueryParamUtil.java index 53c823fd..735020db 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/CgReportQueryParamUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/CgReportQueryParamUtil.java @@ -12,6 +12,7 @@ import net.sf.json.JSONObject; import org.jeecgframework.core.online.def.CgReportConstant; import org.jeecgframework.core.util.DBTypeUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.StringUtil; /** @@ -54,7 +55,10 @@ public class CgReportQueryParamUtil e.printStackTrace(); return; } - sql_inj_throw(value); + +// sql_inj_throw(value); + SqlInjectionUtil.filterContent(value); + value = applyType(filedType,value); if(!StringUtil.isEmpty(value)){ if(value.contains("*")){ @@ -68,10 +72,16 @@ public class CgReportQueryParamUtil }else if("group".equals(queryMode)){ //鑼冨洿鏌ヨ缁勮 String begin = request.getParameter(filedName+"_begin"); - sql_inj_throw(begin); + +// sql_inj_throw(begin); + SqlInjectionUtil.filterContent(begin); + begin= applyType(filedType,begin); String end = request.getParameter(filedName+"_end"); - sql_inj_throw(end); + +// sql_inj_throw(end); + SqlInjectionUtil.filterContent(end); + end= applyType(filedType,end); if(!StringUtil.isEmpty(begin)){ String re = CgReportConstant.OP_RQ+begin; @@ -155,35 +165,36 @@ public class CgReportQueryParamUtil return datetime; } } - - /** - * 闃叉sql娉ㄥ叆 - * @param str 杈撳叆sql - * @return 鏄惁瀛樺湪娉ㄥ叆鍏抽敭瀛 - */ - public static boolean sql_inj(String str) { - if(StringUtil.isEmpty(str)){ - return false; - } - String inj_str = "'|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|;|or|+|,"; -// String inj_str = "'|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|;|or|-|+|,"; - String inj_stra[] = inj_str.split("\\|"); - for (int i = 0; i < inj_stra.length; i++) { - if (str.indexOf(" "+inj_stra[i]+" ") >= 0) { - return true; - } - } - return false; - } - /** - * 褰撳瓨鍦╯ql娉ㄥ叆鏃舵姏寮傚父 - * @param str 杈撳叆sql - */ - public static void sql_inj_throw(String str){ - if(sql_inj(str)){ - throw new RuntimeException("璇锋敞鎰,濉叆鐨勫弬鏁板彲鑳藉瓨鍦⊿QL娉ㄥ叆!"); - } - } + +// /** +// * 闃叉sql娉ㄥ叆 +// * @param str 杈撳叆sql +// * @return 鏄惁瀛樺湪娉ㄥ叆鍏抽敭瀛 +// */ +// public static boolean sql_inj(String str) { +// if(StringUtil.isEmpty(str)){ +// return false; +// } +// String inj_str = "'|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|;|or|+|,"; +//// String inj_str = "'|and|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|;|or|-|+|,"; +// String inj_stra[] = inj_str.split("\\|"); +// for (int i = 0; i < inj_stra.length; i++) { +// if (str.indexOf(" "+inj_stra[i]+" ") >= 0) { +// return true; +// } +// } +// return false; +// } +// /** +// * 褰撳瓨鍦╯ql娉ㄥ叆鏃舵姏寮傚父 +// * @param str 杈撳叆sql +// */ +// public static void sql_inj_throw(String str){ +// if(sql_inj(str)){ +// throw new RuntimeException("璇锋敞鎰,濉叆鐨勫弬鏁板彲鑳藉瓨鍦⊿QL娉ㄥ叆!"); +// } +// } + /** * 鏍规嵁瀛楁绫诲瀷 杩涜澶勭悊 diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/FreemarkerHelper.java b/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/FreemarkerHelper.java index 55ef3d42..c719210d 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/FreemarkerHelper.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/online/util/FreemarkerHelper.java @@ -21,10 +21,15 @@ public class FreemarkerHelper { static{ _tplConfig.setSharedVariable("DictData", (TemplateDirectiveModel)ApplicationContextUtil.getContext().getBean("dictDataTag")); _tplConfig.setSharedVariable("mutiLang", (TemplateDirectiveModel)ApplicationContextUtil.getContext().getBean("mutiLangTag")); + + _tplConfig.setSharedVariable("exp", (TemplateDirectiveModel)ApplicationContextUtil.getContext().getBean("expTag")); + _tplConfig.setClassForTemplateLoading(FreemarkerHelper.class, "/"); _tplConfig.setDateTimeFormat("yyyy-MM-dd HH:mm:ss"); _tplConfig.setDateFormat("yyyy-MM-dd"); _tplConfig.setTimeFormat("HH:mm:ss"); + //classic_compatible璁剧疆锛岃В鍐虫姤绌烘寚閽堥敊璇 + _tplConfig.setClassicCompatible(true); } /** diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseCronTriggerBean.java b/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseCronTriggerBean.java deleted file mode 100644 index fd507afd..00000000 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseCronTriggerBean.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.jeecgframework.core.timer; - -import java.text.ParseException; - -import org.jeecgframework.web.system.pojo.base.TSTimeTaskEntity; -import org.jeecgframework.web.system.service.TimeTaskServiceI; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.quartz.CronTriggerBean; -/** - * 鍦ㄥ師鏈夊姛鑳界殑鍩虹涓婇潰澧炲姞鏁版嵁搴撶殑璇诲彇 - * @author JueYue - * @date 2013-9-22 - * @version 1.0 - */ -public class DataBaseCronTriggerBean extends CronTriggerBean{ - - private static final long serialVersionUID = 1L; - - @Autowired - private TimeTaskServiceI timeTaskService; - /** - * 璇诲彇鏁版嵁搴撴洿鏂版枃浠 - */ - public void afterPropertiesSet() { - super.afterPropertiesSet(); - TSTimeTaskEntity task = timeTaskService.findUniqueByProperty - (TSTimeTaskEntity.class,"taskId",this.getName()); - if(task!=null&&task.getIsEffect().equals("1") - &&!task.getCronExpression().equals(this.getCronExpression())){ - - try { - this.setCronExpression(task.getCronExpression()); - } catch (ParseException e) { - // TODO 寮傚父蹇呴』琚鐞 - e.printStackTrace(); - } - - //DynamicTask.updateSpringMvcTaskXML(this,task.getCronExpression()); - - } - } - -} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseSchedulerFactoryBean.java b/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseSchedulerFactoryBean.java index 4b0b1c68..541be3dc 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseSchedulerFactoryBean.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DataBaseSchedulerFactoryBean.java @@ -1,9 +1,12 @@ package org.jeecgframework.core.timer; +import java.util.List; + import org.jeecgframework.web.system.pojo.base.TSTimeTaskEntity; import org.jeecgframework.web.system.service.TimeTaskServiceI; import org.quartz.Scheduler; +import org.quartz.TriggerKey; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.quartz.SchedulerFactoryBean; /** @@ -21,7 +24,10 @@ public class DataBaseSchedulerFactoryBean extends SchedulerFactoryBean { */ public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); - String[] trigerrNames = this.getScheduler().getTriggerNames(Scheduler.DEFAULT_GROUP); + +// String[] trigerrNames = this.getScheduler().getTriggerNames(Scheduler.DEFAULT_GROUP); + Scheduler scheduler = this.getScheduler(); + List trigerrNames = scheduler.getTriggerGroupNames(); TSTimeTaskEntity task; for (String trigerrName : trigerrNames) { @@ -29,8 +35,10 @@ public class DataBaseSchedulerFactoryBean extends SchedulerFactoryBean { //鏁版嵁搴撴煡璇笉鍒扮殑瀹氭椂浠诲姟鎴栬呭畾鏃朵换鍔$殑杩愯鐘舵佷笉涓1鏃讹紝閮藉仠姝 //TASK #327 瀹氭椂鍣ㄤ换鍔¢粯璁ゆ湭鍚姩 if(task==null || !"1".equals(task.getIsStart())){ - this.getScheduler().pauseTrigger(trigerrName,Scheduler.DEFAULT_GROUP); +// this.getScheduler().pauseTrigger(trigerrName,Scheduler.DEFAULT_GROUP); + scheduler.pauseTrigger(new TriggerKey(trigerrName)); } + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DynamicTask.java b/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DynamicTask.java index a382eaf4..1a336118 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DynamicTask.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/timer/DynamicTask.java @@ -2,7 +2,6 @@ package org.jeecgframework.core.timer; import java.io.IOException; import java.net.UnknownHostException; -import java.text.ParseException; import java.util.List; import javax.annotation.Resource; @@ -17,18 +16,21 @@ import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.web.system.pojo.base.TSTimeTaskEntity; import org.jeecgframework.web.system.service.SystemService; import org.jeecgframework.web.system.service.TimeTaskServiceI; +import org.quartz.CronScheduleBuilder; import org.quartz.CronTrigger; +import org.quartz.JobBuilder; import org.quartz.JobDetail; +import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.SchedulerException; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.quartz.CronTriggerBean; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSONObject; - - /** * 鍔ㄦ佷换鍔,鐢ㄤ互鍔ㄦ佽皟鏁碨pring鐨勪换鍔 * @author JueYue @@ -40,13 +42,13 @@ public class DynamicTask { private static Logger logger = Logger.getLogger(DynamicTask.class); - @Resource + @Autowired(required=false) private Scheduler schedulerFactory; - @Autowired + @Autowired(required=false) private TimeTaskServiceI timeTaskService; - @Autowired + @Autowired(required=false) private SystemService systemService; @@ -56,26 +58,19 @@ public class DynamicTask { */ private boolean startTask(TSTimeTaskEntity task){ try { - /* - //quartz 2.2 - JobDetailImpl jobDetail = new JobDetailImpl(); - jobDetail.setName(taskCode); - jobDetail.setGroup(Scheduler.DEFAULT_GROUP); - jobDetail.setJobClass(getClassByTask(task.getJob_class())); - CronTriggerImpl cronTrigger = new CronTriggerImpl("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP); - cronTrigger.setCronExpression(cronExpress); - */ + //quartz 1.6 - JobDetail jobDetail = new JobDetail(); - jobDetail.setName(task.getId()); - jobDetail.setGroup(Scheduler.DEFAULT_GROUP); - jobDetail.setJobClass(MyClassLoader.getClassByScn(task.getClassName())); - CronTrigger cronTrigger = new CronTrigger("cron_" + task.getId(),Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP); - cronTrigger.setCronExpression(task.getCronExpression()); - schedulerFactory.scheduleJob(jobDetail, cronTrigger); +// JobDetail jobDetail = new JobDetail(); +// jobDetail.setName(task.getId()); +// jobDetail.setGroup(Scheduler.DEFAULT_GROUP); +// jobDetail.setJobClass(MyClassLoader.getClassByScn(task.getClassName())); +// CronTrigger cronTrigger = new CronTrigger("cron_" + task.getId(),Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP); +// cronTrigger.setCronExpression(task.getCronExpression()); + //quartz 2.3.0 + //鍚戣皟搴﹀櫒涓坊鍔犱换鍔 + scheduleJob(task); + return true; - } catch (ParseException e) { - logger.error("startTask ParseException"+ e.getMessage()); } catch (SchedulerException e) { logger.error("startTask SchedulerException"+" cron_" + task.getId()+ e.getMessage()); } @@ -90,13 +85,19 @@ public class DynamicTask { private boolean endTask(TSTimeTaskEntity task){ try{ - /* + //quartz 2.2 - JobKey jobKey = new JobKey(taskName, Scheduler.DEFAULT_GROUP); + TriggerKey triggerKey = new TriggerKey("cron_" + task.getId()); + //鍋滄瑙﹀彂鍣 + schedulerFactory.pauseTrigger(triggerKey); + //绉婚櫎瑙﹀彂鍣 + schedulerFactory.unscheduleJob(triggerKey); + JobKey jobKey = new JobKey(task.getId()); + //鍒犻櫎浠诲姟 schedulerFactory.deleteJob(jobKey); - */ + //quartz 1.6 - schedulerFactory.unscheduleJob("cron_" + task.getId(), Scheduler.DEFAULT_GROUP); +// schedulerFactory.unscheduleJob("cron_" + task.getId()); return true; }catch (SchedulerException e) { logger.error("endTask SchedulerException" + " cron_" + task.getId() + e.getMessage()); @@ -138,13 +139,24 @@ public class DynamicTask { //浠诲姟杩愯涓 if("1".equals(task.getIsStart())){ - CronTriggerBean trigger = (CronTriggerBean)schedulerFactory.getTrigger("cron_" + task.getId(), Scheduler.DEFAULT_GROUP); - String originExpression = trigger.getCronExpression(); + +// CronTriggerBean trigger = (CronTriggerBean)schedulerFactory.getTrigger("cron_" + task.getId(), Scheduler.DEFAULT_GROUP); +// String originExpression = trigger.getCronExpression(); //妫鏌ヨ繍琛屼腑鐨勪换鍔¤Е鍙戣鍒欐槸鍚︿笌鏂拌鍒欎竴鑷 - if (!originExpression.equalsIgnoreCase(newExpression)) { - trigger.setCronExpression(newExpression); - schedulerFactory.rescheduleJob("cron_" + task.getId(), Scheduler.DEFAULT_GROUP, trigger); - } +// if (!originExpression.equalsIgnoreCase(newExpression)) { +// trigger.setCronExpression(newExpression); +// schedulerFactory.rescheduleJob("cron_" + task.getId(), Scheduler.DEFAULT_GROUP, trigger); +// } + //閫氳繃瑙﹀彂鍣╧ey 鍚戣皟搴﹀櫒 鑾峰彇瑙﹀彂鍣ㄥ疄渚 + Trigger oldTrigger = schedulerFactory.getTrigger(new TriggerKey("cron_" + task.getId())); + //鑾峰彇bulid瀵硅薄 + TriggerBuilder tb = oldTrigger.getTriggerBuilder(); + //鍒涘缓瑙﹀彂鍣 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(newExpression); + Trigger newTrigger = tb.withSchedule(cronScheduleBuilder).build(); + //鏇存柊瑙﹀彂鍣 + schedulerFactory.rescheduleJob(oldTrigger.getKey(), newTrigger); + }else{ //绔嬪嵆鐢熸晥 List ipList = IpUtil.getLocalIPList(); @@ -185,8 +197,6 @@ public class DynamicTask { } } catch (SchedulerException e) { logger.error("updateCronExpression SchedulerException" + " cron_" + task.getId() + e.getMessage()); - } catch (ParseException e) { - logger.error("updateCronExpression ParseException" + " cron_" + task.getId() + e.getMessage()); } return false; @@ -256,17 +266,18 @@ public class DynamicTask { if(ipList.contains(runServerIp) || StringUtil.isEmpty(runServerIp) || "鏈湴".equals(runServerIp)){//褰撳墠鏈嶅姟鍣↖P鍖归厤鎴愬姛 //quartz 1.6 - JobDetail jobDetail = new JobDetail(); - jobDetail.setName(task.getId()); - jobDetail.setGroup(Scheduler.DEFAULT_GROUP); - jobDetail.setJobClass(MyClassLoader.getClassByScn(task.getClassName())); - CronTrigger cronTrigger = new CronTrigger("cron_" + task.getId(),Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP); - cronTrigger.setCronExpression(task.getCronExpression()); - schedulerFactory.scheduleJob(jobDetail, cronTrigger); + +// JobDetail jobDetail = new JobDetail(); +// jobDetail.setName(task.getId()); +// jobDetail.setGroup(Scheduler.DEFAULT_GROUP); +// jobDetail.setJobClass(MyClassLoader.getClassByScn(task.getClassName())); +// CronTrigger cronTrigger = new CronTrigger("cron_" + task.getId(),Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP); +// cronTrigger.setCronExpression(task.getCronExpression()); + //鍚戣皟搴﹀櫒涓坊鍔犱换鍔 + scheduleJob(task); + logger.info(" register time task class is { "+task.getClassName()+" } "); } - } catch (ParseException e) { - logger.error("startTask ParseException"+ e.getMessage()); } catch (SchedulerException e) { logger.error("startTask SchedulerException"+" cron_" + task.getId()+ e.getMessage()); } @@ -274,5 +285,27 @@ public class DynamicTask { } } + /** + * 娉ㄥ唽 瀹氭椂浠诲姟 + * @param task 瀹氭椂浠诲姟瀵硅薄 + * @throws SchedulerException + */ + private void scheduleJob(TSTimeTaskEntity task) throws SchedulerException { + //build 瑕佹墽琛岀殑浠诲姟 + JobDetail jobDetail = JobBuilder.newJob(MyClassLoader.getClassByScn(task.getClassName())) + .withIdentity(task.getId()) + .storeDurably() + .requestRecovery() + .build(); + //鏍规嵁Cron琛ㄨ揪寮 build 瑙﹀彂鏃堕棿瀵硅薄 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(task.getCronExpression()); + //build 浠诲姟瑙﹀彂鍣 + CronTrigger cronTrigger = TriggerBuilder.newTrigger() + .withIdentity("cron_" + task.getId()) + .withSchedule(cronScheduleBuilder)//鏍囨槑瑙﹀彂鏃堕棿 + .build(); + //鍚戣皟搴﹀櫒娉ㄥ唽 瀹氭椂浠诲姟 + schedulerFactory.scheduleJob(jobDetail, cronTrigger); + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/DynamicDBUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/DynamicDBUtil.java index 6b3e8b94..5f09736a 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/DynamicDBUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/DynamicDBUtil.java @@ -39,11 +39,12 @@ public class DynamicDBUtil { String driverClassName = dynamicSourceEntity.getDriverClass(); String url = dynamicSourceEntity.getUrl(); String dbUser = dynamicSourceEntity.getDbUser(); - +// update-start--Author:chenjin Date:20160712 for锛氬鏁版嵁婧愮洰鍓嶆暟鎹簱瀵嗙爜鏄槑鏂囷紝閲囩敤鍔犲瘑鏂瑰紡瀛樺偍 //璁剧疆鏁版嵁婧愮殑鏃跺欙紝瑕侀噸鏂拌В瀵 //String dbPassword = dynamicSourceEntity.getDbPassword(); String dbPassword = PasswordUtil.decrypt(dynamicSourceEntity.getDbPassword(), dynamicSourceEntity.getDbUser(), PasswordUtil.getStaticSalt());//瑙e瘑瀛楃涓诧紱 - + +// update-end--Author:chenjin Date:20160712 for锛氬鏁版嵁婧愮洰鍓嶆暟鎹簱瀵嗙爜鏄槑鏂囷紝閲囩敤鍔犲瘑鏂瑰紡瀛樺偍 dataSource.setDriverClassName(driverClassName); dataSource.setUrl(url); @@ -115,7 +116,8 @@ public class DynamicDBUtil { } return effectCount; } - + + //add-begin--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- /** * 鏀寔miniDao璇硶鎿嶄綔鐨刄pdate * @param dbKey 鏁版嵁婧愭爣璇 @@ -132,13 +134,13 @@ public class DynamicDBUtil { effectCount = namedParameterJdbcTemplate.update(sql, data); return effectCount; } - + //add-end--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- public static Object findOne(final String dbKey, String sql, Object... param) { List> list; - + //update-begin--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- list = findList(dbKey, sql, param); - + //update-end--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- if(ListUtils.isNullOrEmpty(list)) { @@ -152,7 +154,7 @@ public class DynamicDBUtil { return list.get(0); } - + //add-begin--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- /** * 鏀寔miniDao璇硶鎿嶄綔鐨勬煡璇 杩斿洖HashMap * @param dbKey 鏁版嵁婧愭爣璇 @@ -171,7 +173,8 @@ public class DynamicDBUtil { } return list.get(0); } - + //add-end--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- + //add-begin--Author:yugwu Date:20170810 for:杩斿洖鍗曚釜瀹炰緥鑰岄潪hashMap---- /** * 鐩存帴sql鏌ヨ 鏍规嵁clazz杩斿洖鍗曚釜瀹炰緥 * @param dbKey 鏁版嵁婧愭爣璇 @@ -198,7 +201,7 @@ public class DynamicDBUtil { Map map = (Map) findOneByHash(dbKey, sql, data); return ReflectHelper.setAll(clazz, map); } - + //add-begin--Author:yugwu Date:20170810 for:杩斿洖鍗曚釜瀹炰緥鑰岄潪hashMap---- public static List> findList(final String dbKey, String sql, Object... param) { List> list; JdbcTemplate jdbcTemplate = getJdbcTemplate(dbKey); @@ -210,7 +213,7 @@ public class DynamicDBUtil { } return list; } - + //add-begin--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- /** * 鏀寔miniDao璇硶鎿嶄綔鐨勬煡璇 * @param dbKey 鏁版嵁婧愭爣璇 @@ -227,7 +230,8 @@ public class DynamicDBUtil { list = namedParameterJdbcTemplate.queryForList(sql, data); return list; } - + //add-end--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- + //add-begin--Author:luobaoli Date:20150620 for锛氬鍔犺繑鍥炲间负List鐨勬柟娉 //姝ゆ柟娉曞彧鑳借繑鍥炲崟鍒楋紝涓嶈兘杩斿洖瀹炰綋绫 public static List findList(final String dbKey, String sql, Class clazz,Object... param) { List list; @@ -240,7 +244,8 @@ public class DynamicDBUtil { } return list; } - + //add-end--Author:luobaoli Date:20150620 for锛氬鍔犺繑鍥炲间负List鐨勬柟娉 + //add-begin--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- /** * 鏀寔miniDao璇硶鎿嶄綔鐨勬煡璇 杩斿洖鍗曞垪鏁版嵁list * @param dbKey 鏁版嵁婧愭爣璇 @@ -282,7 +287,7 @@ public class DynamicDBUtil { List> queryList = findListByHash(dbKey, sql, data); return ReflectHelper.transList2Entrys(queryList, clazz); } - + //add-end--Author:yugwu Date:20170808 for:TASK #1827 銆愭敼閫犮戝鏁版嵁婧愶紝鏀寔minidao璇硶sql---- @SuppressWarnings("unchecked") public static void main(String[] args) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/EhcacheUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/EhcacheUtil.java index 2add999c..4e70c043 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/EhcacheUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/EhcacheUtil.java @@ -62,6 +62,16 @@ public class EhcacheUtil { tagCache.removeAll(); } } + + /** + * 娓呯┖绯荤粺Ehcache缂撳瓨 + */ + public static void clean(String cacheName) { + Cache eCache = manager.getCache(cacheName); + if (eCache != null) { + eCache.removeAll(); + } + } public static void main(String[] args) { String key = "key"; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/JSONHelper.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/JSONHelper.java index e99a1040..12bcf441 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/JSONHelper.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/JSONHelper.java @@ -17,9 +17,6 @@ import org.codehaus.jackson.map.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - /** * JSON鍜孞AVA鐨凱OJO鐨勭浉浜掕浆鎹 * @author 寮犱唬娴 diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/PinyinUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/PinyinUtil.java index 4168d12f..f8446bae 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/PinyinUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/PinyinUtil.java @@ -211,8 +211,9 @@ public class PinyinUtil { try { - pinyingStr = PinyinHelper.toHanyuPinyinString(hanzi, defaultFormat, - separator); + pinyingStr = PinyinHelper.toHanYuPinyinString(hanzi, defaultFormat, + separator,false); + } catch (BadHanyuPinyinOutputFormatCombination e) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisCacheUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisCacheUtil.java index 8f27c01b..db9bb6ab 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisCacheUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisCacheUtil.java @@ -3,7 +3,6 @@ package org.jeecgframework.core.util; import java.util.Set; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; /** * radis 缂撳瓨宸ュ叿绫 @@ -17,7 +16,6 @@ public class RedisCacheUtil { static{ redisTemplate=(RedisTemplate) ApplicationContextUtil.getContext().getBean("redisTemplate"); - redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer()); } public static Object get(String cacheName, Object key) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisUtil.java deleted file mode 100644 index 6bd4c79e..00000000 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/RedisUtil.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.jeecgframework.core.util; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.data.redis.core.BoundKeyOperations; -import org.springframework.data.redis.core.BoundListOperations; -import org.springframework.data.redis.core.BoundValueOperations; -import org.springframework.data.redis.core.RedisTemplate; - -/** - * redis 缂撳瓨宸ュ叿绫 - * yugw 20170929 v2.0 - * redis鏁版嵁搴撲俊鎭湪redis.properties - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class RedisUtil { - - private static RedisTemplate redisTemplate; - private static ConcurrentHashMap boundKeyOperations = new ConcurrentHashMap(); - - /** - * 鍚勪釜宸ュ叿绫荤殑缂撳瓨鍖哄煙锛岄槻姝㈠鍖哄煙涔嬮棿鍥犻噸鍚嶈屾姤閿 - */ - private static String StringRKey = "StringR."; - private static String ObjectRKey = "ObjectR."; - private static String ListRKey = "ListR."; - - static { - if (redisTemplate == null) { - AbstractApplicationContext ac = new ClassPathXmlApplicationContext( - "classpath:/redis.xml"); - redisTemplate = (RedisTemplate) ac.getBean("redisTemplate"); - ac.close(); - } - } - - /** - * 涓撶敤浜嶴tring鐨凴edis澶勭悊宸ュ叿绫 - * 鎵鏈夊伐鍏风被閮藉寘鍚玤etBound銆乻etIfAbsent銆乻et銆乨elete銆乭asKey銆乬et銆乬etAndRemove绛夐氱敤鏂规硶 - * getBound鐢ㄦ潵缂撳瓨澶勭悊绫伙紝闃叉澶氭澶勭悊鐢熸垚澶氫釜澶勭悊绫伙紱 - * setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨 - * set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹 - * delete 鍒犻櫎缂撳瓨 - * hasKey 鏄惁瀛樺湪缂撳瓨 - * get 鑾峰彇缂撳瓨鍐呭 - * getAndRemove 鑾峰彇缂撳瓨鍐呭骞跺垹闄ょ紦瀛 - */ - public static class StringR { - /**getBound鐢ㄦ潵缂撳瓨澶勭悊绫伙紝闃叉澶氭澶勭悊鐢熸垚澶氫釜澶勭悊绫*/ - public static BoundValueOperations getBound(String oldkey){ - cleanOperas(); - String key = StringRKey + oldkey; - BoundKeyOperations boundKeyOperation = boundKeyOperations.get(key); - if(boundKeyOperation == null){ - boundKeyOperation = redisTemplate.boundValueOps(key); - boundKeyOperations.put(key, boundKeyOperation); - } - return (BoundValueOperations)boundKeyOperation; - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨*/ - public static Boolean setIfAbsent(String key, String value) { - return setIfAbsent(key, value, 30L, TimeUnit.MINUTES); - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨锛屽苟璁剧疆缂撳瓨瓒呮椂鏃堕棿*/ - public static Boolean setIfAbsent(String key, String value, long expire, - TimeUnit timeUnit) { - if(hasKey(key)){ - return false; - }else{ - return set(key, value, expire, timeUnit); - } - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹*/ - public static Boolean set(String key, String value) { - return set(key, value, 30L, TimeUnit.MINUTES); - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹癸紝骞惰缃繃鏈熸椂闂*/ - public static Boolean set(String key, String value, long expire, - TimeUnit timeUnit) { - Boolean rt = Boolean.FALSE; - getBound(key).set(value); - if (rt) { - redisTemplate.expire(StringRKey + key, expire, timeUnit); - } - return rt; - } - /**get 鑾峰彇缂撳瓨鍐呭*/ - public static String get(String key) { - return getBound(key).get(); - } - /**getAndRemove 鑾峰彇缂撳瓨鍐呭骞跺垹闄ょ紦瀛*/ - public static String getAndRemove(String key) { - String rt = get(key); - delete(key); - return rt; - } - /**delete 鍒犻櫎缂撳瓨*/ - public static void delete(String key) { - RedisUtil.delete(StringRKey, key); - } - /**hasKey 鏄惁瀛樺湪缂撳瓨*/ - public static Boolean hasKey(String key) { - return RedisUtil.hasKey(StringRKey, key); - } - } - /** - * 涓撶敤浜嶰bject鐨凴edis澶勭悊宸ュ叿绫 - */ - public static class ObjectR { - /**getBound鐢ㄦ潵缂撳瓨澶勭悊绫伙紝闃叉澶氭澶勭悊鐢熸垚澶氫釜澶勭悊绫*/ - public static BoundValueOperations getBound(String oldkey){ - cleanOperas(); - String key = ObjectRKey + oldkey; - BoundKeyOperations boundKeyOperation = boundKeyOperations.get(key); - if(boundKeyOperation == null){ - boundKeyOperation = redisTemplate.boundValueOps(key); - boundKeyOperations.put(key, boundKeyOperation); - } - return (BoundValueOperations)boundKeyOperation; - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨*/ - public static Boolean setIfAbsent(String key, Object value) { - return setIfAbsent(key, value, 30L, TimeUnit.MINUTES); - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨锛屽苟璁剧疆缂撳瓨瓒呮椂鏃堕棿*/ - public static Boolean setIfAbsent(String key, Object value, long expire, - TimeUnit timeUnit) { - if(hasKey(key)){ - return false; - }else{ - return set(key, value, expire, timeUnit); - } - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹*/ - public static Boolean set(String key, Object value) { - return set(key, value, 30L, TimeUnit.MINUTES); - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹癸紝骞惰缃繃鏈熸椂闂*/ - public static Boolean set(String key, Object value, long expire, - TimeUnit timeUnit) { - Boolean rt = Boolean.FALSE; - if (value == null) { - return rt; - } - getBound(key).set(value); - if (rt) { - redisTemplate.expire(ObjectRKey + key, expire, timeUnit); - } - return rt; - } - /**get 鑾峰彇缂撳瓨鍐呭*/ - public static Object get(String key) { - return getBound(key).get(); - } - /**getAndRemove 鑾峰彇缂撳瓨鍐呭骞跺垹闄ょ紦瀛*/ - public static Object getAndRemove(String key) { - Object rt = get(key); - delete(key); - return rt; - } - /**delete 鍒犻櫎缂撳瓨*/ - public static void delete(String key) { - RedisUtil.delete(ObjectRKey, key); - } - /**hasKey 鏄惁瀛樺湪缂撳瓨*/ - public static Boolean hasKey(String key) { - return RedisUtil.hasKey(ObjectRKey, key); - } - } - - /** - * 涓撶敤浜嶭ist鐨凴edis澶勭悊宸ュ叿绫 - * add 鍦╨ist鏈坊鍔犳柊瀹炰綋 - * size 褰撳墠list鐨剆ize - * get 褰撳墠list鐨勭index涓暟鎹 - * getAll 鑾峰彇褰撳墠list鏁版嵁 - * getAllAndRemove 鑾峰彇褰撳墠list鏁版嵁锛屽苟鍒犻櫎缂撳瓨 - */ - public static class ListR { - /**getBound鐢ㄦ潵缂撳瓨澶勭悊绫伙紝闃叉澶氭澶勭悊鐢熸垚澶氫釜澶勭悊绫*/ - public static BoundListOperations getBound(String oldkey){ - cleanOperas(); - String key = ListRKey + oldkey; - BoundKeyOperations boundKeyOperation = boundKeyOperations.get(key); - if(boundKeyOperation == null){ - boundKeyOperation = redisTemplate.boundListOps(key); - boundKeyOperations.put(key, boundKeyOperation); - } - return (BoundListOperations)boundKeyOperation; - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨*/ - public static Boolean setIfAbsent(String key, List value) { - return setIfAbsent(key, value, 30L, TimeUnit.MINUTES); - } - /**setIfAbsent 濡傛灉涓嶅瓨鍦ㄥ氨娣诲姞缂撳瓨锛屽苟璁剧疆缂撳瓨瓒呮椂鏃堕棿*/ - public static Boolean setIfAbsent(String key, List value, long expire, - TimeUnit timeUnit) { - if(hasKey(key)){ - return false; - }else{ - return set(key, value, expire, timeUnit); - } - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹*/ - public static Boolean set(String key, List value) { - return set(key, value, 30L, TimeUnit.MINUTES); - } - /**set 娣诲姞鎴栨洿鏀圭紦瀛樺唴瀹癸紝骞惰缃繃鏈熸椂闂*/ - public static Boolean set(String key, List value, long expire, - TimeUnit timeUnit) { - Boolean rt = Boolean.FALSE; - if (value == null || value.size() <= 0) { - return rt; - } - BoundListOperations boundListOperations = getBound(key); - for(Object obj : value){ - boundListOperations.rightPush(obj); - } - if (rt) { - redisTemplate.expire(ListRKey + key, expire, timeUnit); - } - return rt; - } - /**add 鍦╨ist鏈坊鍔犳柊瀹炰綋e*/ - public static Boolean add(String key, Object value) { - return add(key, value, 30L, TimeUnit.MINUTES); - } - /**add 鍦╨ist鏈坊鍔犳柊瀹炰綋锛屽苟璁剧疆杩囨湡鏃堕棿*/ - public static Boolean add(String key, Object value, long expire, - TimeUnit timeUnit) { - Boolean rt = Boolean.FALSE; - if (value == null) { - return rt; - } - getBound(key).rightPush(value); - if (rt) { - redisTemplate.expire(ListRKey + key, expire, timeUnit); - } - return rt; - } - /**size 褰撳墠list鐨剆ize*/ - public static Long size(String key) { - return getBound(key).size(); - } - /**get 褰撳墠list鐨勭index涓暟鎹*/ - public static Object get(String key, long index) { - return getBound(key).index(index); - } - /**getAll 鑾峰彇褰撳墠list鏁版嵁*/ - public static ArrayList getAll(String key) { - if(!hasKey(key)){ - return null; - } - List list = getBound(key).range(0, size(key) - 1); - ArrayList result = new ArrayList(); - for(Object single : list){ - result.add(single); - } - return result; - } - /**getAllAndRemove 鑾峰彇褰撳墠list鏁版嵁锛屽苟鍒犻櫎缂撳瓨*/ - public static ArrayList getAllAndRemove(String key) { - ArrayList rt = getAll(key); - delete(key); - return rt; - } - /**delete 鍒犻櫎缂撳瓨*/ - public static void delete(String key) { - RedisUtil.delete(ListRKey, key); - } - /**hasKey 鏄惁瀛樺湪缂撳瓨*/ - public static Boolean hasKey(String key) { - return RedisUtil.hasKey(ListRKey, key); - } - } - - private static Long lastGet; - /**娓呯悊boundKeyOperations*/ - public static void cleanOperas(){ - if(lastGet == null){ - lastGet = System.currentTimeMillis(); - return; - } - //姣忚繃20鍒嗛挓娓呯悊涓娆★紝闃叉鏃犳晥Opera鍗犵敤鍐呭瓨 - if(System.currentTimeMillis() - lastGet > 20*60*1000){ - boundKeyOperations = new ConcurrentHashMap(); - } - } - - /** - * 鎵鏈夊垹闄ゆ柟娉曠殑鍏ュ彛 - * @param area 缂撳瓨鍖哄煙 - * @param key - */ - public static void delete(String area, String key) { - redisTemplate.delete(area + key); - } - - /** - * 鎵鏈塰asKey鐨勫叆鍙 - * @param area 缂撳瓨鍖哄煙 - * @param key - */ - public static Boolean hasKey(String area, String key) { - return redisTemplate.hasKey(area + key); - } - /** - * 娓呯悊鎵鏈塺edis缂撳瓨 - */ - public static void cleanAll(){ - redisTemplate.getConnectionFactory().getConnection().flushAll(); - } -} \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/ReflectHelper.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/ReflectHelper.java index 5dbefe76..9efc5fd1 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/ReflectHelper.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/ReflectHelper.java @@ -10,12 +10,15 @@ import java.util.Map; import java.util.Map.Entry; import java.util.regex.Pattern; +import org.apache.log4j.Logger; + /** * @author 寮犱唬娴 * @desc 閫氳繃鍙嶅皠鏉ュ姩鎬佽皟鐢╣et 鍜 set 鏂规硶 */ public class ReflectHelper { - + private static final Logger logger = Logger.getLogger(ReflectHelper.class); + @SuppressWarnings("rawtypes") private Class cls; /** @@ -70,7 +73,7 @@ public class ReflectHelper { param = setM.matcher(methodName).replaceAll(rapl).toLowerCase(); setMethods.put(param, m); } else { - // org.jeecgframework.core.util.LogUtil.info(methodName + " 涓嶆槸getter,setter鏂规硶锛"); + // logger.info(methodName + " 涓嶆槸getter,setter鏂规硶锛"); } } } @@ -87,7 +90,7 @@ public class ReflectHelper { m.invoke(obj, object); return true; } catch (Exception ex) { - org.jeecgframework.core.util.LogUtil.info("invoke getter on " + property + " error: " + ex.toString()); + logger.info("invoke getter on " + property + " error: " + ex.toString()); return false; } } @@ -109,7 +112,7 @@ public class ReflectHelper { value=m.invoke(obj, new Object[] {}); } catch (Exception ex) { - org.jeecgframework.core.util.LogUtil.info("invoke getter on " + property + " error: " + ex.toString()); + logger.info("invoke getter on " + property + " error: " + ex.toString()); } } return value; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/ResourceUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/ResourceUtil.java index c53f4d8b..80762820 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/ResourceUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/ResourceUtil.java @@ -17,7 +17,6 @@ import org.jeecgframework.web.system.manager.ClientManager; import org.jeecgframework.web.system.pojo.base.Client; import org.jeecgframework.web.system.pojo.base.DynamicDataSourceEntity; import org.jeecgframework.web.system.pojo.base.TSIcon; -import org.jeecgframework.web.system.pojo.base.TSRoleFunction; import org.jeecgframework.web.system.pojo.base.TSType; import org.jeecgframework.web.system.pojo.base.TSTypegroup; import org.jeecgframework.web.system.pojo.base.TSUser; @@ -52,7 +51,12 @@ public class ResourceUtil { public static Map dynamicDataSourceMap = new HashMap(); private static final ResourceBundle bundle = java.util.ResourceBundle.getBundle("sysConfig"); - + + /** + * 鍩熷悕璺緞 basePath + */ + private static String basePath = null; + /** * 灞炴ф枃浠禰resources/sysConfig.properties] * #榛樿寮鍚ā绯婃煡璇㈡柟寮 1涓哄紑鍚 鏉′欢鏃犻渶甯*灏辫兘妯$硦鏌ヨ[鏆傛椂鍙栨秷] @@ -86,20 +90,6 @@ public class ResourceUtil { return null; } - @Deprecated - public static final List getSessionTSRoleFunction(String roleId) { - HttpSession session = ContextHolderUtils.getSession(); - if (session.getAttributeNames().hasMoreElements()) { - List TSRoleFunctionList = (List)session.getAttribute(roleId); - if (TSRoleFunctionList != null) { - return TSRoleFunctionList; - } else { - return null; - } - } else { - return null; - } - } /** * 鑾峰緱璇锋眰璺緞銆愭敞鎰忥細 涓嶉氱敤銆 @@ -107,7 +97,7 @@ public class ResourceUtil { * @param request * @return */ - public static String getRequestPath(HttpServletRequest request) { + public static String getJgAuthRequsetPath(HttpServletRequest request) { // String requestPath = request.getRequestURI() + "?" + request.getQueryString(); String queryString = request.getQueryString(); @@ -378,6 +368,20 @@ public class ResourceUtil { data.put("sys."+DataBaseConstant.SYS_TIME_TABLE, DateUtils.formatTime()); return data; } + + /** + * 鑾峰彇褰撳墠鍩熷悕璺緞 + * @param request + * @return + */ + public static String getBasePath() { + if(StringUtils.isBlank(basePath)) { + HttpServletRequest request = ContextHolderUtils.getRequest(); + basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath(); + } + return basePath; + } + /** * sql鍊兼浛鎹 diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/SqlInjectionUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/SqlInjectionUtil.java new file mode 100644 index 00000000..e4ea5e43 --- /dev/null +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/SqlInjectionUtil.java @@ -0,0 +1,42 @@ + + +package org.jeecgframework.core.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * sql娉ㄥ叆澶勭悊宸ュ叿绫 + * @author zhoujf + * + */ +public class SqlInjectionUtil { + private static final Logger logger = LoggerFactory.getLogger(SqlInjectionUtil.class); + /** + * sql娉ㄥ叆杩囨护澶勭悊锛岄亣鍒版敞鍏ュ叧閿瓧鎶涘紓甯 + * @param value + * @return + */ + public static void filterContent(String value) { + if(value == null || "".equals(value)){ + return ; + } + value = value.toLowerCase();//缁熶竴杞负灏忓啓 +// throw new RuntimeException("鍊煎瓨鍦╯ql娉ㄥ叆椋庨櫓锛"+value); +// String xssStr = "and |or |select |update |delete |drop |truncate |%20|=|--|!="; + String xssStr = "'|and |exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |;|or |+|,"; + String[] xssArr = xssStr.split("\\|"); + for(int i=0;i-1){ + logger.info("璇锋敞鎰,鍊煎彲鑳藉瓨鍦⊿QL娉ㄥ叆椋庨櫓!---> {}",value); + throw new RuntimeException("璇锋敞鎰,鍊煎彲鑳藉瓨鍦⊿QL娉ㄥ叆椋庨櫓!--->"+value); + } + } + return ; + } + + public static void main(String[] args) { + String str = "' and"; + filterContent(str); + } + +} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/core/util/SysThemesUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/core/util/SysThemesUtil.java index 3151d7cb..d12ec661 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/core/util/SysThemesUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/core/util/SysThemesUtil.java @@ -43,7 +43,8 @@ public class SysThemesUtil { */ public static String getEasyUiTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); - sb.append(""); + String basePath = ResourceUtil.getBasePath(); + sb.append(""); return sb.toString(); } @@ -66,10 +67,11 @@ public class SysThemesUtil { */ public static String getEasyUiMainTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -98,10 +100,11 @@ public class SysThemesUtil { */ public static String getEasyUiIconTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else { - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -113,15 +116,16 @@ public class SysThemesUtil { */ public static String getCommonTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } - sb.append(""); + sb.append(""); return sb.toString(); } @@ -154,12 +158,13 @@ public class SysThemesUtil { */ public static String getLhgdialogTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -189,13 +194,15 @@ public class SysThemesUtil { */ public static String getBootstrapTabTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); } return sb.toString(); } + /** @@ -205,12 +212,13 @@ public class SysThemesUtil { */ public static String getReportTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -222,12 +230,13 @@ public class SysThemesUtil { */ public static String getValidformDivfromTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -239,12 +248,13 @@ public class SysThemesUtil { */ public static String getValidformStyleTheme(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } return sb.toString(); } @@ -274,12 +284,13 @@ public class SysThemesUtil { */ public static String getValidformTablefrom(SysThemesEnum sysThemesEnum){ StringBuffer sb = new StringBuffer(""); + String basePath = ResourceUtil.getBasePath(); if("metro".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else if("metrole".equals(sysThemesEnum.getThemes())){ - sb.append(""); + sb.append(""); }else{ - sb.append(""); + sb.append(""); } return sb.toString(); } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/jwt/service/RedisTokenManager.java b/jeecg-framework/src/main/java/org/jeecgframework/jwt/service/RedisTokenManager.java index b721802a..0a945f85 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/jwt/service/RedisTokenManager.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/jwt/service/RedisTokenManager.java @@ -10,8 +10,7 @@ import org.jeecgframework.jwt.def.JwtConstants; import org.jeecgframework.jwt.model.TokenModel; import org.jeecgframework.web.system.pojo.base.TSUser; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Component; /** @@ -21,15 +20,8 @@ import org.springframework.stereotype.Component; */ @Component public class RedisTokenManager implements TokenManager { - - private RedisTemplate redisTemplate; - - @Autowired - public void setRedis(RedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - //娉涘瀷璁剧疆鎴怢ong鍚庡繀椤绘洿鏀瑰搴旂殑搴忓垪鍖栨柟妗 - redisTemplate.setKeySerializer(new JdkSerializationRedisSerializer()); - } + @Autowired + private StringRedisTemplate redisTemplate; /** * 鐢熸垚TOKEN diff --git a/jeecg-framework/src/main/java/org/jeecgframework/jwt/util/JwtHttpUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/jwt/util/JwtHttpUtil.java index 063b952e..f9f475c5 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/jwt/util/JwtHttpUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/jwt/util/JwtHttpUtil.java @@ -7,7 +7,10 @@ import java.io.OutputStream; import java.net.ConnectException; import java.net.HttpURLConnection; import java.net.URL; + +import org.apache.log4j.Logger; import org.jeecgframework.core.util.LogUtil; + import com.alibaba.fastjson.JSONObject; /** @@ -16,6 +19,7 @@ import com.alibaba.fastjson.JSONObject; * */ public class JwtHttpUtil { + private static Logger log = Logger.getLogger(JwtHttpUtil.class); /** * 鍙戣捣https璇锋眰骞惰幏鍙栫粨鏋 @@ -70,9 +74,8 @@ public class JwtHttpUtil { inputStream.close(); inputStream = null; httpUrlConn.disconnect(); - System.out.println(buffer.toString()); + log.debug(buffer.toString()); jsonObject = JSONObject.parseObject(buffer.toString()); - // jsonObject = JSONObject.fromObject(buffer.toString()); } catch (ConnectException ce) { LogUtil.info("Weixin server connection timed out."); } catch (Exception e) { @@ -143,9 +146,7 @@ public class JwtHttpUtil { inputStream = null; httpUrlConn.disconnect(); res = buffer.toString(); - System.out.println(res); -// jsonObject = JSONObject.parseObject(buffer.toString()); - // jsonObject = JSONObject.fromObject(buffer.toString()); + log.debug(res); } catch (ConnectException ce) { LogUtil.info("Weixin server connection timed out."); } catch (Exception e) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/BaseTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/BaseTag.java index 021f03f3..309c2147 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/BaseTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/BaseTag.java @@ -11,6 +11,7 @@ import jodd.util.StringUtil; import org.apache.log4j.Logger; import org.jeecgframework.core.enums.SysThemesEnum; import org.jeecgframework.core.util.ContextHolderUtils; +import org.jeecgframework.core.util.ResourceUtil; import org.jeecgframework.core.util.SysThemesUtil; import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.tag.core.JeecgTag; @@ -21,7 +22,7 @@ import org.jeecgframework.tag.core.JeecgTag; * */ public class BaseTag extends JeecgTag { - private Logger log = Logger.getLogger(BaseTag.class); + private static Logger log = Logger.getLogger(BaseTag.class); private static final long serialVersionUID = 1L; protected String type = "default";// 鍔犺浇绫诲瀷 protected String cssTheme ; @@ -80,104 +81,111 @@ public class BaseTag extends JeecgTag { } //鎻掑叆澶氳瑷鑴氭湰 - String lang = (String)((HttpServletRequest) this.pageContext.getRequest()).getSession().getAttribute("lang"); + HttpServletRequest request =(HttpServletRequest) this.pageContext.getRequest(); + String lang = (String)request.getSession().getAttribute("lang"); + String basePath = ResourceUtil.getBasePath(); if(lang==null){lang="zh-cn";} - String langjs = StringUtil.replace("", "{0}", lang); + String langjs = StringUtil.replace("", "{0}", lang); sb.append(langjs); if (oConvertUtils.isIn("jquery-webos", types)) { - sb.append(""); + sb.append(""); } else if (oConvertUtils.isIn("jquery", types)) { - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("ckeditor", types)) { - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("easyui", types)) { - sb.append(""); + sb.append(""); sb.append(SysThemesUtil.getEasyUiTheme(sysThemesEnum)); sb.append(SysThemesUtil.getEasyUiMainTheme(sysThemesEnum)); sb.append(SysThemesUtil.getEasyUiIconTheme(sysThemesEnum)); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(StringUtil.replace("", "{0}", lang)); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(StringUtil.replace("", "{0}", lang)); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("DatePicker", types)) { - sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("jqueryui", types)) { - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("jqueryui-sortable", types)) { - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("prohibit", types)) { - sb.append(""); } + sb.append(""); } if (oConvertUtils.isIn("tools", types)) { sb.append(SysThemesUtil.getCommonTheme(sysThemesEnum)); sb.append(SysThemesUtil.getLhgdialogTheme(sysThemesEnum)); sb.append(SysThemesUtil.getBootstrapTabTheme(sysThemesEnum)); - sb.append(""); - sb.append(StringUtil.replace("", "{0}", lang)); - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(StringUtil.replace("", "{0}", lang)); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("toptip", types)) { - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("autocomplete", types)) { - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("jeasyuiextensions", types)) { - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("ztree", types)) { - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("bootstrap", types)) { - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); } if (oConvertUtils.isIn("bootstrap-table", types)) { - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + + sb.append(""); + sb.append(""); + } if (oConvertUtils.isIn("layer", types)) { - sb.append(""); - sb.append(""); + sb.append(""); + sb.append(""); } types = null; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridColumnTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridColumnTag.java index 505d5b8e..9ede16aa 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridColumnTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridColumnTag.java @@ -64,7 +64,9 @@ public class DataGridColumnTag extends TagSupport { protected String dictCondition; //鑷畾涔夊瓧鍏歌〃鐨勬樉绀烘枃鏈-瀛楀吀鏌ヨ鏉′欢 - + private String filterType = "text";//杩囨护鎿嶄綔鐨勭被鍨 + private boolean optsMenu = false;//鎿嶄綔鍒楅鏍艰浆鍙 銆愯埞鑸朵笓鐢ㄣ + public boolean isNewColumn() { return newColumn; } @@ -95,7 +97,7 @@ public class DataGridColumnTag extends TagSupport { Tag t = findAncestorWithClass(this, DataGridTag.class); DataGridTag parent = (DataGridTag) t; - parent.setColumn(title,field,width,showLen,rowspan,colspan,align,sortable,checkbox,formatter,formatterjs,hidden,replace,treefield,image,imageSize,query,url,funname,arg,queryMode, dictionary,popup,frozenColumn,extend,style,downloadName,autocomplete,extendParams,editor,defaultVal,showMode,newColumn,dictCondition); + parent.setColumn(title,field,width,showLen,rowspan,colspan,align,sortable,checkbox,formatter,formatterjs,hidden,replace,treefield,image,imageSize,query,url,funname,arg,queryMode, dictionary,popup,frozenColumn,extend,style,downloadName,autocomplete,extendParams,editor,defaultVal,showMode,newColumn,dictCondition,filterType,optsMenu); return EVAL_PAGE; } @@ -266,6 +268,19 @@ public class DataGridColumnTag extends TagSupport { this.defaultVal = defaultVal; } - + public String getFilterType() { + return filterType; + } + public void setFilterType(String filterType) { + this.filterType = filterType; + } + + public boolean isOptsMenu() { + return optsMenu; + } + + public void setOptsMenu(boolean optsMenu) { + this.optsMenu = optsMenu; + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridFunOptTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridFunOptTag.java index b208e17e..accdc92e 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridFunOptTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridFunOptTag.java @@ -26,7 +26,8 @@ public class DataGridFunOptTag extends TagSupport { private String urlclass;//鎸夐挳鏍峰紡 private String urlfont;//鎸夐挳鍥炬爣 - + private boolean inGroup;//鎿嶄綔鍒楄彍鍗曚竴寮濮嬫槸鍚﹂殣钘忋愯埞鑸朵笓鐢ㄣ + public int doStartTag() throws JspTagException { return EVAL_PAGE; } @@ -35,7 +36,7 @@ public class DataGridFunOptTag extends TagSupport { Tag t = findAncestorWithClass(this, DataGridTag.class); DataGridTag parent = (DataGridTag) t; - parent.setFunUrl(title,exp,funname,operationCode,urlStyle,urlclass,urlfont); + parent.setFunUrl(title,exp,funname,operationCode,urlStyle,urlclass,urlfont,inGroup); return EVAL_PAGE; } public void setFunname(String funname) { @@ -74,7 +75,12 @@ public class DataGridFunOptTag extends TagSupport { this.urlfont = urlfont; } - - + + public boolean isInGroup() { + return inGroup; + } + public void setInGroup(boolean inGroup) { + this.inGroup = inGroup; + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridOpenOptTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridOpenOptTag.java index 54d9cdec..1dc6f14e 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridOpenOptTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridOpenOptTag.java @@ -25,13 +25,16 @@ public class DataGridOpenOptTag extends TagSupport { private String urlfont;//鎸夐挳鍥炬爣 private String openModel = "OpenWin"; //寮瑰嚭鏂瑰紡 + + private boolean inGroup;//鎿嶄綔鍒楄彍鍗曚竴寮濮嬫槸鍚﹂殣钘忋愯埞鑸朵笓鐢ㄣ + public int doStartTag() throws JspTagException { return EVAL_PAGE; } public int doEndTag() throws JspTagException { Tag t = findAncestorWithClass(this, DataGridTag.class); DataGridTag parent = (DataGridTag) t; - parent.setOpenUrl(url,title,width,height,exp,operationCode,openModel,urlStyle,urlclass,urlfont); + parent.setOpenUrl(url,title,width,height,exp,operationCode,openModel,urlStyle,urlclass,urlfont,inGroup); return EVAL_PAGE; } public void setWidth(String width) { @@ -74,5 +77,11 @@ public class DataGridOpenOptTag extends TagSupport { public void setUrlfont(String urlfont) { this.urlfont = urlfont; } + public boolean isInGroup() { + return inGroup; + } + public void setInGroup(boolean inGroup) { + this.inGroup = inGroup; + } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridTag.java index 6491119d..ecbb4ddf 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/DataGridTag.java @@ -60,7 +60,7 @@ import com.google.gson.Gson; */ @SuppressWarnings({"serial","rawtypes","unchecked","static-access"}) public class DataGridTag extends TagSupport { - private Logger log = Logger.getLogger(DataGridTag.class); + private static Logger log = Logger.getLogger(DataGridTag.class); private final String DATE_FORMATTER = "yyyy-MM-dd"; private final String DATETIME_FORMATTER = "yyyy-MM-dd hh:mm:ss"; @@ -407,13 +407,15 @@ public class DataGridTag extends TagSupport { /** * 璁剧疆鑷畾涔夊嚱鏁版搷浣淯RL */ - public void setFunUrl(String title, String exp, String funname,String operationCode, String urlStyle,String urlclass,String urlfont) { + public void setFunUrl(String title, String exp, String funname,String operationCode, String urlStyle,String urlclass,String urlfont,boolean inGroup) { DataGridUrl dataGridUrl = new DataGridUrl(); dataGridUrl.setTitle(title); dataGridUrl.setType(OptTypeDirection.Fun); dataGridUrl.setExp(exp); dataGridUrl.setFunname(funname); + dataGridUrl.setInGroup(inGroup); + if(checkBrowerIsNotIE()){ dataGridUrl.setUrlStyle(urlStyle); @@ -433,7 +435,7 @@ public class DataGridTag extends TagSupport { * @param urlfont * @param urlclass */ - public void setOpenUrl(String url, String title, String width, String height, String exp,String operationCode, String openModel, String urlStyle, String urlclass, String urlfont) { + public void setOpenUrl(String url, String title, String width, String height, String exp,String operationCode, String openModel, String urlStyle, String urlclass, String urlfont,boolean inGroup) { DataGridUrl dataGridUrl = new DataGridUrl(); dataGridUrl.setTitle(title); dataGridUrl.setUrl(url); @@ -442,6 +444,8 @@ public class DataGridTag extends TagSupport { dataGridUrl.setType(OptTypeDirection.valueOf(openModel)); dataGridUrl.setExp(exp); + dataGridUrl.setInGroup(inGroup); + if(checkBrowerIsNotIE()){ dataGridUrl.setUrlStyle(urlStyle); @@ -474,7 +478,7 @@ public class DataGridTag extends TagSupport { String arg,String queryMode, String dictionary,boolean popup, boolean frozenColumn,String extend, - String style,String downloadName,boolean isAuto,String extendParams,String editor,String defaultVal,String showMode, boolean newColumn,String dictCondition) { + String style,String downloadName,boolean isAuto,String extendParams,String editor,String defaultVal,String showMode, boolean newColumn,String dictCondition,String filterType,boolean optsMenu) { DataGridColumn dataGridColumn = new DataGridColumn(); dataGridColumn.setAlign(align); @@ -517,6 +521,9 @@ public class DataGridTag extends TagSupport { dataGridColumn.setDictCondition(dictCondition); + dataGridColumn.setFilterType(filterType); + dataGridColumn.setOptsMenu(optsMenu); + columnList.add(dataGridColumn); Set operationCodes = (Set) super.pageContext.getRequest().getAttribute(Globals.OPERATIONCODES); @@ -654,9 +661,11 @@ public class DataGridTag extends TagSupport { if("bootstrap-table".equals(component)){ ComponentFactory componentFactory = new BootstrapTableComponent(); String content = componentFactory.invoke("/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable.ftl", getDataGridTag()); + //log.debug(" content ===>" + content); out.print(content); }else{ out.print(end().toString()); + //log.debug(" end() ===>" + end().toString()); } out.flush(); @@ -958,7 +967,7 @@ public class DataGridTag extends TagSupport { sb.append(""); - sb.append("-- 璇烽夋嫨 --"); + sb.append(""); if(dictionary.indexOf(",")>-1){ //琛ㄦ牸鏁版嵁淇℃伅 try{ @@ -1691,6 +1700,14 @@ public class DataGridTag extends TagSupport { //update by jg_renjie at 2016/1/11 for:TASK #823 澧炲姞form瀹炵幇Form琛ㄥ崟楠岃瘉,姝ゅ閬垮厤reset鏃惰蛋楠岃瘉锛屼唬鐮佸仛浜嗗啑浣 sb.append("}"); } + + //楂樼骇鏌ヨ閬垮厤鏂规硶鍚嶅嚭鐜伴噸澶 + if(oConvertUtils.isNotEmpty(complexSuperQuery)) { + sb.append("function "+name+"SuperQuery(queryCode){if(typeof(windowapi)=='undefined'){$.dialog({content:'url:superQueryMainController.do?dialog&code='+queryCode+'&tableName="+name+"',width:880,height:400,zIndex:getzIndex(),title:'楂樼骇鏌ヨ鏋勯犲櫒',cache:false,lock:true})}else{$.dialog({content:'url:superQueryMainController.do?dialog&code='+queryCode+'&tableName="+name+"',width:880,height:400,zIndex:getzIndex(),title:title,cache:false,lock:true,parent:windowapi})}};"); + } + //杩囨护鎿嶄綔 + getFilterFields(sb); + sb.append(""); sb.append(""); sb.append(""); @@ -2007,7 +2024,9 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)) { - sb.append(""); + + sb.append(""); + sb.append(""); sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); sb.append(""); @@ -2025,7 +2044,9 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)) { - sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + + sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + } } @@ -2041,7 +2062,9 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)) { - sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + + sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + } } @@ -2512,7 +2535,13 @@ public class DataGridTag extends TagSupport { } if (OptTypeDirection.OpenTab.equals(dataGridUrl.getType())) { - sb.append("href+=\"[\";"); + + if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){//鍊樿嫢urlclass涓嶄负绌猴紝鍒欏幓鎺夐摼鎺ュ墠闈㈢殑"["; + sb.append("href+=\""+urlfont.toString()+"\";"); + }else{ + sb.append("href+=\"[\";"); + } + } if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){//鍊樿嫢urlclass涓嶄负绌猴紝鍒欏幓鎺夐摼鎺ュ悗闈㈢殑"]"; sb.append("href+=\"" + dataGridUrl.getTitle() + " \";"); @@ -2805,9 +2834,14 @@ public class DataGridTag extends TagSupport { }else if (StringUtil.isNotEmpty(column.getField()) && column.getField().equals("opt")) {// 鍔犲叆鎿嶄綔 sb.append(",formatter:function(value,rec,index){"); - // sb.append("return \""); - this.getOptUrl(sb); + + if(column.isOptsMenu()){ + getOptsMenuUrl(sb); + }else{ + this.getOptUrl(sb); + } sb.append("}"); + }else if(column.getFormatter()!=null) { sb.append(",formatter:function(value,rec,index){"); @@ -3487,7 +3521,9 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)) { - sb.append(""); + + sb.append(""); + sb.append(""); sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); sb.append(""); @@ -3505,7 +3541,7 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)){ - sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); } } @@ -3521,7 +3557,9 @@ public class DataGridTag extends TagSupport { } if(oConvertUtils.isNotEmpty(complexSuperQuery)){ - sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + + sb.append(""+MutiLangUtil.getLang("common.advancedQuery")+""); + } } @@ -4008,17 +4046,224 @@ appendLine(sb," }}\">鍏崇郴"); } } + protected boolean filterBtn = false;//鎸夐挳杩囨护妯″紡鏄惁寮鍚紝鍒楄〃涓婅嫢鏈変竴涓寜閽彲浠ヨ鍏惰皟鐢▁xFilter鍑芥暟鍑虹幇杩囨护琛-- + public boolean isFilterBtn() { + return filterBtn; + } + public void setFilterBtn(boolean filterBtn) { + this.filterBtn = filterBtn; + } + /** + * 鑾峰彇杩囨护瀛楁閰嶇疆 + * @return + */ + private void getFilterFields(StringBuffer sb){ + if(this.isFilterBtn()){ + StringBuffer ffs = new StringBuffer(); + int index = 0; + for (DataGridColumn column :columnList) { + if(column.getField().equals("opt")){ + continue; + } + if(index!=0){ + ffs.append(","); + } + index++; + String filterType = column.getFilterType(); + ffs.append("{"); + ffs.append("field:'"+column.getField()+"',"); + ffs.append("type:'"+filterType+"',"); + if("combobox".equals(filterType)){ + ffs.append("options:{"); + ffs.append("panelHeight:'auto',"); + ffs.append("data:[{value:'',text:'All'}"); + for (ColumnValue columnValue : columnValueList) { + if (columnValue.getName().equals(column.getField())) { + String[] value = columnValue.getValue().split(","); + String[] text = columnValue.getText().split(","); + for (int k = 0; k < value.length; k++) { + ffs.append(",{value:'"+value[k]+"',text:'"+text[k]+"'}"); + } + break; + } + } + ffs.append("],"); + ffs.append("onChange:function(value){");//if (value == ''){}$('#"+name+"').datagrid('removeFilterRule', '"+column.getField()+"'); + // else { + ffs.append("$('#"+name+"').datagrid('addFilterRule', {field: '"+column.getField()+"',op: 'equal',value: value});");//} + ffs.append("$('#"+name+"').datagrid('doFilter');}}");//option-end + }else{ + ffs.append("options:{precision:1},"); + if("numberbox".equals(filterType) || "datebox".equals(filterType)|| "datetimebox".equals(filterType)){ + ffs.append("op:['equal','lessorequal','greaterorequal']"); + }else{ + ffs.append("op:['equal','contains']"); + } + } + ffs.append("}"); + } + sb.append("function "+name+"Filter(){$('#"+name+"').datagrid('enableFilter',["+ffs.toString()+"]);}"); + } + } + /** + * 鎷艰鎿嶄綔鍦板潃,鏂扮殑椋庢牸 + * @param sb + */ + private void getOptsMenuUrl(StringBuffer sb){ + this.getOptUrl(sb,true,false); + StringBuffer groupString = new StringBuffer(); + this.getOptUrl(groupString,true,true); + if(oConvertUtils.isNotEmpty(groupString.toString())){ + sb.append("href+='';"); + sb.append("href+='';"); + sb.append(groupString.toString()); + sb.append("href+='';"); + } + sb.append("return href;"); + } + /** + * * 鎷艰鎿嶄綔鍦板潃,鏂扮殑椋庢牸 + * @param sb + * @param noReturn 鏄惁涓嶅湪璇ユ柟娉曚腑杩斿洖href + * @param initGroup 鏄惁鍔犺浇鐨勬槸闅愯棌鑿滃崟 + */ + protected void getOptUrl(StringBuffer sb,boolean noReturn,boolean initGroup) { + //娉細鎿嶄綔鍒楄〃浼氬甫鍏ュ悎璁″垪涓幓锛屾晠鍔犳鍒ゆ柇 + List list = urlList; + if(!initGroup){ + sb.append("if(!rec.id){return '';}"); + sb.append("var href='';"); + } + for (DataGridUrl dataGridUrl : list) { + if(initGroup){ + //鑻ュ姞杞界殑鏄粍鑿滃崟 浣嗚鑿滃崟鍏跺疄涓嶆槸缁勮彍鍗曞垯 璺宠繃 + if(!dataGridUrl.isInGroup()){ + continue; + } + }else{ + //鑻ュ姞杞界殑涓嶆槸缁勮彍鍗 浣嗚鑿滃崟鍏跺疄鏄粍鑿滃崟鍒 璺宠繃 + if(dataGridUrl.isInGroup()){ + continue; + } + } + String url = dataGridUrl.getUrl(); + MessageFormat formatter = new MessageFormat(""); + if (dataGridUrl.getValue() != null) { + String[] testvalue = dataGridUrl.getValue().split(","); + List value = new ArrayList(); + for (String string : testvalue) { + value.add("\"+rec." + string + " +\""); + } + url = formatter.format(url, value.toArray()); + } + if (url != null && dataGridUrl.getValue() == null) { + url = formatUrlPlus(url); + } + String exp = dataGridUrl.getExp();// 鍒ゆ柇鏄剧ず琛ㄨ揪寮 + if (StringUtil.isNotEmpty(exp)) { + String[] ShowbyFields = exp.split("&&"); + for (String ShowbyField : ShowbyFields) { + int beginIndex = ShowbyField.indexOf("#"); + int endIndex = ShowbyField.lastIndexOf("#"); + String exptype = ShowbyField.substring(beginIndex + 1, endIndex);// 琛ㄨ揪寮忕被鍨 + String field = ShowbyField.substring(0, beginIndex);// 鍒ゆ柇鏄剧ず渚濇嵁瀛楁 + String[] values = ShowbyField.substring(endIndex + 1, ShowbyField.length()).split(",");// 浼犲叆瀛楁鍊 + String value = ""; + for (int i = 0; i < values.length; i++) { + value += "'" + "" + values[i] + "" + "'"; + if (i < values.length - 1) { + value += ","; + } + } + if ("eq".equals(exptype)) { + sb.append("if($.inArray(rec." + field + ",[" + value + "])>=0){"); + } + if ("ne".equals(exptype)) { + sb.append("if($.inArray(rec." + field + ",[" + value + "])<0){"); + } + if ("empty".equals(exptype) && value.equals("'true'")) { + sb.append("if(rec." + field + "==''){"); + } + if ("empty".equals(exptype) && value.equals("'false'")) { + sb.append("if(rec." + field + "!=''){"); + } + } + } + StringBuffer style = new StringBuffer(); + if (!StringUtil.isEmpty(dataGridUrl.getUrlStyle())) { + style.append(" style=\'"); + style.append(dataGridUrl.getUrlStyle()); + style.append("\' "); + } + StringBuffer urlclass = new StringBuffer(); + StringBuffer urlfont = new StringBuffer(); + if(initGroup){ + urlclass.append(" class=\'btn btn-menu fa "); + if(!StringUtil.isEmpty(dataGridUrl.getUrlfont())){ + urlclass.append(dataGridUrl.getUrlfont()); + }else{ + urlclass.append("fa-font"); + } + urlclass.append(" menu-more\'"); + }else{ + urlclass.append(" class=\'btn-menu\'"); + urlfont.append(""); + } + if (OptTypeDirection.Fun.equals(dataGridUrl.getType())) { + String name = TagUtil.getFunction(dataGridUrl.getFunname()); + String parmars = TagUtil.getFunParams(dataGridUrl.getFunname()); + sb.append("href+=\""+urlfont.toString()+"\";"); + } + if (OptTypeDirection.OpenWin.equals(dataGridUrl.getType())) { + String funname = dataGridUrl.getFunname(); + if(oConvertUtils.isEmpty(funname)){ + funname = "openwindow"; + } + String dgFormWidth = dataGridUrl.getWidth(); + if("100%".equals(dgFormWidth)){ + dgFormWidth = "'"+dgFormWidth+"'"; + }else if(oConvertUtils.isEmpty(dgFormWidth)){ + dgFormWidth = "''"; + } + String dgFormHeight = dataGridUrl.getHeight(); + if("100%".equals(dgFormHeight)){ + dgFormHeight = "'"+dgFormHeight+"'"; + }else if(oConvertUtils.isEmpty(dgFormHeight)){ + dgFormHeight = "''"; + } + sb.append("href+=\""+urlfont.toString()+"\";"); + } + sb.append("href+=\"" + "" + " \";"); + if (StringUtil.isNotEmpty(exp)) { + for (int i = 0; i < exp.split("&&").length; i++) { + sb.append("}"); + } + } + } + if(!noReturn){ + sb.append("return href;"); + } + } + /** * 楂樼骇鏌ヨ鏋勯犲櫒 * @param sb */ private void addAdvancedQuery(StringBuffer sb,String buttonSytle) { - FreemarkerHelper free = new FreemarkerHelper(); + + /*FreemarkerHelper free = new FreemarkerHelper(); Map mainConfig = new HashMap(); mainConfig.put("queryCode", complexSuperQuery); mainConfig.put("tableName", name); String complexSuperQuery = free.parseTemplate("/org/jeecgframework/tag/ftl/complexSuperQuery.ftl", mainConfig); - appendLine(sb,complexSuperQuery); + appendLine(sb,complexSuperQuery);*/ + } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/FormValidationTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/FormValidationTag.java index 7795444c..c10d6bd9 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/FormValidationTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/FormValidationTag.java @@ -1,12 +1,15 @@ package org.jeecgframework.tag.core.easyui; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.TagSupport; +import org.apache.log4j.Logger; import org.jeecgframework.core.enums.SysThemesEnum; import org.jeecgframework.core.util.ContextHolderUtils; import org.jeecgframework.core.util.StringUtil; @@ -18,7 +21,9 @@ import org.jeecgframework.core.util.SysThemesUtil; * */ public class FormValidationTag extends TagSupport { + private static final Logger logger = Logger.getLogger(FormValidationTag.class); private static final long serialVersionUID = 8360534826228271024L; + protected String formid = "formobj";// 琛ㄥ崟FORM ID protected Boolean refresh = true; protected String callback;// 鍥炶皟鍑芥暟 @@ -81,6 +86,9 @@ public class FormValidationTag extends TagSupport { } public int doStartTag() throws JspException { + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //long start = System.currentTimeMillis(); + //logger.debug("=================Form=====doStartTag==========寮濮嬫椂闂:" + sdf.format(new Date()) + "=============================="); JspWriter out = null; try { out = this.pageContext.getOut(); @@ -124,11 +132,18 @@ public class FormValidationTag extends TagSupport { e2.printStackTrace(); } } + //long end = System.currentTimeMillis(); + //logger.debug("==============Form=====doStartTag=================缁撴潫鏃堕棿:" + sdf.format(new Date()) + "=============================="); + //logger.debug("===============Form=====doStartTag=================鑰楁椂:" + (end - start) + "ms=============================="); + return EVAL_PAGE; } public int doEndTag() throws JspException { + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + //long start = System.currentTimeMillis(); + //logger.debug("=================Form=====doEndTag==========寮濮嬫椂闂:" + sdf.format(new Date()) + "=============================="); StringBuffer sb = null; String lang = (String)((HttpServletRequest) this.pageContext.getRequest()).getSession().getAttribute("lang"); @@ -357,6 +372,10 @@ public class FormValidationTag extends TagSupport { } catch (Exception e2) { } } + + //long end = System.currentTimeMillis(); + //logger.debug("==============Form=====doEndTag=================缁撴潫鏃堕棿:" + sdf.format(new Date()) + "=============================="); + //logger.debug("===============Form=====doEndTag=================鑰楁椂:" + (end - start) + "ms=============================="); return EVAL_PAGE; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuButtonsTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuButtonsTag.java index 772b28a3..9a1dfafc 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuButtonsTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuButtonsTag.java @@ -23,6 +23,7 @@ import org.jeecgframework.web.system.service.SystemService; * @Title:MenuButtonTag * @description:鏂版潈闄怞SP鏍囩锛岄氳繃鏍囩鐨 鈥滄潈闄愭爣绀衡 鎺у埗浠g爜鐗囨鏄惁鍔犺浇 * @version V1.0 + * 銆愯埞鑸朵笓鐢ㄣ * 鏉冮檺鍒ゆ柇 name-code * 1.娌℃湁閰嶇疆鏉冮檺瑙勫垯 鍒欑洿鎺ュ姞杞 * 2.閰嶇疆浜嗕絾鏄病鏈夊嬀閫 涓嶅姞杞 @@ -311,14 +312,14 @@ public class MenuButtonsTag extends TagSupport{ */ private void addAdvancedQuery(StringBuffer sb,String queryCode,String tableName) { MenuButtonsEnum menu = MenuButtonsEnum.getMenuByCode("superQuery"); - sb.append(""); - - FreemarkerHelper free = new FreemarkerHelper(); + sb.append(""); + //onclick=\"superQuery('"+codes+"','"+tableName+"')\" + /*FreemarkerHelper free = new FreemarkerHelper(); Map mainConfig = new HashMap(); mainConfig.put("queryCode", queryCode); mainConfig.put("tableName", tableName); String complexSuperQuery = free.parseTemplate("/org/jeecgframework/tag/ftl/complexSuperQueryForPage.ftl", mainConfig); - appendLine(sb,complexSuperQuery); + appendLine(sb,complexSuperQuery);*/ } private void appendLine(StringBuffer sb,String str) { String format = "\r\n"; //璋冭瘯 鏍煎紡鍖 diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuTag.java index e217e5e9..bd78fb10 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/MenuTag.java @@ -71,9 +71,11 @@ public class MenuTag extends JeecgTag { // if(endString != null){ // endString.setLength(0); // } +// endString = null; //end().setLength(0); - } catch (Exception e2) { + } catch (Exception e) { + e.printStackTrace(); } } return EVAL_PAGE; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/TagUtil.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/TagUtil.java index c8ec8cad..c49bcf6b 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/TagUtil.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/TagUtil.java @@ -8,17 +8,21 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.log4j.Logger; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.jeecgframework.core.common.hibernate.qbc.PageList; import org.jeecgframework.core.common.model.json.ComboBox; import org.jeecgframework.core.common.model.json.DataGrid; +import org.jeecgframework.core.util.ContextHolderUtils; import org.jeecgframework.core.util.ReflectHelper; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; +import org.jeecgframework.tag.core.util.GzipUtilities; import org.jeecgframework.tag.vo.datatable.DataTableReturn; import org.jeecgframework.tag.vo.easyui.Autocomplete; import org.jeecgframework.web.system.pojo.base.TSRole; @@ -36,6 +40,8 @@ import com.alibaba.fastjson.JSONObject; * @author liuht 淇敼涓嶈兘杈撳叆鍙屽紩鍙烽棶棰樿В鍐 */ public class TagUtil { + private static Logger log = Logger.getLogger(TagUtil.class); + /** * Summary: getFiled(鑾峰緱瀹炰綋Bean涓墍鏈夊睘鎬) * @@ -235,6 +241,73 @@ public class TagUtil { return jsonTemp.toString(); } + /** + * 寰幆LIST瀵硅薄鎷兼帴EASYUI鏍煎紡鐨凧SON鏁版嵁Footers鏄痡son鏍煎紡鐨勬暟鎹 + * @param fields + * @param total + * @param list + * @param dataStyle + * @param page + */ + private static String listtojsonByFootersJson(String[] fields, int total, List> list,String footers, String dataStyle, int pageSize) throws Exception { + StringBuffer jsonTemp = new StringBuffer(); + if("jqgrid".equals(dataStyle)){ + int totalPage = total % pageSize > 0 ? total / pageSize + 1 : total / pageSize; + if(totalPage == 0) totalPage = 1; + jsonTemp.append("{\"total\":" + totalPage ); + }else{ + jsonTemp.append("{\"total\":" + total ); + } + jsonTemp.append(",\"rows\":["); + int i; + String fieldName; + if(list==null){ + list = new ArrayList(); + } + for (int j = 0; j < list.size(); ++j) { + jsonTemp.append("{\"state\":\"closed\","); + Object fieldValue = null; + for (i = 0; i < fields.length; ++i) { + fieldName = fields[i].toString(); + if (list.get(j) instanceof Map) + fieldValue = ((Map, ?>) list.get(j)).get(fieldName); + else { + fieldValue = fieldNametoValues(fieldName, list.get(j)); + } + jsonTemp.append("\"" + fieldName + "\"" + ":\"" + getStringValue(fieldValue).replace("\"", "\\\"") + "\""); + if (i != fields.length - 1) { + jsonTemp.append(","); + } + } + if (j != list.size() - 1) + jsonTemp.append("},"); + else { + jsonTemp.append("}"); + } + } + jsonTemp.append("]"); + if (footers != null) { + jsonTemp.append(","); + jsonTemp.append("\"footer\":["); + JSONArray js=JSONArray.parseArray(footers); + for(int f=0;fmap=(Map) js.get(f); + for(String key:map.keySet()){ + if(StringUtil.isEmpty(map.get(key).toString())){ + jsonTemp.append("\"" + key + "\":\"" + getTotalValue(key, list) + "\","); + }else{ + jsonTemp.append("\"" + key + "\":\"" + map.get(key).toString() + "\","); + } + } + jsonTemp.append("},"); + } + jsonTemp.append("]"); + } + jsonTemp.append("}"); + return jsonTemp.toString(); + } + //涓虹┖鏃惰繑鍥炵┖涓 private static String getStringValue(Object obj){ return (obj == null) ? "" : obj.toString(); @@ -343,7 +416,13 @@ public class TagUtil { try { if(!StringUtil.isEmpty(dg.getFooter())){ - jObject = JSONObject.parseObject(listtojson(dg.getField().split(","), dg.getTotal(), dg.getResults(),dg.getFooter().split(","),dg.getDataStyle(),dg.getRows())); + + if(dg.getFooter().startsWith("[")){ + jObject = JSONObject.parseObject(listtojsonByFootersJson(dg.getField().split(","), dg.getTotal(), dg.getResults(),dg.getFooter(),dg.getDataStyle(),dg.getRows())); + }else{ + jObject = JSONObject.parseObject(listtojson(dg.getField().split(","), dg.getTotal(), dg.getResults(),dg.getFooter().split(","),dg.getDataStyle(),dg.getRows())); + } + }else{ jObject = JSONObject.parseObject(listtojson(dg.getField().split(","), dg.getTotal(), dg.getResults(),null,dg.getDataStyle(),dg.getRows())); } @@ -479,15 +558,26 @@ public class TagUtil { response.setHeader("Cache-Control", "no-store"); JSONObject object = TagUtil.getJson(dg); PrintWriter pw = null; + try { - pw=response.getWriter(); + + HttpServletRequest request = ContextHolderUtils.getRequest(); + if (GzipUtilities.isGzipSupported(request) && !GzipUtilities.isGzipDisabled(request)) { + log.debug("-------datagrid----json-----寮鍚疓zip鍘嬬缉-------------"); + pw = GzipUtilities.getGzipWriter(response); + response.setHeader("Content-Encoding", "gzip"); + } else { + pw = response.getWriter(); + } + + pw.write(object.toString()); pw.flush(); + pw.close(); } catch (IOException e) { e.printStackTrace(); }finally{ try { - pw.close(); object.clear(); object = null; @@ -514,14 +604,23 @@ public class TagUtil { JSONArray rows = object.getJSONArray("rows"); PrintWriter pw = null; try { - pw=response.getWriter(); + + HttpServletRequest request = ContextHolderUtils.getRequest(); + if (GzipUtilities.isGzipSupported(request) && !GzipUtilities.isGzipDisabled(request)) { + log.info("-------datagrid----json-----寮鍚疓zip鍘嬬缉-------------"); + pw = GzipUtilities.getGzipWriter(response); + response.setHeader("Content-Encoding", "gzip"); + } else { + pw = response.getWriter(); + } + pw.write(rows.toString()); pw.flush(); + pw.close(); } catch (IOException e) { e.printStackTrace(); }finally{ try { - pw.close(); object.clear(); @@ -553,14 +652,23 @@ public class TagUtil { } PrintWriter pw = null; try { - pw=response.getWriter(); + + HttpServletRequest request = ContextHolderUtils.getRequest(); + if (GzipUtilities.isGzipSupported(request) && !GzipUtilities.isGzipDisabled(request)) { + log.debug("-------datagrid----json-----寮鍚疓zip鍘嬬缉-------------"); + pw = GzipUtilities.getGzipWriter(response); + response.setHeader("Content-Encoding", "gzip"); + } else { + pw = response.getWriter(); + } + pw.write(object.toString()); pw.flush(); + pw.close(); } catch (IOException e) { e.printStackTrace(); }finally{ try { - pw.close(); object.clear(); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/WebUploaderTag.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/WebUploaderTag.java index e859663c..a7c6c013 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/WebUploaderTag.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/easyui/WebUploaderTag.java @@ -33,7 +33,7 @@ public class WebUploaderTag extends TagSupport { private String buttonText;//鎺т欢鎸夐挳鏄剧ず鏂囨湰 private String extensions;//鍏佽鐨勬枃浠跺悗缂锛屼笉甯︾偣锛屽涓敤閫楀彿鍒嗗壊 private String extendParams;//绫讳技css鍐欐硶 杩欐槸鏂囦欢涓婁紶鏃跺欓渶瑕佷紶閫掔殑鍙傛暟 - private String dataType;//鍙璇ュ睘鎬ф湁鍊,鍧囪涔嬩负涓嶄负绌 + private String datatype;//鍙璇ュ睘鎬ф湁鍊,鍧囪涔嬩负涓嶄负绌 private String nullMsg;//绌虹殑鏃跺欑殑鎻愮ず淇℃伅,榛樿浼氭牴鎹綋鍓嶆帶浠剁殑绫诲瀷鎻愮ず,鏂囦欢绫诲垯鎻愮ず鈥滆閫夋嫨鏂囦欢鈥;鍥剧墖绫诲垯鎻愮ず鈥滆閫夋嫨鍥剧墖鈥. private String readOnly="false";//淇濈暀瀛楁 private String bizType;//涓氬姟绫诲瀷,鏍规嵁璇ョ被鍨嬬‘瀹氫笂浼犺矾寰 @@ -150,8 +150,8 @@ public class WebUploaderTag extends TagSupport { //鑾峰彇鏂囦欢鍚 sb.append("\r\nvar mygetFileName=function(filepath){if(filepath.lastIndexOf('\\\\')>0){return filepath.substring(filepath.lastIndexOf('\\\\')+1);\r\n}else if(filepath.lastIndexOf('/')>0){return filepath.substring(filepath.lastIndexOf('/')+1);}else{return filepath;}}"); //濡傛灉dataType鏈夊 - if(oConvertUtils.isNotEmpty(dataType)){ - sb.append("\r\n$('#"+name+"uploader').find('div.btns').append('');"); + if(oConvertUtils.isNotEmpty(datatype)){ + sb.append("\r\n$('#"+name+"uploader').find('div.btns').append('');"); } sb.append("\r\nvar reset_"+name+"_dataTypeInpVal=function(addOrdel){var obj = $(\"#" + name + "dataTypeInp\");if(obj.length>0){var objval=obj.val()||'';\r\nif (addOrdel == 1) {if(objval==''){obj.val('1');}else{obj.val(objval.toString()+(parseInt(objval.length)+1));}}else{if(objval.length <=1){obj.val('');}else{obj.val(objval.substr(0,objval.length-1));\r\n}\r\n}obj.blur();}}"); //璁剧疆榛樿鍊 @@ -372,11 +372,11 @@ public class WebUploaderTag extends TagSupport { public void setExtensions(String extensions) { this.extensions = extensions; } - public String getDataType() { - return dataType; + public String getDatatype() { + return datatype; } - public void setDataType(String dataType) { - this.dataType = dataType; + public void setDatatype(String datatype) { + this.datatype = datatype; } public String getNullMsg() { if(oConvertUtils.isEmpty(nullMsg)){ diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable.ftl b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable.ftl index 4ccf4b49..acc1b968 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable.ftl +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable.ftl @@ -9,7 +9,7 @@ <#list dataGrid.columnList as po> <#if po.query==true> - <#include "bootstrapTable-search.ftl"> + <#include "/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable-search.ftl"> #if> #list> @@ -129,12 +129,12 @@ } <#list dataGrid.columnList as po> <#if po.field!="opt"> - <#include "bootstrapTable-column.ftl"> + <#include "/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable-column.ftl"> <#else> ,{ title: "鎿嶄綔",align: 'center',valign: 'middle',width: ${po.width}, formatter: function (value, row, index) { - <#include "bootstrapTable-opt.ftl"> + <#include "/org/jeecgframework/tag/core/factory/ftl/component/bootstrapTable-opt.ftl"> } } #if> diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/util/ComponentTools.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/util/ComponentTools.java index 26f0627c..26ee5b2d 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/util/ComponentTools.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/factory/util/ComponentTools.java @@ -93,23 +93,24 @@ public class ComponentTools { urlclass.append("\'"); } StringBuffer urlfont = new StringBuffer(); + if(!StringUtil.isEmpty(dataGridUrl.getUrlfont())){ - urlfont.append(" "); + urlfont.append("\' aria-hidden=\'true\'>"); } if (OptTypeDirection.Confirm.equals(dataGridUrl.getType())) { if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){ - sb.append("href+=\" "+urlfont.toString()+" \";"); + sb.append("href+=\" "+urlfont.toString()+" \";"); }else{ - sb.append("href+=\" \";"); + sb.append("href+=\" \";"); } } if (OptTypeDirection.Del.equals(dataGridUrl.getType())) { if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){//鍊樿嫢urlclass涓嶄负绌猴紝鍒欏幓鎺夐摼鎺ュ墠闈㈢殑"["; - sb.append("href+=\" "+urlfont.toString()+" \";"); + sb.append("href+=\" "+urlfont.toString()+" \";"); }else{ - sb.append("href+=\"\";"); + sb.append("href+=\"\";"); } } @@ -117,31 +118,31 @@ public class ComponentTools { String name = TagUtil.getFunction(dataGridUrl.getFunname()); String parmars = getFunParams(dataGridUrl.getFunname()); if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){//鍊樿嫢urlclass涓嶄负绌猴紝鍒欏幓鎺夐摼鎺ュ墠闈㈢殑"["; - sb.append("href+=\" "+urlfont.toString()+" \";"); + sb.append("href+=\" "+urlfont.toString()+" \";"); }else{ - sb.append("href+=\"\";"); + sb.append("href+=\"\";"); } } if (OptTypeDirection.OpenWin.equals(dataGridUrl.getType())) { if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){//鍊樿嫢urlclass涓嶄负绌猴紝鍒欏幓鎺夐摼鎺ュ墠闈㈢殑"["; - sb.append("href+=\" "+urlfont.toString()+" \";"); + sb.append("href+=\" "+urlfont.toString()+" \";"); }else{ - sb.append("href+=\"\";"); + sb.append("href+=\"\";"); } } //update-end--Author:liuht Date:20130228 for锛氬脊鍑虹獥鍙h缃弬鏁颁笉鐢熸晥 if (OptTypeDirection.Deff.equals(dataGridUrl.getType())) { if(!StringUtil.isEmpty(dataGridUrl.getUrlclass())){ - sb.append("href+=\" "+urlfont.toString()+" \";"); + sb.append("href+=\" "+urlfont.toString()+" \";"); }else{ - sb.append("href+=\"\";"); + sb.append("href+=\"\";"); } } if (OptTypeDirection.OpenTab.equals(dataGridUrl.getType())) { - sb.append("href+=\"\";"); + sb.append("href+=\"\";"); } - sb.append("href+=\"" + dataGridUrl.getTitle() + " \";"); - + sb.append("href+=\"" + dataGridUrl.getTitle() + " \";"); + if (StringUtil.isNotEmpty(exp)) { for (int i = 0; i < exp.split("&&").length; i++) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/core/util/GzipUtilities.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/util/GzipUtilities.java new file mode 100644 index 00000000..82097a38 --- /dev/null +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/core/util/GzipUtilities.java @@ -0,0 +1,24 @@ +package org.jeecgframework.tag.core.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.zip.GZIPOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class GzipUtilities { + + public static boolean isGzipSupported(HttpServletRequest request) { + String encodings = request.getHeader("Accept-Encoding"); + return ((encodings != null) && (encodings.indexOf("gzip") != -1)); + } + + public static boolean isGzipDisabled(HttpServletRequest request) { + String flag = request.getParameter("disableGzip"); + return ((flag != null) && (!flag.equalsIgnoreCase("false"))); + } + + public static PrintWriter getGzipWriter(HttpServletResponse response) throws IOException { + return (new PrintWriter(new GZIPOutputStream(response.getOutputStream()))); + } +} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridColumn.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridColumn.java index 659e0522..e72aa7b0 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridColumn.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridColumn.java @@ -51,7 +51,10 @@ public class DataGridColumn { protected String showMode;//琛ㄥ崟鍏冪礌,鏌ヨ琛ㄥ崟涓樉绀烘牱寮,榛樿鏍峰紡select protected boolean newColumn; - + + private String filterType = "text";//杩囨护鎿嶄綔鐨勭被鍨 + private boolean optsMenu = false;//鎿嶄綔鍒楅鏍艰浆鍙 + public boolean isNewColumn() { return newColumn; } @@ -330,6 +333,20 @@ public class DataGridColumn { this.defaultVal = defaultVal; } + public String getFilterType() { + return filterType; + } + public void setFilterType(String filterType) { + this.filterType = filterType; + } + + public boolean isOptsMenu() { + return optsMenu; + } + public void setOptsMenu(boolean optsMenu) { + this.optsMenu = optsMenu; + } + @Override public String toString() { return "DataGridColumn [title=" + title + ", field=" + field + ", width=" + width + ", showLen=" + showLen + ", rowspan=" + rowspan + ", colspan=" + colspan + diff --git a/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridUrl.java b/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridUrl.java index 94a6f8e0..460f45b5 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridUrl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/tag/vo/easyui/DataGridUrl.java @@ -28,6 +28,8 @@ public class DataGridUrl { private String operationCode;//鎸夐挳鐨勬搷浣淐ode + private boolean inGroup = false; + public String getOnclick() { return onclick; } @@ -163,6 +165,14 @@ public class DataGridUrl { this.id = id; } + public boolean isInGroup() { + return inGroup; + } + + public void setInGroup(boolean inGroup) { + this.inGroup = inGroup; + } + @Override public String toString() { return "DataGridUrl [url=" + url + ", title=" + title + ", icon=" + icon + ", value=" + value + ", width=" + width + ", height=" + height + diff --git a/jeecg-framework/src/main/java/com/jeecg/black/controller/TsBlackListController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/black/controller/TsBlackListController.java similarity index 95% rename from jeecg-framework/src/main/java/com/jeecg/black/controller/TsBlackListController.java rename to jeecg-framework/src/main/java/org/jeecgframework/web/black/controller/TsBlackListController.java index 015d3697..d0aa0088 100644 --- a/jeecg-framework/src/main/java/com/jeecg/black/controller/TsBlackListController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/black/controller/TsBlackListController.java @@ -1,4 +1,4 @@ -package com.jeecg.black.controller; +package org.jeecgframework.web.black.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -39,6 +39,7 @@ import org.jeecgframework.web.system.pojo.base.InterfaceRuleDto; import org.jeecgframework.web.system.service.SystemService; import org.jeecgframework.web.system.util.InterfaceUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -51,8 +52,8 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; -import com.jeecg.black.entity.TsBlackListEntity; -import com.jeecg.black.service.TsBlackListServiceI; +import org.jeecgframework.web.black.entity.TsBlackListEntity; +import org.jeecgframework.web.black.service.TsBlackListServiceI; /** * @Title: Controller @@ -87,7 +88,7 @@ public class TsBlackListController extends BaseController { */ @RequestMapping(params = "list") public ModelAndView list(HttpServletRequest request) { - return new ModelAndView("com/jeecg/black/tsBlackListList"); + return new ModelAndView("jeecg/black/tsBlackListList"); } /** @@ -182,6 +183,11 @@ public class TsBlackListController extends BaseController { try{ tsBlackListService.save(tsBlackList); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); + + }catch(DataIntegrityViolationException ce){ + j.setSuccess(false); + message = "璇P:"+tsBlackList.getIp()+"宸插瓨鍦!"; + }catch(Exception e){ e.printStackTrace(); message = "榛戝悕鍗曟坊鍔犲け璐"; @@ -208,7 +214,12 @@ public class TsBlackListController extends BaseController { MyBeanUtils.copyBeanNotNull2Bean(tsBlackList, t); tsBlackListService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); - } catch (Exception e) { + + } catch(DataIntegrityViolationException ce){ + j.setSuccess(false); + message = "璇P:"+tsBlackList.getIp()+"宸插瓨鍦!"; + + }catch (Exception e) { e.printStackTrace(); message = "榛戝悕鍗曟洿鏂板け璐"; throw new BusinessException(e.getMessage()); @@ -229,7 +240,7 @@ public class TsBlackListController extends BaseController { tsBlackList = tsBlackListService.getEntity(TsBlackListEntity.class, tsBlackList.getId()); req.setAttribute("tsBlackListPage", tsBlackList); } - return new ModelAndView("com/jeecg/black/tsBlackList-add"); + return new ModelAndView("jeecg/black/tsBlackList-add"); } /** * 榛戝悕鍗曠紪杈戦〉闈㈣烦杞 @@ -242,7 +253,7 @@ public class TsBlackListController extends BaseController { tsBlackList = tsBlackListService.getEntity(TsBlackListEntity.class, tsBlackList.getId()); req.setAttribute("tsBlackListPage", tsBlackList); } - return new ModelAndView("com/jeecg/black/tsBlackList-update"); + return new ModelAndView("jeecg/black/tsBlackList-update"); } /** diff --git a/jeecg-framework/src/main/java/com/jeecg/black/entity/TsBlackListEntity.java b/jeecg-framework/src/main/java/org/jeecgframework/web/black/entity/TsBlackListEntity.java similarity index 99% rename from jeecg-framework/src/main/java/com/jeecg/black/entity/TsBlackListEntity.java rename to jeecg-framework/src/main/java/org/jeecgframework/web/black/entity/TsBlackListEntity.java index a8a169e1..3f214089 100644 --- a/jeecg-framework/src/main/java/com/jeecg/black/entity/TsBlackListEntity.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/black/entity/TsBlackListEntity.java @@ -1,4 +1,4 @@ -package com.jeecg.black.entity; +package org.jeecgframework.web.black.entity; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/jeecg-framework/src/main/java/com/jeecg/black/service/TsBlackListServiceI.java b/jeecg-framework/src/main/java/org/jeecgframework/web/black/service/TsBlackListServiceI.java similarity index 77% rename from jeecg-framework/src/main/java/com/jeecg/black/service/TsBlackListServiceI.java rename to jeecg-framework/src/main/java/org/jeecgframework/web/black/service/TsBlackListServiceI.java index d5b31efb..c90cb051 100644 --- a/jeecg-framework/src/main/java/com/jeecg/black/service/TsBlackListServiceI.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/black/service/TsBlackListServiceI.java @@ -1,5 +1,5 @@ -package com.jeecg.black.service; -import com.jeecg.black.entity.TsBlackListEntity; +package org.jeecgframework.web.black.service; +import org.jeecgframework.web.black.entity.TsBlackListEntity; import org.jeecgframework.core.common.service.CommonService; import java.io.Serializable; diff --git a/jeecg-framework/src/main/java/com/jeecg/black/service/impl/TsBlackListServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/black/service/impl/TsBlackListServiceImpl.java similarity index 96% rename from jeecg-framework/src/main/java/com/jeecg/black/service/impl/TsBlackListServiceImpl.java rename to jeecg-framework/src/main/java/org/jeecgframework/web/black/service/impl/TsBlackListServiceImpl.java index b13f0c2b..b28fc552 100644 --- a/jeecg-framework/src/main/java/com/jeecg/black/service/impl/TsBlackListServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/black/service/impl/TsBlackListServiceImpl.java @@ -1,7 +1,7 @@ -package com.jeecg.black.service.impl; -import com.jeecg.black.service.TsBlackListServiceI; +package org.jeecgframework.web.black.service.impl; +import org.jeecgframework.web.black.service.TsBlackListServiceI; import org.jeecgframework.core.common.service.impl.CommonServiceImpl; -import com.jeecg.black.entity.TsBlackListEntity; +import org.jeecgframework.web.black.entity.TsBlackListEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphConfigHeadController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphConfigHeadController.java index c4eac1a1..b628e216 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphConfigHeadController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphConfigHeadController.java @@ -30,7 +30,7 @@ import org.springframework.web.servlet.ModelAndView; /** * @Title: Controller - * @Description: Online绉诲姩鎶ヨ〃閰嶇疆鍔熻兘 + * @Description: Online绉诲姩鍥捐〃閰嶇疆 * @author scott * @date 2016-01-10 16:00:21 * @version V1.0 @@ -52,7 +52,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { /** - * 鍔ㄦ佹姤琛ㄩ厤缃姮澶村垪琛 椤甸潰璺宠浆 + * 绉诲姩鍥捐〃閰嶇疆鎶ご鍒楄〃 椤甸潰璺宠浆 * * @return */ @@ -86,7 +86,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鍒犻櫎鍔ㄦ佹姤琛ㄩ厤缃姮澶 + * 鍒犻櫎绉诲姩鍥捐〃閰嶇疆鎶ご * * @return */ @@ -96,14 +96,14 @@ public class CgDynamGraphConfigHeadController extends BaseController { String message = null; AjaxJson j = new AjaxJson(); cgDynamGraphConfigHead = systemService.getEntity(CgDynamGraphConfigHeadEntity.class, cgDynamGraphConfigHead.getId()); - message = "鍔ㄦ佹姤琛ㄩ厤缃姮澶村垹闄ゆ垚鍔"; + message = "绉诲姩鍥捐〃閰嶇疆鎶ご鍒犻櫎鎴愬姛"; try{ cgDynamGraphConfigHeadService.delMain(cgDynamGraphConfigHead); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); logger.info("["+IpUtil.getIpAddr(request)+"][online绉诲姩鍥捐〃鍒犻櫎]["+cgDynamGraphConfigHead.getCode()+"]"+message); }catch(Exception e){ e.printStackTrace(); - message = "鍔ㄦ佹姤琛ㄩ厤缃姮澶村垹闄ゅけ璐"; + message = "绉诲姩鍥捐〃閰嶇疆鎶ご鍒犻櫎澶辫触"; throw new BusinessException(e.getMessage()); } j.setMsg(message); @@ -111,7 +111,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鎵归噺鍒犻櫎鍔ㄦ佹姤琛ㄩ厤缃姮澶 + * 鎵归噺鍒犻櫎绉诲姩鍥捐〃閰嶇疆鎶ご * * @return */ @@ -120,7 +120,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { public AjaxJson doBatchDel(String ids,HttpServletRequest request){ String message = null; AjaxJson j = new AjaxJson(); - message = "鍔ㄦ佹姤琛ㄩ厤缃姮澶村垹闄ゆ垚鍔"; + message = "绉诲姩鍥捐〃閰嶇疆鎶ご鍒犻櫎鎴愬姛"; try{ for(String id:ids.split(",")){ CgDynamGraphConfigHeadEntity cgDynamGraphConfigHead = systemService.getEntity(CgDynamGraphConfigHeadEntity.class, id); @@ -130,7 +130,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } }catch(Exception e){ e.printStackTrace(); - message = "鍔ㄦ佹姤琛ㄩ厤缃姮澶村垹闄ゅけ璐"; + message = "绉诲姩鍥捐〃閰嶇疆鎶ご鍒犻櫎澶辫触"; throw new BusinessException(e.getMessage()); } j.setMsg(message); @@ -138,7 +138,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 娣诲姞鍔ㄦ佹姤琛ㄩ厤缃姮澶 + * 娣诲姞绉诲姩鍥捐〃閰嶇疆鎶ご * * @param ids * @return @@ -157,14 +157,14 @@ public class CgDynamGraphConfigHeadController extends BaseController { logger.info("["+IpUtil.getIpAddr(request)+"][online绉诲姩鍥捐〃褰曞叆]["+cgDynamGraphConfigHead.getCode()+"]"+message); }catch(Exception e){ e.printStackTrace(); - message = "鍔ㄦ佹姤琛ㄩ厤缃姮澶存坊鍔犲け璐"; + message = "绉诲姩鍥捐〃閰嶇疆鎶ご娣诲姞澶辫触"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } /** - * 鏇存柊鍔ㄦ佹姤琛ㄩ厤缃姮澶 + * 鏇存柊绉诲姩鍥捐〃閰嶇疆鎶ご * * @param ids * @return @@ -183,7 +183,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { logger.info("["+IpUtil.getIpAddr(request)+"][online绉诲姩鍥捐〃鏇存柊]["+cgDynamGraphConfigHead.getCode()+"]"+message); }catch(Exception e){ e.printStackTrace(); - message = "鏇存柊鍔ㄦ佹姤琛ㄩ厤缃姮澶村け璐"; + message = "鏇存柊绉诲姩鍥捐〃閰嶇疆鎶ご澶辫触"; throw new BusinessException(e.getMessage()); } j.setMsg(message); @@ -191,7 +191,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鍔ㄦ佹姤琛ㄩ厤缃姮澶存柊澧為〉闈㈣烦杞 + * 绉诲姩鍥捐〃閰嶇疆鎶ご鏂板椤甸潰璺宠浆 * * @return */ @@ -205,7 +205,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鍔ㄦ佹姤琛ㄩ厤缃姮澶寸紪杈戦〉闈㈣烦杞 + * 绉诲姩鍥捐〃閰嶇疆鎶ご缂栬緫椤甸潰璺宠浆 * * @return */ @@ -219,7 +219,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鍔犺浇鏄庣粏鍒楄〃[鍔ㄦ佹姤琛ㄩ厤缃槑缁哴 + * 鍔犺浇鏄庣粏鍒楄〃[绉诲姩鍥捐〃閰嶇疆鏄庣粏] * * @return */ @@ -230,7 +230,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { //鑾峰彇鍙傛暟 Object id0 = cgDynamGraphConfigHead.getId(); //=================================================================================== - //鏌ヨ-鍔ㄦ佹姤琛ㄩ厤缃槑缁 + //鏌ヨ-绉诲姩鍥捐〃閰嶇疆鏄庣粏 String hql0 = "from CgDynamGraphConfigItemEntity where 1 = 1 AND cgrheadId = ? "; try{ List cgDynamGraphConfigItemEntityList = systemService.findHql(hql0,id0); @@ -242,7 +242,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { } /** - * 鍔犺浇鍙傛暟鍒楄〃[鍔ㄦ佹姤琛ㄥ弬鏁癩 + * 鍔犺浇鍙傛暟鍒楄〃[绉诲姩鍥捐〃鍙傛暟] * * @return */ @@ -253,7 +253,7 @@ public class CgDynamGraphConfigHeadController extends BaseController { //鑾峰彇鍙傛暟 Object id0 = cgDynamGraphConfigHead.getId(); //=================================================================================== - //鏌ヨ-鍔ㄦ佹姤琛ㄩ厤缃槑缁 + //鏌ヨ-绉诲姩鍥捐〃閰嶇疆鏄庣粏 String hql0 = "from CgDynamGraphConfigParamEntity where 1 = 1 AND cgrheadId = ? "; try{ List cgDynamGraphConfigParamEntityList = systemService.findHql(hql0,id0); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphController.java index 55efc6fa..98b3f46c 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/controller/CgDynamGraphController.java @@ -8,9 +8,6 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -18,7 +15,6 @@ import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.jeecgframework.core.common.controller.BaseController; -import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.enums.SysThemesEnum; import org.jeecgframework.core.online.def.CgReportConstant; import org.jeecgframework.core.online.exception.CgReportNotFoundException; @@ -26,11 +22,12 @@ import org.jeecgframework.core.online.util.CgReportQueryParamUtil; import org.jeecgframework.core.online.util.FreemarkerHelper; import org.jeecgframework.core.util.ContextHolderUtils; import org.jeecgframework.core.util.DynamicDBUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.SqlUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.SysThemesUtil; -import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.web.cgdynamgraph.service.core.CgDynamGraphServiceI; +import org.jeecgframework.web.cgreport.service.core.CgReportServiceI; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -49,6 +46,8 @@ import org.springframework.web.bind.annotation.ResponseBody; public class CgDynamGraphController extends BaseController { @Autowired private CgDynamGraphServiceI cgDynamGraphService; + @Autowired + private CgReportServiceI cgReportService; @RequestMapping(params = "design") public void design(String id, HttpServletRequest request,String gtype, @@ -136,7 +135,7 @@ public class CgDynamGraphController extends BaseController { fl.put(CgReportConstant.ITEM_FIELDNAME, ((String)fl.get(CgReportConstant.ITEM_FIELDNAME)).toLowerCase()); String isQuery = (String) fl.get(CgReportConstant.ITEM_ISQUERY); if(CgReportConstant.BOOL_TRUE.equalsIgnoreCase(isQuery)){ - loadDic(fl,fl); + cgReportService.loadDic(fl); queryList.add(fl); } } @@ -160,68 +159,6 @@ public class CgDynamGraphController extends BaseController { } - /** - * 澶勭悊鏁版嵁瀛楀吀 - * @param result 鏌ヨ鐨勭粨鏋滈泦 - * @param beans 瀛楁閰嶇疆 - */ - @SuppressWarnings("unchecked") - private void dealDic(List> result, - List> beans) { - for(Map bean:beans){ - String dict_code = (String) bean.get(CgReportConstant.ITEM_DICCODE); - if(StringUtil.isEmpty(dict_code)){ - //涓嶉渶瑕佸鐞嗗瓧鍏 - continue; - }else{ - List> dicDatas = queryDic(dict_code); - for(Map r:result){ - String value = String.valueOf(r.get(bean.get(CgReportConstant.ITEM_FIELDNAME))); - for(Map m:dicDatas){ - String typecode = String.valueOf(m.get("typecode")); - String typename = String.valueOf(m.get("typename")); - if(value.equalsIgnoreCase(typecode)){ - r.put(bean.get(CgReportConstant.ITEM_FIELDNAME),typename); - } - } - } - } - } - } - /** - * 澶勭悊鍙栧艰〃杈惧紡 - * @param result - * @param beans - */ - @SuppressWarnings("unchecked") - private void dealReplace(List> result, - List> beans){ - for(Map bean:beans){ - try{ - //鑾峰彇鍙栧艰〃杈惧紡 - String replace = (String) bean.get(CgReportConstant.ITEM_REPLACE); - if(StringUtil.isEmpty(replace)){ - continue; - } - String[] groups = replace.split(","); - for(String g:groups){ - String[] items = g.split("_"); - String v = items[0];//閫昏緫鍒ゆ柇鍊 - String txt = items[1];//瑕佽浆鎹㈢殑鏂囨湰 - for(Map r:result){ - String value = String.valueOf(r.get(bean.get(CgReportConstant.ITEM_FIELDNAME))); - if(value.equalsIgnoreCase(v)){ - r.put(bean.get(CgReportConstant.ITEM_FIELDNAME),txt); - } - } - } - }catch (Exception e) { - //杩欓噷鍑虹幇寮傚父鍘熷洜鏄洜涓哄彇鍊艰〃杈惧紡涓嶆纭 - e.printStackTrace(); - throw new BusinessException("鍙栧艰〃杈惧紡涓嶆纭"); - } - } - } /** * 鍔ㄦ佹姤琛ㄦ暟鎹煡璇 * @param configId 閰嶇疆id-code @@ -254,6 +191,9 @@ public class CgDynamGraphController extends BaseController { for(String param :paramList){ String value = request.getParameter(param); value = value==null?"":value; + + SqlInjectionUtil.filterContent(value); + querySql = querySql.replace("${"+param+"}", value); } }else{ @@ -285,8 +225,8 @@ public class CgDynamGraphController extends BaseController { size = cgDynamGraphService.countQueryByCgDynamGraphSql(querySql, queryparams); } - dealDic(result,items); - dealReplace(result,items); + cgReportService.dealDic(result,items); + cgReportService.dealReplace(result,items); response.setContentType("application/json"); response.setHeader("Cache-Control", "no-store"); PrintWriter writer = null; @@ -317,8 +257,8 @@ public class CgDynamGraphController extends BaseController { List params = null; Map reJson = new HashMap(); try{ - fields = getFields(sql, dbKey); - params = getSqlParams(sql); + fields = cgReportService.getFields(sql, dbKey); + params = cgReportService.getSqlParams(sql); }catch (Exception e) { e.printStackTrace(); String errorInfo = "瑙f瀽澶辫触!澶辫触鍘熷洜锛"; @@ -342,90 +282,4 @@ public class CgDynamGraphController extends BaseController { return reJson; } - private List getFields(String sql,String dbKey){ - List fields = null; - sql = getSql(sql); - if(StringUtils.isNotBlank(dbKey)){ - List> dataList=DynamicDBUtil.findList(dbKey,SqlUtil.jeecgCreatePageSql(dbKey,sql,null,1,1),null); - if(dataList.size()<1){ - throw new BusinessException("璇ユ姤琛╯ql娌℃湁鏁版嵁"); - } - Set fieldsSet= dataList.get(0).keySet(); - fields = new ArrayList(fieldsSet); - }else{ - fields = cgDynamGraphService.getSqlFields(sql); - } - return fields; - } - - private String getSql(String sql){ - String regex = "\\$\\{\\w+\\}"; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - //System.out.println(whereParam); - sql = sql.replace(whereParam, "'' or 1=1 or 1=''"); - sql = sql.replace("'''", "''"); - //System.out.println(sql); - } - //鍏煎鍥捐〃 - regex = "\\{\\w+\\}"; - p = Pattern.compile(regex); - m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - //System.out.println(whereParam); - sql = sql.replace(whereParam, " 1=1 "); - //System.out.println(sql); - } - return sql; - } - - public List getSqlParams(String sql) { - if(oConvertUtils.isEmpty(sql)){ - return null; - } - List params = new ArrayList(); - String regex = "\\$\\{\\w+\\}"; - - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - params.add(whereParam.substring(whereParam.indexOf("{")+1,whereParam.indexOf("}"))); - } - return params; - } - - - /** - * 瑁呰浇鏁版嵁瀛楀吀 - * @param m 瑕佹斁鍏reemarker鐨勬暟鎹 - * @param bean 璇诲彇鍑烘潵鐨勫姩鎬侀厤缃暟鎹 - */ - @SuppressWarnings("unchecked") - private void loadDic(Map m, Map cgDynamGraphMap) { - String dict_code = (String) cgDynamGraphMap.get("dict_code"); - if(StringUtil.isEmpty(dict_code)){ - m.put(CgReportConstant.FIELD_DICTLIST, new ArrayList(0)); - return; - } - List> dicDatas = queryDic(dict_code); - m.put(CgReportConstant.FIELD_DICTLIST, dicDatas); - } - /** - * 鏌ヨ鏁版嵁瀛楀吀 - * @param diccode 瀛楀吀缂栫爜 - * @return - */ - private List> queryDic(String diccode) { - StringBuilder dicSql = new StringBuilder(); - dicSql.append(" SELECT TYPECODE,TYPENAME FROM"); - dicSql.append(" "+CgReportConstant.SYS_DIC); - dicSql.append(" "+"WHERE TYPEGROUPID = "); - dicSql.append(" "+"(SELECT ID FROM "+CgReportConstant.SYS_DICGROUP+" WHERE TYPEGROUPCODE = '"+diccode+"' )"); - List> dicDatas = cgDynamGraphService.findForJdbc(dicSql.toString()); - return dicDatas; - } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/engine/core/cgDynamGraphDesign.ftl b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/engine/core/cgDynamGraphDesign.ftl index dc44b719..c8986651 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/engine/core/cgDynamGraphDesign.ftl +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/engine/core/cgDynamGraphDesign.ftl @@ -266,7 +266,7 @@ <#if x['search_mode']=="single"> <#if (x['field_dictlist']?size >0)> - -- 璇烽夋嫨 -- + <#list x['field_dictlist'] as xd> ${xd['typename']} #list> diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphItems.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphItems.sql index ae7028e3..66499203 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphItems.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphItems.sql @@ -13,5 +13,5 @@ ci.cgrhead_id as cgreport_head_id from jform_cgdynamgraph_item ci,jform_cgdynamgraph_head ch where 1=1 and ci.cgrhead_id = ch.id -and ch.code = '${configId}' +and ch.code = :configId order by ci.order_num asc \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphMainConfig.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphMainConfig.sql index 11e21e2f..f4ff34eb 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphMainConfig.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgdynamgraph/sql/core/CgDynamGraphDao_queryCgDynamGraphMainConfig.sql @@ -7,4 +7,4 @@ ch.content as content, ch.db_source, ch.graph_type from jform_cgdynamgraph_head ch -where ch.code = '${id}' \ No newline at end of file +where ch.code = :id \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/CgAutoListConstant.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/CgAutoListConstant.java index b4281b9d..3c74e126 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/CgAutoListConstant.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/CgAutoListConstant.java @@ -171,4 +171,10 @@ public class CgAutoListConstant { public static final String BASEPATH = "basePath"; + + //===============Online寮鍙戞潈闄恵閽堝sql鏁忔劅鎿嶄綔}================= + /** 1锛 鏈夊湪绾垮紑鍙戞潈闄 */ + public static final String SYS_DEV_FLAG_1 = "1"; + /** 0锛 鏃犲湪绾垮紑鍙戞潈闄 */ + public static final String SYS_DEV_FLAG_0 = "0"; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml index 90072f03..e5953c3a 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/common/spring-mvc-cgform.xml @@ -13,6 +13,8 @@ + + @@ -28,6 +30,8 @@ + + diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/autolist/CgAutoListController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/autolist/CgAutoListController.java index 8d834292..97767529 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/autolist/CgAutoListController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/autolist/CgAutoListController.java @@ -27,6 +27,7 @@ import org.jeecgframework.core.util.IpUtil; import org.jeecgframework.core.util.JeecgDataAutorUtils; import org.jeecgframework.core.util.MutiLangUtil; import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.SysThemesUtil; import org.jeecgframework.core.util.oConvertUtils; @@ -183,11 +184,12 @@ public class CgAutoListController extends BaseController{ * @param request * @param response * @param dataGrid + * @throws Exception */ @SuppressWarnings("unchecked") @RequestMapping(params = "datagrid") public void datagrid(String configId,String page,String field,String rows,String sort,String order, HttpServletRequest request, - HttpServletResponse response, DataGrid dataGrid) { + HttpServletResponse response, DataGrid dataGrid) throws Exception { Object dataRuleSql =JeecgDataAutorUtils.loadDataSearchConditonSQLString(); //request.getAttribute(Globals.MENU_DATA_AUTHOR_RULE_SQL); long start = System.currentTimeMillis(); //step.1 鑾峰彇鍔ㄦ侀厤缃 @@ -220,6 +222,9 @@ public class CgAutoListController extends BaseController{ if("null".equalsIgnoreCase(parentIdDefault)) { parentIdDefault = null; } + + SqlInjectionUtil.filterContent(treeId); + if(treeId == null) { treeId = parentIdDefault; }else { @@ -285,9 +290,19 @@ public class CgAutoListController extends BaseController{ } resultMap.put(b.getFieldName(), sb.toString().substring(0, sb.toString().length()-1)); } - + + } + } + + if("Blob".equals(b.getType())) { + for(Map resultMap:result){ + Object obj = resultMap.get(b.getFieldName()); + if(obj instanceof byte[]) { + resultMap.put(b.getFieldName(), new String((byte[])obj,"utf-8")); + } } } + } Long size = cgTableService.getQuerySingleSize(table, field, params); dealDic(result,beans); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgFormBuildController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgFormBuildController.java index 3e880d84..8e33bcc9 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgFormBuildController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgFormBuildController.java @@ -10,13 +10,14 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; import org.jeecgframework.core.common.controller.BaseController; import org.jeecgframework.core.common.model.json.AjaxJson; import org.jeecgframework.core.enums.SysThemesEnum; @@ -42,6 +43,8 @@ import org.jeecgframework.web.cgform.service.template.CgformTemplateServiceI; import org.jeecgframework.web.cgform.util.FillRuleUtil; import org.jeecgframework.web.cgform.util.PublicUtil; import org.jeecgframework.web.cgform.util.TemplateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -60,7 +63,8 @@ import freemarker.template.TemplateException; @Controller @RequestMapping("/cgFormBuildController") public class CgFormBuildController extends BaseController { - private static final Logger logger = Logger.getLogger(CgFormBuildController.class); + private static final Logger logger = LoggerFactory.getLogger(CgFormBuildController.class); + @Autowired private TempletContext templetContext; @Autowired @@ -97,8 +101,8 @@ public class CgFormBuildController extends BaseController { @RequestMapping(params = "mobileForm") public void mobileForm(HttpServletRequest request,HttpServletResponse response) { String tableName =request.getParameter("tableName"); - String sql = "select form_template_mobile from cgform_head where table_name = '"+tableName+"'"; - Map mp = cgFormFieldService.findOneForJdbc(sql); + String sql = "select form_template_mobile from cgform_head where table_name = ?"; + Map mp = cgFormFieldService.findOneForJdbc(sql,tableName); if(mp.containsKey("form_template_mobile") && oConvertUtils.isNotEmpty(mp.get("form_template_mobile"))){ String urlTemplateName=request.getParameter("olstylecode"); if(oConvertUtils.isEmpty(urlTemplateName)){ @@ -122,7 +126,51 @@ public class CgFormBuildController extends BaseController { } } + /** + * 杩囨护online鎵╁睍鍙傛暟涓璿alue灞炴 + * @param list 琛ㄥ崟鍒楅泦鍚 + */ + private void replaceExtendJson(List> list){ + if(list!=null && !list.isEmpty()){ + for (Map column : list) { + Object extendJson=column.get("extend_json"); + if(extendJson!=null && !extendJson.equals("")){ + String reg="value=\"[\\S]*\" "; + column.put("extend_json", extendJson.toString().replaceAll(reg,"")); + } + } + } + } + + + /** + * 璁剧疆椤甸潰瀛楀吀绫诲瀷鐨勯粯璁ゅ + * 绫诲瀷锛 select銆乧heckbox銆乺adio + * @param list + * @param dataForm + */ + private void initAddDictTagDefaultVal(List> list,Map dataForm){ + if(list!=null && !list.isEmpty()){ + for (Map column : list) { + Object extendJson = column.get("extend_json"); + Object show_type = column.get("show_type"); + if(oConvertUtils.isNotEmpty(extendJson) && oConvertUtils.isNotEmpty(show_type) && "radio|checkbox|list".contains(show_type.toString())){ + Pattern p = Pattern.compile("value=\"[\\S]*\" "); + Matcher m = p.matcher(extendJson.toString()); + String dfVal = ""; + while(m.find()) { + dfVal = m.group(); + } + dfVal = dfVal.replace("value=","").replace("\"","").trim(); + dataForm.put(column.get("field_name").toString(),dfVal); + logger.debug("--------------online娣诲姞椤甸潰瀛楀吀绫诲瀷榛樿鍊煎垵濮嬪寲----------field_name:{} ,dfVal:{} ,show_type :{}", column.get("field_name").toString(),dfVal,show_type.toString()); + } + } + } + } + + /** * form琛ㄥ崟椤甸潰璺宠浆 */ @@ -182,21 +230,27 @@ public class CgFormBuildController extends BaseController { Map dataForm = new HashMap(); if(StringUtils.isNotEmpty(id)){ - dataForm = dataBaseService.findOneForJdbc(tablename, id); - if(dataForm!=null){ - Iterator it=dataForm.entrySet().iterator(); - while(it.hasNext()){ - Map.Entry entry=(Map.Entry)it.next(); - String ok=(String)entry.getKey(); - Object ov=entry.getValue(); - data.put(ok, ov); - } - }else{ - logger.info("online琛ㄥ崟銆"+tablename+"銆戙"+id+"銆戜笉瀛樺湪"); - id = null; - dataForm = new HashMap(); - } + dataForm = dataBaseService.findOneForJdbc(tablename, id); + if(dataForm!=null){ + Iterator it=dataForm.entrySet().iterator(); + while(it.hasNext()){ + Map.Entry entry=(Map.Entry)it.next(); + String ok=(String)entry.getKey(); + Object ov=entry.getValue(); + + if(ov instanceof byte[]) { + ov=new String((byte[])ov,"utf-8"); + entry.setValue(ov); + } + + data.put(ok, ov); + } + }else{ + logger.info("online琛ㄥ崟銆"+tablename+"銆戙"+id+"銆戜笉瀛樺湪"); + id = null; + dataForm = new HashMap(); } + } //濡傛灉璇ヨ〃鏄富琛ㄦ煡鍑哄叧鑱旂殑闄勮〃 CgFormHeadEntity head = (CgFormHeadEntity)data.get("head"); @@ -205,6 +259,11 @@ public class CgFormBuildController extends BaseController { //鑾峰彇涓昏〃鎴栧崟琛ㄨ〃鍗曟暟鎹 if(StringUtils.isBlank(id)){ + + //Online娣诲姞椤甸潰锛宻elect\radio\checkbox 鏀寔榛樿鍊艰缃 + initAddDictTagDefaultVal((List>)data.get("columns"),dataForm); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); logger.info("============================濉艰鍒欏紑濮嬫椂闂:"+sdf.format(new Date())+"=============================="); long startTime = System.currentTimeMillis(); @@ -222,6 +281,10 @@ public class CgFormBuildController extends BaseController { CgSubTableVO subTableVO=(CgSubTableVO) field.get(subTable); subTableData=new ArrayList>(); subDataForm=new HashMap(); + + //Online娣诲姞椤甸潰锛宻elect\radio\checkbox鎺т欢锛 鏀寔榛樿鍊艰缃 + initAddDictTagDefaultVal((List>)subTableVO.getFieldList(),subDataForm); + putFormData(subTableVO.getFieldList(),subDataForm); putFormData(subTableVO.getHiddenFieldList(),subDataForm); subTableData.add(subDataForm); @@ -240,14 +303,25 @@ public class CgFormBuildController extends BaseController { //鑾峰彇闄勮〃琛ㄨ〃鍗曟暟鎹 if(StringUtils.isNotEmpty(id)){ + + //杩囨护鎵╁睍鍙傛暟value灞炴 + replaceExtendJson((List>) data.get("columns")); + replaceExtendJson((List>) data.get("columnhidden")); + if(head.getJformType()==CgAutoListConstant.JFORM_TYPE_MAIN_TALBE){ String subTableStr = head.getSubTableStr(); if(StringUtils.isNotEmpty(subTableStr)){ String [] subTables = subTableStr.split(","); List> subTableData = new ArrayList>(); + Map field = (Map) data.get("field"); for(String subTable:subTables){ - subTableData = cgFormFieldService.getSubTableData(tableName,subTable,id); - tableData.put(subTable, subTableData); + subTableData = cgFormFieldService.getSubTableData(tableName,subTable,id); + tableData.put(subTable, subTableData); + CgSubTableVO subTableVO=(CgSubTableVO) field.get(subTable); + + replaceExtendJson(subTableVO.getFieldList()); + replaceExtendJson(subTableVO.getHiddenFieldList()); + } } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgformSqlController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgformSqlController.java index 490a0638..b3fe5d63 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgformSqlController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/build/CgformSqlController.java @@ -29,6 +29,7 @@ import org.jeecgframework.core.util.IpUtil; import org.jeecgframework.core.util.LogUtil; import org.jeecgframework.core.util.ReflectHelper; import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.springframework.beans.BeanUtils; @@ -264,6 +265,9 @@ public class CgformSqlController extends BaseController { if(t instanceof CgFormHeadPojo){ reflectHelper.setMethodValue("isDbsynch", "N"); } + + SqlInjectionUtil.filterContent(dbTable.getTableName()); + id = (String) reflectHelper.getMethodValue("id"); countSql = "select id from "+ dbTable.getTableName() + " where id=?"; if(t instanceof CgFormHeadPojo){ diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/config/CgFormHeadController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/config/CgFormHeadController.java index 7b9e3775..f3dd90e0 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/config/CgFormHeadController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/config/CgFormHeadController.java @@ -251,8 +251,8 @@ public class CgFormHeadController extends BaseController { logger.info("---鍚屾鏁版嵁搴 ---doDbSynch-----> TableName:"+cgFormHead.getTableName()+" ---淇敼鏃堕棿 :"+cgFormHead.getUpdateDate()+" ----鍒涘缓鏃堕棿:"+cgFormHead.getCreateDate() +"---璇锋眰IP ---+"+oConvertUtils.getIpAddrByRequest(request)); //瀹夊叏鎺у埗锛屽垽鏂笉鍦╫nline绠$悊涓〃鍗曚笉鍏佽鎿嶄綔 - String sql = "select count(*) from cgform_head where table_name = '"+cgFormHead.getTableName()+"'"; - Long i = systemService.getCountForJdbc(sql); + String sql = "select count(*) from cgform_head where table_name = ?"; + Long i = systemService.getCountForJdbcParam(sql,cgFormHead.getTableName()); if(i==0){ message = "鍚屾澶辫触锛岄潪娉曟棤鎺堟潈璁块棶锛"; logger.info(message+" ----- 璇锋眰IP ---+"+IpUtil.getIpAddr(request)); @@ -260,8 +260,8 @@ public class CgFormHeadController extends BaseController { return j; } TSUser currentUser = ResourceUtil.getSessionUser(); - if("0".equals(currentUser.getDevFlag())){ - message = "鍚屾澶辫触锛屾偍涓嶆槸寮鍙戜汉鍛樻棤鎺堟潈璁块棶锛"; + if(CgAutoListConstant.SYS_DEV_FLAG_0.equals(currentUser.getDevFlag())){ + message = "鍚屾澶辫触锛屽綋鍓嶇敤鎴锋湭鎺堟潈寮鍙戞潈闄愶紒"; logger.info(message+" ----- 璇锋眰IP ---+"+IpUtil.getIpAddr(request)); j.setMsg(message); return j; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/template/CgformTemplateController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/template/CgformTemplateController.java index df0a4a91..6d244cc7 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/template/CgformTemplateController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/template/CgformTemplateController.java @@ -20,6 +20,7 @@ import jodd.io.ZipUtil; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; +import org.jeecgframework.core.annotation.JAuth; import org.jeecgframework.core.common.controller.BaseController; import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery; @@ -510,6 +511,7 @@ public class CgformTemplateController extends BaseController { * @param path * @param response */ + @JAuth @RequestMapping(params = "showPic") public void showPic(HttpServletRequest request,String code, String path,HttpServletResponse response){ String defaultPath="default.jpg"; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/upload/CgUploadController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/upload/CgUploadController.java index efe70a2f..1fb940dc 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/upload/CgUploadController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/controller/upload/CgUploadController.java @@ -34,7 +34,6 @@ import org.jeecgframework.core.util.ResourceUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.RequestMapping; @@ -136,10 +135,8 @@ public class CgUploadController extends BaseController { boolean updateFlag = false; if(path.equals(realPath)){ //鑾峰彇杩欎釜鍏宠仈鐨勫叾浠栨枃浠朵俊鎭 - String hql = "from CgUploadEntity where cgformId = '"+file.getCgformId()+"' " - + " and cgformField = '"+file.getCgformField()+"' " - + " and cgformName = '"+file.getCgformName()+"'"; - List uploadList = systemService.findHql(hql); + String hql = "from CgUploadEntity where cgformId = ? and cgformField = ? and cgformName = ?"; + List uploadList = systemService.findHql(hql,file.getCgformId(),file.getCgformField(),file.getCgformName()); if(uploadList != null && !uploadList.isEmpty() && uploadList.size() > 1){ for (CgUploadEntity cgUploadEntity : uploadList) { if(!file.getId().equals(cgUploadEntity.getId())){ diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/autolist/autolist.ftl b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/autolist/autolist.ftl index 9a5eccef..f39a2ea4 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/autolist/autolist.ftl +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/autolist/autolist.ftl @@ -353,7 +353,7 @@ function createDataGrid${config_id}(){ <#if x['field_isQuery']=="Y"> <#if (x['field_dictlist']?size >0)> - -- 璇烽夋嫨 -- + <#list x['field_dictlist'] as xd> ${xd['typename']} #list> diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/tag/ExpTag.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/tag/ExpTag.java new file mode 100644 index 00000000..153fa0a3 --- /dev/null +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/engine/tag/ExpTag.java @@ -0,0 +1,91 @@ +package org.jeecgframework.web.cgform.engine.tag; + +import java.io.IOException; +import java.io.Writer; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import freemarker.core.Environment; +import freemarker.template.TemplateDirectiveBody; +import freemarker.template.TemplateDirectiveModel; +import freemarker.template.TemplateException; +import freemarker.template.TemplateModel; +import freemarker.template.TemplateModelException; +import freemarker.template.TemplateScalarModel; + +/** + * 鑷畾涔塐nline鑷畾涔夋寜閽 + * 浣跨敤鏂规硶 锛<@exp exp='${x['exp']}' data='name' > + * @author gj_shaojc + * + */ +@Component("expTag") +public class ExpTag implements TemplateDirectiveModel { + + private static final Logger LOG = LoggerFactory.getLogger(ExpTag.class); + + public void execute(Environment env, Map params, TemplateModel[] loopVars, + TemplateDirectiveBody body) throws TemplateException, IOException { + + String exp = getAttribute(params, "exp"); + String data = getAttribute(params, "data"); + if (exp == null||data == null) { + throw new TemplateException( + "Can not find attribute 'name' in data tag", env); + } + StringBuilder resexp=new StringBuilder(); + String[] ShowbyFields = exp.split("&&"); + for (String ShowbyField : ShowbyFields) { + int beginIndex = ShowbyField.indexOf("#"); + int endIndex = ShowbyField.lastIndexOf("#"); + String exptype = ShowbyField.substring(beginIndex + 1, endIndex);// 琛ㄨ揪寮忕被鍨 + String field = ShowbyField.substring(0, beginIndex);// 鍒ゆ柇鏄剧ず渚濇嵁瀛楁 + String[] values = ShowbyField.substring(endIndex + 1, ShowbyField.length()).split(",");// 浼犲叆瀛楁鍊 + String value = ""; + for (int i = 0; i < values.length; i++) { + value += "'" + "" + values[i] + "" + "'"; + if (i < values.length - 1) { + value += ","; + } + } + if ("eq".equals(exptype)) { + resexp.append("$.inArray("+data+"." + field + ",[" + value + "])>=0"); + } + if ("ne".equals(exptype)) { + resexp.append("$.inArray("+data+"." + field + ",[" + value + "])<0"); + } + if ("empty".equals(exptype) && value.equals("'true'")) { + resexp.append(""+data+"." + field + "==''"); + } + if ("empty".equals(exptype) && value.equals("'false'")) { + resexp.append(""+data+"." + field + "!=''"); + } + } + Writer out = env.getOut(); + out.append(resexp); + } + + /** + * 鍙栧緱鏍囩鍙傛暟 + * + * @param params + * @param name + * @return + */ + @SuppressWarnings("unchecked") + private String getAttribute(Map params, String name) { + String value = null; + if (params.containsKey(name)) { + TemplateModel paramValue = (TemplateModel) params.get(name); + try { + value = ((TemplateScalarModel) paramValue).getAsString(); + } catch (TemplateModelException e) { + LOG.error("get attribute '{}' error", name, e); + } + } + return value; + } +} diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/interceptors/CgFormVersionInterceptor.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/interceptors/CgFormVersionInterceptor.java index 327efe1f..8e4c2dc2 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/interceptors/CgFormVersionInterceptor.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/interceptors/CgFormVersionInterceptor.java @@ -30,7 +30,7 @@ public class CgFormVersionInterceptor implements HandlerInterceptor { public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3) throws Exception { - String requestPath = ResourceUtil.getRequestPath(arg0);// 鐢ㄦ埛璁块棶鐨勮祫婧愬湴鍧 + String requestPath = ResourceUtil.getJgAuthRequsetPath(arg0);// 鐢ㄦ埛璁块棶鐨勮祫婧愬湴鍧 if(!includeUrls.contains(requestPath)){ return; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/build/DataBaseServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/build/DataBaseServiceImpl.java index 683cfe23..8830d38d 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/build/DataBaseServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/build/DataBaseServiceImpl.java @@ -17,6 +17,7 @@ import org.jeecgframework.core.util.DBTypeUtil; import org.jeecgframework.core.util.DateUtils; import org.jeecgframework.core.util.MyClassLoader; import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.UUIDGenerator; import org.jeecgframework.core.util.oConvertUtils; @@ -131,6 +132,9 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe * @param data 鏁版嵁 */ private Map dataAdapter(String tableName,Map data) { + + SqlInjectionUtil.filterContent(tableName); + //step.1 鑾峰彇琛ㄥ崟鐨勫瓧娈甸厤缃 Map fieldConfigs =cgFormFieldService.getAllCgFormFieldByTableName(tableName); //step.2 杩唬灏嗚鎸佷箙鍖栫殑鏁版嵁 @@ -235,11 +239,14 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe } } - if(id instanceof java.lang.String){ - sqlBuffer.append(" where id='").append(id).append("'"); - }else{ - sqlBuffer.append(" where id=").append(id); - } +// if(id instanceof java.lang.String){ +// sqlBuffer.append(" where id='").append(id).append("'"); +// }else{ +// sqlBuffer.append(" where id=").append(id); +// } + sqlBuffer.append(" where id=:id"); + data.put("id", id); + CgFormHeadEntity cgFormHeadEntity = cgFormFieldService.getCgFormHeadByTableName(tableName); int num = this.executeSql(sqlBuffer.toString(), data); @@ -263,6 +270,9 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe */ public Map findOneForJdbc(String tableName, String id) { + + SqlInjectionUtil.filterContent(tableName); + StringBuffer sqlBuffer = new StringBuffer(); sqlBuffer.append("select * from ").append(tableName); sqlBuffer.append(" where id= ? "); @@ -570,6 +580,9 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe */ private void deleteSubTableDataById(Object subId,String subTableName){ StringBuilder sql = new StringBuilder(""); + + SqlInjectionUtil.filterContent(subTableName); + sql.append(" delete from ").append(subTableName).append(" where id = ? "); this.executeSql(sql.toString(), subId); @@ -644,7 +657,6 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe ||getAllFieldByTableName(tableName).containsKey(DataBaseConstant.SYS_USER_CODE_TABLE)){ data.put(DataBaseConstant.SYS_USER_CODE_TABLE, ResourceUtil.getUserSystemData(DataBaseConstant.SYS_USER_CODE)); } - //--author锛歴cott---begin------date:20170725--------for: 娴佺▼鐘舵佽祴浜堥粯璁ゅ---------- if(data.containsKey(DataBaseConstant.BPM_STATUS_TABLE) ||getAllFieldByTableName(tableName).containsKey(DataBaseConstant.BPM_STATUS_TABLE)){ data.put(DataBaseConstant.BPM_STATUS_TABLE, ResourceUtil.getUserSystemData(DataBaseConstant.BPM_STATUS_TABLE)); @@ -738,12 +750,14 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe public CgformEnhanceJavaEntity getCgformEnhanceJavaEntityByCodeFormId(String buttonCode, String formId) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformEnhanceJavaEntity t"); - hql.append(" where t.formId='").append(formId).append("'"); - hql.append(" and t.buttonCode ='").append(buttonCode).append("'"); + + hql.append(" where t.formId=?"); + hql.append(" and t.buttonCode =?"); hql.append(" and t.activeStatus ='1'"); - List list = this.findHql(hql.toString()); + List list = this.findHql(hql.toString(),formId,buttonCode); + if(list!=null&&list.size()>0){ return list.get(0); } @@ -753,8 +767,8 @@ public class DataBaseServiceImpl extends CommonServiceImpl implements DataBaseSe public List getCgformEnhanceJavaEntityByFormId( String formId) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformEnhanceJavaEntity t"); - hql.append(" where t.formId='").append(formId).append("'"); - List list = this.findHql(hql.toString()); + hql.append(" where t.formId=?"); + List list = this.findHql(hql.toString(),formId); return list; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonServiceImpl.java index a4fc584e..e9777fcd 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonServiceImpl.java @@ -36,12 +36,17 @@ public class CgformButtonServiceImpl extends CommonServiceImpl implements Cgform public List checkCgformButton(CgformButtonEntity cgformButtonEntity) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformButtonEntity t"); - hql.append(" where t.formId='").append(cgformButtonEntity.getFormId()).append("'"); - hql.append(" and t.buttonCode ='").append(cgformButtonEntity.getButtonCode()).append("'"); + + hql.append(" where t.formId=?"); + hql.append(" and t.buttonCode =?"); + List list = null; if(cgformButtonEntity.getId()!=null){ - hql.append(" and t.id !='").append(cgformButtonEntity.getId()).append("'"); + hql.append(" and t.id !=?"); + list = this.findHql(hql.toString(),cgformButtonEntity.getFormId(),cgformButtonEntity.getButtonCode(),cgformButtonEntity.getId()); + }else{ + list = this.findHql(hql.toString(),cgformButtonEntity.getFormId(),cgformButtonEntity.getButtonCode()); } - List list = this.findHql(hql.toString()); + return list; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonSqlServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonSqlServiceImpl.java index ebbf00db..78d5aa4f 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonSqlServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/button/CgformButtonSqlServiceImpl.java @@ -23,12 +23,17 @@ public class CgformButtonSqlServiceImpl extends CommonServiceImpl implements Cgf CgformButtonSqlEntity cgformButtonSqlEntity) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformButtonSqlEntity t"); - hql.append(" where t.formId='").append(cgformButtonSqlEntity.getFormId()).append("'"); - hql.append(" and t.buttonCode ='").append(cgformButtonSqlEntity.getButtonCode()).append("'"); + + hql.append(" where t.formId=?"); + hql.append(" and t.buttonCode =?"); + List list = null; if(cgformButtonSqlEntity.getId()!=null){ - hql.append(" and t.id !='").append(cgformButtonSqlEntity.getId()).append("'"); + hql.append(" and t.id !=?"); + list = this.findHql(hql.toString(),cgformButtonSqlEntity.getFormId(),cgformButtonSqlEntity.getButtonCode(),cgformButtonSqlEntity.getId()); + }else{ + list = this.findHql(hql.toString(),cgformButtonSqlEntity.getFormId(),cgformButtonSqlEntity.getButtonCode()); } - List list = this.findHql(hql.toString()); + return list; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/CgFormFieldServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/CgFormFieldServiceImpl.java index e23ac585..618165de 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/CgFormFieldServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/CgFormFieldServiceImpl.java @@ -19,6 +19,7 @@ import org.jeecgframework.core.common.service.impl.CommonServiceImpl; import org.jeecgframework.core.constant.Globals; import org.jeecgframework.core.util.ContextHolderUtils; import org.jeecgframework.core.util.MyBeanUtils; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.web.cgform.common.CgAutoListConstant; @@ -387,6 +388,8 @@ public class CgFormFieldServiceImpl extends CommonServiceImpl implements List> list = this.findForJdbc(sql1.toString(), subTableName, mainTableName); + SqlInjectionUtil.filterContent(subTableName); + StringBuilder sql2 = new StringBuilder(""); sql2.append("select sub.* from ").append(subTableName).append(" sub "); sql2.append(", ").append(mainTableName).append(" main "); diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/DbTableServiceMysqlImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/DbTableServiceMysqlImpl.java index ee9f910b..8720ffe1 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/DbTableServiceMysqlImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/DbTableServiceMysqlImpl.java @@ -51,12 +51,12 @@ public class DbTableServiceMysqlImpl implements DbTableServiceI { return " DROP TABLE IF EXISTS "+tableProperty.getTableName()+" ;"; } - + @Deprecated public String updateTableSQL(CgFormHeadEntity cgFormHead, JdbcTemplate jdbcTemplate) { String sql = "select column_name,data_type,column_comment,numeric_precision,numeric_scale,character_maximum_length," + - "is_nullable nullable from information_schema.columns where table_name = '"+cgFormHead.getTableName()+"'and table_schema = '"+CodeResourceUtil.DATABASE_NAME+"';"; + "is_nullable nullable from information_schema.columns where table_name = ? and table_schema = ?;"; - Map fieldMap = DbTableUtil.getColumnMap(jdbcTemplate.queryForList(sql)); + Map fieldMap = DbTableUtil.getColumnMap(jdbcTemplate.queryForList(sql,cgFormHead.getTableName(),CodeResourceUtil.DATABASE_NAME)); StringBuilder sb = new StringBuilder(); sb.append(createChangeTableSql(cgFormHead)); CgFormFieldEntity column,agoColumn = null; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ColumnMeta.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ColumnMeta.java index acc9ece3..e4487962 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ColumnMeta.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ColumnMeta.java @@ -66,9 +66,11 @@ public class ColumnMeta { } }else{ if (colunmType.contains("date") || colunmType.contains("blob") || colunmType.contains("text")) { - return columnName.equals(meta.getColumnName()) + + return colunmType.equals(meta.getColunmType()) && columnName.equals(meta.getColumnName()) &&isNullable.equals(meta.isNullable) &&isEquals(comment,meta.getComment())&&isEquals(fieldDefault,meta.getFieldDefault()); + }else { return colunmType.equals(meta.getColunmType()) &&isNullable.equals(meta.isNullable)&&columnSize==meta.getColumnSize() diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ExtendJsonConvert.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ExtendJsonConvert.java index 811fde35..1212da68 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ExtendJsonConvert.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/config/util/ExtendJsonConvert.java @@ -94,9 +94,11 @@ public class ExtendJsonConvert { } re.append("\" "); } catch (Exception e) { + re.append(key+"="+"\""); - re.append(obj.get(key)+"\""); + re.append(obj.get(key)+"\" ");//涓轰簡姝e垯鍖归厤 鍔犱笂绌烘牸 //re.append("\" "); + } } }catch (Exception e) { diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJavaServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJavaServiceImpl.java index 5282fd2d..92f73fb1 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJavaServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJavaServiceImpl.java @@ -79,9 +79,11 @@ public class CgformEnhanceJavaServiceImpl extends CommonServiceImpl implements C String buttonCode, String formId) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformEnhanceJavaEntity t"); - hql.append(" where t.formId='").append(formId).append("'"); - hql.append(" and t.buttonCode ='").append(buttonCode).append("'"); - List list = this.findHql(hql.toString()); + + hql.append(" where t.formId=?"); + hql.append(" and t.buttonCode =?"); + List list = this.findHql(hql.toString(),formId,buttonCode); + if(list!=null&&list.size()>0){ return list.get(0); } @@ -93,12 +95,17 @@ public class CgformEnhanceJavaServiceImpl extends CommonServiceImpl implements C CgformEnhanceJavaEntity cgformEnhanceJavaEntity) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformEnhanceJavaEntity t"); - hql.append(" where t.formId='").append(cgformEnhanceJavaEntity.getFormId()).append("'"); - hql.append(" and t.buttonCode ='").append(cgformEnhanceJavaEntity.getButtonCode()).append("'"); + + hql.append(" where t.formId=?"); + hql.append(" and t.buttonCode =?"); + List list = null; if(cgformEnhanceJavaEntity.getId()!=null){ - hql.append(" and t.id !='").append(cgformEnhanceJavaEntity.getId()).append("'"); + hql.append(" and t.id !=?"); + list = this.findHql(hql.toString(),cgformEnhanceJavaEntity.getFormId(),cgformEnhanceJavaEntity.getButtonCode(),cgformEnhanceJavaEntity.getId()); + }else{ + list = this.findHql(hql.toString(),cgformEnhanceJavaEntity.getFormId(),cgformEnhanceJavaEntity.getButtonCode()); } - List list = this.findHql(hql.toString()); + return list; } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJsServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJsServiceImpl.java index 47b1f6b4..b343a71f 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJsServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/enhance/CgformEnhanceJsServiceImpl.java @@ -23,9 +23,11 @@ public class CgformEnhanceJsServiceImpl extends CommonServiceImpl implements Cgf public CgformEnhanceJsEntity getCgformEnhanceJsByTypeFormId(String cgJsType, String formId) { StringBuilder hql = new StringBuilder(""); hql.append(" from CgformEnhanceJsEntity t"); - hql.append(" where t.formId='").append(formId).append("'"); - hql.append(" and t.cgJsType ='").append(cgJsType).append("'"); - List list = this.findHql(hql.toString()); + + hql.append(" where t.formId=?"); + hql.append(" and t.cgJsType =?"); + List list = this.findHql(hql.toString(),formId,cgJsType); + if(list!=null&&list.size()>0){ return list.get(0); } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/generate/TempletContextWord.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/generate/TempletContextWord.java index f135ca66..e8013b99 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/generate/TempletContextWord.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/service/impl/generate/TempletContextWord.java @@ -47,6 +47,7 @@ public class TempletContextWord { private SystemService systemService; @Autowired private CgformFtlServiceI cgformFtlService; + @Resource(name = "freemarkerWord") private Configuration freemarker; diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionById.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionById.sql index fb4e649c..3f960d5a 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionById.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionById.sql @@ -1,4 +1,4 @@ select jform_version from cgform_head -where id = '${id}' \ No newline at end of file +where id = :id \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionByTableName.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionByTableName.sql index dc18d50f..dc013bc0 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionByTableName.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_getCgFormVersionByTableName.sql @@ -1,4 +1,4 @@ select jform_version from cgform_head -where table_name = '${tableName}' \ No newline at end of file +where table_name = :tableName \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_updateVersion.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_updateVersion.sql index 2dceb641..068b6b57 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_updateVersion.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/config/CgFormVersionDao_updateVersion.sql @@ -1 +1 @@ -update cgform_head set jform_version = '${newVersion}' where id = '${formId}' \ No newline at end of file +update cgform_head set jform_version = :newVersion where id = :formId \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/upload/CgFormUploadDao_updateBackFileInfo.sql b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/upload/CgFormUploadDao_updateBackFileInfo.sql index a962a2b6..e47f15c1 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/upload/CgFormUploadDao_updateBackFileInfo.sql +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgform/sql/upload/CgFormUploadDao_updateBackFileInfo.sql @@ -1 +1 @@ -update ${cgFormName} set ${cgFormField} = '${fileUrl}' where id='${cgFormId}' \ No newline at end of file +update ${cgFormName} set ${cgFormField} = :fileUrl where id= :cgFormId \ No newline at end of file diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/controller/core/CgReportController.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/controller/core/CgReportController.java index ddf75b25..34742b97 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/controller/core/CgReportController.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/controller/core/CgReportController.java @@ -8,9 +8,6 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -18,7 +15,6 @@ import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; import org.jeecgframework.core.common.controller.BaseController; -import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.enums.SysThemesEnum; import org.jeecgframework.core.online.def.CgReportConstant; import org.jeecgframework.core.online.exception.CgReportNotFoundException; @@ -26,14 +22,11 @@ import org.jeecgframework.core.online.util.CgReportQueryParamUtil; import org.jeecgframework.core.online.util.FreemarkerHelper; import org.jeecgframework.core.util.ContextHolderUtils; import org.jeecgframework.core.util.DynamicDBUtil; -import org.jeecgframework.core.util.MutiLangUtil; -import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.SqlInjectionUtil; import org.jeecgframework.core.util.SqlUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.SysThemesUtil; -import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.web.cgreport.service.core.CgReportServiceI; -import org.jeecgframework.web.system.pojo.base.TSType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -184,7 +177,7 @@ public class CgReportController extends BaseController { fl.put(CgReportConstant.ITEM_FIELDNAME, ((String)fl.get(CgReportConstant.ITEM_FIELDNAME)).toLowerCase()); String isQuery = (String) fl.get(CgReportConstant.ITEM_ISQUERY); if(CgReportConstant.BOOL_TRUE.equalsIgnoreCase(isQuery)){ - loadDic(fl,fl); + cgReportService.loadDic(fl); queryList.add(fl); } } @@ -208,72 +201,6 @@ public class CgReportController extends BaseController { } - /** - * 澶勭悊鏁版嵁瀛楀吀 - * @param result 鏌ヨ鐨勭粨鏋滈泦 - * @param beans 瀛楁閰嶇疆 - */ - @SuppressWarnings("unchecked") - private void dealDic(List> result, - List> beans) { - for(Map bean:beans){ - String dict_code = (String) bean.get(CgReportConstant.ITEM_DICCODE); - String field_name=bean.get(CgReportConstant.ITEM_FIELDNAME).toString(); - if(StringUtil.isEmpty(dict_code)){ - //涓嶉渶瑕佸鐞嗗瓧鍏 - continue; - }else{ - -// List> dicDatas = queryDic(dict_code); - List dicDatas = ResourceUtil.allTypes.get(dict_code.toLowerCase()); - for(Map r:result){ - String value = String.valueOf(r.get(field_name)); - for(TSType m:dicDatas){ - String typecode = String.valueOf(m.getTypecode()); - if(value.equalsIgnoreCase(typecode)){ - String typename = String.valueOf(m.getTypename()); - r.put(bean.get(CgReportConstant.ITEM_FIELDNAME),MutiLangUtil.doMutiLang(typename, null)); - } - } - } - - } - } - } - /** - * 澶勭悊鍙栧艰〃杈惧紡 - * @param result - * @param beans - */ - @SuppressWarnings("unchecked") - private void dealReplace(List> result, - List> beans){ - for(Map bean:beans){ - try{ - //鑾峰彇鍙栧艰〃杈惧紡 - String replace = (String) bean.get(CgReportConstant.ITEM_REPLACE); - if(StringUtil.isEmpty(replace)){ - continue; - } - String[] groups = replace.split(","); - for(String g:groups){ - String[] items = g.split("_"); - String v = items[0];//閫昏緫鍒ゆ柇鍊 - String txt = items[1];//瑕佽浆鎹㈢殑鏂囨湰 - for(Map r:result){ - String value = String.valueOf(r.get(bean.get(CgReportConstant.ITEM_FIELDNAME))); - if(value.equalsIgnoreCase(v)){ - r.put(bean.get(CgReportConstant.ITEM_FIELDNAME),txt); - } - } - } - }catch (Exception e) { - //杩欓噷鍑虹幇寮傚父鍘熷洜鏄洜涓哄彇鍊艰〃杈惧紡涓嶆纭 - e.printStackTrace(); - throw new BusinessException("鍙栧艰〃杈惧紡涓嶆纭"); - } - } - } /** * 鍔ㄦ佹姤琛ㄦ暟鎹煡璇 * @param configId 閰嶇疆id-code @@ -306,6 +233,9 @@ public class CgReportController extends BaseController { for(String param :paramList){ String value = request.getParameter(param); value = value==null?"":value; + + SqlInjectionUtil.filterContent(value); + querySql = querySql.replace("${"+param+"}", value); } }else{ @@ -340,8 +270,8 @@ public class CgReportController extends BaseController { size = cgReportService.countQueryByCgReportSql(querySql, queryparams); } - dealDic(result,items); - dealReplace(result,items); + cgReportService.dealDic(result,items); + cgReportService.dealReplace(result,items); response.setContentType("application/json"); response.setHeader("Cache-Control", "no-store"); PrintWriter writer = null; @@ -372,8 +302,8 @@ public class CgReportController extends BaseController { List params = null; Map reJson = new HashMap(); try{ - fields = getFields(sql, dbKey); - params = getSqlParams(sql); + fields = cgReportService.getFields(sql, dbKey); + params = cgReportService.getSqlParams(sql); }catch (Exception e) { e.printStackTrace(); String errorInfo = "瑙f瀽澶辫触!澶辫触鍘熷洜锛"; @@ -397,90 +327,4 @@ public class CgReportController extends BaseController { return reJson; } - private List getFields(String sql,String dbKey){ - List fields = null; - sql = getSql(sql); - if(StringUtils.isNotBlank(dbKey)){ - List> dataList=DynamicDBUtil.findList(dbKey,SqlUtil.jeecgCreatePageSql(dbKey,sql,null,1,1),null); - if(dataList.size()<1){ - throw new BusinessException("璇ユ姤琛╯ql娌℃湁鏁版嵁"); - } - Set fieldsSet= dataList.get(0).keySet(); - fields = new ArrayList(fieldsSet); - }else{ - fields = cgReportService.getSqlFields(sql); - } - return fields; - } - - private String getSql(String sql){ - String regex = "\\$\\{\\w+\\}"; - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - //System.out.println(whereParam); - sql = sql.replace(whereParam, "'' or 1=1 or 1=''"); - sql = sql.replace("'''", "''"); - //System.out.println(sql); - } - //鍏煎鍥捐〃 - regex = "\\{\\w+\\}"; - p = Pattern.compile(regex); - m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - //System.out.println(whereParam); - sql = sql.replace(whereParam, " 1=1 "); - //System.out.println(sql); - } - return sql; - } - - public List getSqlParams(String sql) { - if(oConvertUtils.isEmpty(sql)){ - return null; - } - List params = new ArrayList(); - String regex = "\\$\\{\\w+\\}"; - - Pattern p = Pattern.compile(regex); - Matcher m = p.matcher(sql); - while(m.find()){ - String whereParam = m.group(); - params.add(whereParam.substring(whereParam.indexOf("{")+1,whereParam.indexOf("}"))); - } - return params; - } - - - /** - * 瑁呰浇鏁版嵁瀛楀吀 - * @param m 瑕佹斁鍏reemarker鐨勬暟鎹 - * @param bean 璇诲彇鍑烘潵鐨勫姩鎬侀厤缃暟鎹 - */ - @SuppressWarnings("unchecked") - private void loadDic(Map m, Map cgReportMap) { - String dict_code = (String) cgReportMap.get("dict_code"); - if(StringUtil.isEmpty(dict_code)){ - m.put(CgReportConstant.FIELD_DICTLIST, new ArrayList(0)); - return; - } - List> dicDatas = queryDic(dict_code); - m.put(CgReportConstant.FIELD_DICTLIST, dicDatas); - } - /** - * 鏌ヨ鏁版嵁瀛楀吀 - * @param diccode 瀛楀吀缂栫爜 - * @return - */ - private List> queryDic(String diccode) { - StringBuilder dicSql = new StringBuilder(); - dicSql.append(" SELECT TYPECODE,TYPENAME FROM"); - dicSql.append(" "+CgReportConstant.SYS_DIC); - dicSql.append(" "+"WHERE TYPEGROUPID = "); - dicSql.append(" "+"(SELECT ID FROM "+CgReportConstant.SYS_DICGROUP+" WHERE TYPEGROUPCODE = '"+diccode+"' )"); - List> dicDatas = cgReportService.findForJdbc(dicSql.toString()); - return dicDatas; - } } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlist.ftl b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlist.ftl index dfe5a32e..8432e2dd 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlist.ftl +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlist.ftl @@ -109,7 +109,7 @@ $(function(){$('#${config_id}List').datagrid( <#if x['search_mode']=="single"> <#if (x['field_dictlist']?size >0)> - -- 璇烽夋嫨 -- + <#list x['field_dictlist'] as xd> ${xd['typename']} #list> diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlistpopup.ftl b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlistpopup.ftl index 277433d9..60704672 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlistpopup.ftl +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/engine/core/cgreportlistpopup.ftl @@ -96,7 +96,7 @@ $(function(){$('#${config_id}List').datagrid( <#if x['search_mode']=="single"> <#if (x['field_dictlist']?size >0)> - -- 璇烽夋嫨 -- + <#list x['field_dictlist'] as xd> ${xd['typename']} #list> diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/core/CgReportServiceI.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/core/CgReportServiceI.java index 1215f4d8..4b0a7465 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/core/CgReportServiceI.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/core/CgReportServiceI.java @@ -54,4 +54,26 @@ public interface CgReportServiceI extends CommonService{ * @return */ public List getSqlFields(String sql); + /** + * 瑙f瀽sql瀛楁锛屾敮鎸佸鏁版嵁婧 + * @param sql + * @param dbKey + * @return + */ + public List getFields(String sql, String dbKey); + /** + * 瑙f瀽sql鍙傛暟 + * @param sql + * @return + */ + public List getSqlParams(String sql); + + /** + * 鍔犺浇瀛楀吀 + * @param fl + * @param fl2 + */ + public void loadDic(Map fl); + public void dealDic(List> result, List> items); + public void dealReplace(List> result, List> items); } diff --git a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/impl/core/CgReportServiceImpl.java b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/impl/core/CgReportServiceImpl.java index 0a5a3421..fe436f70 100644 --- a/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/impl/core/CgReportServiceImpl.java +++ b/jeecg-framework/src/main/java/org/jeecgframework/web/cgreport/service/impl/core/CgReportServiceImpl.java @@ -6,16 +6,23 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.lang.StringUtils; import org.jeecgframework.web.cgreport.dao.core.CgReportDao; import org.jeecgframework.web.cgreport.entity.core.CgreportConfigHeadEntity; import org.jeecgframework.web.cgreport.entity.core.CgreportConfigParamEntity; import org.jeecgframework.web.cgreport.service.core.CgReportServiceI; - +import org.jeecgframework.web.system.pojo.base.TSType; import org.jeecgframework.core.common.dao.jdbc.JdbcDao; import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.common.service.impl.CommonServiceImpl; import org.jeecgframework.core.online.def.CgReportConstant; +import org.jeecgframework.core.util.DynamicDBUtil; +import org.jeecgframework.core.util.MutiLangUtil; +import org.jeecgframework.core.util.ResourceUtil; +import org.jeecgframework.core.util.SqlUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -138,4 +145,199 @@ public class CgReportServiceImpl extends CommonServiceImpl implements List fileds = new ArrayList(fieldsSet); return fileds; } + + //------------------------------------------------------------------------------------------------------------ + /** + * 鍔ㄦ佹暟鎹簮锛 鑾峰彇SQL瑙f瀽鐨勫瓧娈 + */ + public List getFields(String sql,String dbKey){ + List fields = null; + sql = getSql(sql); + if(StringUtils.isNotBlank(dbKey)){ + List> dataList=DynamicDBUtil.findList(dbKey,SqlUtil.jeecgCreatePageSql(dbKey,sql,null,1,1),null); + if(dataList.size()<1){ + throw new BusinessException("璇ユ姤琛╯ql娌℃湁鏁版嵁"); + } + Set fieldsSet= dataList.get(0).keySet(); + fields = new ArrayList(fieldsSet); + }else{ + fields = this.getSqlFields(sql); + } + return fields; + } + + /** + * 杩囨护闈炴硶sql瑙勫垯锛岄檷浣巗ql娉ㄥ叆椋庨櫓 + * @param sql + * @return + */ + private String getSql(String sql){ + String regex = "\\$\\{\\w+\\}"; + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(sql); + while(m.find()){ + String whereParam = m.group(); + //System.out.println(whereParam); + sql = sql.replace(whereParam, "'' or 1=1 or 1=''"); + sql = sql.replace("'''", "''"); + //System.out.println(sql); + } + //鍏煎鍥捐〃 + regex = "\\{\\w+\\}"; + p = Pattern.compile(regex); + m = p.matcher(sql); + while(m.find()){ + String whereParam = m.group(); + //System.out.println(whereParam); + sql = sql.replace(whereParam, " 1=1 "); + //System.out.println(sql); + } + return sql; + } + + /** + * 瑙f瀽SQL鍙傛暟 + */ + public List getSqlParams(String sql) { + if(oConvertUtils.isEmpty(sql)){ + return null; + } + List params = new ArrayList(); + String regex = "\\$\\{\\w+\\}"; + + Pattern p = Pattern.compile(regex); + Matcher m = p.matcher(sql); + while(m.find()){ + String whereParam = m.group(); + params.add(whereParam.substring(whereParam.indexOf("{")+1,whereParam.indexOf("}"))); + } + return params; + } + + + /** + * 瑁呰浇鏁版嵁瀛楀吀 + * @param m 瑕佹斁鍏reemarker鐨勬暟鎹 + * @param bean 璇诲彇鍑烘潵鐨勫姩鎬侀厤缃暟鎹 + */ + public void loadDic(Map m) { + String dict_code = (String) m.get("dict_code"); + if(StringUtil.isEmpty(dict_code)){ + m.put(CgReportConstant.FIELD_DICTLIST, new ArrayList(0)); + return; + } + List> dicDatas = queryDicBySQL(dict_code); + m.put(CgReportConstant.FIELD_DICTLIST, dicDatas); + } + + /** + * 鏌ヨ鏁版嵁瀛楀吀锛屾墿灞曚簡瀵筍QL鐨勬敮鎸 + * @param dictCodeOrSQL 瀛楀吀缂栫爜鎴朣QL + * @author bit 2014-4-19 + */ + private List> queryDicBySQL(String dictCodeOrSQL) { + List> dicDatas = null; + dictCodeOrSQL = dictCodeOrSQL.trim(); + if(dictCodeOrSQL.toLowerCase().startsWith("select ")) { + + dictCodeOrSQL = dictCodeOrSQL.replaceAll("'[kK][eE][yY]'", "typecode").replaceAll("'[vV][aA][lL][uU][eE]'", "typename"); + + dicDatas = this.findForJdbc(dictCodeOrSQL); + }else { + dicDatas = queryDic(dictCodeOrSQL); + } + return dicDatas; + } + + + /** + * 鏌ヨ鏁版嵁瀛楀吀 + * @param diccode 瀛楀吀缂栫爜 + * @return + */ + private List> queryDic(String diccode) { + + List> dicDatas = new ArrayList>(); + List tstypes = ResourceUtil.allTypes.get(diccode.toLowerCase()); + for(TSType t:tstypes){ + Map mp = new HashMap(); + mp.put("typecode",t.getTypecode()); + mp.put("typename",MutiLangUtil.doMutiLang(t.getTypename(), null)); + dicDatas.add(mp); + } +// StringBuilder dicSql = new StringBuilder(); +// dicSql.append(" SELECT TYPECODE,TYPENAME FROM"); +// dicSql.append(" "+CgReportConstant.SYS_DIC); +// dicSql.append(" "+"WHERE TYPEGROUPID = "); +// dicSql.append(" "+"(SELECT ID FROM "+CgReportConstant.SYS_DICGROUP+" WHERE TYPEGROUPCODE = ? )"); +// List> dicDatas = cgReportService.findForJdbc(dicSql.toString(),diccode); + + return dicDatas; + } + + /** + * 澶勭悊鍙栧艰〃杈惧紡 + * @param result + * @param beans + */ + @SuppressWarnings("unchecked") + public void dealReplace(List