Browse Source

spring cache redis

albertshaw 8 years ago
parent
commit
7b1da97045
25 changed files with 929 additions and 588 deletions
  1. 9 2
      pom.xml
  2. 295 0
      schema/industry_category_init.sql
  3. 41 8
      src/main/java/com/goafanti/common/controller/PublicController.java
  4. 21 0
      src/main/java/com/goafanti/common/dao/IndustryCategoryMapper.java
  5. 89 0
      src/main/java/com/goafanti/common/mapper/IndustryCategoryMapper.xml
  6. 45 0
      src/main/java/com/goafanti/common/model/IndustryCategory.java
  7. 35 0
      src/main/java/com/goafanti/common/service/IndustryCategoryService.java
  8. 29 11
      src/main/java/com/goafanti/common/utils/LoggerUtils.java
  9. 30 0
      src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java
  10. 33 0
      src/main/java/com/goafanti/core/cache/template/FastJsonRedisTemplate.java
  11. 1 1
      src/main/java/com/goafanti/core/mybatis/BaseMybatisDao.java
  12. 0 135
      src/main/java/com/goafanti/core/shiro/cache/JedisManager.java
  13. 0 109
      src/main/java/com/goafanti/core/shiro/cache/JedisShiroCache.java
  14. 0 100
      src/main/java/com/goafanti/core/shiro/cache/JedisShiroSessionRepository.java
  15. 0 10
      src/main/java/com/goafanti/core/shiro/cache/ShiroCacheManager.java
  16. 101 0
      src/main/java/com/goafanti/core/shiro/cache/ShiroRedisCache.java
  17. 25 0
      src/main/java/com/goafanti/core/shiro/cache/ShiroRedisCacheManager.java
  18. 0 32
      src/main/java/com/goafanti/core/shiro/cache/impl/CustomShiroCacheManager.java
  19. 0 31
      src/main/java/com/goafanti/core/shiro/cache/impl/JedisShiroCacheManager.java
  20. 28 0
      src/main/java/com/goafanti/core/shiro/cache/template/SessionRedisTemplate.java
  21. 18 7
      src/main/java/com/goafanti/core/shiro/listener/CustomSessionListener.java
  22. 2 10
      src/main/java/com/goafanti/core/shiro/token/TokenManager.java
  23. 4 1
      src/main/resources/spring/spring-mybatis.xml
  24. 118 126
      src/main/resources/spring/spring-shiro.xml
  25. 5 5
      src/main/webapp/WEB-INF/views/index.html

+ 9 - 2
pom.xml

@@ -95,6 +95,13 @@
 			<artifactId>spring-messaging</artifactId>
 			<version>${org.springframework-version}</version>
 		</dependency>
+		
+		<dependency>
+		    <groupId>org.springframework.data</groupId>
+		    <artifactId>spring-data-redis</artifactId>
+		    <version>1.8.3.RELEASE</version>
+		</dependency>
+		
 		<dependency>
 		    <groupId>org.thymeleaf</groupId>
 		    <artifactId>thymeleaf-spring4</artifactId>
@@ -116,7 +123,7 @@
 		<dependency>
 			<groupId>redis.clients</groupId>
 			<artifactId>jedis</artifactId>
-			<version>2.8.0</version>
+			<version>2.9.0</version>
 		</dependency>
 		<!-- redis end -->
 
@@ -271,7 +278,7 @@
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>fastjson</artifactId>
-			<version>1.2.16</version>
+			<version>1.2.31</version>
 		</dependency>
 
 		<!-- AspectJ -->

+ 295 - 0
schema/industry_category_init.sql

