// _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ // _/_/_/_/_/_/ 下面将产生JSON格式的返回值 // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ @RequestMapping(value = "/select") @ResponseBody public Page select( @ModelAttribute Page page, @ModelAttribute User user, Model uiModel, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { super.select(page, uiModel, httpServletRequest, httpServletResponse); UserCriteria userCriteria = new UserCriteria(); UserCriteria.Criteria criteria = userCriteria.createCriteria(); userCriteria.setPage(page); userCriteria.setOrderByClause("id desc"); if (null != user.getId() && !"".equals(user.getId())) { criteria.andIdLike("%" + user.getId() + "%"); } if (null != user.getUsername() && !"".equals(user.getUsername())) { criteria.andUsernameLike("%" + user.getUsername() + "%"); } if (null != user.getPassword() && !"".equals(user.getPassword())) { criteria.andPasswordLike("%" + user.getPassword() + "%"); } page = userService.select(userCriteria); return page; }
/* * (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; }
@RequestMapping(value = "/update") @ResponseBody public String update( @ModelAttribute User user, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { userService.update(user); String id = user.getId(); return id; }
@RequestMapping(value = "updateForm") public String update( @Valid User user, BindingResult result, Model uiModel, HttpServletRequest httpServletRequest) { uiModel.asMap().clear(); userService.update(user); populateEditForm(uiModel, user); return "redirect:edit/" + encodeUrlPathSegment(user.getId().toString(), httpServletRequest); }
private List<Map<String, Object>> createExcelRecord(List<User> list) { List<Map<String, Object>> listmap = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); map.put("sheetName", "sheet1"); listmap.add(map); User user = null; for (int j = 0; j < list.size(); j++) { user = list.get(j); Map<String, Object> mapValue = new HashMap<String, Object>(); mapValue.put("Id", user.getId()); mapValue.put("Username", user.getUsername()); mapValue.put("Password", user.getPassword()); mapValue.put("Status", user.getStatus()); mapValue.put("Description", user.getDescription()); mapValue.put("Enabled", user.getEnabled()); mapValue.put("CreateDate", user.getCreateDate()); mapValue.put("UpdateDate", user.getUpdateDate()); mapValue.put("Ip", user.getIp()); mapValue.put("Telephone", user.getTelephone()); mapValue.put("Salt", user.getSalt()); mapValue.put("Locked", user.getLocked()); mapValue.put("Email", user.getEmail()); mapValue.put("Sex", user.getSex()); mapValue.put("Address", user.getAddress()); listmap.add(mapValue); } return listmap; }