generated from root/miduo_server
登录sdk
parent
2881b838d1
commit
a02f9b950f
|
|
@ -1,7 +1,6 @@
|
|||
package com.ljsd.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ljsd.pojo.SuJieAccount;
|
||||
import com.ljsd.redis.RedisKey;
|
||||
import com.ljsd.util.BaseGlobal;
|
||||
import com.ljsd.util.EncryptUtils;
|
||||
|
|
@ -56,8 +55,8 @@ public class GetUserController extends HttpServlet {
|
|||
return;
|
||||
}
|
||||
if(!"3".equals(platform)){
|
||||
SuJieAccount suJieAccount = loginVerfify(platform, openId, token);
|
||||
if(suJieAccount == null){
|
||||
boolean result = loginVerfify(platform, openId, token);
|
||||
if(!result){
|
||||
response.sendError(400, "verify fail");
|
||||
return;
|
||||
}
|
||||
|
|
@ -99,7 +98,7 @@ public class GetUserController extends HttpServlet {
|
|||
}
|
||||
|
||||
|
||||
public static SuJieAccount loginVerfify(String platForm,String openId,String token){
|
||||
public static boolean loginVerfify(String platForm,String openId,String token){
|
||||
try{
|
||||
String loginUrl = "";
|
||||
if("1".equals(platForm)){
|
||||
|
|
@ -108,40 +107,38 @@ public class GetUserController extends HttpServlet {
|
|||
loginUrl = KTSDKConstans.iosVerify;
|
||||
}
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("userID", openId);
|
||||
params.put("userid", openId);
|
||||
params.put("token", token);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("userID=").append(openId)
|
||||
.append("token=").append(token)
|
||||
.append(KTSDKConstans.appid);
|
||||
sb.append("userid=").append(openId)
|
||||
.append("token=").append(token).append(KTSDKConstans.appid).append(KTSDKConstans.appkey);
|
||||
|
||||
String sign = EncryptUtils.createMD5String(sb.toString());
|
||||
params.put("sign", sign);
|
||||
params.put("appid", KTSDKConstans.appid);
|
||||
String loginResult = HttpUtils.doPost(loginUrl,params);
|
||||
if(loginResult == null || loginResult.isEmpty()){
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
return parseLoginResult(loginResult);
|
||||
}catch(Exception e){
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static SuJieAccount parseLoginResult(String orderResult){
|
||||
private static boolean parseLoginResult(String orderResult){
|
||||
try {
|
||||
SuJieAccount suJieAccount = (SuJieAccount)JSONObject.parse(orderResult);
|
||||
int state = suJieAccount.getState();
|
||||
if(state != 0){
|
||||
return null;
|
||||
JSONObject jsonObject = JSONObject.parseObject(orderResult);
|
||||
int state = jsonObject.getIntValue("state");
|
||||
if(state != 1){
|
||||
return false;
|
||||
}
|
||||
return suJieAccount;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
package com.ljsd.pojo;
|
||||
|
||||
public class SuJieAccount {
|
||||
private String accountID;
|
||||
private String accountName;
|
||||
private int state;
|
||||
|
||||
public SuJieAccount() {
|
||||
}
|
||||
|
||||
public SuJieAccount(String accountID, String accountName){
|
||||
this.accountID = accountID;
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public String getAccountID() {
|
||||
return accountID;
|
||||
}
|
||||
public void setAccountID(String accountID) {
|
||||
this.accountID = accountID;
|
||||
}
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue