1.修改权限问题
2.修改获取经办端token方法
This commit is contained in:
@@ -181,6 +181,7 @@ public class SysLoginController
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/getTjmhToken")
|
@GetMapping("/getTjmhToken")
|
||||||
public AjaxResult getTjmhToken(@RequestParam("code") String code){
|
public AjaxResult getTjmhToken(@RequestParam("code") String code){
|
||||||
|
System.out.println("参数code==========================="+code);
|
||||||
if(StringUtils.isBlank(code)){
|
if(StringUtils.isBlank(code)){
|
||||||
return AjaxResult.error("参数code为空,请传递code参数");
|
return AjaxResult.error("参数code为空,请传递code参数");
|
||||||
}
|
}
|
||||||
@@ -212,6 +213,7 @@ public class SysLoginController
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/getWwTjmHlwToken")
|
@GetMapping("/getWwTjmHlwToken")
|
||||||
public AjaxResult getWwTjmHlwToken(@RequestParam("token") String token){
|
public AjaxResult getWwTjmHlwToken(@RequestParam("token") String token){
|
||||||
|
System.out.println("互联网token================================"+token);
|
||||||
if (StringUtils.isNotBlank(token)) {
|
if (StringUtils.isNotBlank(token)) {
|
||||||
WwTokenResult wwTokenResult=new WwTokenResult();
|
WwTokenResult wwTokenResult=new WwTokenResult();
|
||||||
wwTokenResult.setAccessToken(token);
|
wwTokenResult.setAccessToken(token);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class IndustryController extends BaseController
|
|||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
@ApiOperation("行业树结构")
|
@ApiOperation("行业树结构")
|
||||||
@PreAuthorize("@ss.hasPermi('cms:industry:list')")
|
// @PreAuthorize("@ss.hasPermi('cms:industry:list')")
|
||||||
@GetMapping("/treeselect")
|
@GetMapping("/treeselect")
|
||||||
public AjaxResult treeselect(Industry industry)
|
public AjaxResult treeselect(Industry industry)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import com.ruoyi.common.core.domain.entity.tymh.nwToken.NwUserInfoResult;
|
|||||||
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwTokenResult;
|
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwTokenResult;
|
||||||
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwTyInfo;
|
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwTyInfo;
|
||||||
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwUserLogin;
|
import com.ruoyi.common.core.domain.entity.tymh.wwToken.WwUserLogin;
|
||||||
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.crypto.CryptoUtil;
|
import com.ruoyi.common.utils.crypto.CryptoUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -19,6 +22,7 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -72,6 +76,11 @@ public class OauthClient {
|
|||||||
@Value("${oauth.write-timeout:30}")
|
@Value("${oauth.write-timeout:30}")
|
||||||
private int writeTimeout;
|
private int writeTimeout;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
private final String MH_JBD_TOKEN="mhjdb:token:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取经办段token
|
* 获取经办段token
|
||||||
*/
|
*/
|
||||||
@@ -92,6 +101,19 @@ public class OauthClient {
|
|||||||
throw new RuntimeException("授权码解密失败:" + e.getMessage(), e);
|
throw new RuntimeException("授权码解密失败:" + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断redis中是否存在获取token
|
||||||
|
String redisKey=MH_JBD_TOKEN+decryptedCode;
|
||||||
|
NwTokenResult cacheResult=redisCache.getCacheObject(redisKey);
|
||||||
|
if(cacheResult!=null){
|
||||||
|
long ttlSeconds = redisCache.getExpire(redisKey);
|
||||||
|
if (ttlSeconds > 60) {
|
||||||
|
return cacheResult;
|
||||||
|
} else {
|
||||||
|
redisCache.deleteObject(redisKey);
|
||||||
|
throw new RuntimeException("令牌剩余时间不足(" + ttlSeconds + "秒),已清理旧数据");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>(2);
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
params.put("appid", appid);
|
params.put("appid", appid);
|
||||||
params.put("code", decryptedCode);
|
params.put("code", decryptedCode);
|
||||||
@@ -104,9 +126,11 @@ public class OauthClient {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (StringUtils.isEmpty(result.getAccessToken())) {
|
if (StringUtils.isEmpty(result.getAccessToken())) {
|
||||||
|
redisCache.deleteObject(decryptedCode);
|
||||||
throw new RuntimeException("Token获取失败:返回的accessToken为空");
|
throw new RuntimeException("Token获取失败:返回的accessToken为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redisCache.setCacheObject(redisKey,result,safeLongToInt(result.getExpiresIn()), TimeUnit.MINUTES);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,6 +451,24 @@ public class OauthClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Long 转 int
|
||||||
|
*/
|
||||||
|
private int safeLongToInt(Long value) {
|
||||||
|
if (value == null) {
|
||||||
|
throw new ServiceException("门户 Token 有效期不能为空");
|
||||||
|
}
|
||||||
|
// 校验是否超过 int 最大值(实际场景几乎不会触发)
|
||||||
|
if (value > Integer.MAX_VALUE) {
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
// 校验是否为负数(无效有效期)
|
||||||
|
if (value < 0) {
|
||||||
|
throw new ServiceException("门户 Token 有效期不能为负数");
|
||||||
|
}
|
||||||
|
return value.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 静态返回解析
|
* 静态返回解析
|
||||||
* @param <T>
|
* @param <T>
|
||||||
|
|||||||
Reference in New Issue
Block a user