|
@@ -1,9 +1,12 @@
|
|
package com.fdkankan.manage.service.impl;
|
|
package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import cn.hutool.jwt.JWTUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
import com.fdkankan.manage.common.PageInfo;
|
|
|
|
+import com.fdkankan.manage.common.RedisKeyUtil;
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
import com.fdkankan.manage.common.ResultCode;
|
|
import com.fdkankan.manage.entity.*;
|
|
import com.fdkankan.manage.entity.*;
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
import com.fdkankan.manage.exception.BusinessException;
|
|
@@ -11,10 +14,14 @@ import com.fdkankan.manage.mapper.IJySceneUserAuthMapper;
|
|
import com.fdkankan.manage.service.*;
|
|
import com.fdkankan.manage.service.*;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fdkankan.manage.vo.request.SceneParam;
|
|
import com.fdkankan.manage.vo.request.SceneParam;
|
|
|
|
+import com.fdkankan.manage.vo.response.ManageLoginResponse;
|
|
|
|
+import com.fdkankan.manage.vo.response.SceneAuthVo;
|
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -158,6 +165,68 @@ public class JySceneUserAuthServiceImpl extends ServiceImpl<IJySceneUserAuthMapp
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ RedisUtil redisUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ ISysUserService sysUserService;
|
|
|
|
+ @Autowired
|
|
|
|
+ IJySceneUserAuthService jySceneUserAuthService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Object checkNumAuth(String num,String token) {
|
|
|
|
+ if(StringUtils.isBlank(num)){
|
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
|
+ }
|
|
|
|
+ ScenePro pro = sceneProService.getByNum(num);
|
|
|
|
+ ScenePlus plus = scenePlusService.getByNum(num);
|
|
|
|
+ if(pro == null && plus == null){
|
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXITS);
|
|
|
|
+ }
|
|
|
|
+ String redisKey = String.format(RedisKeyUtil.loginToken,token);
|
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
|
+ }
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ SceneAuthVo sceneAuthVo = new SceneAuthVo();
|
|
|
|
+
|
|
|
|
+ JySceneAuth jySceneAuth = jySceneAuthService.getByNum(num);
|
|
|
|
+ if(jySceneAuth!=null && jySceneAuth.getAuthType() == 1){
|
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysUser byId = sysUserService.getById(result.getId());
|
|
|
|
+ JyUser jyUser = jyUserService.getBySysId(byId.getId());
|
|
|
|
+ JySceneUserAuth jySceneUserAuth = jySceneUserAuthService.getByNumAndJyUserId(jyUser.getId(), num);
|
|
|
|
+ if(jySceneAuth != null){
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ if(jySceneUserAuth.getLookAuth() == 1 ||
|
|
|
|
+ ( jySceneUserAuth.getLookAuth() == 2 && jySceneUserAuth.getLookEndTime().getTime() >date.getTime())){
|
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
|
+ }
|
|
|
|
+ if(jySceneUserAuth.getEditAuth() == 1 ||
|
|
|
|
+ (jySceneUserAuth.getEditAuth() == 2 && jySceneUserAuth.getEditEndTime().getTime() >date.getTime())){
|
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(pro != null && jyUser.getUserId().equals(pro.getUserId())){
|
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
|
+ }
|
|
|
|
+ if(plus != null && jyUser.getUserId().equals(plus.getUserId())){
|
|
|
|
+ sceneAuthVo.setViewAuth(true);
|
|
|
|
+ sceneAuthVo.setEditAuth(true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return sceneAuthVo;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<JySceneUserAuth> getByJyUserId(Integer jyUserId) {
|
|
public List<JySceneUserAuth> getByJyUserId(Integer jyUserId) {
|
|
LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<JySceneUserAuth> wrapper = new LambdaQueryWrapper<>();
|