コード例 #1
0
ファイル: UserService.java プロジェクト: chenqibai/ief
 public int login(BaseParam baseParam, UserInfoDO loginParam, LoginResult loginResult)
     throws ParseException {
   loginParam.setPhone(SecretUtil.encrypt(loginParam.getPhone(), SecretUtil.PASSWORD));
   System.out.println("+++++++++++++" + loginParam.getPhone());
   UserInfoDO vo = userInfoMapper.getUserInfoByPhoneAndPassword(loginParam.getPhone());
   if (vo != null) {
     if (!SecretUtil.decrypt(vo.getPassword(), SecretUtil.PASSWORD)
         .equals(loginParam.getPassword())) return 2; // 密码不正确
     loginResult.setUserId(vo.getUserId());
     loginResult.setWanted(vo.getWantedNum());
     loginResult.setOwned(vo.getOwnedNum());
     loginResult.setUserName(vo.getUserName());
     loginResult.setSex(vo.getSex());
     loginResult.setBirthday(vo.getBirthday());
     loginResult.setBirthdayType(vo.getBirthdayType());
     loginResult.setHometown(vo.getHometown());
     loginResult.setLocate(vo.getLocate());
     loginResult.setUserHeadImg(vo.getUserHeadImg());
     loginResult.setSessionId(
         SecretUtil.encrypt(
             baseParam.getDeviceId() + "|" + vo.getUserId(), SecretUtil.AUTHPASSWORD));
     return 1; // 登录成功
   } else {
     return 0; // 账号不存在
   }
 }
コード例 #2
0
ファイル: UserService.java プロジェクト: chenqibai/ief
 public int register(BaseParam baseParam, UserInfoDO registerUserParam, LoginResult loginResult) {
   registerUserParam.setPhone(
       SecretUtil.encrypt(registerUserParam.getPhone(), SecretUtil.PASSWORD));
   registerUserParam.setPassword(
       SecretUtil.encrypt(registerUserParam.getPassword(), SecretUtil.PASSWORD));
   try {
     int rtl = userInfoMapper.addUserInfo(registerUserParam);
     if (rtl == 1) {
       loginResult.setSessionId(
           SecretUtil.encrypt(
               baseParam.getDeviceId() + "|" + registerUserParam.getUserId(),
               SecretUtil.AUTHPASSWORD));
       loginResult.setUserId(registerUserParam.getUserId());
     }
     return 1;
   } catch (DuplicateKeyException e) {
     return -1;
   }
 }