1
2
3
4
5 package gboat2.web.business.impl;
6
7 import gboat2.base.core.dao.QuerySupport;
8 import gboat2.base.core.service.BaseService;
9 import gboat2.web.business.IGroupRoleBusiness;
10 import gboat2.web.model.GroupRoleMapper;
11 import gboat2.web.model.GroupRoleVO;
12
13 import java.util.HashMap;
14 import java.util.Iterator;
15 import java.util.List;
16 import java.util.Map;
17
18 import org.springframework.stereotype.Service;
19 import org.springframework.transaction.annotation.Transactional;
20
21
22
23
24
25
26
27
28 @Transactional
29 @Service
30 public class GroupRoleBusinessImpl extends BaseService implements IGroupRoleBusiness {
31
32 @Override
33 public boolean deleteAllByGroupId(String groupId) {
34 String hql = "delete from GroupRoleMapper as g where g.groupId = :groupId";
35 Map<String, Object> parameters = new HashMap<String, Object>();
36 parameters.put("groupId", groupId);
37 super.baseDAO.deleteByQuery(hql, parameters);
38 return true;
39 }
40
41 @Override
42 public boolean saveGroupRole(String groupId, String roleId) {
43 GroupRoleMapper groupRole = new GroupRoleMapper();
44 groupRole.setGroupId(groupId);
45 groupRole.setRoleId(roleId);
46 super.save(groupRole);
47 return true;
48 }
49
50 @Override
51 public List<GroupRoleMapper> findAllByGroupId(String groupId) {
52 List<GroupRoleMapper> result = null;
53 Map<String, Object> params = new HashMap<String, Object>();
54 params.put(QuerySupport.PARAM_TABLENAME, GroupRoleMapper.class);
55 params.put("_groupId", groupId);
56 result = (List<GroupRoleMapper>) super.query(params);
57 return result;
58 }
59
60 @Override
61 public Map<String, GroupRoleMapper> findAllByGroupIdToMap(String groupId) {
62 Map<String, GroupRoleMapper> result = new HashMap<String, GroupRoleMapper>();
63 List<GroupRoleMapper> list = this.findAllByGroupId(groupId);
64 if (list != null && list.size() > 0){
65 Iterator<GroupRoleMapper> iter = list.iterator();
66 while (iter.hasNext()){
67 GroupRoleMapper g = iter.next();
68 result.put(g.getRoleId(), g);
69 }
70 }
71 return result;
72 }
73
74 @SuppressWarnings("unchecked")
75 @Override
76 public List<GroupRoleVO> findGroupRoleVOByGRID(String groupId) {
77 List<GroupRoleVO> result = null;
78 Map<String, Object> params = new HashMap<String, Object>();
79 params.put(QuerySupport.PARAM_TABLENAME, GroupRoleVO.class);
80 params.put("_groupId", groupId);
81 result = (List<GroupRoleVO>) super.query(params);
82 return result;
83 }
84
85 @Override
86 public boolean deleteByRoleId(String roleId) {
87 String hql = "delete from GroupRoleMapper as g where g.roleId = :roleId";
88 Map<String, Object> parameters = new HashMap<String, Object>();
89 parameters.put("roleId", roleId);
90 super.baseDAO.deleteByQuery(hql, parameters);
91 return true;
92 }
93
94 @Override
95 public List<GroupRoleVO> findRoleOfGroup(String groupId) {
96 List<GroupRoleVO> result = null;
97 String[][] params = {
98 {GroupRoleVO.class.getName()},
99 {"_groupId", groupId}
100 };
101 result = (List<GroupRoleVO>) super.query(params);
102 return result;
103 }
104
105 @Override
106 public List<GroupRoleVO> findGroupByRole(String roleId) {
107 List<GroupRoleVO> result = null;
108 String[][] params = {
109 {GroupRoleVO.class.getName()},
110 {"_roleId", roleId}
111 };
112 result = (List<GroupRoleVO>) super.query(params);
113 return result;
114 }
115
116 }