| | |
| | | |
| | | import com.google.gson.GsonBuilder; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.dto.user.LoginInfoDto; |
| | | import com.yeshi.buwan.dto.user.QQUserInfo; |
| | |
| | | } |
| | | |
| | | |
| | | LoginUser lu = null; |
| | | try { |
| | | LoginUser lu = userService.login(loginInfoDto); |
| | | if (lu != null) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("LoginUid", lu.getId()); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | lu = userService.login(loginInfoDto); |
| | | if (lu == null) { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | return; |
| | | } |
| | | } catch (LoginUserException e) { |
| | | //用户不存在 |
| | | if (e.getCode() == LoginUserException.CODE_NO_USER && loginTypeInt == LoginUser.LOGIN_TYPE_EMAIL) { |
| | | if (e.getCode() == LoginUserException.CODE_NO_USER && loginTypeInt != LoginUser.LOGIN_TYPE_EMAIL) { |
| | | //注册 |
| | | try { |
| | | userService.register(loginInfoDto); |
| | | lu = userService.register(loginInfoDto); |
| | | } catch (RegisterUserException e1) { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | return; |
| | | } |
| | | |
| | | } else { |
| | | out.print(JsonUtil.loadFalseJson(e.getMessage())); |
| | | return; |
| | | } |
| | | } |
| | | if (lu != null) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("LoginUid", lu.getId()); |
| | | object.put("Portrait", lu.getPortrait()); |
| | | object.put("NickName", lu.getName()); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | } |
| | | } |
| | | |
| | | |