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>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- bouncycastle start -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.56</version>
|
||||
</dependency>
|
||||
<!-- bouncycastle end -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.com.tenlion.controller.app.apis.weixinlogin;
|
||||
|
||||
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -26,7 +27,7 @@ public class WeiXinLoginAppController {
|
||||
* @throws Exception
|
||||
*/
|
||||
@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);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.com.tenlion.service.weixinlogin;
|
||||
|
||||
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,6 @@ public interface IWeiXinLoginService {
|
||||
* @return
|
||||
* @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;
|
||||
|
||||
import cn.com.tenlion.pojo.dtos.weixinlogin.WeiXinLoginResult;
|
||||
import cn.com.tenlion.service.weixinlogin.IWeiXinLoginService;
|
||||
import cn.com.tenlion.util.AesUtil;
|
||||
import cn.com.tenlion.util.WxUtil;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -27,15 +29,13 @@ public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
|
||||
/**小程序授权类型*/
|
||||
private static String GRANT_TYPE = "authorization_code";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 微信小程序登录
|
||||
* @param code
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String weiXinLoginBySmallRoutine(String code) throws Exception{
|
||||
public WeiXinLoginResult weiXinLoginBySmallRoutine(String code) throws Exception{
|
||||
if(StringUtils.isEmpty(code)){
|
||||
throw new Exception("code不能为空");
|
||||
}
|
||||
@ -46,12 +46,26 @@ public class WeiXinLoginServiceImpl implements IWeiXinLoginService {
|
||||
param.put("js_code", code);
|
||||
param.put("grant_type", GRANT_TYPE);
|
||||
String str = WxUtil.doGet(VX_SMALL_ROUTINE_SESSION_KEY, param);
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return "";
|
||||
} else {
|
||||
JSONObject json = JSONObject.parseObject(str);
|
||||
json.getString("");
|
||||
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 {
|
||||
initResult.setCode("500");
|
||||
initResult.setMsg("系统异常");
|
||||
return initResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.com.tenlion.util;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.Base64;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
@ -16,7 +17,12 @@ import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
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.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user