예제 #1
0
 private void doLogin(
     HttpServletRequest request,
     HttpServletResponse response,
     final long uid,
     final long tpId,
     RunType runType,
     boolean persistent)
     throws PassportAccountException {
   Passport passport = passportMapper.selectByPrimaryKey(uid);
   if (null == passport) {
     log.error("Login error. Can not find passport[id=" + uid + "].");
   }
   Date shield = passport.getShieldTime();
   if (shield != null && shield.getTime() > System.currentTimeMillis()) {
     throw new PassportAccountException(PassportAccountException.USER_IS_SHIELD, shield.getTime());
   }
   loginSessionManager.login(request, response, uid, tpId, false, persistent);
   // 更新最后登录时间
   updateLastLoginTime(uid, runType);
   // updateOnlineState(uid);
   addLoginLog(request, uid);
   // 启动一个线程来获取和保存
   if (tpId > 0) {
     taskExecutor.execute(
         new Runnable() {
           @Override
           public void run() {
             // friendService.updateExpiredFriends(uid, tpId);
             userStatusService.updateUserStatus(uid, tpId);
           }
         });
   }
 }
예제 #2
0
  private void updateLastLoginTime(long uid, RunType runType) {
    Date cDate = new Date();
    Passport updatePassport = new Passport();
    updatePassport.setId(uid);
    updatePassport.setLastLoginTime(cDate);
    passportMapper.updateByPrimaryKeySelective(updatePassport);

    Profile updateProfile = new Profile();
    updateProfile.setUid(uid);
    if (RunType.CONNET == runType || RunType.WEB == runType) {
      updateProfile.setLastWebLoginTime(cDate);
      profileMapper.updateByPrimaryKeySelective(updateProfile);
    }
  }