// @Override public Page select(AuthorizationCriteria criteria) { Page page = new Page(); @SuppressWarnings("rawtypes") List list = authorizationMapper.selectByExample(criteria); page.setRows(list); int total = authorizationMapper.countByExample(criteria); page.setTotal(total); return page; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#select(com.jcin.cms.utils.Page) */ @Override public Page select(Page page) { super.select(page); // setOrderByClause("SER_NO asc , ORG_ID desc"); AuthorizationCriteria authorizationCriteria = new AuthorizationCriteria(); authorizationCriteria.setOrderByClause("id desc"); authorizationCriteria.setPage(page); @SuppressWarnings("rawtypes") List list = authorizationMapper.selectByExample(authorizationCriteria); page.setRows(list); int total = authorizationMapper.countByExample(authorizationCriteria); page.setTotal(total); return page; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#insertBatch(List) */ @Override @Transactional public int insertBatch(List<Authorization> list) { int result = authorizationMapper.insertBatch(list); super.insertBatch(list); return result; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#selectByPrimaryKey(java.lang * .String) */ @Override public Authorization selectByPrimaryKey(String id) { super.selectByPrimaryKey(id); Authorization article = authorizationMapper.selectByPrimaryKey(id); return article; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#deleteByPrimaryKey((java.lang * .String )) */ @Override @Transactional public int deleteByPrimaryKey(String id) { // super.deleteByPrimaryKey(id); int result = authorizationMapper.deleteByPrimaryKey(id); return result; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#update(com.jcin.cms.service.system. * Authorization) */ @Override @Transactional public String update(Authorization record) { // super.update(record); record.setUpdateDate(new Date()); int result = authorizationMapper.updateByPrimaryKeySelective(record); return record.getId(); }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#deleteBatch(List) */ @Override @Transactional public int deleteBatch(List<String> list) { AuthorizationCriteria authorizationCriteria = new AuthorizationCriteria(); authorizationCriteria.createCriteria().andIdIn(list); int result = authorizationMapper.deleteByExample(authorizationCriteria); super.deleteBatch(list); return result; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#insert(com.jcin.cms.service.system. * Authorization) */ @Override @Transactional public String insert(Authorization record) { super.insert(record); record.setCreateDate(new Date()); int result = authorizationMapper.insert(record); String id = record.getId(); return id; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IUserServiceShiro#findPermissions(java.lang * .String) */ @Override public Set<String> findPermissions(String username) { // ----------- 此处应该用sql去实现的,现在先用程序实现。 UserCriteria userCriteria = new UserCriteria(); UserCriteria.Criteria criteria = userCriteria.createCriteria(); criteria.andUsernameEqualTo(username); List<User> users = userMapper.selectByExample(userCriteria); List<UserGroup> userGroups = new ArrayList<UserGroup>(); // 查询用户组 for (User user : users) { UserGroupCriteria userGroupCriteria = new UserGroupCriteria(); UserGroupCriteria.Criteria cri = userGroupCriteria.createCriteria(); cri.andIdEqualTo(user.getUserGroupId()); userGroups.addAll(userGroupMapper.selectByExample(userGroupCriteria)); } List<UserGroupRole> userGroupRoles = new ArrayList<UserGroupRole>(); // 查询中间表 for (UserGroup userGroup : userGroups) { UserGroupRoleCriteria userGroupRoleCriteria = new UserGroupRoleCriteria(); UserGroupRoleCriteria.Criteria cri = userGroupRoleCriteria.createCriteria(); cri.andUserGroupIdEqualTo(userGroup.getId()); userGroupRoles.addAll(userGroupRoleMapper.selectByExample(userGroupRoleCriteria)); } List<Role> roles = new ArrayList<Role>(); // 查询角色表 for (UserGroupRole userGroupRole : userGroupRoles) { RoleCriteria roleCriteria = new RoleCriteria(); RoleCriteria.Criteria rolecri = roleCriteria.createCriteria(); rolecri.andIdEqualTo(userGroupRole.getRoleId()); roles.addAll(roleMapper.selectByExample(roleCriteria)); } List<RoleAuthorization> roleAuthorizations = new ArrayList<RoleAuthorization>(); for (Role role : roles) { RoleAuthorizationCriteria authorizationCriteria = new RoleAuthorizationCriteria(); RoleAuthorizationCriteria.Criteria roleAuthcri = authorizationCriteria.createCriteria(); roleAuthcri.andRoleIdEqualTo(role.getId()); roleAuthorizations.addAll(roleAuthorizationMapper.selectByExample(authorizationCriteria)); } List<Authorization> authorizations = new ArrayList<Authorization>(); for (RoleAuthorization roleAuthorization : roleAuthorizations) { AuthorizationCriteria authorizationCriteria = new AuthorizationCriteria(); AuthorizationCriteria.Criteria authcri = authorizationCriteria.createCriteria(); authcri.andIdEqualTo(roleAuthorization.getAuthorizationId()); authorizations.addAll(authorizationMapper.selectByExample(authorizationCriteria)); } Set<String> set = new HashSet<String>(); for (Authorization authorization : authorizations) { set.add(authorization.getName()); } return set; }
/* * (non-Javadoc) * * @see * com.jcin.cms.service.system.IAuthorizationService#selectAll() */ @Override public List<Authorization> selectAll() { List<Authorization> list = authorizationMapper.selectByExample(null); return list; }