Merge branch 'main' of D:\CF_work\ideaWorkSpace\business-card with conflicts.
This commit is contained in:
parent
3240ecc3dc
commit
2e0f24397d
9
pom.xml
9
pom.xml
@ -113,6 +113,15 @@
|
|||||||
<version>2.0.4</version>
|
<version>2.0.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- bouncycastle start -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
<version>1.56</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- bouncycastle end -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.com.tenlion.controller.app.apis.weixinlogin;
|
package cn.com.tenlion.controller.app.apis.weixinlogin;
|
||||||
|
|
||||||
|
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||||
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -26,7 +27,7 @@ public class WeiXinLoginAppController {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@GetMapping("weiXinLoginBySmallRoutine/{vxCode}")
|
@GetMapping("weiXinLoginBySmallRoutine/{vxCode}")
|
||||||
public String weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception{
|
public WeiXinLoginResult weiXinLoginBySmallRoutine (@PathVariable("vxCode") String vxCode) throws Exception{
|
||||||
return weiXinLoginService.weiXinLoginBySmallRoutine(vxCode);
|
return weiXinLoginService.weiXinLoginBySmallRoutine(vxCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.com.tenlion.service.weixinlogin;
|
package cn.com.tenlion.service.weixinlogin;
|
||||||
|
|
||||||
|
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,6 +20,6 @@ public interface IWeiXinLoginService {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
String weiXinLoginBySmallRoutine(String code) throws Exception;
|
WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package cn.com.tenlion.service.weixinlogin.impl;
|
package cn.com.tenlion.service.weixinlogin.impl;
|
||||||
|
|
||||||
|
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||||
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
||||||
|
import cn.com.tenlion.util.AesUtil;
|
||||||
import cn.com.tenlion.util.WxUtil;
|
import cn.com.tenlion.util.WxUtil;
|
||||||
import com.alibaba.druid.util.StringUtils;
|
import com.alibaba.druid.util.StringUtils;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@ -27,15 +29,13 @@ public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
|
|||||||
/**小程序授权类型*/
|
/**小程序授权类型*/
|
||||||
private static String GRANT_TYPE = "authorization_code";
|
private static String GRANT_TYPE = "authorization_code";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序登录
|
* 微信小程序登录
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String weiXinLoginBySmallRoutine(String code) throws Exception{
|
public WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception{
|
||||||
if(StringUtils.isEmpty(code)){
|
if(StringUtils.isEmpty(code)){
|
||||||
throw new Exception("code不能为空");
|
throw new Exception("code不能为空");
|
||||||
}
|
}
|
||||||
@ -46,12 +46,26 @@ public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
|
|||||||
param.put("js_code", code);
|
param.put("js_code", code);
|
||||||
param.put("grant_type", GRANT_TYPE);
|
param.put("grant_type", GRANT_TYPE);
|
||||||
String str = WxUtil.doGet(VX_SMALL_ROUTINE_SESSION_KEY, param);
|
String str = WxUtil.doGet(VX_SMALL_ROUTINE_SESSION_KEY, param);
|
||||||
if (StringUtils.isEmpty(str)) {
|
JSONObject json = JSONObject.parseObject(str);
|
||||||
return "";
|
Integer errcode = json.getInteger("errcode");
|
||||||
|
WeiXinLoginResult initResult = new WeiXinLoginResult();
|
||||||
|
if (errcode == 0) {
|
||||||
|
String skye = json.getString("session_key");
|
||||||
|
String openId = json.getString("openid");
|
||||||
|
String unionId = json.getString("unionid");
|
||||||
|
String token = AesUtil.aesCommonEncoder(skye,openId+unionId);
|
||||||
|
initResult.setCode("200");
|
||||||
|
initResult.setMsg("success");
|
||||||
|
initResult.setToken(token);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// json.getString("errmsg");
|
||||||
|
return initResult;
|
||||||
} else {
|
} else {
|
||||||
JSONObject json = JSONObject.parseObject(str);
|
initResult.setCode("500");
|
||||||
json.getString("");
|
initResult.setMsg("系统异常");
|
||||||
return "";
|
return initResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.com.tenlion.util;
|
package cn.com.tenlion.util;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xml.internal.security.utils.Base64;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
@ -16,7 +17,12 @@ import org.apache.http.util.EntityUtils;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.Security;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user