|
|
@@ -3,13 +3,8 @@ package org.springblade.auth.wechat;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-import com.ruoyi.common.core.controller.BaseController;
|
|
|
-import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
-import com.ruoyi.common.utils.StringUtils;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -38,11 +33,9 @@ import java.util.Map;
|
|
|
* @author BladeX
|
|
|
*/
|
|
|
@Slf4j
|
|
|
-@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("/wechat")
|
|
|
-@Api(value = "微信小程序", tags = "微信小程序接口")
|
|
|
-public class WechatController extends BaseController {
|
|
|
+public class WechatController {
|
|
|
|
|
|
/**
|
|
|
* 微信授权登录
|
|
|
@@ -51,9 +44,6 @@ public class WechatController extends BaseController {
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@PostMapping(value = "/programLogin")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "code", required = true)
|
|
|
- })
|
|
|
@ResponseBody
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "获取openId接口", notes = "获取openId接口")
|
|
|
@@ -106,12 +96,8 @@ public class WechatController extends BaseController {
|
|
|
log.info("响应内容为=====>" + res);
|
|
|
}
|
|
|
// 释放资源
|
|
|
- if (httpClient != null) {
|
|
|
- httpClient.close();
|
|
|
- }
|
|
|
- if (response != null) {
|
|
|
- response.close();
|
|
|
- }
|
|
|
+ httpClient.close();
|
|
|
+ response.close();
|
|
|
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
//获得token
|
|
|
@@ -124,7 +110,7 @@ public class WechatController extends BaseController {
|
|
|
//得到一个JSON对象
|
|
|
JSONObject object = JSON.parseObject(body);
|
|
|
String accessToken = object.getString("access_token");
|
|
|
- if (StringUtils.isNotEmpty(accessToken)) {
|
|
|
+ if (ObjectUtils.isNotNull(accessToken)) {
|
|
|
log.info("通过code获取token异常:" + object.toJSONString());
|
|
|
map.put("accessToken",accessToken);
|
|
|
}
|
|
|
@@ -145,7 +131,7 @@ public class WechatController extends BaseController {
|
|
|
JSONObject object = JSON.parseObject(body);
|
|
|
JSONObject jsonObject = object.getJSONObject("phone_info");
|
|
|
String phoneNumber = jsonObject.getString("phoneNumber");
|
|
|
- if (StringUtils.isNotEmpty(phoneNumber)) {
|
|
|
+ if (ObjectUtils.isNotNull(phoneNumber)) {
|
|
|
log.info("获取手机号异常:" + object.toJSONString());
|
|
|
map.put("phoneNumber",phoneNumber);
|
|
|
}
|