|
@@ -1,5 +1,6 @@
|
|
|
package com.dk.oauth.service.impl;
|
|
package com.dk.oauth.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -9,6 +10,8 @@ import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
|
|
+import com.dk.common.util.HttpUtils;
|
|
|
|
|
+import com.dk.oauth.config.WxConfig;
|
|
|
import com.dk.oauth.dto.AuthAccessTokenDto;
|
|
import com.dk.oauth.dto.AuthAccessTokenDto;
|
|
|
import com.dk.oauth.entity.*;
|
|
import com.dk.oauth.entity.*;
|
|
|
import com.dk.oauth.mapper.AuthAccessTokenMapper;
|
|
import com.dk.oauth.mapper.AuthAccessTokenMapper;
|
|
@@ -24,6 +27,7 @@ import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -33,6 +37,7 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* (AuthAccessToken)表服务实现类
|
|
* (AuthAccessToken)表服务实现类
|
|
@@ -60,6 +65,9 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
|
|
|
@Resource
|
|
@Resource
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WxConfig config;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 分页查询
|
|
* 分页查询
|
|
|
*
|
|
*
|
|
@@ -86,6 +94,25 @@ public class AuthAccessTokenServiceImpl extends ServiceImpl<AuthAccessTokenMappe
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @desc : 登录凭证校验
|
|
|
|
|
+ * @author : 姜永辉
|
|
|
|
|
+ * @date : 2022/5/12 9:33
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseResultVO<JSONObject> loginWechat(Map<String, Object> map) {
|
|
|
|
|
+ ResponseResultVO<JSONObject> res = HttpUtils.get(config.getCode2Session()
|
|
|
|
|
+ + "appid=" + config.getAppId()
|
|
|
|
|
+ + "&secret=" + config.getAppSecret()
|
|
|
|
|
+ + "&js_code=" + map.get("code")
|
|
|
|
|
+ + "&grant_type=authorization_code");
|
|
|
|
|
+ if (res.getData() != null && res.getData().get("errcode") != null) {
|
|
|
|
|
+ return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(),
|
|
|
|
|
+ res.getData().get("errmsg") == null ? res.getData().getString("errcode")
|
|
|
|
|
+ : "微信服务器异常:" + res.getData().getString("errmsg"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* @desc : 获取token
|
|
* @desc : 获取token
|
|
|
* @author : 洪旭东
|
|
* @author : 洪旭东
|
|
|
* @date : 2024-02-20 14:04
|
|
* @date : 2024-02-20 14:04
|