1
2
3
4
5 package gboat2.web.business.impl;
6
7 import gboat2.base.core.cache.ICacheService;
8 import gboat2.base.core.service.BaseService;
9 import gboat2.web.Constants;
10 import gboat2.web.business.ICacheAssistBusiness;
11 import gboat2.web.business.IGroupBusiness;
12 import gboat2.web.model.Group;
13
14 import java.util.List;
15
16 import org.apache.commons.lang3.StringUtils;
17 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Service;
19 import org.springframework.transaction.annotation.Transactional;
20
21
22
23
24
25
26
27 @Transactional
28 @Service
29 public class CacheAssistantImpl extends BaseService implements ICacheAssistBusiness {
30
31 @Autowired
32 private ICacheService cacheSer;
33
34 @Autowired
35 private IGroupBusiness groupBusi;
36
37
38
39
40
41 @Override
42 public void removeCacheOfPriority(String authForId, String systemId) {
43 if (StringUtils.isEmpty(authForId) || StringUtils.isEmpty(systemId)) {
44 return;
45 }
46 if (authForId.indexOf(".") != -1) {
47
48
49 this.cacheSer.remove(Constants.PRIORITY_CACHE_CATALOG, authForId + "-" + systemId);
50
51 this.cacheSer.remove(Constants.MENU_TREE_CACHE_CATALOG, authForId + "-" + systemId);
52 } else {
53
54 List<Group> list = this.groupBusi.getAllGroup();
55 if (null != list && list.size() > 0) {
56 for (Group g : list) {
57
58 this.cacheSer.remove(Constants.PRIORITY_CACHE_CATALOG, g.getGroupId() + "." + authForId + "-" + systemId);
59
60 this.cacheSer.remove(Constants.MENU_TREE_CACHE_CATALOG, g.getGroupId() + "." + authForId + "-" + systemId);
61 }
62 }
63 }
64 }
65
66 @Override
67 public void removeCacheOfMenuTree(String authForId, String systemId) {
68 if (StringUtils.isEmpty(authForId) || StringUtils.isEmpty(systemId)) {
69 return;
70 }
71 if (authForId.indexOf(".") != -1) {
72
73
74 this.cacheSer.remove(Constants.MENU_TREE_CACHE_CATALOG, authForId + "-" + systemId);
75 } else {
76
77 List<Group> list = this.groupBusi.getAllGroup();
78 if (null != list && list.size() > 0) {
79 for (Group g : list) {
80
81 this.cacheSer.remove(Constants.MENU_TREE_CACHE_CATALOG, g.getGroupId() + "." + authForId + "-" + systemId);
82 }
83 }
84 }
85 }
86
87 }