java --登录

登录流程代码

    /**
     * 用户登录
     * 
     * @param loginInfo
     *            电话/邮件
     * @param password
     *            密码
     * @param appToken
     *               appToken                          
     * @return 用户登录信息
     */
    public ResultObject addLogin(String loginInfo, String password, String appToken){
        
        ResultObject ro = new ResultObject();
        //登录
        UserInfoVO userInfoVO = customerInfoMapper.login(loginInfo, password);
        //登录失败
        if (userInfoVO == null) {
            ro.setResultCode(ResultCode.FAILED);
            ro.setResultMsg(ResultMsg.MSG_LOGIN_FAILED);
            ro.setData(new UserInfoVO());
        }else
        {
            //登录成功,修改最后登录时间
            CustomerInfo customerInfo = new CustomerInfo();
            customerInfo.setCustomerId(userInfoVO.getUserId());
            customerInfo.setLastLoginTime(Utils.getSysTime());
            customerInfoMapper.updateByPrimaryKeySelective(customerInfo);
            
            //登录成功后,更新APP_TOKEN
            if (!(StringUtils.isEmpty(appToken))) {
                //不为空则更新appToken
                customerInfo.setLastLoginTime(null);
                customerInfo.setAppToken(appToken);
                customerInfoMapper.updateByPrimaryKeySelective(customerInfo);
            }
            
            ro.setData(userInfoVO);
            ro.setResultCode(ResultCode.SUCCESS);
            ro.setResultMsg(ResultMsg.MSG_LOGIN_SUCCESS);
            
        }
        
        return ro;
    }


你可能感兴趣的:(java --登录)