@@ -0,0 +1,295 @@
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (1,'采掘',0,-9.39);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (100,'石油开采',1,-9.51);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (101,'煤炭开采',1,-6.65);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (102,'焦炭加工',1,-6.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (103,'其他采掘',1,-3.5);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (104,'采掘服务',1,-21.3);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (105,'油气钻采服务',1,-21.73);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (106,'其他采掘服务',1,-2.76);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (2,'化工',0,-6.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (107,'石油化工',2,-10.43);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (108,'石油加工',2,-10.7);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (109,'石油贸易',2,29.42);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (110,'化学原料',2,8.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (111,'纯碱',2,9.71);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (112,'氯碱',2,6.86);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (113,'无机盐',2,8.68);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (114,'其他化学原料',2,15.26);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (115,'化学制品',2,3.49);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (116,'氮肥',2,-6.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (117,'磷肥',2,33.04);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (118,'钾肥',2,8.08);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (119,'复合肥',2,8.68);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (120,'农药',2,-2.08);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (121,'日用化学产品',2,17.55);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (122,'涂料油漆油墨制造',2,19.69);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (123,'民爆用品',2,1.27);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (124,'纺织化学用品',2,2.88);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (125,'氟化工及制冷剂',2,9.15);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (126,'磷化工及磷酸盐',2,11.11);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (127,'聚氨酯',2,-1.91);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (128,'玻纤',2,14.15);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (129,'其他化学制品',2,18.65);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (130,'化学纤维',2,3.67);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (131,'涤纶',2,9.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (132,'维纶',2,-21.27);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (133,'粘胶',2,-4.26);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (134,'氨纶',2,-8.3);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (135,'其他纤维',2,-8.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (136,'塑料',2,15.53);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (137,'合成革',2,14.07);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (138,'改性塑料',2,11.56);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (139,'其他塑料制品',2,19.2);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (140,'橡胶',2,0.62);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (141,'轮胎',2,0.4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (142,'其他橡胶制品',2,9.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (143,'炭黑',2,-3.86);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (3,'钢铁',0,-7.23);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (144,'普钢',3,-6.98);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (145,'特钢',3,-12.22);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (146,'有色金属',3,4.46);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (147,'工业金属',3,2.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (148,'铝',3,-2.61);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (149,'铜',3,7.19);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (150,'铅锌',3,-3.25);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (151,'黄金',3,11.71);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (152,'稀有金属',3,5.43);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (153,'稀土',3,-1.06);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (154,'钨',3,-10.85);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (155,'锂',3,65.16);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (156,'其他稀有小金属',3,9.78);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (157,'金属非金属新材料',3,9.1);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (158,'金属新材料',3,10.7);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (159,'磁性材料',3,13.45);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (160,'非金属新材料',3,5.05);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (4,'建筑材料',0,2.09);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (161,'水泥制造',4,-0.43);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (162,'玻璃制造',4,14.43);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (163,'管材',4,3.7);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (164,'耐火材料',4,4.13);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (165,'其他建材',4,4.55);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (5,'建筑装饰',0,6.41);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (166,'房屋建设',5,10.2);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (167,'装修装饰',5,6.1);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (168,'园林工程',5,19.79);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (169,'基础建设',5,5.55);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (170,'城轨建设',5,6.29);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (171,'路桥施工',5,8.75);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (172,'水利工程',5,14.84);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (173,'铁路建设',5,2.62);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (174,'其他基础建设',5,1.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (175,'专业工程',5,0.88);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (176,'钢结构',5,1.1);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (177,'化学工程',5,-3.46);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (178,'国际工程承包',5,-2.49);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (179,'其他专业工程',5,3.28);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (6,'电气设备',0,9.99);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (180,'电机',6,14.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (181,'电气自动化设备',6,15.5);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (182,'电网自动化',6,11.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (183,'工控自动化',6,25.7);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (184,'计量仪表',6,17.87);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (185,'电源设备',6,8.21);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (186,'综合电力设备商',6,-2.97);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (187,'风电设备',6,16.59);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (188,'光伏设备',6,29.4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (189,'火电设备',6,-8.97);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (190,'储能设备',6,25.2);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (191,'其它电源设备',6,-4.04);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (192,'高低压设备',6,9.82);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (193,'高压设备',6,9.89);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (194,'中压设备',6,24.3);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (195,'低压设备',6,7.12);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (196,'线缆部件及其他',6,6.12);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (7,'机械设备',0,-0.88);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (197,'通用机械',7,2.83);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (198,'机床工具',7,0.62);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (199,'机械基础件',7,6.09);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (200,'磨具磨料',7,15.28);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (201,'内燃机',7,-7.91);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (202,'制冷空调设备',7,-8.96);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (203,'其它通用机械',7,10.38);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (204,'专用设备',7,-4.98);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (205,'工程机械',7,-10.27);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (206,'重型机械',7,-1.8);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (207,'冶金矿采化工设备',7,-17.21);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (208,'楼宇设备',7,8.18);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (209,'环保设备',7,13.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (210,'纺织服装设备',7,6.46);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (211,'农用机械',7,-2.3);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (212,'印刷包装机械',7,5.96);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (213,'其它专用机械',7,4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (214,'仪器仪表',7,20.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (215,'金属制品',7,-3.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (216,'运输设备',7,5.77);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (217,'铁路设备',7,5.77);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (8,'国防军工',0,3.72);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (218,'航天装备',8,12.94);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (219,'航空装备',8,5.96);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (220,'地面兵装',8,4.49);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (221,'船舶制造',8,0.62);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (9,'汽车',0,12.43);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (222,'汽车整车',9,12.39);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (223,'乘用车',9,13.31);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (224,'商用载货车',9,7.28);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (225,'商用载客车',9,11.67);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (226,'汽车零部件',9,17.71);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (227,'汽车服务',9,5.38);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (228,'其他交运设备',9,-0.53);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (10,'家用电器',0,6.56);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (229,'白色家电',10,7.18);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (230,'冰箱',10,9.29);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (231,'空调',10,5.54);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (232,'洗衣机',10,15.79);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (233,'小家电',10,12.91);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (234,'家电零部件',10,1.25);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (235,'视听器材',10,5.56);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (236,'彩电',10,5.71);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (237,'其它视听器材',10,2.52);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (11,'纺织服装',0,7.14);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (238,'纺织制造',11,5.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (239,'毛纺',11,6.56);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (240,'棉纺',11,6.78);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (241,'丝绸',11,2.51);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (242,'印染',11,-2.96);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (243,'辅料',11,9.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (244,'其他纺织',11,5.99);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (245,'服装家纺',11,8.19);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (246,'男装',11,7.59);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (247,'女装',11,3.84);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (248,'休闲服装',11,22.21);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (249,'鞋帽',11,-1.85);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (250,'家纺',11,4.8);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (251,'其他服装',11,3.66);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (12,'轻工制造',0,7.39);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (252,'造纸',12,6.87);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (253,'包装印刷',12,9.22);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (254,'家用轻工',12,7.22);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (255,'家具',12,15.22);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (256,'其他家用轻工',12,7.42);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (257,'珠宝首饰',12,2.58);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (258,'文娱用品',12,8.05);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (259,'其他轻工制造',12,-2.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (13,'商业贸易',0,-2.59);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (260,'一般零售',13,1.12);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (261,'百货',13,3.75);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (262,'超市',13,5.88);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (263,'多业态零售',13,-2.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (264,'专业零售',13,3.89);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (265,'专业连锁',13,3.89);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (266,'商业物业经营',13,10.04);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (267,'一般物业经营',13,-0.29);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (268,'专业市场',13,16.94);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (269,'贸易',13,-12.92);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (14,'农林牧渔',0,9.69);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (270,'种植业',14,-5.77);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (271,'种子生产',14,0.39);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (272,'粮食种植',14,-11.86);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (273,'其他种植业',14,-3.9);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (274,'渔业',14,11.66);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (275,'海洋捕捞',14,17.1);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (276,'水产养殖',14,10.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (277,'林业',14,-19.95);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (278,'饲料',14,12.34);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (279,'农产品加工',14,-2.69);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (280,'果蔬加工',14,6.34);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (281,'粮油加工',14,-12.86);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (282,'其他农产品加工',14,1.12);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (283,'农业综合',14,18.2);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (284,'畜禽养殖',14,22.35);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (285,'动物保健',14,6.51);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (15,'食品饮料',0,4.82);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (286,'饮料制造',15,1.84);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (287,'白酒',15,4.68);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (288,'啤酒',15,-2.45);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (289,'其他酒类',15,-3.02);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (290,'软饮料',15,-3.36);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (291,'葡萄酒',15,2.14);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (292,'黄酒',15,3.16);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (293,'食品加工',15,7.72);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (294,'肉制品',15,8.36);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (295,'调味发酵品',15,9.31);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (296,'乳品',15,6.11);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (297,'食品综合',15,9.88);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (16,'休闲服务',0,16.27);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (298,'景点',16,17.07);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (299,'人工景点',16,47.67);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (300,'自然景点',16,6.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (301,'酒店',16,46.85);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (302,'旅游综合',16,13.3);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (303,'餐饮',16,-10.92);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (17,'医药生物',0,13.66);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (304,'化学制药',17,9.06);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (305,'化学原料药',17,6.59);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (306,'化学制剂',17,10.84);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (307,'中药',17,11.24);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (308,'生物制品',17,16.86);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (309,'医药商业',17,16.27);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (310,'医疗器械',17,19.95);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (311,'医疗服务',17,30.26);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (18,'公用事业',0,-1.57);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (312,'电力',18,-3.85);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (313,'火电',18,-5.59);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (314,'水电',18,3.42);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (315,'燃机发电',18,4.64);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (316,'热电',18,-3.02);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (317,'新能源发电',18,10.83);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (318,'水务',18,9.26);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (319,'燃气',18,7.24);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (320,'环保工程及服务',18,21.73);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (19,'交通运输',0,8.99);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (321,'港口',19,6.03);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (322,'高速公路',19,6.83);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (323,'公交',19,3.94);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (324,'航空运输',19,5.48);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (325,'机场',19,7.73);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (326,'航运',19,4.65);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (327,'铁路运输',19,-2.09);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (328,'物流',19,17.39);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (20,'房地产',0,17.79);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (329,'房地产开发',20,17.89);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (330,'园区开发',20,13.89);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (21,'电子',0,24.45);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (331,'半导体',21,29.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (332,'集成电路',21,33.37);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (333,'分立器件',21,15.18);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (334,'半导体材料',21,18.95);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (335,'元件',21,16.82);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (336,'印制电路板',21,11.4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (337,'被动元件',21,20.51);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (338,'光学光电子',21,29.25);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (339,'显示器件',21,30.07);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (340,'LED',21,23.67);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (341,'光学元件',21,45.25);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (342,'其他电子',21,20.68);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (343,'电子制造',21,23.41);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (344,'电子系统组装',21,24.18);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (345,'电子零部件制造',21,23.22);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (22,'计算机',0,13.4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (346,'计算机设备',22,11.4);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (347,'计算机应用',22,15.91);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (348,'软件开发',22,23.05);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (349,'IT服务',22,13.15);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (23,'传媒',0,26.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (350,'文化传媒',23,15.55);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (351,'平面媒体',23,11.45);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (352,'影视动漫',23,32.26);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (353,'有线电视网络',23,10.78);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (354,'其他文化传媒',23,12.73);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (355,'营销传播',23,30.65);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (356,'营销服务',23,30.65);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (357,'互联网传媒',23,61.04);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (358,'移动互联网服务',23,29.56);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (359,'互联网信息服务',23,108.93);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (360,'其他互联网服务',23,23.21);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (24,'通信',0,4.55);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (361,'通信运营',24,-3.05);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (362,'通信设备',24,14.82);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (363,'终端设备',24,10.19);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (364,'通信传输设备',24,15.47);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (365,'通信配套服务',24,15.87);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (25,'银行',0,7.52);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (366,'非银金融',25,15.93);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (367,'证券',25,39.21);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (368,'保险',25,14.63);
+insert into `industry_category` (`id`,`name`,`pid`,`value`) values (369,'多元金融',25,29.76);

+ 41 - 8
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
@@ -30,6 +31,7 @@ import com.aliyuncs.sms.model.v20160927.SingleSendSmsResponse;
 import com.goafanti.admin.service.AftFileService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.service.IndustryCategoryService;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.common.utils.PictureUtils;
 import com.goafanti.common.utils.TimeUtils;
@@ -42,25 +44,28 @@ import com.goafanti.user.service.UserService;
 @RequestMapping("/open")
 public class PublicController extends BaseController {
 	@Value(value = "${accessKey}")
-	private String			accessKey			= null;
+	private String					accessKey			= null;
 
 	@Value(value = "${accessSecret}")
-	private String			accessSecret		= null;
+	private String					accessSecret		= null;
 
 	@Value(value = "${upload.path}")
-	private String			uploadPath			= null;
+	private String					uploadPath			= null;
 
 	@Value(value = "${upload.private.path}")
-	private String			uploadPrivatePath	= null;
+	private String					uploadPrivatePath	= null;
 
 	@Value(value = "${static.host}")
-	private String			staticHost			= null;
+	private String					staticHost			= null;
 
 	@Resource
-	private UserService		userService;
+	private UserService				userService;
 
 	@Resource
-	private AftFileService	aftFileService;
+	private AftFileService			aftFileService;
+
+	@Autowired
+	private IndustryCategoryService	industryCategoryService;
 
 	/**
 	 * 获取验证码
@@ -340,5 +345,33 @@ public class PublicController extends BaseController {
 		}
 		return res;
 	}
-	
+
+	@RequestMapping(value = "/findIndustryCategory", method = RequestMethod.GET)
+	@ResponseBody
+	public Result findIndustryCategory(String id) {
+		Integer pid = 0;
+		if (StringUtils.isNumeric(id)) {
+			try {
+				pid = Integer.parseInt(id);
+			} catch (Exception e) {
+				pid = 0;
+			}
+		}
+		return new Result().data(industryCategoryService.list(pid));
+	}
+
+	@RequestMapping(value = "/clearIndustryCategory", method = RequestMethod.GET)
+	@ResponseBody
+	public Result clearIndustryCategory(String id) {
+		Integer pid = 0;
+		if (StringUtils.isNumeric(id)) {
+			try {
+				pid = Integer.parseInt(id);
+			} catch (Exception e) {
+				pid = 0;
+			}
+		}
+		industryCategoryService.clear(pid);
+		return new Result().data(pid);
+	}
 }

+ 21 - 0
src/main/java/com/goafanti/common/dao/IndustryCategoryMapper.java

@@ -0,0 +1,21 @@
+package com.goafanti.common.dao;
+
+import java.util.List;
+
+import com.goafanti.common.model.IndustryCategory;
+
+public interface IndustryCategoryMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(IndustryCategory record);
+
+    int insertSelective(IndustryCategory record);
+
+    IndustryCategory selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(IndustryCategory record);
+
+    int updateByPrimaryKey(IndustryCategory record);
+    
+    List<IndustryCategory> listByPid(Integer pid);
+}

+ 89 - 0
src/main/java/com/goafanti/common/mapper/IndustryCategoryMapper.xml

@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.IndustryCategoryMapper">
+  <resultMap id="BaseResultMap" type="com.goafanti.common.model.IndustryCategory">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="pid" jdbcType="INTEGER" property="pid" />
+    <result column="value" jdbcType="DECIMAL" property="value" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, name, pid, value
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from industry_category
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from industry_category
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" parameterType="com.goafanti.common.model.IndustryCategory">
+    insert into industry_category (id, name, pid, 
+      value)
+    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=INTEGER}, 
+      #{value,jdbcType=DECIMAL})
+  </insert>
+  <insert id="insertSelective" parameterType="com.goafanti.common.model.IndustryCategory">
+    insert into industry_category
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null">
+        name,
+      </if>
+      <if test="pid != null">
+        pid,
+      </if>
+      <if test="value != null">
+        value,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=INTEGER},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="pid != null">
+        #{pid,jdbcType=INTEGER},
+      </if>
+      <if test="value != null">
+        #{value,jdbcType=DECIMAL},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.IndustryCategory">
+    update industry_category
+    <set>
+      <if test="name != null">
+        name = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="pid != null">
+        pid = #{pid,jdbcType=INTEGER},
+      </if>
+      <if test="value != null">
+        value = #{value,jdbcType=DECIMAL},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.IndustryCategory">
+    update industry_category
+    set name = #{name,jdbcType=VARCHAR},
+      pid = #{pid,jdbcType=INTEGER},
+      value = #{value,jdbcType=DECIMAL}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  
+  <select id="listByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from industry_category
+    where pid = #{pid,jdbcType=INTEGER}
+  </select>
+</mapper>

+ 45 - 0
src/main/java/com/goafanti/common/model/IndustryCategory.java

@@ -0,0 +1,45 @@
+package com.goafanti.common.model;
+
+import java.math.BigDecimal;
+
+public class IndustryCategory {
+    private Integer id;
+
+    private String name;
+
+    private Integer pid;
+
+    private BigDecimal value;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getPid() {
+        return pid;
+    }
+
+    public void setPid(Integer pid) {
+        this.pid = pid;
+    }
+
+    public BigDecimal getValue() {
+        return value;
+    }
+
+    public void setValue(BigDecimal value) {
+        this.value = value;
+    }
+}

+ 35 - 0
src/main/java/com/goafanti/common/service/IndustryCategoryService.java

@@ -0,0 +1,35 @@
+package com.goafanti.common.service;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.common.dao.IndustryCategoryMapper;
+import com.goafanti.common.model.IndustryCategory;
+import com.goafanti.common.utils.LoggerUtils;
+
+@Service
+public class IndustryCategoryService {
+
+	private static final Logger	logger	= LoggerFactory.getLogger(IndustryCategoryService.class);
+
+	@Autowired
+	IndustryCategoryMapper		industryCategoryMapper;
+
+	@Cacheable(value = "IndustryCategoryCache", key = "'IndustryCategory:'+#pid")
+	public List<IndustryCategory> list(Integer pid) {
+		LoggerUtils.debug(logger, "缓存行业列表:[%s]", pid);
+		return industryCategoryMapper.listByPid(pid);
+	}
+
+	@CacheEvict(value = "IndustryCategoryCache", key = "'IndustryCategory:'+#pid")
+	public void clear(Integer pid) {
+		LoggerUtils.debug(logger, "清除行业列表缓存:[%s]", pid);
+	}
+
+}

+ 29 - 11
src/main/java/com/goafanti/common/utils/LoggerUtils.java

@@ -19,10 +19,9 @@ public class LoggerUtils {
 	 *            输出信息
 	 */
 	public static void debug(Class<? extends Object> clazz, String message) {
-		if (!isDebug)
-			return;
-		Logger logger = LoggerFactory.getLogger(clazz);
-		logger.debug(message);
+		if (isDebug) {
+			LoggerFactory.getLogger(clazz).debug(message);
+		}
 	}
 
 	/**
@@ -35,16 +34,35 @@ public class LoggerUtils {
 	 * @param value
 	 *            输出信息value
 	 */
-	public static void fmtDebug(Class<? extends Object> clazz, String fmtString, Object... value) {
-		if (!isDebug)
-			return;
-		if (StringUtils.isBlank(fmtString)) {
-			return;
+	public static void debug(Class<? extends Object> clazz, String fmtString, Object... value) {
+		if (isDebug && StringUtils.isNotBlank(fmtString) && null != value && value.length != 0) {
+			fmtString = String.format(fmtString, value);
+			debug(clazz, fmtString);
 		}
-		if (null != value && value.length != 0) {
+	}
+
+	/**
+	 * 
+	 * @param logger
+	 * @param fmtString
+	 * @param value
+	 */
+	public static void debug(Logger logger, String fmtString, Object... value) {
+		if (isDebug && StringUtils.isNotBlank(fmtString) && null != value && value.length != 0) {
 			fmtString = String.format(fmtString, value);
+			logger.debug(fmtString);
+		}
+	}
+	
+	/**
+	 * 
+	 * @param logger
+	 * @param message
+	 */
+	public static void debug(Logger logger, String message) {
+		if (isDebug) {
+			logger.debug(message);
 		}
-		debug(clazz, fmtString);
 	}
 
 	/**

+ 30 - 0
src/main/java/com/goafanti/core/cache/serializer/FastJsonRedisSerializer.java

@@ -0,0 +1,30 @@
+package com.goafanti.core.cache.serializer;
+
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.parser.ParserConfig;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+
+public class FastJsonRedisSerializer implements RedisSerializer<Object> {
+	public FastJsonRedisSerializer() {
+		ParserConfig.getGlobalInstance().addAccept("com.goafanti.common.model.IndustryCategory");
+	}
+
+	@Override
+	public byte[] serialize(Object t) throws SerializationException {
+		if (t == null)
+			return null;
+		return JSON.toJSONBytes(t, SerializerFeature.WRITE_MAP_NULL_FEATURES, SerializerFeature.QuoteFieldNames,
+				SerializerFeature.WriteClassName, SerializerFeature.IgnoreNonFieldGetter);
+	}
+
+	@Override
+	public Object deserialize(byte[] bytes) throws SerializationException {
+		if (bytes == null)
+			return null;
+		return JSON.parse(bytes);
+	}
+
+}

+ 33 - 0
src/main/java/com/goafanti/core/cache/template/FastJsonRedisTemplate.java

@@ -0,0 +1,33 @@
+package com.goafanti.core.cache.template;
+
+import org.springframework.data.redis.connection.DefaultStringRedisConnection;
+import org.springframework.data.redis.connection.RedisConnection;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+import com.goafanti.core.cache.serializer.FastJsonRedisSerializer;
+
+public class FastJsonRedisTemplate extends RedisTemplate<String, Object> {
+
+	public FastJsonRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+		setConnectionFactory(redisConnectionFactory);
+		
+		StringRedisSerializer stringSerializer = new StringRedisSerializer();
+		
+		RedisSerializer<Object> redisSerializer = new FastJsonRedisSerializer();
+		
+		this.setKeySerializer(stringSerializer);
+		this.setValueSerializer(redisSerializer);
+		this.setHashKeySerializer(stringSerializer);
+		this.setHashValueSerializer(redisSerializer);
+		
+		afterPropertiesSet();
+	}
+
+	@Override
+	protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) {
+		return new DefaultStringRedisConnection(connection);
+	}
+}

+ 1 - 1
src/main/java/com/goafanti/core/mybatis/BaseMybatisDao.java

@@ -82,7 +82,7 @@ public class BaseMybatisDao<T> extends SqlSessionDaoSupport {
 		BoundSql boundSql = c.getMappedStatement(sqlId).getBoundSql(params);
 		String sqlcode = boundSql.getSql();
 
-		LoggerUtils.fmtDebug(SELF, "findByPageBySqlId sql : %s", sqlcode);
+		LoggerUtils.debug(SELF, "findByPageBySqlId sql : %s", sqlcode);
 		String countCode = "", countId = "";
 		BoundSql countSql = null;
 		/**

+ 0 - 135
src/main/java/com/goafanti/core/shiro/cache/JedisManager.java

@@ -1,135 +0,0 @@
-package com.goafanti.core.shiro.cache;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.shiro.session.Session;
-
-import com.goafanti.common.constant.ShiroConstants;
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.common.utils.SerializeUtil;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.exceptions.JedisConnectionException;
-
-public class JedisManager {
-
-	private JedisPool jedisPool;
-
-	public Jedis getJedis() {
-		Jedis jedis = null;
-		try {
-			jedis = getJedisPool().getResource();
-		} catch (Exception e) {
-			throw new JedisConnectionException(e);
-		}
-		return jedis;
-	}
-
-	public void returnResource(Jedis jedis, boolean isBroken) {
-		if (jedis == null)
-			return;
-		/**
-		 * @deprecated starting from Jedis 3.0 this method will not be exposed.
-		 *             Resource cleanup should be done using @see
-		 *             {@link redis.clients.jedis.Jedis#close()} if (isBroken){
-		 *             getJedisPool().returnBrokenResource(jedis); }else{
-		 *             getJedisPool().returnResource(jedis); }
-		 */
-		jedis.close();
-	}
-
-	public byte[] getValueByKey(int dbIndex, byte[] key) throws Exception {
-		Jedis jedis = null;
-		byte[] result = null;
-		boolean isBroken = false;
-		try {
-			jedis = getJedis();
-			jedis.select(dbIndex);
-			result = jedis.get(key);
-		} catch (Exception e) {
-			isBroken = true;
-			throw e;
-		} finally {
-			returnResource(jedis, isBroken);
-		}
-		return result;
-	}
-
-	public void deleteByKey(int dbIndex, byte[] key) throws Exception {
-		Jedis jedis = null;
-		boolean isBroken = false;
-		try {
-			jedis = getJedis();
-			jedis.select(dbIndex);
-			Long result = jedis.del(key);
-			LoggerUtils.fmtDebug(getClass(), "删除Session结果:%s", result);
-		} catch (Exception e) {
-			isBroken = true;
-			throw e;
-		} finally {
-			returnResource(jedis, isBroken);
-		}
-	}
-
-	public void saveValueByKey(int dbIndex, byte[] key, byte[] value, int expireTime) throws Exception {
-		Jedis jedis = null;
-		boolean isBroken = false;
-		try {
-			jedis = getJedis();
-			jedis.select(dbIndex);
-			jedis.set(key, value);
-			if (expireTime > 0)
-				jedis.expire(key, expireTime);
-		} catch (Exception e) {
-			isBroken = true;
-			throw e;
-		} finally {
-			returnResource(jedis, isBroken);
-		}
-	}
-
-	public JedisPool getJedisPool() {
-		return jedisPool;
-	}
-
-	public void setJedisPool(JedisPool jedisPool) {
-		this.jedisPool = jedisPool;
-	}
-
-	/**
-	 * 获取所有Session
-	 * 
-	 * @param dbIndex
-	 * @param redisShiroSession
-	 * @return
-	 * @throws Exception
-	 */
-	@SuppressWarnings("unchecked")
-	public Collection<Session> AllSession(int dbIndex, String redisShiroSession) throws Exception {
-		Jedis jedis = null;
-		boolean isBroken = false;
-		Set<Session> sessions = new HashSet<Session>();
-		try {
-			jedis = getJedis();
-			jedis.select(dbIndex);
-
-			Set<byte[]> byteKeys = jedis.keys((ShiroConstants.REDIS_SHIRO_ALL).getBytes());
-			if (byteKeys != null && byteKeys.size() > 0) {
-				for (byte[] bs : byteKeys) {
-					Session obj = SerializeUtil.deserialize(jedis.get(bs), Session.class);
-					if (obj instanceof Session) {
-						sessions.add(obj);
-					}
-				}
-			}
-		} catch (Exception e) {
-			isBroken = true;
-			throw e;
-		} finally {
-			returnResource(jedis, isBroken);
-		}
-		return sessions;
-	}
-}

+ 0 - 109
src/main/java/com/goafanti/core/shiro/cache/JedisShiroCache.java

@@ -1,109 +0,0 @@
-package com.goafanti.core.shiro.cache;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.common.utils.SerializeUtil;
-
-@SuppressWarnings("unchecked")
-public class JedisShiroCache<K, V> implements Cache<K, V> {
-
-	/**
-	 * 为了不和其他的缓存混淆,采用追加前缀方式以作区分
-	 */
-	private static final String REDIS_SHIRO_CACHE = "goafanti-cache:";
-	/**
-	 * Redis 分片(分区),也可以在配置文件中配置
-	 */
-	private static final int DB_INDEX = 1;
-
-	private JedisManager jedisManager;
-
-	private String name;
-
-	public JedisShiroCache(String name, JedisManager jedisManager) {
-		this.name = name;
-		this.jedisManager = jedisManager;
-	}
-
-	/**
-	 * 自定义realm中的授权/认证的类名加上授权/认证英文名字
-	 */
-	public String getName() {
-		if (name == null)
-			return "";
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	@Override
-	public V get(K key) throws CacheException {
-		byte[] byteKey = SerializeUtil.serialize(buildCacheKey(key));
-		byte[] byteValue = new byte[0];
-		try {
-			byteValue = jedisManager.getValueByKey(DB_INDEX, byteKey);
-		} catch (Exception e) {
-			LoggerUtils.error(getClass(), "get value by cache throw exception", e);
-		}
-		return (V) SerializeUtil.deserialize(byteValue);
-	}
-
-	@Override
-	public V put(K key, V value) throws CacheException {
-		V previos = get(key);
-		try {
-			jedisManager.saveValueByKey(DB_INDEX, SerializeUtil.serialize(buildCacheKey(key)),
-					SerializeUtil.serialize(value), -1);
-		} catch (Exception e) {
-			LoggerUtils.error(getClass(), "put cache throw exception", e);
-		}
-		return previos;
-	}
-
-	@Override
-	public V remove(K key) throws CacheException {
-		V previos = get(key);
-		try {
-			jedisManager.deleteByKey(DB_INDEX, SerializeUtil.serialize(buildCacheKey(key)));
-		} catch (Exception e) {
-			LoggerUtils.error(getClass(), "remove cache  throw exception", e);
-		}
-		return previos;
-	}
-
-	@Override
-	public void clear() throws CacheException {
-		// TODO--
-	}
-
-	@Override
-	public int size() {
-		if (keys() == null)
-			return 0;
-		return keys().size();
-	}
-
-	@Override
-	public Set<K> keys() {
-		// TODO
-		return null;
-	}
-
-	@Override
-	public Collection<V> values() {
-		// TODO
-		return null;
-	}
-
-	private String buildCacheKey(Object key) {
-		return REDIS_SHIRO_CACHE + getName() + ":" + key;
-	}
-
-}

+ 0 - 100
src/main/java/com/goafanti/core/shiro/cache/JedisShiroSessionRepository.java

@@ -1,100 +0,0 @@
-package com.goafanti.core.shiro.cache;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-import org.apache.shiro.session.Session;
-
-import com.goafanti.common.constant.ShiroConstants;
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.common.utils.SerializeUtil;
-import com.goafanti.core.shiro.session.SessionStatus;
-import com.goafanti.core.shiro.session.ShiroSessionRepository;
-
-/**
- * Session 管理
- * 
- * @author sojson.com
- *
- */
-@SuppressWarnings("unchecked")
-public class JedisShiroSessionRepository implements ShiroSessionRepository {
-
-	private static final int SESSION_VAL_TIME_SPAN = 18000;
-	private static final int DB_INDEX = 1;
-
-	private JedisManager jedisManager;
-
-	@Override
-	public void saveSession(Session session) {
-		if (session == null || session.getId() == null)
-			throw new NullPointerException("session is empty");
-		try {
-			byte[] key = SerializeUtil.serialize(buildRedisSessionKey(session.getId()));
-
-			// 不存在才添加。
-			if (null == session.getAttribute(ShiroConstants.SESSION_STATUS)) {
-				// Session 踢出自存存储。
-				SessionStatus sessionStatus = new SessionStatus();
-				session.setAttribute(ShiroConstants.SESSION_STATUS, sessionStatus);
-			}
-
-			byte[] value = SerializeUtil.serialize(session);
-			long sessionTimeOut = session.getTimeout() / 1000;
-			Long expireTime = sessionTimeOut + SESSION_VAL_TIME_SPAN + (5 * 60);
-			getJedisManager().saveValueByKey(DB_INDEX, key, value, expireTime.intValue());
-		} catch (Exception e) {
-			LoggerUtils.fmtError(getClass(), e, "save session error,id:[%s]", session.getId());
-		}
-	}
-
-	@Override
-	public void deleteSession(Serializable id) {
-		if (id == null) {
-			throw new NullPointerException("session id is empty");
-		}
-		try {
-			getJedisManager().deleteByKey(DB_INDEX, SerializeUtil.serialize(buildRedisSessionKey(id)));
-		} catch (Exception e) {
-			LoggerUtils.fmtError(getClass(), e, "删除session出现异常,id:[%s]", id);
-		}
-	}
-
-	@Override
-	public Session getSession(Serializable id) {
-		if (id == null)
-			throw new NullPointerException("session id is empty");
-		Session session = null;
-		try {
-			byte[] value = getJedisManager().getValueByKey(DB_INDEX, SerializeUtil.serialize(buildRedisSessionKey(id)));
-			session = SerializeUtil.deserialize(value, Session.class);
-		} catch (Exception e) {
-			LoggerUtils.fmtError(getClass(), e, "获取session异常,id:[%s]", id);
-		}
-		return session;
-	}
-
-	@Override
-	public Collection<Session> getAllSessions() {
-		Collection<Session> sessions = null;
-		try {
-			sessions = getJedisManager().AllSession(DB_INDEX, ShiroConstants.REDIS_SHIRO_SESSION);
-		} catch (Exception e) {
-			LoggerUtils.fmtError(getClass(), e, "获取全部session异常");
-		}
-
-		return sessions;
-	}
-
-	private String buildRedisSessionKey(Serializable sessionId) {
-		return ShiroConstants.REDIS_SHIRO_SESSION + sessionId;
-	}
-
-	public JedisManager getJedisManager() {
-		return jedisManager;
-	}
-
-	public void setJedisManager(JedisManager jedisManager) {
-		this.jedisManager = jedisManager;
-	}
-}

+ 0 - 10
src/main/java/com/goafanti/core/shiro/cache/ShiroCacheManager.java

@@ -1,10 +0,0 @@
-package com.goafanti.core.shiro.cache;
-
-import org.apache.shiro.cache.Cache;
-
-public interface ShiroCacheManager {
-
-	<K, V> Cache<K, V> getCache(String name);
-
-	void destroy();
-}

+ 101 - 0
src/main/java/com/goafanti/core/shiro/cache/ShiroRedisCache.java

@@ -0,0 +1,101 @@
+package com.goafanti.core.shiro.cache;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheException;
+import org.springframework.data.redis.core.RedisTemplate;
+
+public class ShiroRedisCache implements Cache<String, Object> {
+
+	public static final String				PREFIX		= "SHIRO_SESSION:";
+
+	private RedisTemplate<String, Object>	redisTemplate;
+
+	private String							name		= "shiro_session";
+
+	private Set<String>						emptySet	= new HashSet<>();
+
+	public ShiroRedisCache() {
+
+	}
+
+	public ShiroRedisCache(RedisTemplate<String, Object> redisTemplate, String name) {
+		this.redisTemplate = redisTemplate;
+		this.name = name;
+	}
+
+	@Override
+	public Object get(String key) throws CacheException {
+		if (key == null) {
+			return null;
+		}
+		return redisTemplate.opsForValue().get(decorateKey(key));
+	}
+
+	@Override
+
+	public Object put(String key, Object value) throws CacheException {
+		if (key == null || value == null) {
+			return null;
+		}
+
+		redisTemplate.opsForValue().set(decorateKey(key), value);
+		return value;
+	}
+
+	@Override
+	public Object remove(String key) throws CacheException {
+		if (key == null) {
+			return null;
+		}
+		redisTemplate.delete(decorateKey(key));
+		return Boolean.TRUE;
+	}
+
+	@Override
+	public void clear() throws CacheException {
+		redisTemplate.getConnectionFactory().getConnection().flushDb();
+	}
+
+	@Override
+	public int size() {
+		return redisTemplate.getConnectionFactory().getConnection().dbSize().intValue();
+	}
+
+	@Override
+	public Set<String> keys() {
+		Set<String> set = redisTemplate.keys(PREFIX + "*");
+		if (set == null) {
+			return emptySet;
+		}
+		return set;
+	}
+
+	@Override
+	public Collection<Object> values() {
+		return redisTemplate.opsForValue().multiGet(keys());
+	}
+
+	public RedisTemplate<String, Object> getRedisTemplate() {
+		return redisTemplate;
+	}
+
+	public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
+		this.redisTemplate = redisTemplate;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	private String decorateKey(String key) {
+		return PREFIX + key;
+	}
+}

+ 25 - 0
src/main/java/com/goafanti/core/shiro/cache/ShiroRedisCacheManager.java

@@ -0,0 +1,25 @@
+package com.goafanti.core.shiro.cache;
+
+import org.apache.shiro.cache.AbstractCacheManager;
+import org.apache.shiro.cache.Cache;
+import org.apache.shiro.cache.CacheException;
+import org.springframework.data.redis.core.RedisTemplate;
+
+public class ShiroRedisCacheManager extends AbstractCacheManager {
+
+	private RedisTemplate<String, Object> redisTemplate;
+
+	@Override
+	protected Cache<String, Object> createCache(String name) throws CacheException {
+		return new ShiroRedisCache(redisTemplate, name);
+	}
+
+	public RedisTemplate<String, Object> getRedisTemplate() {
+		return redisTemplate;
+	}
+
+	public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
+		this.redisTemplate = redisTemplate;
+	}
+	
+}

+ 0 - 32
src/main/java/com/goafanti/core/shiro/cache/impl/CustomShiroCacheManager.java

@@ -1,32 +0,0 @@
-package com.goafanti.core.shiro.cache.impl;
-
-import org.apache.shiro.cache.Cache;
-import org.apache.shiro.cache.CacheException;
-import org.apache.shiro.cache.CacheManager;
-import org.apache.shiro.util.Destroyable;
-
-import com.goafanti.core.shiro.cache.ShiroCacheManager;
-
-public class CustomShiroCacheManager implements CacheManager, Destroyable {
-
-	private ShiroCacheManager shiroCacheManager;
-
-	@Override
-	public <K, V> Cache<K, V> getCache(String name) throws CacheException {
-		return getShiroCacheManager().getCache(name);
-	}
-
-	@Override
-	public void destroy() throws Exception {
-		shiroCacheManager.destroy();
-	}
-
-	public ShiroCacheManager getShiroCacheManager() {
-		return shiroCacheManager;
-	}
-
-	public void setShiroCacheManager(ShiroCacheManager shiroCacheManager) {
-		this.shiroCacheManager = shiroCacheManager;
-	}
-
-}

+ 0 - 31
src/main/java/com/goafanti/core/shiro/cache/impl/JedisShiroCacheManager.java

@@ -1,31 +0,0 @@
-package com.goafanti.core.shiro.cache.impl;
-
-import org.apache.shiro.cache.Cache;
-
-import com.goafanti.core.shiro.cache.JedisManager;
-import com.goafanti.core.shiro.cache.JedisShiroCache;
-import com.goafanti.core.shiro.cache.ShiroCacheManager;
-
-public class JedisShiroCacheManager implements ShiroCacheManager {
-
-	private JedisManager jedisManager;
-
-	@Override
-	public <K, V> Cache<K, V> getCache(String name) {
-		return new JedisShiroCache<K, V>(name, getJedisManager());
-	}
-
-	@Override
-	public void destroy() {
-		// 如果和其他系统,或者应用在一起就不能关闭
-		// getJedisManager().getJedis().shutdown();
-	}
-
-	public JedisManager getJedisManager() {
-		return jedisManager;
-	}
-
-	public void setJedisManager(JedisManager jedisManager) {
-		this.jedisManager = jedisManager;
-	}
-}

+ 28 - 0
src/main/java/com/goafanti/core/shiro/cache/template/SessionRedisTemplate.java

@@ -0,0 +1,28 @@
+package com.goafanti.core.shiro.cache.template;
+
+import org.springframework.data.redis.connection.DefaultStringRedisConnection;
+import org.springframework.data.redis.connection.RedisConnection;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+public class SessionRedisTemplate extends RedisTemplate<String, Object> {
+
+	public SessionRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+		setConnectionFactory(redisConnectionFactory);
+		StringRedisSerializer stringSerializer = new StringRedisSerializer();
+		RedisSerializer<Object> redisSerializer = new JdkSerializationRedisSerializer(this.getClass().getClassLoader());
+		this.setKeySerializer(stringSerializer);
+		this.setValueSerializer(redisSerializer);
+		this.setHashKeySerializer(stringSerializer);
+		this.setHashValueSerializer(redisSerializer);
+		afterPropertiesSet();
+	}
+
+	@Override
+	protected RedisConnection preProcessConnection(RedisConnection connection, boolean existingConnection) {
+		return new DefaultStringRedisConnection(connection);
+	}
+}

+ 18 - 7
src/main/java/com/goafanti/core/shiro/listener/CustomSessionListener.java

@@ -2,12 +2,18 @@ package com.goafanti.core.shiro.listener;
 
 import org.apache.shiro.session.Session;
 import org.apache.shiro.session.SessionListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.redis.core.RedisTemplate;
 
-import com.goafanti.core.shiro.session.ShiroSessionRepository;
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.core.shiro.cache.ShiroRedisCache;
 
 public class CustomSessionListener implements SessionListener {
 
-	private ShiroSessionRepository shiroSessionRepository;
+	private RedisTemplate<String, Object>	redisTemplate;
+
+	private static final Logger				logger	= LoggerFactory.getLogger(CustomSessionListener.class);
 
 	/**
 	 * 一个回话的生命周期开始
@@ -27,15 +33,20 @@ public class CustomSessionListener implements SessionListener {
 
 	@Override
 	public void onExpiration(Session session) {
-		shiroSessionRepository.deleteSession(session.getId());
+		Object sessionId = session.getId();
+		if (sessionId != null && sessionId instanceof String) {
+			sessionId = (String) sessionId;
+			redisTemplate.delete(ShiroRedisCache.PREFIX + sessionId);
+			LoggerUtils.debug(logger, "删除过期session,id:[%s]", sessionId);
+		}
 	}
 
-	public ShiroSessionRepository getShiroSessionRepository() {
-		return shiroSessionRepository;
+	public RedisTemplate<String, Object> getRedisTemplate() {
+		return redisTemplate;
 	}
 
-	public void setShiroSessionRepository(ShiroSessionRepository shiroSessionRepository) {
-		this.shiroSessionRepository = shiroSessionRepository;
+	public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) {
+		this.redisTemplate = redisTemplate;
 	}
 
 }

+ 2 - 10
src/main/java/com/goafanti/core/shiro/token/TokenManager.java

@@ -9,16 +9,11 @@ import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.AftUser;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.SpringContextUtils;
-import com.goafanti.core.shiro.session.CustomSessionManager;
 
 public class TokenManager {
-	private static final String					CSRF_TOKEN				= "CSRF_TOKEN";
+	private static final String		CSRF_TOKEN	= "CSRF_TOKEN";
 	// 用户登录管理
-	public static final UserRealm				realm					= SpringContextUtils.getBean("userRealm",
-			UserRealm.class);
-	// 用户session管理
-	public static final CustomSessionManager	customSessionManager	= SpringContextUtils
-			.getBean("customSessionManager", CustomSessionManager.class);
+	public static final UserRealm	realm		= SpringContextUtils.getBean("userRealm", UserRealm.class);
 
 	/**
 	 * 获取当前登录的用户User对象
@@ -226,7 +221,4 @@ public class TokenManager {
 		realm.clearCachedAuthorizationInfo(userIds);
 	}
 
-	// public static void forbidUser(Long userId) {
-	// customSessionManager.forbidUserById(userId, ShiroConstants.USER_DISABLE);
-	// }
 }

+ 4 - 1
src/main/resources/spring/spring-mybatis.xml

@@ -2,6 +2,7 @@
 <beans xmlns="http://www.springframework.org/schema/beans"
 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xmlns:aop="http://www.springframework.org/schema/aop"
+	xmlns:cache="http://www.springframework.org/schema/cache"
 	xmlns:tx="http://www.springframework.org/schema/tx"
 	xmlns:context="http://www.springframework.org/schema/context"
 	xsi:schemaLocation="
@@ -9,7 +10,8 @@
 			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
 			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
 			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
-			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
+			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
+			http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.0.xsd">
 	
 	<context:component-scan base-package="com.goafanti.*.service;com.goafanti.*.*.service" />
 	
@@ -82,6 +84,7 @@
 			<tx:method name="*"  read-only="true"/>
 		</tx:attributes>
 	</tx:advice>
+ 	<cache:annotation-driven />
  	
 	<aop:config proxy-target-class="true">
 		<aop:pointcut id="myPointcut"

+ 118 - 126
src/main/resources/spring/spring-shiro.xml

@@ -9,153 +9,145 @@
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
-    
-     <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
-        <property name="maxIdle" value="100"/>
-        <property name="minIdle" value="10"/>
-        <property name="testOnBorrow" value="true"/>
-    </bean>
-    
-	<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
-		<constructor-arg index="0" ref="jedisPoolConfig" />
-	    <constructor-arg index="1" value="${jedis.host}" name="host" type="java.lang.String"/>
-	    <constructor-arg index="2" value="${jedis.port}"  name="port" type="int"/>
-	    <constructor-arg index="3" value="${jedis.timeout}"  name="timeout" type="int"/>
-	    <constructor-arg index="4" value="${jedis.password}"  name="password" type="java.lang.String"/>
+
+	<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
+		<property name="maxIdle" value="100" />
+		<property name="minIdle" value="10" />
+		<property name="testOnBorrow" value="true" />
 	</bean>
-	
 
-	<bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"/>
+	<bean id="redisConnectionFactory"
+		class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
+		<property name="hostName" value="${jedis.host}" />
+		<property name="port" value="${jedis.port}" />
+		<property name="password" value="${jedis.password}" />
+		<property name="timeout" value="${jedis.timeout}" />
+		<property name="poolConfig" ref="jedisPoolConfig" />
+		<!-- <property name="database" value="${jedis.dbIndex}" /> -->
+	</bean>
+
+	<bean id="redisTemplate" class="com.goafanti.core.cache.template.FastJsonRedisTemplate">
+		<constructor-arg index="0" ref="redisConnectionFactory" />
+	</bean>
 
+	<bean id="sessionRedisTemplate"
+		class="com.goafanti.core.shiro.cache.template.SessionRedisTemplate">
+		<constructor-arg index="0" ref="redisConnectionFactory" />
+	</bean>
+
+	<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager">
+		<constructor-arg index="0" ref="redisTemplate" />
+	</bean>
 	
+	<bean id="shrioRedisCacheManager" class="com.goafanti.core.shiro.cache.ShiroRedisCacheManager">
+		<property name="redisTemplate" ref="sessionRedisTemplate" />
+	</bean>
+
+	<bean id="sessionIdGenerator"
+		class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator" />
+
+
 	<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
-	    <constructor-arg value="AFT_SID"/>
-	    <property name="httpOnly" value="true"/>
-	    
-	    <property name="maxAge" value="1296000"/>
-	    <!-- 
-	    <property name="domain" value=""/>
-	     -->
-	</bean>
-	<!-- custom shiro session listener -->
+		<constructor-arg value="AFT_SID" />
+		<property name="httpOnly" value="true" />
+		<property name="maxAge" value="1296000" />
+		<!-- <property name="domain" value=""/> -->
+	</bean>
+
 	<bean id="customSessionListener" class="com.goafanti.core.shiro.listener.CustomSessionListener">
-	    <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
-	</bean>
- 	
-	<!-- custom shiro session listener -->
-	<bean id="customShiroSessionDAO" class="com.goafanti.core.shiro.CustomShiroSessionDAO">
-	    <property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
-	    <property name="sessionIdGenerator" ref="sessionIdGenerator"/>
-	</bean>
-	<!--  -->
-	<bean id="customSessionManager" class="com.goafanti.core.shiro.session.CustomSessionManager">
-		<property name="shiroSessionRepository" ref="jedisShiroSessionRepository"/>
-		 <property name="customShiroSessionDAO" ref="customShiroSessionDAO"/>
-	</bean>
- 
-	<!--  -->
-	<bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
-		 <!--  -->
-	     <property name="interval" value="${session.validate.timespan}"/>
-	     <property name="sessionManager" ref="sessionManager"/>
-	</bean>
-	<!--  -->
-    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
-        <property name="realm" ref="userRealm"/>
-        <property name="sessionManager" ref="sessionManager"/>
-        <property name="cacheManager" ref="customShiroCacheManager"/>
-    </bean>
-	<!--  -->
-	<bean id="customShiroCacheManager" class="com.goafanti.core.shiro.cache.impl.CustomShiroCacheManager">
-	    <property name="shiroCacheManager" ref="jedisShiroCacheManager"/>
+		<property name="redisTemplate" ref="sessionRedisTemplate" />
 	</bean>
-	
-	<!--  -->
-	<bean id="jedisShiroCacheManager" class="com.goafanti.core.shiro.cache.impl.JedisShiroCacheManager">
-	    <property name="jedisManager" ref="jedisManager"/>
+
+	<bean id="enterpriseCacheSessionDAO"
+		class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
+		<property name="sessionIdGenerator" ref="sessionIdGenerator" />
 	</bean>
+
 	<!-- -->
-	<bean id="jedisManager" class="com.goafanti.core.shiro.cache.JedisManager">
-	    <property name="jedisPool" ref="jedisPool"/>
+	<bean id="sessionValidationScheduler"
+		class="org.apache.shiro.session.mgt.ExecutorServiceSessionValidationScheduler">
+		<!-- -->
+		<property name="interval" value="${session.validate.timespan}" />
+		<property name="sessionManager" ref="sessionManager" />
 	</bean>
-	<!-- SecurityUtils.setSecurityManager(securityManager) -->
-	<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-	    <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/>
-	    <property name="arguments" ref="securityManager"/>
+	<!-- -->
+	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
+		<property name="realm" ref="userRealm" />
+		<property name="sessionManager" ref="sessionManager" />
+		<property name="cacheManager" ref="shrioRedisCacheManager" />
 	</bean>
 
-	<!-- credential matcher -->  
-	<bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
-	    <property name="hashAlgorithmName" value="${pwd.hash_algorithm_name}"/>  
-	    <property name="hashIterations" value="${pwd.hash_iterations}"/>  
-	    <property name="storedCredentialsHexEncoded" value="true"/>  
-	</bean>  
-	<!--  -->
-	<bean id="userRealm" class="com.goafanti.core.shiro.token.UserRealm" >
-		<property name="credentialsMatcher" ref="credentialsMatcher"/>  
+	<bean id="authorizationAttributeSourceAdvisor"
+		class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
+		<property name="securityManager" ref="securityManager" />
+	</bean>
+
+	<!-- credential matcher -->
+	<bean id="credentialsMatcher"
+		class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
+		<property name="hashAlgorithmName" value="${pwd.hash_algorithm_name}" />
+		<property name="hashIterations" value="${pwd.hash_iterations}" />
+		<property name="storedCredentialsHexEncoded" value="true" />
 	</bean>
-	
-	<!-- Session Manager -->
-	<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
-		<!--    -->
-	 	<property name="sessionValidationInterval" value="1800000"/>  
-	 	 <!-- -->  
-	<property name="globalSessionTimeout" value="1800000"/>
-	   <property name="sessionDAO" ref="customShiroSessionDAO"/>
-	   <!-- session  -->
-	   <property name="sessionListeners">
-	       <list>
-	           <ref bean="customSessionListener"/>
-	       </list>
-	   </property>
-	   <!--  -->	
-	  <property name="sessionValidationScheduler" ref="sessionValidationScheduler"/>
-	  <!--  -->
-	  <property name="sessionValidationSchedulerEnabled" value="true"/>
-	   <!--  -->
-	  <property name="deleteInvalidSessions" value="true"/>
-		<!--  -->
-	   <property name="sessionIdCookie" ref="sessionIdCookie"/>
-	</bean>
-	<!--  -->
-	<bean id="jedisShiroSessionRepository" class="com.goafanti.core.shiro.cache.JedisShiroSessionRepository" >
-		 <property name="jedisManager" ref="jedisManager"/>
-	</bean>
-
-	<!--
-		
-	-->
-	
 	<!-- -->
-    <bean id="shiroManager" class="com.goafanti.core.shiro.service.impl.ShiroManagerImpl"/>
-	
+	<bean id="userRealm" class="com.goafanti.core.shiro.token.UserRealm">
+		<property name="credentialsMatcher" ref="credentialsMatcher" />
+	</bean>
+
+	<!-- Session Manager -->
+	<bean id="sessionManager"
+		class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
+		<!-- -->
+		<property name="sessionValidationInterval" value="1800000" />
+		<!-- -->
+		<property name="globalSessionTimeout" value="1800000" />
+		<property name="sessionDAO" ref="enterpriseCacheSessionDAO" />
+		<property name="cacheManager" ref="shrioRedisCacheManager" />
+		<!-- session -->
+		<property name="sessionListeners">
+			<list>
+				<ref bean="customSessionListener" />
+			</list>
+		</property>
+		<!-- -->
+		<property name="sessionValidationScheduler" ref="sessionValidationScheduler" />
+		<!-- -->
+		<property name="sessionValidationSchedulerEnabled" value="true" />
+		<!-- -->
+		<property name="deleteInvalidSessions" value="true" />
+		<!-- -->
+		<property name="sessionIdCookie" ref="sessionIdCookie" />
+	</bean>
+
+	<bean id="shiroManager" class="com.goafanti.core.shiro.service.impl.ShiroManagerImpl" />
+
 	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
 		<property name="securityManager" ref="securityManager" />
 		<property name="loginUrl" value="/user/login" />
 		<property name="successUrl" value="/" />
 		<property name="unauthorizedUrl" value="/user/login" />
-	
-       <property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}"/>   
-       <property name="filters">
-           <util:map>
-              <entry key="login">
-              	<bean id="login" class="com.goafanti.core.shiro.filter.LoginFilter"/>
-              </entry>
-              <entry key="permission">
-              	<bean id="permission" class="com.goafanti.core.shiro.filter.PermissionFilter">
-              		<property name="loginUrl" value="/admin/login" />
-              	</bean>
-              </entry>
-              <entry key="admin">
-              	<bean id="admin" class="com.goafanti.core.shiro.filter.AdminFilter">
-              		<property name="loginUrl" value="/admin/login" />
-              	</bean>
-              </entry>
-           </util:map>
-       </property>
+
+		<property name="filterChainDefinitions" value="#{shiroManager.loadFilterChainDefinitions()}" />
+		<property name="filters">
+			<util:map>
+				<entry key="login">
+					<bean id="login" class="com.goafanti.core.shiro.filter.LoginFilter" />
+				</entry>
+				<entry key="permission">
+					<bean id="permission" class="com.goafanti.core.shiro.filter.PermissionFilter">
+						<property name="loginUrl" value="/admin/login" />
+					</bean>
+				</entry>
+				<entry key="admin">
+					<bean id="admin" class="com.goafanti.core.shiro.filter.AdminFilter">
+						<property name="loginUrl" value="/admin/login" />
+					</bean>
+				</entry>
+			</util:map>
+		</property>
 	</bean>
 	<!-- -->
 	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />
-	
+
 </beans>
 

+ 5 - 5
src/main/webapp/WEB-INF/views/index.html

@@ -15,7 +15,7 @@
 	<div class="container header_nav">
 		<div class="row clearfix">
 			<div class="col-md-12 logo">
-				<img th:src="${staticDomain + '/html/img/logo.png'}" />
+				<img th:src="${staticDomain + '/portal/img/logo.png'}" />
 			</div>
 
 		</div>
@@ -140,7 +140,7 @@
 					<div id="tab4" class="tab-pane">
 						<div class="content_info ">
 							<div class="info_img">
-								<img th:src="${staticDomain + '/html/img/mx_img_1.png'}" />
+								<img th:src="${staticDomain + '/portal/img/mx_img_1.png'}" />
 							</div>
 							<div class="info_txt">
 								<p>美国工程院院士,资深核能咨询顾问,美国能源部高级 顾问,美国国家研究委员会董事会能源与环境系统主席。</p>
@@ -152,7 +152,7 @@
 						</div>
 						<div class="content_info ">
 							<div class="info_img">
-								<img th:src="${staticDomain + '/html/img/mx_img_2.png'}" />
+								<img th:src="${staticDomain + '/portal/img/mx_img_2.png'}" />
 							</div>
 							<div class="info_txt">
 								<p>加拿大工程院院士,加拿大皇家学院院士,荣获英国国际名人传记中心颁发的的“信号处理研究及教育杰出贡献奖”。</p>
@@ -164,7 +164,7 @@
 						</div>
 						<div class="content_info ">
 							<div class="info_img">
-								<img th:src="${staticDomain + '/html/img/mx_img_3.png'}" />
+								<img th:src="${staticDomain + '/portal/img/mx_img_3.png'}" />
 							</div>
 							<div class="info_txt">
 								<p>英国皇家工程院院士,英国纽卡斯尔大学水利工程系教授,1995年获得欧洲地球物理学会金徽章奖。</p>
@@ -176,7 +176,7 @@
 						</div>
 						<div class="content_info ">
 							<div class="info_img">
-								<img th:src="${staticDomain + '/html/img/mx_img_4.png'}" />
+								<img th:src="${staticDomain + '/portal/img/mx_img_4.png'}" />
 							</div>
 							<div class="info_txt">
 								<p>(杂交水稻之父、首届国家最高科学奖获得者