generated from root/miduo_server
我要当大圣渠道
parent
0f1d33aa9a
commit
70f441ee0a
|
@ -52,6 +52,7 @@ public class GetUserController extends HttpServlet {
|
|||
serviceMap.put("XQFP", new XqfpVerifyService("XQFP"));
|
||||
serviceMap.put("ZZXX", new ZzxxVerifyService("ZZXX"));
|
||||
serviceMap.put("AQLM", new AQLMVerifyService("AQLM"));
|
||||
serviceMap.put("WYDDS", new EightUVerifyService("WYDDS"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
package com.ljsd.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ljsd.pojo.VerifyParams;
|
||||
import com.ljsd.util.AppConstans;
|
||||
import com.ljsd.util.HttpUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EightUVerifyService extends AbstractVerifyService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EightUVerifyService.class);
|
||||
|
||||
public static final String app_id = "8600";
|
||||
|
||||
public EightUVerifyService(String sign) {
|
||||
super(sign);
|
||||
}
|
||||
@Override
|
||||
public boolean verify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token){
|
||||
try {
|
||||
//如果是自己人不需要验证了
|
||||
if(AppConstans.appsecret.equals(admin)) {
|
||||
return true;
|
||||
}
|
||||
if (!"3".equals(platform) ) {//正式 切不是pc
|
||||
VerifyParams params = new VerifyParams();
|
||||
VerifyParams formatParam = getFormatParam(params,request, openId, token);
|
||||
boolean result = verifyFormat(formatParam);
|
||||
if (!result) {
|
||||
response.sendError(400, "verify fail");
|
||||
LOGGER.error("verify fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyTest(VerifyParams params) {
|
||||
return doVerify(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyFormat(VerifyParams params) {
|
||||
return doVerify(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean doVerify(VerifyParams params) {
|
||||
String loginUrl = "https://h5.8uyx.com/cp/api_check_user";
|
||||
LOGGER.info("8U渠道登录验证-->{}",params.getOpenId());
|
||||
Map<String,String> paras = new HashMap<>();
|
||||
paras.put("appid",params.getAppId());
|
||||
paras.put("uid",params.getOpenId());
|
||||
paras.put("token",params.getToken());
|
||||
boolean result = false;
|
||||
try {
|
||||
String r = HttpUtils.doPost(loginUrl, paras);
|
||||
LOGGER.info("8U渠道登录验证请求结果:{}",r);
|
||||
if (r != null && r.equals("1")) {
|
||||
result = true;
|
||||
}
|
||||
}catch (IOException e){
|
||||
LOGGER.info("8U渠道登录验证验证失败,{}",e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VerifyParams getTestParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||
return getFormatParam(params,request,openId,token);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VerifyParams getFormatParam(VerifyParams params, HttpServletRequest request, String openId, String token) {
|
||||
params.setAppId(app_id);
|
||||
params.setToken(token);
|
||||
params.setOpenId(openId);
|
||||
return params;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue