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.IRoleBusiness;
10 import gboat2.web.model.Role;
11
12 import java.util.ArrayList;
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16
17 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Transactional;
19
20
21
22
23
24
25
26
27
28 @Transactional
29 @Service
30 public class RoleBusinessImpl extends BaseService implements IRoleBusiness {
31
32 @Override
33 public Role findRoleByRoleCode(String roleCode) {
34 Map<String, Object> params = new HashMap<String, Object>();
35 String hql = "from Role as r where r.roleCode = :roleCode";
36 params.put("roleCode", roleCode);
37 Role r = (Role) baseDAO.get(hql ,params);
38 return r;
39 }
40
41 @Override
42 public Role findRoleByRoleName(String roleName) {
43 Map<String, Object> params = new HashMap<String, Object>();
44 String hql = "from Role as r where r.roleName = :roleName";
45 params.put("roleName", roleName);
46 Role r = (Role) baseDAO.get(hql ,params);
47 return r;
48 }
49
50 @Override
51 public List<Role> findAllRole() {
52 Map<String, Object> params = new HashMap<String, Object>();
53 List<Role> listOfRole = null;
54 params.put(QuerySupport.PARAM_TABLENAME, Role.class);
55 listOfRole = (List<Role>) super.query(params);
56 return listOfRole;
57 }
58
59 @Override
60 public List<String> findAllRoleName() {
61 List<Role> listOfRole = findAllRole();
62 List<String> listOfRoleName = new ArrayList<String>();
63 for(Role role : listOfRole){
64 listOfRoleName.add(role.getRoleName());
65 }
66 return listOfRoleName;
67 }
68
69 }