|
@@ -1,10 +1,12 @@
|
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.jwt.JWTUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.common.util.JwtUtil;
|
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
import com.fdkankan.manage.common.RedisKeyUtil;
|
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
@@ -314,13 +316,15 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
IJySceneUserAuthService jySceneUserAuthService;
|
|
|
@Autowired
|
|
|
IJyUserShareService jyUserShareService;
|
|
|
+ @Autowired
|
|
|
+ ManageService manageService;
|
|
|
|
|
|
@Override
|
|
|
- public Object checkNumAuth(String num,String token) {
|
|
|
+ public Object checkNumAuth(String num,String token,String clientIP,String userName,String password) {
|
|
|
if(StringUtils.isBlank(num)){
|
|
|
throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
|
- log.info("checkNumAuth-----------num:{},token:{}",num,token);
|
|
|
+ log.info("checkNumAuth-----------num:{},token:{},userName:{},password:{}",num,token,userName,password);
|
|
|
ScenePro pro = sceneProService.getByNum(num);
|
|
|
ScenePlus plus = scenePlusService.getByNum(num);
|
|
|
if(pro == null && plus == null){
|
|
@@ -333,23 +337,36 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
|
if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
|
|
|
sceneAuthVo.setViewAuth(true);
|
|
|
}
|
|
|
-
|
|
|
- String redisKey = String.format(RedisKeyUtil.loginToken,token);
|
|
|
- if(StringUtils.isBlank(token) || !redisUtil.hasKey(redisKey) ){
|
|
|
+ if(StringUtils.isBlank(token) && (StringUtils.isBlank(userName) || StringUtils.isBlank(password))){
|
|
|
return sceneAuthVo;
|
|
|
}
|
|
|
+ Long sysUserId = null;
|
|
|
+ if(StringUtils.isNotBlank(token)){
|
|
|
+ String redisKey = String.format(RedisKeyUtil.loginToken,token);
|
|
|
+ if( !redisUtil.hasKey(redisKey) ){
|
|
|
+ return sceneAuthVo;
|
|
|
+ }
|
|
|
+ String userStr = redisUtil.get(redisKey);
|
|
|
+ ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
|
|
|
+ Long userId = result.getUserId();
|
|
|
+ if(userId == null){
|
|
|
+ redisUtil.del(redisKey);
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
+ }else {
|
|
|
+ redisUtil.expire(redisKey,2 * 60 * 60);
|
|
|
+ }
|
|
|
+ sysUserId = result.getId();
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(userName) && StringUtils.isNotBlank(password)){
|
|
|
+ ManageLoginResponse login = manageService.login(clientIP, userName, password);
|
|
|
+ sysUserId = login.getId();
|
|
|
+ }
|
|
|
|
|
|
- String userStr = redisUtil.get(redisKey);
|
|
|
- ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
|
|
|
- Long userId = result.getUserId();
|
|
|
- if(userId == null){
|
|
|
- redisUtil.del(redisKey);
|
|
|
- throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
- }else {
|
|
|
- redisUtil.expire(redisKey,2 * 60 * 60);
|
|
|
+ if(sysUserId == null){
|
|
|
+ return sceneAuthVo;
|
|
|
}
|
|
|
|
|
|
- SysUser byId = sysUserService.getById(result.getId());
|
|
|
+ SysUser byId = sysUserService.getById(sysUserId);
|
|
|
if(byId.getRoleId() == 1L || byId.getRoleId() == 45L){
|
|
|
sceneAuthVo.setViewAuth(true);
|
|
|
sceneAuthVo.setEditAuth(true);
|