@Override public User saveAdmin( User user, String password, String ip, Integer siteId, Integer groupId, Byte step, Boolean allChannels) { UnifiedUser unifiedUser = unifiedUserSvc.save(user.getUsername(), user.getEmail(), password, ip); user.forAdmin(unifiedUser); Group group = null; if (groupId != null) { group = groupSvc.findById(groupId); } else { group = groupSvc.getRegDef(); } if (group == null) { throw new RuntimeException("register default member group not setted!"); } user.setGroup(group); user.init(); getDao().save(user); if (user.getExt() == null) { user.setExt(new UserExt()); } userExtSvc.save(user.getExt(), user); if (siteId != null) { Site site; site = websiteSvc.findById(siteId); userSiteSvc.save(site, user, step, allChannels); } return user; }
@Override public User registerMember( String username, String email, String password, String ip, Integer groupId, UserExt userExt, Boolean activation, EmailSender sender, MessageTemplate msgTpl) { UnifiedUser unifiedUser = unifiedUserSvc.save(username, email, password, ip, activation, sender, msgTpl); User user = new User(); user.forMember(unifiedUser); Group group = null; if (groupId != null) { group = groupSvc.findById(groupId); } else { group = groupSvc.getRegDef(); } if (group == null) { throw new RuntimeException("register default member group not found!"); } user.setGroup(group); user.init(); getDao().save(user); userExtSvc.save(userExt, user); return user; }
private User updateAdmin(User user, String password, Integer groupId, Boolean allChannels) { // Updater<User> updater = new Updater<User>(user); // updater.include("email"); // user = (User) getDao().updateByUpdater(updater); user.setGroup(groupSvc.findById(groupId)); updateDefault(user); userExtSvc.update(user.getExt(), user); // 更新角色 Integer[] roleIds = user.getRoleIds(); user.getRoles().clear(); if (roleIds != null) { for (Integer rid : roleIds) { user.addToRoles(roleSvc.findById(rid)); } } // 更新栏目权限 Integer[] channelIds = user.getChannelIds(); Set<Channel> channels = user.getChannels(); // 清除 if (channels != null) { for (Channel channel : channels) { channel = channelSvc.findById(channel.getId()); channel.getUsers().remove(user); } user.getChannels().clear(); } // 添加 if (!allChannels && channelIds != null) { Channel channel; for (Integer cid : channelIds) { channel = channelSvc.findById(cid); channel.addToUsers(user); } } unifiedUserSvc.update(user.getId(), password, user.getEmail()); return user; }