Skip to content

Commit

Permalink
fix: 用户登录失败时,提示信息不准确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
armink committed Mar 3, 2024
1 parent f1e013b commit 33cd7a6
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions src/main/java/com/meteor/wechatbc/entitiy/session/BaseRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Data;
import lombok.ToString;
import okhttp3.Cookie;
import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -49,26 +50,36 @@ public BaseRequest(String xmlData){
try {
builder = factory.newDocumentBuilder();
Document document = builder.parse(new ByteArrayInputStream(xmlData.getBytes()));
NodeList skeyList = document.getElementsByTagName("skey");
if (skeyList.getLength() > 0) {
Element skeyElement = (Element) skeyList.item(0);
this.skey = skeyElement.getTextContent();;
}
NodeList wxsidList = document.getElementsByTagName("wxsid");
if (wxsidList.getLength() > 0) {
Element wxsidElement = (Element) wxsidList.item(0);
this.sid = wxsidElement.getTextContent();
}
NodeList wxuniList = document.getElementsByTagName("wxuin");
if (wxsidList.getLength() > 0) {
Element wxuniElement = (Element) wxuniList.item(0);
this.uin = wxuniElement.getTextContent();
}
NodeList passTicketList = document.getElementsByTagName("pass_ticket");
if (passTicketList.getLength() > 0) {
Element passTicketElement = (Element) passTicketList.item(0);
this.passTicket = passTicketElement.getTextContent();

Element errorElement = (Element) document.getElementsByTagName("error").item(0);
if (errorElement == null) {
NodeList skeyList = document.getElementsByTagName("skey");
if (skeyList.getLength() > 0) {
Element skeyElement = (Element) skeyList.item(0);
this.skey = skeyElement.getTextContent();;
}
NodeList wxsidList = document.getElementsByTagName("wxsid");
if (wxsidList.getLength() > 0) {
Element wxsidElement = (Element) wxsidList.item(0);
this.sid = wxsidElement.getTextContent();
}
NodeList wxuniList = document.getElementsByTagName("wxuin");
if (wxsidList.getLength() > 0) {
Element wxuniElement = (Element) wxuniList.item(0);
this.uin = wxuniElement.getTextContent();
}
NodeList passTicketList = document.getElementsByTagName("pass_ticket");
if (passTicketList.getLength() > 0) {
Element passTicketElement = (Element) passTicketList.item(0);
this.passTicket = passTicketElement.getTextContent();
}
} else {
String ret = errorElement.getElementsByTagName("ret").item(0).getTextContent();
String message = errorElement.getElementsByTagName("message").item(0).getTextContent();
LogManager.getLogger("BASE-REQUEST").error("登录失败:" + message + " CODE: " + ret);
throw new RuntimeException();
}

} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
} catch (IOException e) {
Expand Down

0 comments on commit 33cd7a6

Please sign in to comment.