admin
2021-04-01 1d28c69a351ae108f4116a10f19f615c89a660a2
src/main/java/com/yeshi/buwan/controller/parser/CommentParser.java
@@ -2,6 +2,7 @@
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;
@@ -109,29 +110,38 @@
        }
        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("登录失败"));
        }
    }