1 package gboat2.web.service.impl;
2
3 import gboat2.base.bridge.model.UserSession;
4 import gboat2.web.business.IGroupBusiness;
5 import gboat2.web.business.IGroupRoleBusiness;
6 import gboat2.web.business.IRoleBusiness;
7 import gboat2.web.model.Group;
8 import gboat2.web.model.GroupRoleVO;
9 import gboat2.web.model.GroupType;
10 import gboat2.web.model.Role;
11 import gboat2.web.model.RoleType;
12 import gboat2.web.model.SystemConfig;
13 import gboat2.web.model.SystemType;
14 import gboat2.web.service.IRoleService;
15 import gboat2.web.service.ISystemConfigService;
16
17 import java.util.List;
18
19 import org.springframework.beans.factory.annotation.Autowired;
20
21
22
23
24
25
26 public class RoleServiceImpl implements IRoleService {
27
28 @Autowired
29 private IRoleBusiness roleBusiness;
30
31 @Autowired
32 private IGroupBusiness groupBusiness;
33
34 @Autowired
35 private IGroupRoleBusiness groupRoleBusiness;
36
37 @Autowired
38 private ISystemConfigService systemConfigService;
39
40 @Override
41 public Role findRoleByRoleCode(String roleCode){
42 return roleBusiness.findRoleByRoleCode(roleCode);
43 }
44
45 @Override
46 public List<Role> findAllRole() {
47 return roleBusiness.findAllRole();
48 }
49
50
51
52
53 @Override
54 public List<String> findAllRoleName() {
55 return roleBusiness.findAllRoleName();
56 }
57
58 @Override
59 public List<Group> findAllGroup() {
60 return groupBusiness.getAllGroup();
61 }
62
63 @Override
64 public List<GroupRoleVO> findAllRoleByGroupId(String groupId) {
65 return groupRoleBusiness.findRoleOfGroup(groupId);
66 }
67
68 @Override
69 public Role findRoleByRoleName(String roleName) {
70 return roleBusiness.findRoleByRoleName(roleName);
71 }
72
73 @Override
74 public RoleType findRoleTypeBySession(UserSession session) {
75 if (session.getRoleCode() == null) {
76 return null;
77 }
78
79 String roleType = session.getRoleCode();
80 for (RoleType rt : RoleType.values()) {
81 if (rt.name().equals(roleType)) {
82 return rt;
83 }
84 }
85
86 return null;
87 }
88
89 @Override
90 public GroupType findGroupTypeBySession(UserSession session) {
91 if (session.getGroupCode() == null) {
92 return null;
93 }
94
95 String groupType = session.getGroupCode();
96 for (GroupType gt : GroupType.values()) {
97 if (gt.name().equals(groupType)) {
98 return gt;
99 }
100 }
101
102 return null;
103 }
104
105 @Override
106 public SystemType findSystemTypeBySession(UserSession session) {
107 SystemConfig systemConfig = systemConfigService.getSystemConfig(session.getSystemId());
108 if ("glodon.gbp.index.jy".equals(systemConfig.getLoginBundleName())) {
109 return SystemType.gbmp;
110 } else if ("glodon.gfm.index".equals(systemConfig.getLoginBundleName())) {
111 return SystemType.gfm;
112 }
113 return null;
114 }
115
116 @Override
117 public List<GroupRoleVO> findAllRoleByGroupCode(String groupCode) {
118 List<GroupRoleVO> ret = null;
119 Group g = this.groupBusiness.findGroupByGroupCode(groupCode);
120 ret = this.groupRoleBusiness.findRoleOfGroup(g.getGroupId());
121 return ret;
122 }
123 }