示例#1
0
 @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;
 }
示例#2
0
 @Override
 public User deleteById(Integer id) {
   unifiedUserSvc.deleteById(id);
   User bean = getDao().deleteById(id);
   // 删除收藏信息
   bean.clearCollection();
   return bean;
 }
示例#3
0
 @Override
 public void updatePwdEmail(Integer id, String password, String email) {
   User user = findById(id);
   if (!StringUtils.isBlank(email)) {
     user.setEmail(email);
   } else {
     user.setEmail(null);
   }
   unifiedUserSvc.update(id, password, email);
 }
示例#4
0
 @Override
 public User updateUserConllection(User user, Integer cid, Integer operate) {
   Updater<User> updater = new Updater<User>(user);
   user = (User) getDao().updateByUpdater(updater);
   if (operate.equals(1)) {
     user.addToCollection(contentSvc.findById(cid));
   } // 取消收藏
   else if (operate.equals(0)) {
     user.delFromCollection(contentSvc.findById(cid));
   }
   return user;
 }
示例#5
0
 @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;
 }
示例#6
0
 @Override
 public void updateUploadSize(Integer userId, Integer size) {
   User user = findById(userId);
   user.setUploadTotal(user.getUploadTotal() + size);
   if (user.getUploadDate() != null) {
     if (User.isToday(user.getUploadDate())) {
       size += user.getUploadSize();
     }
   }
   user.setUploadDate(new java.sql.Date(System.currentTimeMillis()));
   user.setUploadSize(size);
 }
示例#7
0
 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;
 }
示例#8
0
 @Override
 public void updateLoginInfo(Integer userId, String ip) {
   Date now = new Timestamp(System.currentTimeMillis());
   User user = findById(userId);
   if (user != null) {
     if (user.getLoginCount() == null || user.getLoginCount() < 0) {
       user.setLoginCount(0);
     }
     user.setLoginCount(user.getLoginCount() + 1);
     user.setLastLoginTime(user.getCurrentLoginTime());
     user.setLastLoginIp(user.getCurrentLoginIp());
     user.setCurrentLoginTime(now);
     user.setCurrentLoginIp(ip);
   }
 }